예제 #1
0
        private static NameValueCollection GetProps(SchedulerType type)
        {
            switch (type)
            {
            case SchedulerType.InMemory:
                return(new NameValueCollection
                {
                    { "quartz.serializer.type", "binary" },
                    { "quartz.scheduler.instanceName", Guid.NewGuid().ToString() },
                    { "quartz.jobStore.type", "Quartz.Simpl.RAMJobStore, Quartz" },
                    { "quartz.threadPool.threadCount", _threadCount.ToString() }
                });

            case SchedulerType.SqlServer:
                return(new NameValueCollection
                {
                    { "quartz.serializer.type", "binary" },
                    { "quartz.scheduler.instanceName", Guid.NewGuid().ToString() },
                    { "quartz.jobStore.type", "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" },
                    { "quartz.jobStore.driverDelegateType", "Quartz.Impl.AdoJobStore.StdAdoDelegate" },
                    { "quartz.jobStore.tablePrefix", "QRTZ_" },
                    { "quartz.jobStore.dataSource", "default" },
                    { "quartz.dataSource.default.connectionString", _connectionString },
                    { "quartz.dataSource.default.provider", "SqlServer" },
                    { "quartz.jobStore.useProperties", "true" },
                    { "quartz.jobStore.lockHandler.type", "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" },
                    { "quartz.threadPool.threadCount", _threadCount.ToString() }
                });

            default:
                throw new ArgumentException(type.ToString());
            }
        }
예제 #2
0
 private void Insert()
 {
     try
     {
         var schedulerType = new SchedulerType
         {
             Name        = txtName.Text.Trim(),
             DisplayName = txtDisplayName.Text.Trim()
         };
         if (!string.IsNullOrEmpty(txtDescription.Text))
         {
             schedulerType.Description = txtDescription.Text.Trim();
         }
         int status;
         if (int.TryParse(cbxSchedulerTypeStatus.SelectedItem.Value, out status))
         {
             schedulerType.Status = (SchedulerTypeStatus)status;
         }
         schedulerType.Status = (SchedulerTypeStatus)status;
         SchedulerTypeServices.Create(schedulerType);
         wdTimeSheetRule.Hide();
     }
     catch (Exception ex)
     {
         Dialog.Alert("Có lỗi xảy ra trong quá trình thêm mới: {0}".FormatWith(ex.Message));
     }
 }
예제 #3
0
        /// <summary>
        /// Retrieves a given <see cref="TestScheduler"/> (and instantiates it, if required).
        /// </summary>
        /// <param name="type">
        /// The type of the test scheduler.
        /// </param>
        /// <returns>
        /// An instance of the <see cref="TestScheduler"/> reserved for the usage as a scheduler of a <param name="type">specified type</param>.
        /// </returns>
        private TestScheduler RetrieveTestScheduler(SchedulerType type)
        {
            var index = (int)type;
            var retrieveTestScheduler = this.testSchedulers[index] ?? (this.testSchedulers[index] = new TestScheduler());

            return(retrieveTestScheduler);
        }
예제 #4
0
 /// <summary>
 /// pnl : 整個課表的 container
 /// schType : 課表類型
 /// 
 /// </summary>
 /// <param name="pnl"></param>
 /// <param name="schType"></param>
 public DecScheduler(DevComponents.DotNetBar.PanelEx pnl, SchedulerType schType)
 {
     this.pnlContainer = pnl;
     this.schType = schType;
     this.cells = new Dictionary<string, DevComponents.DotNetBar.PanelEx>();
     this.decPeriods = new Dictionary<string, DecPeriod>();
     this.headerCells = new Dictionary<string, DevComponents.DotNetBar.PanelEx>();
 }
예제 #5
0
 public Scheduler(long id, SchedulerType type, long franchiseId, TimeSpan interval, DateTime?startedAt, DateTime?lastRun)
 {
     Id          = id;
     Type        = type;
     FranchiseId = franchiseId;
     Interval    = interval;
     StartedAt   = startedAt;
 }
