TempDailyMonitor

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using RunRules;
using System.Reflection;
using System.IO;


namespace RunRules
{


    public class MonitorFactory 
    {
        private static MonitorFactory _instance = new MonitorFactory();
        public static MonitorFactory Instance
        {
            get { return _instance; }
        }


        public IQSDB MakeRules(string Name)
        {
            IQSDB MyRule= null;
            try
            {
                Assembly tempAssembly;
                tempAssembly = Assembly.Load("DailyRun");
                Type type = tempAssembly.GetType(Name, true);
                MyRule = (IQSDB)Activator.CreateInstance(type);
            }
            catch (TypeLoadException e)
            {
                Console.WriteLine("Wrong Rule type,exception caught - {0}", e.Message);
            }
            return MyRule;
        }
    }
  
   
   


    class Program
    {
        List<Rules> list = new List<Rules>();
        static void Main(string[] args)
        {
            Type[] typePublic = null; Type typeIQSDB = null;
            string exeDirPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //得到运行目录           




            string[] dellPaths = Directory.GetFiles(exeDirPath, "*.dll");//得到所有的DLL
            for (int i = 0; i < dellPaths.Length; i++)
            {
                Assembly asm = Assembly.LoadFile(dellPaths[i]);
                typePublic = asm.GetExportedTypes();//得到所有的public方法  
                typeIQSDB = typeof(IQSDB);//接口的类型  




                for (int j = 0; j < typePublic.Length; j++)
                {
                    if (typeIQSDB.IsAssignableFrom(typePublic[j]) && !typePublic[j].IsAbstract)
                    {
                        IQSDB obj = (IQSDB)Activator.CreateInstance(typePublic[j]);
                        obj.RunCheck();
                    }
                    // IQSDB obj = MonitorFactory.Instance.MakeRules("DailyRun.RunDailyMonitor");
                    // obj.RunCheck();
                }
                Console.ReadKey();
            }
        }
        void Initil()
        {
            Rules rule1 = new Rules(); rule1.RuleName = "QSDB_APAC"; rule1.deadLine = "21:00"; rule1.dateAdd = 0; list.Add(rule1);
            Rules rule2 = new Rules(); rule2.RuleName = "QSDB_EMEA"; rule2.deadLine = "23:00"; rule2.dateAdd = 0; list.Add(rule2);
            Rules rule3 = new Rules(); rule3.RuleName = "QSDB_NAM"; rule3.deadLine = "01:00"; rule3.dateAdd = -1; list.Add(rule3);
            Rules rule4 = new Rules(); rule4.RuleName = "DCCHECK"; rule4.deadLine = "02:00"; rule4.dateAdd = -1; list.Add(rule4);
            Rules rule5 = new Rules(); rule5.RuleName = "QSDB_OCEAN"; rule5.deadLine = "04:00"; rule5.dateAdd = -1; list.Add(rule5);


        }




    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值