private void UploadJobForm_Load(object sender, EventArgs e) { Cancelled = false; //Few changes based on form mode (create or edit) Text = UploadJobDetail == null ? Resources.Add_upload_job : string.Format(Resources.Edit_job_0, UploadJobDetail.Key.Name); addToolStripButton.Text = UploadJobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job; jobName.Enabled = UploadJobDetail == null; jobGroupComboBox.DataSource = Properties.Settings.Default.JobGroups; jobGroupComboBox.ValueMember = null; jobGroupComboBox.DisplayMember = "Name"; jobGroupComboBox.Enabled = UploadJobDetail == null; instanceComboBox.DataSource = Properties.Settings.Default.Instances; instanceComboBox.ValueMember = null; instanceComboBox.DisplayMember = "Name"; var dataJobs = Properties.Settings.Default.DataJobs.Where(x => x.Type == DataJobType.Upload); var dataJobsBindingList = new BindingList <DataJob>(dataJobs.ToList()); dataJobComboBox.DataSource = dataJobsBindingList; dataJobComboBox.ValueMember = null; dataJobComboBox.DisplayMember = "Name"; var applications = Properties.Settings.Default.AadApplications.Where(x => x.AuthenticationType == AuthenticationType.User); var applicationsBindingList = new BindingList <AadApplication>(applications.ToList()); aadApplicationComboBox.DataSource = applicationsBindingList; aadApplicationComboBox.ValueMember = null; aadApplicationComboBox.DisplayMember = "Name"; userComboBox.DataSource = Properties.Settings.Default.Users; userComboBox.ValueMember = null; userComboBox.DisplayMember = "Login"; orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions)); upJobStartAtDateTimePicker.Value = DateTime.Now; procJobStartAtDateTimePicker.Value = DateTime.Now; inputFolderTextBox.Text = Properties.Settings.Default.UploadInputFolder; uploadSuccessFolderTextBox.Text = Properties.Settings.Default.UploadSuccessFolder; uploadErrorsFolderTextBox.Text = Properties.Settings.Default.UploadErrorsFolder; processingSuccessFolderTextBox.Text = Properties.Settings.Default.ProcessingSuccessFolder; processingErrorsFolderTextBox.Text = Properties.Settings.Default.ProcessingErrorsFolder; if ((UploadJobDetail != null) && (UploadTrigger != null)) { jobName.Text = UploadJobDetail.Key.Name; var jobGroup = ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault( x => x.Name == UploadJobDetail.Key.Group); jobGroupComboBox.SelectedItem = jobGroup; jobDescription.Text = UploadJobDetail.Description; useStandardSubfolder.Checked = false; inputFolderTextBox.Text = UploadJobDetail.JobDataMap[SettingsConstants.InputDir]?.ToString() ?? string.Empty; uploadSuccessFolderTextBox.Text = UploadJobDetail.JobDataMap[SettingsConstants.UploadSuccessDir]?.ToString() ?? string.Empty; uploadErrorsFolderTextBox.Text = UploadJobDetail.JobDataMap[SettingsConstants.UploadErrorsDir]?.ToString() ?? string.Empty; legalEntityTextBox.Text = UploadJobDetail.JobDataMap[SettingsConstants.Company]?.ToString() ?? string.Empty; isDataPackageCheckBox.Checked = (UploadJobDetail.JobDataMap[SettingsConstants.IsDataPackage] != null) && Convert.ToBoolean( UploadJobDetail.JobDataMap[SettingsConstants.IsDataPackage].ToString()); statusFileExtensionTextBox.Text = UploadJobDetail.JobDataMap[SettingsConstants.StatusFileExtension]?.ToString() ?? ".Status"; numericUpDownIntervalUploads.Value = Math.Round(Convert.ToDecimal(UploadJobDetail.JobDataMap[SettingsConstants.DelayBetweenFiles])); serviceAuthRadioButton.Checked = (UploadJobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication] != null) && Convert.ToBoolean(UploadJobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication].ToString()); if (!serviceAuthRadioButton.Checked) { User axUser = null; if (UploadJobDetail.JobDataMap[SettingsConstants.UserName] != null) { axUser = ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault( x => x.Login == UploadJobDetail.JobDataMap[SettingsConstants.UserName].ToString()); } if (axUser == null) { var userName = UploadJobDetail.JobDataMap[SettingsConstants.UserName]; if (userName != null) { axUser = new User { Login = userName.ToString(), Password = UploadJobDetail.JobDataMap[SettingsConstants.UserPassword].ToString() } } ; var disabledUser = new Users { axUser }; userComboBox.DataSource = disabledUser; userComboBox.Enabled = false; } userComboBox.SelectedItem = axUser; } var application = ((IEnumerable <AadApplication>)aadApplicationComboBox.DataSource).FirstOrDefault(app => app.ClientId == UploadJobDetail.JobDataMap[SettingsConstants.AadClientId].ToString()); if (application == null) { if (UploadJobDetail.JobDataMap[SettingsConstants.AadClientSecret] == null) { application = new AadApplication { ClientId = UploadJobDetail.JobDataMap[SettingsConstants.AadClientId].ToString(), Name = Resources.IMPORTED_CHANGE_THIS, AuthenticationType = AuthenticationType.User }; Properties.Settings.Default.AadApplications.Add(application); applications = Properties.Settings.Default.AadApplications.Where(x => x.AuthenticationType == AuthenticationType.User); applicationsBindingList = new BindingList <AadApplication>(applications.ToList()); aadApplicationComboBox.DataSource = applicationsBindingList; aadApplicationComboBox.ValueMember = null; aadApplicationComboBox.DisplayMember = "Name"; } else { application = new AadApplication { ClientId = UploadJobDetail.JobDataMap[SettingsConstants.AadClientId].ToString(), Secret = UploadJobDetail.JobDataMap[SettingsConstants.AadClientSecret].ToString(), Name = Resources.IMPORTED, AuthenticationType = AuthenticationType.Service }; var disabledApplication = new AadApplications { application }; aadApplicationComboBox.DataSource = disabledApplication; aadApplicationComboBox.Enabled = false; authMethodPanel.Enabled = false; } } aadApplicationComboBox.SelectedItem = application; var dataJob = ((IEnumerable <DataJob>)dataJobComboBox.DataSource).FirstOrDefault( dj => dj.ActivityId == UploadJobDetail.JobDataMap[SettingsConstants.ActivityId].ToString()); if (dataJob == null) { dataJob = new DataJob { ActivityId = UploadJobDetail.JobDataMap[SettingsConstants.ActivityId].ToString(), EntityName = UploadJobDetail.JobDataMap[SettingsConstants.EntityName].ToString(), Type = DataJobType.Upload, Name = Resources.IMPORTED_CHANGE_THIS }; Properties.Settings.Default.DataJobs.Add(dataJob); dataJobs = Properties.Settings.Default.DataJobs.Where(x => x.Type == DataJobType.Upload); dataJobsBindingList = new BindingList <DataJob>(dataJobs.ToList()); dataJobComboBox.DataSource = dataJobsBindingList; dataJobComboBox.ValueMember = null; dataJobComboBox.DisplayMember = "Name"; } dataJobComboBox.SelectedItem = dataJob; var axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x => (x.AosUri == UploadJobDetail.JobDataMap[SettingsConstants.AosUri].ToString()) && (x.AadTenant == UploadJobDetail.JobDataMap[SettingsConstants.AadTenant].ToString()) && (x.AzureAuthEndpoint == UploadJobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString())); if (axInstance == null) { axInstance = new Instance { AosUri = UploadJobDetail.JobDataMap[SettingsConstants.AosUri].ToString(), AadTenant = UploadJobDetail.JobDataMap[SettingsConstants.AadTenant].ToString(), AzureAuthEndpoint = UploadJobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString(), Name = Resources.IMPORTED_CHANGE_THIS }; Properties.Settings.Default.Instances.Add(axInstance); } instanceComboBox.SelectedItem = axInstance; searchPatternTextBox.Text = UploadJobDetail.JobDataMap[SettingsConstants.SearchPattern]?.ToString() ?? "*.*"; orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions)); var selectedOrderBy = OrderByOptions.FileName; if (UploadJobDetail.JobDataMap[SettingsConstants.OrderBy] != null) { selectedOrderBy = (OrderByOptions) Enum.Parse(typeof(OrderByOptions), UploadJobDetail.JobDataMap[SettingsConstants.OrderBy].ToString()); } orderByComboBox.SelectedItem = selectedOrderBy; orderDescendingRadioButton.Checked = (UploadJobDetail.JobDataMap[SettingsConstants.ReverseOrder] != null) && Convert.ToBoolean( UploadJobDetail.JobDataMap[SettingsConstants.ReverseOrder] .ToString()); pauseIndefinitelyCheckBox.Checked = (UploadJobDetail.JobDataMap[SettingsConstants.IndefinitePause] != null) && Convert.ToBoolean(UploadJobDetail.JobDataMap[SettingsConstants.IndefinitePause].ToString()); if (UploadTrigger.GetType() == typeof(SimpleTriggerImpl)) { var localTrigger = (SimpleTriggerImpl)UploadTrigger; upJobSimpleTriggerRadioButton.Checked = true; upJobHoursDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; upJobMinutesDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; } else if (UploadTrigger.GetType() == typeof(CronTriggerImpl)) { var localTrigger = (CronTriggerImpl)UploadTrigger; upJobCronTriggerRadioButton.Checked = true; upJobCronExpressionTextBox.Text = localTrigger.CronExpressionString; } if (UploadJobDetail.JobDataMap[SettingsConstants.RetryCount] != null) { retriesCountUpDown.Value = Convert.ToDecimal(UploadJobDetail.JobDataMap[SettingsConstants.RetryCount]); } if (UploadJobDetail.JobDataMap[SettingsConstants.RetryDelay] != null) { retriesDelayUpDown.Value = Convert.ToDecimal(UploadJobDetail.JobDataMap[SettingsConstants.RetryDelay]); } pauseOnExceptionsCheckBox.Checked = (UploadJobDetail.JobDataMap[SettingsConstants.PauseJobOnException] != null) && Convert.ToBoolean(UploadJobDetail.JobDataMap[SettingsConstants.PauseJobOnException].ToString()); verboseLoggingCheckBox.Checked = (UploadJobDetail.JobDataMap[SettingsConstants.LogVerbose] != null) && Convert.ToBoolean(UploadJobDetail.JobDataMap[SettingsConstants.LogVerbose].ToString()); Properties.Settings.Default.Save(); } if ((ProcessingJobDetail != null) && (ProcessingTrigger != null)) { useMonitoringJobCheckBox.Checked = true; processingSuccessFolderTextBox.Text = ProcessingJobDetail.JobDataMap[SettingsConstants.ProcessingSuccessDir]?.ToString() ?? string.Empty; processingErrorsFolderTextBox.Text = ProcessingJobDetail.JobDataMap[SettingsConstants.ProcessingErrorsDir]?.ToString() ?? string.Empty; delayBetweenStatusCheckNumericUpDown.Value = Math.Round(Convert.ToDecimal(ProcessingJobDetail.JobDataMap[SettingsConstants.DelayBetweenStatusCheck])); getExecutionErrorsCheckBox.Checked = (ProcessingJobDetail.JobDataMap[SettingsConstants.GetExecutionErrors] != null) && Convert.ToBoolean(ProcessingJobDetail.JobDataMap[SettingsConstants.GetExecutionErrors].ToString()); if (ProcessingTrigger.GetType() == typeof(SimpleTriggerImpl)) { var localTrigger = (SimpleTriggerImpl)ProcessingTrigger; procJobSimpleTriggerRadioButton.Checked = true; procJobHoursDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; procJobMinutesDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; } else if (ProcessingTrigger.GetType() == typeof(CronTriggerImpl)) { var localTrigger = (CronTriggerImpl)ProcessingTrigger; procJobCronTriggerRadioButton.Checked = true; procJobCronExpressionTextBox.Text = localTrigger.CronExpressionString; } } }
private void UploadJobForm_Load(object sender, EventArgs e) { Cancelled = false; //Few changes based on form mode (create or edit) Text = UploadJobDetail == null ? Resources.Add_upload_job : string.Format(Resources.Edit_job_0, UploadJobDetail.Key.Name); addToolStripButton.Text = UploadJobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job; jobName.Enabled = UploadJobDetail == null; jobGroupComboBox.DataSource = Properties.Settings.Default.JobGroups; jobGroupComboBox.ValueMember = null; jobGroupComboBox.DisplayMember = "Name"; jobGroupComboBox.Enabled = UploadJobDetail == null; instanceComboBox.DataSource = Properties.Settings.Default.Instances; instanceComboBox.ValueMember = null; instanceComboBox.DisplayMember = "Name"; appRegistrationComboBox.DataSource = Properties.Settings.Default.AadApplications.Where(x => x.AuthenticationType == AuthenticationType.User).ToList(); appRegistrationComboBox.ValueMember = null; appRegistrationComboBox.DisplayMember = "Name"; userComboBox.DataSource = Properties.Settings.Default.Users; userComboBox.ValueMember = null; userComboBox.DisplayMember = "Login"; dataJobComboBox.DataSource = Properties.Settings.Default.DataJobs.Where(x => x.Type == DataJobType.Upload).ToList(); dataJobComboBox.ValueMember = null; dataJobComboBox.DisplayMember = "Name"; orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions)); upJobStartAtDateTimePicker.Value = DateTime.Now; procJobStartAtDateTimePicker.Value = DateTime.Now; inputFolderTextBox.Text = Properties.Settings.Default.UploadInputFolder; uploadSuccessFolderTextBox.Text = Properties.Settings.Default.UploadSuccessFolder; uploadErrorsFolderTextBox.Text = Properties.Settings.Default.UploadErrorsFolder; processingSuccessFolderTextBox.Text = Properties.Settings.Default.ProcessingSuccessFolder; processingErrorsFolderTextBox.Text = Properties.Settings.Default.ProcessingErrorsFolder; if ((UploadJobDetail != null) && (UploadTrigger != null)) { jobName.Text = UploadJobDetail.Key.Name; var jobGroup = ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault(x => x.Name == UploadJobDetail.Key.Group); jobGroupComboBox.SelectedItem = jobGroup; jobDescription.Text = UploadJobDetail.Description; useStandardSubfolder.Checked = false; inputFolderTextBox.Text = UploadJobDetail.JobDataMap.GetString(SettingsConstants.InputDir); uploadSuccessFolderTextBox.Text = UploadJobDetail.JobDataMap.GetString(SettingsConstants.UploadSuccessDir); uploadErrorsFolderTextBox.Text = UploadJobDetail.JobDataMap.GetString(SettingsConstants.UploadErrorsDir); legalEntityTextBox.Text = UploadJobDetail.JobDataMap.GetString(SettingsConstants.Company); isDataPackageCheckBox.Checked = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.IsDataPackage); statusFileExtensionTextBox.Text = UploadJobDetail.JobDataMap.GetString(SettingsConstants.StatusFileExtension) ?? ".Status"; numericUpDownIntervalUploads.Value = UploadJobDetail.JobDataMap.GetInt(SettingsConstants.DelayBetweenFiles); serviceAuthRadioButton.Checked = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.UseServiceAuthentication); if (!serviceAuthRadioButton.Checked) { User axUser = null; if (!UploadJobDetail.JobDataMap.GetString(SettingsConstants.UserName).IsNullOrWhiteSpace()) { axUser = ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault(x => x.Login == UploadJobDetail.JobDataMap.GetString(SettingsConstants.UserName)); } if (axUser == null) { axUser = new User { Login = UploadJobDetail.JobDataMap.GetString(SettingsConstants.UserName), Password = UploadJobDetail.JobDataMap.GetString(SettingsConstants.UserPassword) }; Properties.Settings.Default.Users.Add(axUser); userComboBox.DataSource = Properties.Settings.Default.Users; } userComboBox.SelectedItem = axUser; } var application = ((IEnumerable <AadApplication>)appRegistrationComboBox.DataSource).FirstOrDefault(app => app.ClientId == UploadJobDetail.JobDataMap.GetString(SettingsConstants.AadClientId)); if (application == null) { if (!serviceAuthRadioButton.Checked) { application = new AadApplication { ClientId = UploadJobDetail.JobDataMap.GetString(SettingsConstants.AadClientId) ?? Guid.Empty.ToString(), Name = $"{Resources.IMPORTED_CHANGE_THIS} {DateTime.Now.ToShortDateString()} {DateTime.Now.ToLongTimeString()}", AuthenticationType = AuthenticationType.User }; } else { application = new AadApplication { ClientId = UploadJobDetail.JobDataMap.GetString(SettingsConstants.AadClientId) ?? Guid.Empty.ToString(), Secret = UploadJobDetail.JobDataMap.GetString(SettingsConstants.AadClientSecret) ?? String.Empty, Name = $"{Resources.IMPORTED_CHANGE_THIS} {DateTime.Now.ToShortDateString()} {DateTime.Now.ToLongTimeString()}", AuthenticationType = AuthenticationType.Service }; } Properties.Settings.Default.AadApplications.Add(application); appRegistrationComboBox.DataSource = Properties.Settings.Default.AadApplications; } appRegistrationComboBox.SelectedItem = application; var dataJob = ((IEnumerable <DataJob>)dataJobComboBox.DataSource).FirstOrDefault(dj => dj.ActivityId == UploadJobDetail.JobDataMap.GetString(SettingsConstants.ActivityId)); if (dataJob == null) { dataJob = new DataJob { ActivityId = UploadJobDetail.JobDataMap.GetString(SettingsConstants.ActivityId), EntityName = UploadJobDetail.JobDataMap.GetString(SettingsConstants.EntityName), Type = DataJobType.Upload, Name = $"{Resources.IMPORTED_CHANGE_THIS} {DateTime.Now.ToShortDateString()} {DateTime.Now.ToLongTimeString()}" }; Properties.Settings.Default.DataJobs.Add(dataJob); dataJobComboBox.DataSource = Properties.Settings.Default.DataJobs.Where(x => x.Type == DataJobType.Upload).ToList(); } dataJobComboBox.SelectedItem = dataJob; var axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x => (x.AosUri == UploadJobDetail.JobDataMap.GetString(SettingsConstants.AosUri)) && (x.AadTenant == UploadJobDetail.JobDataMap.GetString(SettingsConstants.AadTenant)) && (x.AzureAuthEndpoint == UploadJobDetail.JobDataMap.GetString(SettingsConstants.AzureAuthEndpoint))); if (axInstance == null) { axInstance = new Instance { AosUri = UploadJobDetail.JobDataMap.GetString(SettingsConstants.AosUri), AadTenant = UploadJobDetail.JobDataMap.GetString(SettingsConstants.AadTenant), AzureAuthEndpoint = UploadJobDetail.JobDataMap.GetString(SettingsConstants.AzureAuthEndpoint), UseADAL = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.UseADAL), Name = $"{Resources.IMPORTED_CHANGE_THIS} {DateTime.Now.ToShortDateString()} {DateTime.Now.ToLongTimeString()}" }; Properties.Settings.Default.Instances.Add(axInstance); instanceComboBox.DataSource = Properties.Settings.Default.Instances; } instanceComboBox.SelectedItem = axInstance; searchPatternTextBox.Text = UploadJobDetail.JobDataMap.GetString(SettingsConstants.SearchPattern) ?? "*.*"; orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions)); var selectedOrderBy = OrderByOptions.FileName; if (!UploadJobDetail.JobDataMap.GetString(SettingsConstants.OrderBy).IsNullOrWhiteSpace()) { selectedOrderBy = (OrderByOptions)Enum.Parse(typeof(OrderByOptions), UploadJobDetail.JobDataMap.GetString(SettingsConstants.OrderBy)); } orderByComboBox.SelectedItem = selectedOrderBy; orderDescendingRadioButton.Checked = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.ReverseOrder); pauseIndefinitelyCheckBox.Checked = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.IndefinitePause); if (UploadTrigger.GetType() == typeof(SimpleTriggerImpl)) { var localTrigger = (SimpleTriggerImpl)UploadTrigger; upJobSimpleTriggerRadioButton.Checked = true; upJobHoursDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; upJobMinutesDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; } else if (UploadTrigger.GetType() == typeof(CronTriggerImpl)) { var localTrigger = (CronTriggerImpl)UploadTrigger; upJobCronTriggerRadioButton.Checked = true; upJobCronExpressionTextBox.Text = localTrigger.CronExpressionString; } retriesCountUpDown.Value = UploadJobDetail.JobDataMap.GetInt(SettingsConstants.RetryCount); retriesDelayUpDown.Value = UploadJobDetail.JobDataMap.GetInt(SettingsConstants.RetryDelay); pauseOnExceptionsCheckBox.Checked = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.PauseJobOnException); verboseLoggingCheckBox.Checked = UploadJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.LogVerbose); Properties.Settings.Default.Save(); } if ((ProcessingJobDetail != null) && (ProcessingTrigger != null)) { useMonitoringJobCheckBox.Checked = true; processingSuccessFolderTextBox.Text = ProcessingJobDetail.JobDataMap.GetString(SettingsConstants.ProcessingSuccessDir); processingErrorsFolderTextBox.Text = ProcessingJobDetail.JobDataMap.GetString(SettingsConstants.ProcessingErrorsDir); delayBetweenStatusCheckNumericUpDown.Value = ProcessingJobDetail.JobDataMap.GetInt(SettingsConstants.DelayBetweenStatusCheck); getExecutionErrorsCheckBox.Checked = ProcessingJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.GetExecutionErrors); if (ProcessingTrigger.GetType() == typeof(SimpleTriggerImpl)) { var localTrigger = (SimpleTriggerImpl)ProcessingTrigger; procJobSimpleTriggerRadioButton.Checked = true; procJobHoursDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; procJobMinutesDateTimePicker.Value = DateTime.Now.Date + localTrigger.RepeatInterval; } else if (ProcessingTrigger.GetType() == typeof(CronTriggerImpl)) { var localTrigger = (CronTriggerImpl)ProcessingTrigger; procJobCronTriggerRadioButton.Checked = true; procJobCronExpressionTextBox.Text = localTrigger.CronExpressionString; } } SetDropDownsWidth(this); }