예제 #6
0
        public void HandleStartEvent(string schedulerName, SchedulerType schedulerType, IntervalType intervalType, int interval, RepeatInterval repeatInterval = RepeatInterval.None, int repeatIntervalValue = 0)
        {
            ProcessTask(schedulerName);
            var delay     = TimerHelper.Getinterval(intervalType, interval);
            var scheduler = _schedulerFactory.New(schedulerName, delay);

            AddEventHandler(scheduler, intervalType, repeatInterval, repeatIntervalValue);
        }
예제 #7
0
 private Scheduler GetScheduler(string id, SchedulerType type, double interval)
 {
     return(new Scheduler
     {
         Id = id,
         Type = type,
         Timer = TimerHelper.GetTimer(interval)
     });
 }
예제 #8
0
 private Scheduler GetScheduler(string id, SchedulerType type, Timer timer)
 {
     return(new Scheduler
     {
         Id = id,
         Type = type,
         Timer = timer
     });
 }
예제 #9
0
 public static IScheduler Create(SchedulerType schedulerType)
 {
     switch (schedulerType)
     {
         case SchedulerType.RoundRobin:
             return new RoundRobinScheduler();
         case SchedulerType.Priority:
             return null;
         default:
             throw new InvalidOperationException("Scheduler type cannot be created by factory");
     }
 }
예제 #10
0
        /// <summary>
        /// Create instance of write scheduler.
        /// </summary>
        /// <param name="schedulerType"></param>
        /// <returns></returns>
        static public IWriteScheduler CreateWriteScheduler(SchedulerType schedulerType)
        {
            // Create instance of scheduler:
            if (SchedulerType.Priority == schedulerType)
            {
                return(new Priority());
            }
            else if (SchedulerType.RoundRobin == schedulerType)
            {
                return(new RoundRobin());
            }

            throw new ArgumentException(String.Format("Invalid scheduler type \"{0}\"", schedulerType));
        }
예제 #11
0
        public static IScheduler Create(SchedulerType schedulerType)
        {
            switch (schedulerType)
            {
            case SchedulerType.RoundRobin:
                return(new RoundRobinScheduler());

            case SchedulerType.Priority:
                return(null);

            default:
                throw new InvalidOperationException("Scheduler type cannot be created by factory");
            }
        }
예제 #12
0
        /// <summary>
        /// Creates the scheduler object.
        /// </summary>
        /// <param name="schedulerId">The scheduler identifier.</param>
        private void CreateSchedulerObject(SchedulerType schedulerId)
        {
            switch (schedulerId)
            {
            case SchedulerType.PullData:
                PullDataScheduler = new SchedulerViewModel
                                        (1,
                                        "PullData",
                                        "This scheduler is responsible to pull the data from cloud/ecommerce",
                                        TimeSpan.FromMinutes(1));
                break;

            case SchedulerType.GetIds:
                GetIdsScheduler = new SchedulerViewModel
                                      (2,
                                      "GetIds",
                                      "This scheduler is responsible to get the modified ids from ERP to connector queue",
                                      TimeSpan.FromMinutes(1));
                break;

            case SchedulerType.PushData:
                PushDataScheduler = new SchedulerViewModel
                                        (3,
                                        "PushData",
                                        "This scheduler is responsible to push the data from Connector queue to cloud/ecommerce",
                                        TimeSpan.FromMinutes(1));
                break;

            case SchedulerType.PullResponse:
                PullResponseScheduler = new SchedulerViewModel
                                            (4,
                                            "PullResponse",
                                            "This scheduler is responsible to pull the responses from cloud/ecommerce",
                                            TimeSpan.FromMinutes(1));
                break;

            case SchedulerType.CleanUp:
                CleanupScheduler = new SchedulerViewModel
                                       (5,
                                       "Cleanup",
                                       "This scheduler is responsible to clean up the data in the connector database and log files",
                                       new TimeSpan(1, 0, 0, 0));
                break;
            }
        }
