コード例 #1
0
        public Schedule(string name, IScheduledComponent component, DateTime startTime, DateTime endTime, int repeatSchedule, int useMultiCoreProcess)
        {
            //Check if the schedule is configured to run continuously without end time!!
            if (startTime.ToShortTimeString().Equals("00:00") && endTime.ToShortTimeString().Equals("00:00") && repeatSchedule > 0)
            {
                endTime = DateTime.MaxValue;
            }

            if (startTime > endTime)
            {
                endTime = startTime;
            }

            if (startTime == endTime)
            {
                repeatSchedule = 0;
            }
            else
            if (repeatSchedule == 0)
            {
                endTime = startTime;
            }

            LoggerName             = name;
            LoggerComponent        = component;
            _startTime             = startTime;
            _endTime               = endTime;
            _repeatSchedule        = repeatSchedule;
            _scheduleProcessStatus = Scheduler.ScheduleProcessStatus.Created;
            _useMultiCoreProcess   = Convert.ToBoolean(useMultiCoreProcess);
        }
コード例 #2
0
        public static List <ISchedule> GetSchedules()
        {
            SchedulerHelper.SetDefaultDateTimeFormat();
            var    schedules = new List <ISchedule>();
            string scheduledComponentsFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"NexGenIpos.Scheduler.Schedules.csv");
            var    parser = new DelimitedTextFileParser(scheduledComponentsFile, ',', true);

            foreach (var line in parser)
            {
                string componentName = line[0].Trim().ToUpper();

                if (componentName.StartsWith("--"))
                {
                    continue;
                }

                IScheduledComponent component = null;
                var startTime           = DateTime.Parse(line[1].Trim());
                var endTime             = DateTime.Parse(line[2].Trim());
                var repeatSchedule      = line.Length > 3 ? int.Parse(line[3].Trim()) : 0;
                var useMultiCoreProcess = line.Length > 4 ? int.Parse(line[4].Trim()) : 0;

                string compFullName = componentName;
                int    compNameLen  = componentName.IndexOf("_");
                compNameLen = (compNameLen > 0 ? compNameLen - 1 : componentName.Length);

                componentName = componentName.Substring(0, compNameLen);

                //when new schedule component is created, add to switch case here
                switch (componentName)
                {
                case "RECIEPT":
                    component = new ReceiptCompComponent();
                    break;

                case "MASTERSBAT":
                    component = new EtlILDataComponent();
                    break;

                case "SMSREMINDER":
                    component = new SmsReminderComponent();
                    break;

                case "PROPOSAlWITHDRAW":
                    component = new SmsReminderComponent();
                    break;

                case "BIZDATE":
                    component = new BizDateComponent();
                    break;

                default:
                    throw new ApplicationException(string.Format("Specified scheduler component is not created or added to component library: {0}", componentName));
                }

                ISchedule schedule = new Schedule(compFullName, component, startTime, endTime, repeatSchedule, useMultiCoreProcess);
                schedules.Add(schedule);
            }

            return(schedules);
        }