Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            ServiceLog.InfoLog("Windows Service Start");
            DateTimeConfig           dtconfig = new DateTimeConfig();
            DynamicQueue             dq       = new DynamicQueue();
            ParameterizedThreadStart pts      = new ParameterizedThreadStart(dq.SendDynamicPacketMultiple);
            Thread th = new Thread(pts);

            th.Start(dtconfig);
            threadlist.Add(th);
        }
Esempio n. 2
0
        public void SendDynamicPacketOnce(DateTimeConfig config)
        {
            ServiceLog.InfoLog("SendDynamicPacketOnce Start");
            DateTime RunDate = new DateTime();

            if (config.RunMethod == "Mannual")
            {
                RunDate = config.RecordDate;
            }
            else if (config.RunMethod == "Default")
            {
                RunDate = DateTime.Parse(System.DateTime.Now.ToShortDateString()).AddDays(-1);
            }
            SendDynamicPacket(RunDate);
        }
Esempio n. 3
0
        public void SendDynamicPacketMultiple(object datetimeconfig)
        {
            ServiceLog.InfoLog("SendDynamicPacketMultiple Start");
            DateTimeConfig config = datetimeconfig as DateTimeConfig;

            ServiceLog.InfoLog("Service Run Mehtod." + config.RunMethod);
            List <RunDateConfig> RunDateList = new List <RunDateConfig>();

            if (config.RunMethod != "Auto")
            {
                SendDynamicPacketOnce(config);
                return;
            }
            ServiceLog.InfoLog("Service Run Mehtod." + config.RunMethod);
            for (DateTime startdt = config.StartDate; startdt <= config.EndDate; startdt = startdt.AddDays(1))
            {
                DateTime currentdt = Convert.ToDateTime(startdt.ToShortDateString() + " " + config.RunTime);
                if (currentdt > DateTime.Now)
                {
                    ServiceLog.InfoLog("Service Run Mehtod Add Run Date List." + currentdt);
                    RunDateConfig runconfig = new RunDateConfig()
                    {
                        Rundate = currentdt, IsRun = false
                    };
                    RunDateList.Add(runconfig);
                }
            }
            while (true)
            {
                foreach (RunDateConfig rundate in RunDateList)
                {
                    if (DateTime.Now >= rundate.Rundate && rundate.IsRun == false)
                    {
                        ServiceLog.InfoLog("Service Auto Method Run." + rundate.Rundate);
                        DateTime RecordDate = Convert.ToDateTime(rundate.Rundate.ToShortDateString()).AddDays(-1);
                        SendDynamicPacket(RecordDate);
                        int dateindex = RunDateList.IndexOf(rundate);
                        RunDateList[dateindex].IsRun = true;
                    }
                    Thread.Sleep(1000);
                }
                Thread.Sleep(1000);
            }
        }