private void OnButtonOkClick(object sender, EventArgs e)
        {
            if (_engineList.SettingAvailable)
            {
                EngineSetting setting = _engineList.Settings[_listBoxSettings.SelectedIndex];
                string        name    = _textBoxName.Text;

                if (string.IsNullOrWhiteSpace(name))
                {
                    return;
                }

                bool nameChanged = name != setting.Name;

                if (nameChanged && _listBoxSettings.Items.Contains(name))
                {
                    MessageBox.Show(this, "Setting with this name already exists.", "Zentropy", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (nameChanged)
                {
                    setting.Name = name;
                }

                setting.ExecutablePath = _comboBoxExePath.Text;
                setting.LogoPath       = _comboBoxLogoPath.Text;
                setting.UciOptions     = _textBoxUciOptions.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                _engineList.TryAddExePath(setting.ExecutablePath);
                _engineList.TryAddLogoPath(setting.LogoPath);
                EngineSelected?.Invoke();
                UpdateUI(_listBoxSettings.SelectedIndex);
                Close();
            }
        }
        private void OpenEngineConfig(int index)
        {
            EngineSetting setting = _engineList.Settings[index];

            _textBoxName.Text       = setting.Name;
            _textBoxUciOptions.Text = string.Join(Environment.NewLine, setting.UciOptions);
            _comboBoxExePath.Text   = setting.ExecutablePath;
            _comboBoxLogoPath.Text  = setting.LogoPath;
        }
        private void OnButtonAddNewClick(object sender, EventArgs e)
        {
            EngineSetting setting = new EngineSetting();
            string        name    = _textBoxName.Text;

            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }

            bool warn = false;

            while (_listBoxSettings.Items.Contains(name))
            {
                if (warn)
                {
                    MessageBox.Show(this, "Setting with this name already exists.", "Zentropy", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    warn = true;
                }

                string input = Interaction.InputBox("Enter new name for setting:", "Zentropy - Setting name");

                if (string.IsNullOrWhiteSpace(input))
                {
                    return;
                }
                else
                {
                    name = input;
                }
            }

            setting.Name           = name;
            setting.ExecutablePath = _comboBoxExePath.Text;
            setting.LogoPath       = _comboBoxLogoPath.Text;
            setting.UciOptions     = _textBoxUciOptions.Text.Split('\n');

            _engineList.TryAddExePath(setting.ExecutablePath);
            _engineList.TryAddLogoPath(setting.LogoPath);
            _engineList.Settings.Add(setting);

            UpdateUI(_listBoxSettings.SelectedIndex);

            _listBoxSettings.SelectedIndex = _listBoxSettings.Items.Count - 1;
        }
Beispiel #4
0
        public void OnProvisioningStartElapsedTime(object sender, ElapsedEventArgs elapsedEventArgs, EngineSetting engineSetting)
        {
            try
            {
                _iLogger.WriteLogEntry(_tenantId.ToString(), null, _name + " OnProvisioningStartElapsedTime timer elapsed.", LogLevelType.Info);

                if (engineSetting.Schedules != null && engineSetting.Schedules.Any())
                {
                    var now = DateTime.Now;

                    foreach (var schedule in engineSetting.Schedules)
                    {
                        bool scheduleRun = false;

                        switch (now.DayOfWeek)
                        {
                        case DayOfWeek.Sunday:
                            if (schedule.Sunday && schedule.SundayStartTime < now.TimeOfDay && schedule.SundayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        case DayOfWeek.Monday:
                            if (schedule.Monday && schedule.MondayStartTime < now.TimeOfDay && schedule.MondayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        case DayOfWeek.Tuesday:
                            if (schedule.Tuesday && schedule.TuesdayStartTime < now.TimeOfDay && schedule.TuesdayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        case DayOfWeek.Wednesday:
                            if (schedule.Wednesday && schedule.WednesdayStartTime < now.TimeOfDay && schedule.WednesdayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        case DayOfWeek.Thursday:
                            if (schedule.Thursday && schedule.ThursdayStartTime < now.TimeOfDay && schedule.ThursdayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        case DayOfWeek.Friday:
                            if (schedule.Friday && schedule.FridayStartTime < now.TimeOfDay && schedule.FridayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        case DayOfWeek.Saturday:
                            if (schedule.Saturday && schedule.SaturdayStartTime < now.TimeOfDay && schedule.SaturdayEndtime > now.TimeOfDay)
                            {
                                scheduleRun = true;
                            }

                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }

                        if (scheduleRun)
                        {
                            Provision();
                            break;
                        }
                    }
                }
                else
                {
                    Provision();
                }

                _iLogger.WriteLogEntry(_tenantId.ToString(), null, _name + " OnProvisioningStartElapsedTime timer elapsed Finished.", LogLevelType.Info);
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Application Error", _name + "  Crashed again..." + ex, EventLogEntryType.Error);
                //Some how this is getting hit...
            }

            _provisioningStartTimer.Start();
        }