예제 #13
0
        /// <summary>
        /// Run test program.
        /// </summary>
        /// <param name="program"></param>
        static void Run(SchedulerType schedulerType, string deviceFolder, int fileCount, int taskCount)
        {
            // Report program options
            Console.WriteLine("[{0}] pi scheduler type = {1}", DateTime.Now.ToFileTime(), schedulerType);
            Console.WriteLine("[{0}] pi device folder = {1}", DateTime.Now.ToFileTime(), deviceFolder);
            Console.WriteLine("[{0}] pi file count = {1}", DateTime.Now.ToFileTime(), fileCount);
            Console.WriteLine("[{0}] pm {1}kb", DateTime.Now.ToFileTime(), GC.GetTotalMemory(true) / 1024);

            FileGenerator   fileGenerator  = GetFileGenerator();
            IWriteScheduler writeScheduler = CreateWriteScheduler(schedulerType);

            foreach (IDevice device in GetDevices(new DirectoryInfo(deviceFolder)))
            {
                Console.WriteLine("[{0}] pi register device {1}", DateTime.Now.ToFileTime(), device.Id);
                writeScheduler.Register(device);
            }


            // Test using sequential writes.
            Console.WriteLine("[{0}] pm {1}kb", DateTime.Now.ToFileTime(), GC.GetTotalMemory(true) / 1024);
            DisplayScheduler(writeScheduler);
            foreach (Tuple <string, byte[]> current in fileGenerator.GetFiles(fileCount))
            {
                writeScheduler.Write(current.Item1, current.Item2);
                DisplayScheduler(writeScheduler);
            }
            Console.WriteLine("[{0}] pm {1}kb", DateTime.Now.ToFileTime(), GC.GetTotalMemory(true) / 1024);

            // Test using concurrent writes.
            Task[] tasks = new Task[taskCount];
            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = new Task(() =>
                {
                    foreach (Tuple <string, byte[]> current in fileGenerator.GetFiles(fileCount))
                    {
                        writeScheduler.Write(current.Item1, current.Item2);
                        DisplayScheduler(writeScheduler);
                    }
                });
                tasks[i].Start();
            }
            Task.WaitAll(tasks);
        }
예제 #14
0
파일: Domain.cs 프로젝트: ApexWeed/NetML
        public Domain()
        {
            Position = new Point();
            Nodes    = new List <Node>();

            Type        = DomainType.CSMA;
            BaseAddress = "10.0.0.0";
            Model       = MobilityModel.RandomWalk;
            XMin        = -50;
            XMax        = 50;
            YMin        = -50;
            YMax        = 50;

            DataRate = "10Mbps";
            Delay    = "40ms";

            Standard = WifiStandard.IEEE80211a;
            Mode     = WifiMode.Infrastructure;

            Scheduler = SchedulerType.Simple;

            if (CSMABackgroundBrush == null)
            {
                CSMABackgroundBrush = new SolidBrush(Color.FromArgb(064, 048, 128, 048));
            }
            if (IEEE81211BackgroundBrush == null)
            {
                IEEE81211BackgroundBrush = new SolidBrush(Color.FromArgb(064, 064, 000, 128));
            }
            if (LTEBackgroundBrush == null)
            {
                LTEBackgroundBrush = new SolidBrush(Color.FromArgb(064, 048, 048, 128));
            }
            if (WimaxBackgroundBrush == null)
            {
                WimaxBackgroundBrush = new SolidBrush(Color.FromArgb(064, 128, 048, 048));
            }

            if (TextBrush == null)
            {
                TextBrush = Brushes.Black;
            }
        }
예제 #15
0
        public static async void AddQuartz(this IServiceCollection services,
                                           SchedulerType type,
                                           int threadCount,
                                           string connectionString = null)
        {
            _connectionString = connectionString;
            _threadCount      = threadCount;

            NameValueCollection props = GetProps(type);

            var factory   = new StdSchedulerFactory(props);
            var scheduler = await factory.GetScheduler();

            services.AddSingleton <ISchedulerService, SchedulerService>();
            services.AddSingleton(scheduler);

            var jobFactory = new IoCJobFactory(services.BuildServiceProvider());

            scheduler.JobFactory = jobFactory;
        }
