示例#1
0
        public bool HasSameJobTypeList(WorkerSettings p)
        {
            var firstNotSecond = _arrJobTypes.Except(p.JobTypes).ToList();
            var secondNotFirst = p.JobTypes.Except(_arrJobTypes).ToList();

            return(firstNotSecond.Count == 0 && secondNotFirst.Count == 0);
        }
示例#2
0
        public bool Equals(WorkerSettings p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((_iMaxCount == p.MaxCount) && HasSameJobTypeList(p));
        }
示例#3
0
        public static void GetJobPriority(Job oJob, out WorkerPriorityType oPriority, out bool lowIOPriority)
        {
            JobType oType = WorkerSettings.GetJobType(oJob);

            foreach (WorkerPriority oPrioritySettings in MainForm.Instance.Settings.WorkerPriority)
            {
                if (oPrioritySettings.JobType.Equals(oType))
                {
                    oPriority     = oPrioritySettings.Priority;
                    lowIOPriority = oPrioritySettings.LowIOPriority;
                    return;
                }
            }
            oPriority     = WorkerPriorityType.IDLE;
            lowIOPriority = true;
        }
示例#4
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            WorkerSettings p = obj as WorkerSettings;

            if ((System.Object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((_iMaxCount == p.MaxCount) && HasSameJobTypeList(p));
        }
示例#5
0
        private void BtnAddSettings_Click(object sender, EventArgs e)
        {
            if (workerJobsListBox.CheckedItems.Count == 0)
            {
                MessageBox.Show("Please select at least one job type.", "Add Worker Rule", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            WorkerSettings oSettings = new WorkerSettings();

            for (int i = 0; i < workerJobsListBox.Items.Count; i++)
            {
                if (workerJobsListBox.GetItemCheckState(i) != CheckState.Checked)
                {
                    continue;
                }
                JobType oType = (JobType)((EnumProxy)workerJobsListBox.Items[i]).RealValue;
                oSettings.JobTypes.Add(oType);
            }
            oSettings.MaxCount = (int)numericUpDown1.Value;

            foreach (WorkerSettings oSettingsExisting in MainForm.Instance.Settings.WorkerSettings)
            {
                if (oSettingsExisting.HasSameJobTypeList(oSettings))
                {
                    if (oSettingsExisting.MaxCount != oSettings.MaxCount)
                    {
                        oSettingsExisting.MaxCount = oSettings.MaxCount;
                        UpdateWorkerSettingsListBox();
                    }
                    else
                    {
                        MessageBox.Show("This rule set is already in the list.", "Add Worker Rule", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    return;
                }
            }

            MainForm.Instance.Settings.WorkerSettings.Add(oSettings);
            UpdateWorkerSettingsListBox();
        }