예제 #16
0
        public Scheduler New(string id, SchedulerType schedulerType, IntervalType intervalType = IntervalType.Minutely, int interval = 1)
        {
            var delayInterval = TimerHelper.Getinterval(intervalType, interval);

            return(GetScheduler(id, schedulerType, delayInterval));
        }
예제 #17
0
        /*  Constructor  */
        public DecPeriod(DevComponents.DotNetBar.PanelEx pnl, int colIndex, int rowIndex, SchedulerType schType)
        {
            this._pnl = pnl;
            this._schType = schType;
            this._colIndex = colIndex;
            this._rowIndex = rowIndex;
            /*
            this.pnlCover = new Panel();
            this.pnlCover.Size = new Size(this._pnl.Size.Width-2, this._pnl.Size.Height-2);
            this.pnlCover.Location = new Point(1, 1);
            this.pnlCover.Click += new EventHandler(_pnl_Click);
            this.pnlCover.MouseEnter += new EventHandler(_pnl_MouseEnter);
            this.pnlCover.MouseLeave += new EventHandler(_pnl_MouseLeave);
            this.pnlCover.BackColor = Color.Yellow;
            this.pnlCover.BringToFront();
            this._pnl.Controls.Add(this.pnlCover);
            */

            /* 註冊事件  */

            this._pnl.Click += new EventHandler(_pnl_Click);
            this._pnl.MouseEnter += new EventHandler(_pnl_MouseEnter);
            this._pnl.MouseLeave += new EventHandler(_pnl_MouseLeave);

            /* picBox */
            this.picBox = new PictureBox();
            Size s = new Size(16, 16);
            Point pt = new Point(this._pnl.Width - s.Width - 6, this._pnl.Height - s.Height - 6);
            this.picBox.Size = s;
            this.picBox.Location = pt;
            //this.picBox.Image = Properties.Resources.busy;
            this.picBox.SizeMode = PictureBoxSizeMode.StretchImage;
            this.picBox.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this._pnl.Controls.Add(this.picBox);
            this.picBox.Click += new EventHandler(picBox_Click);

            /* 建立 label */
            this.dicLables = new Dictionary<string, Label>();
            int initX = 6;
            int initY = 6;
            int labelHeight = 20;
            for (int i = 0; i < 3; i++)
            {
                Label lbl = new Label();
                lbl.Name = string.Format("label{0}", (i + 1).ToString());
                lbl.Visible = true;
                lbl.Text = "This is :" + i.ToString();
                Point p = new Point(initX, initY + i * labelHeight);
                lbl.Location = p;
                if (i == 0)
                    this.lbl1 = lbl;
                else if (i == 1)
                    this.lbl2 = lbl;
                else if (i == 2)
                    this.lbl3 = lbl;

                lbl.Click += new EventHandler(_pnl_Click);

                lbl.MouseEnter += new EventHandler(lbl_MouseEnter);
                lbl.MouseLeave += new EventHandler(lbl_MouseLeave);

                /*    * */
                this.dicLables.Add(lbl.Name, lbl);
                this._pnl.Controls.Add(lbl);
            }
        }
예제 #18
0
        /// <summary>
        /// Load command line options and return executable.
        /// </summary>
        /// <param name="program"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        static Action BuildCommand(SchedulerType schedulerType, string deviceFolder, int fileCount, int taskCount, string[] args)
        {
            List <string> errorList = new List <string>();

            for (int i = 0; i < args.Length; i += 2)
            {
                int j = i + 1;
                switch (args[i].ToLower())
                {
                case "-?":
                case "-h":
                case "--help":
                    return(() => DisplayHelp());

                case "-d":
                case "--devices":
                    if (j > args.Length)
                    {
                        errorList.Add("Missing devive folder");
                    }
                    else if (!Directory.Exists(args[j]))
                    {
                        errorList.Add(String.Format("Invalid device folder : '{0}'", args[j]));
                    }
                    else
                    {
                        deviceFolder = args[j];
                    }
                    break;

                case "-c":
                case "--count":
                    if (j > args.Length)
                    {
                        errorList.Add("Missing file value");
                    }
                    else if (!int.TryParse(args[j], out fileCount))
                    {
                        errorList.Add(String.Format("Invalid file count specified: '{0}'", args[j]));
                    }
                    break;

                case "-t":
                case "--type":

                    if (j > args.Length)
                    {
                        errorList.Add("Missing value for test type ");
                    }
                    else if (!Enum.TryParse <SchedulerType>(args[j], out schedulerType))
                    {
                        errorList.Add(String.Format("Invalid test type specified: '{0}'.", args[j]));
                    }
                    break;

                default:
                    errorList.Add(String.Format("Invalid option {0}", args[i]));
                    i = args.Length;
                    break;
                }
            }

            if (0 < errorList.Count())
            {
                return(() =>
                {
                    DisplayError(errorList.ToArray());
                    DisplayHelp();
                });
            }
            return(() => Run(schedulerType, deviceFolder, fileCount, taskCount));
        }
예제 #19
0
 public Scheduler New(string id, double intervalDelay, SchedulerType type = SchedulerType.Parent)
 {
     return(GetScheduler(id, type, intervalDelay));
 }
예제 #20
0
 public WdScheduler(SchedulerType type) : this()
 {
     SchedulerType = type;
 }
예제 #21
0
 public Scheduler New(string id, Timer timer, SchedulerType type = SchedulerType.Parent)
 {
     return(GetScheduler(id, type, timer));
 }
예제 #22
0
 /// <summary>
 /// Retrieves a given <see cref="TestScheduler"/> (and instantiates it, if required).
 /// </summary>
 /// <param name="type">
 /// The type of the test scheduler.
 /// </param>
 /// <returns>
 /// An instance of the <see cref="TestScheduler"/> reserved for the usage as a scheduler of a <param name="type">specified type</param>.
 /// </returns>
 private TestScheduler RetrieveTestScheduler(SchedulerType type)
 {
     var index = (int)type;
     var retrieveTestScheduler = this.testSchedulers[index] ?? (this.testSchedulers[index] = new TestScheduler());
     return retrieveTestScheduler;
 }
예제 #23
0
 public SchedulersViewModel(SchedulerType schedulerId)
 {
     currentSchedulerId = schedulerId;
     CreateSchedulerObject(schedulerId);
 }
예제 #24
0
 public WdScheduler(SchedulerType type, Expression <Func <bool> > condition) : this()
 {
     SchedulerType = type;
     StopCondition = condition;
 }
예제 #25
0
 private void AdjustScheduleType()
 {
     if (this.mediumConfigurationList.Count == 0)
     {
         this.type = SchedulerType.Invalid;
     }
     else if (this.mediumConfigurationList.Count == 1)
     {
         switch (this.mediumConfigurationList[0].Type)
         {
             case CacheMediumType.File:
                 this.type = SchedulerType.FileScheduler;
                 break;
             case CacheMediumType.RAM:
                 this.type = SchedulerType.RAMScheduler;
                 break;
             default:
                 throw new NotSupportedException();
         }
     }
     else if (this.mediumConfigurationList.Count == 1)
     {
         this.type = SchedulerType.RAMFileScheduler;
     }
     else
     {
         throw new NotSupportedException();
     }
 }
예제 #26
0
        public SchedulerConfiguration()
        {
            this.type = SchedulerType.Invalid;

            this.mediumConfigurationList = new List<MediumConfiguration>();
        }
예제 #27
0
 /// <summary>
 /// Actor设置
 /// </summary>
 /// <param name="maxQueueCount">限制最大队列的数量</param>
 /// <param name="sleepTime">多少毫秒秒没有订单沉睡</param>
 public ActorOptionAttribute(long maxQueueCount = 0, int ideltime = 5000, SchedulerType schedulerType = SchedulerType.None)
 {
     MaxQueueCount = maxQueueCount;
     Ideltime      = ideltime;
     SchedulerType = schedulerType;
 }
예제 #28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="masterNodeName">Master node name</param>
 /// <param name="schedulerType">Scheduler type</param>
 public SchedulerEndpoint(string masterNodeName, SchedulerType schedulerType)
 {
     MasterNodeName = masterNodeName;
     SchedulerType  = schedulerType;
 }