private void ButtonOK_Click(object sender, EventArgs e)
 {
     if (InputIsValid())
     {
         AadApplication = new AadApplication
         {
             Name               = textBox1.Text,
             ClientId           = textBox2.Text,
             Secret             = textBox3.Text,
             AuthenticationType = (AuthenticationType)comboBox1.SelectedItem
         }
     }
     ;
     else
     {
         DialogResult = DialogResult.None;
     }
 }
        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 ImportJobForm_Load(object sender, EventArgs e)
        {
            Cancelled = false;
            //Few changes based on form mode (create or edit)
            Text = ImportJobDetail == null
                ? Resources.Add_import_job
                : string.Format(Resources.Edit_job_0, ImportJobDetail.Key.Name);
            addJobButton.Text = ImportJobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job;
            jobName.Enabled   = ImportJobDetail == null;

            jobGroupComboBox.DataSource    = Properties.Settings.Default.JobGroups;
            jobGroupComboBox.ValueMember   = null;
            jobGroupComboBox.DisplayMember = "Name";

            jobGroupComboBox.Enabled = ImportJobDetail == null;

            instanceComboBox.DataSource    = Properties.Settings.Default.Instances;
            instanceComboBox.ValueMember   = null;
            instanceComboBox.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;

            importFromPackagePath                 = OdataActionsConstants.ImportFromPackageActionPath;
            getAzureWriteUrlPath                  = OdataActionsConstants.GetAzureWriteUrlActionPath;
            getExecutionSummaryStatusPath         = OdataActionsConstants.GetExecutionSummaryStatusActionPath;
            getExecutionSummaryPageUrlPath        = OdataActionsConstants.GetExecutionSummaryPageUrlActionPath;
            getImportTargetErrorKeysFileUrlPath   = OdataActionsConstants.GetImportTargetErrorKeysFileUrlPath;
            generateImportTargetErrorKeysFilePath = OdataActionsConstants.GenerateImportTargetErrorKeysFilePath;

            if (ImportJobDetail != null)
            {
                jobName.Text = ImportJobDetail.Key.Name;

                var jobGroup =
                    ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault(
                        x => x.Name == ImportJobDetail.Key.Group);
                jobGroupComboBox.SelectedItem = jobGroup;

                jobDescription.Text = ImportJobDetail.Description;

                useStandardSubfolder.Checked = false;
                inputFolderTextBox.Text      = ImportJobDetail.JobDataMap[SettingsConstants.InputDir]?.ToString() ??
                                               string.Empty;
                uploadSuccessFolderTextBox.Text =
                    ImportJobDetail.JobDataMap[SettingsConstants.UploadSuccessDir]?.ToString() ?? string.Empty;

                uploadErrorsFolderTextBox.Text =
                    ImportJobDetail.JobDataMap[SettingsConstants.UploadErrorsDir]?.ToString() ?? string.Empty;

                packageTemplateTextBox.Text =
                    ImportJobDetail.JobDataMap[SettingsConstants.PackageTemplate]?.ToString() ?? string.Empty;

                legalEntityTextBox.Text = ImportJobDetail.JobDataMap[SettingsConstants.Company]?.ToString() ??
                                          string.Empty;
                statusFileExtensionTextBox.Text =
                    ImportJobDetail.JobDataMap[SettingsConstants.StatusFileExtension]?.ToString() ?? ".Status";

                dataProject.Text = ImportJobDetail.JobDataMap[SettingsConstants.DataProject]?.ToString() ??
                                   string.Empty;

                overwriteDataProjectCheckBox.Checked =
                    (ImportJobDetail.JobDataMap[SettingsConstants.OverwriteDataProject] != null) &&
                    Convert.ToBoolean(ImportJobDetail.JobDataMap[SettingsConstants.OverwriteDataProject].ToString());

                executeImportCheckBox.Checked =
                    (ImportJobDetail.JobDataMap[SettingsConstants.ExecuteImport] != null) &&
                    Convert.ToBoolean(ImportJobDetail.JobDataMap[SettingsConstants.ExecuteImport].ToString());

                serviceAuthRadioButton.Checked =
                    (ImportJobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication] != null) &&
                    Convert.ToBoolean(ImportJobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication].ToString());
                if (!serviceAuthRadioButton.Checked)
                {
                    User axUser = null;
                    if (ImportJobDetail.JobDataMap[SettingsConstants.UserName] != null)
                    {
                        axUser =
                            ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault(
                                x => x.Login == ImportJobDetail.JobDataMap[SettingsConstants.UserName].ToString());
                    }
                    if (axUser == null)
                    {
                        var userName = ImportJobDetail.JobDataMap[SettingsConstants.UserName];
                        if (userName != null)
                        {
                            axUser = new User
                            {
                                Login    = userName.ToString(),
                                Password = ImportJobDetail.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 == ImportJobDetail.JobDataMap[SettingsConstants.AadClientId].ToString());
                if (application == null)
                {
                    if (ImportJobDetail.JobDataMap[SettingsConstants.AadClientSecret] == null)
                    {
                        application = new AadApplication
                        {
                            ClientId           = ImportJobDetail.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           = ImportJobDetail.JobDataMap[SettingsConstants.AadClientId].ToString(),
                            Secret             = ImportJobDetail.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 axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x =>
                                                                                                      (x.AosUri == ImportJobDetail.JobDataMap[SettingsConstants.AosUri].ToString()) &&
                                                                                                      (x.AadTenant == ImportJobDetail.JobDataMap[SettingsConstants.AadTenant].ToString()) &&
                                                                                                      (x.AzureAuthEndpoint == ImportJobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString()));
                if (axInstance == null)
                {
                    axInstance = new Instance
                    {
                        AosUri            = ImportJobDetail.JobDataMap[SettingsConstants.AosUri].ToString(),
                        AadTenant         = ImportJobDetail.JobDataMap[SettingsConstants.AadTenant].ToString(),
                        AzureAuthEndpoint = ImportJobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString(),
                        Name = Resources.IMPORTED_CHANGE_THIS
                    };
                    Properties.Settings.Default.Instances.Add(axInstance);
                }
                instanceComboBox.SelectedItem = axInstance;

                searchPatternTextBox.Text = ImportJobDetail.JobDataMap[SettingsConstants.SearchPattern]?.ToString() ??
                                            "*.*";
                orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions));
                var selectedOrderBy = OrderByOptions.FileName;
                if (ImportJobDetail.JobDataMap[SettingsConstants.OrderBy] != null)
                {
                    selectedOrderBy =
                        (OrderByOptions)
                        Enum.Parse(typeof(OrderByOptions),
                                   ImportJobDetail.JobDataMap[SettingsConstants.OrderBy].ToString());
                }
                orderByComboBox.SelectedItem = selectedOrderBy;

                orderDescendingRadioButton.Checked = (ImportJobDetail.JobDataMap[SettingsConstants.ReverseOrder] != null) &&
                                                     Convert.ToBoolean(
                    ImportJobDetail.JobDataMap[SettingsConstants.ReverseOrder]
                    .ToString());

                pauseIndefinitelyCheckBox.Checked =
                    (ImportJobDetail.JobDataMap[SettingsConstants.IndefinitePause] != null) &&
                    Convert.ToBoolean(ImportJobDetail.JobDataMap[SettingsConstants.IndefinitePause].ToString());

                if (ImportTrigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)ImportTrigger;
                    upJobSimpleTriggerRadioButton.Checked = true;
                    upJobHoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    upJobMinutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                }
                else if (ImportTrigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)ImportTrigger;
                    upJobCronTriggerRadioButton.Checked = true;
                    upJobCronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }
                if (ImportJobDetail.JobDataMap[SettingsConstants.RetryCount] != null)
                {
                    retriesCountUpDown.Value = Convert.ToDecimal(ImportJobDetail.JobDataMap[SettingsConstants.RetryCount]);
                }
                if (ImportJobDetail.JobDataMap[SettingsConstants.RetryDelay] != null)
                {
                    retriesDelayUpDown.Value = Convert.ToDecimal(ImportJobDetail.JobDataMap[SettingsConstants.RetryDelay]);
                }
                pauseOnExceptionsCheckBox.Checked =
                    (ImportJobDetail.JobDataMap[SettingsConstants.PauseJobOnException] != null) &&
                    Convert.ToBoolean(ImportJobDetail.JobDataMap[SettingsConstants.PauseJobOnException].ToString());

                importFromPackagePath = ImportJobDetail.JobDataMap[SettingsConstants.ImportFromPackageActionPath]?.ToString() ?? OdataActionsConstants.ImportFromPackageActionPath;
                getAzureWriteUrlPath  = ImportJobDetail.JobDataMap[SettingsConstants.GetAzureWriteUrlActionPath]?.ToString() ?? OdataActionsConstants.GetAzureWriteUrlActionPath;

                LegalEntityFileSeperator.Text =
                    ImportJobDetail.JobDataMap[SettingsConstants.LegalEntityFileSeperator]?.ToString() ?? string.Empty;


                Properties.Settings.Default.Save();
            }
            if ((ExecutionJobDetail != null) && (ExecutionTrigger != null))
            {
                useMonitoringJobCheckBox.Checked    = true;
                processingSuccessFolderTextBox.Text =
                    ExecutionJobDetail.JobDataMap[SettingsConstants.ProcessingSuccessDir]?.ToString() ?? string.Empty;
                processingErrorsFolderTextBox.Text =
                    ExecutionJobDetail.JobDataMap[SettingsConstants.ProcessingErrorsDir]?.ToString() ?? string.Empty;

                if (ExecutionTrigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)ExecutionTrigger;
                    procJobSimpleTriggerRadioButton.Checked = true;
                    procJobHoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    procJobMinutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                }
                else if (ExecutionTrigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)ExecutionTrigger;
                    procJobCronTriggerRadioButton.Checked = true;
                    procJobCronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }

                getExecutionSummaryStatusPath         = ExecutionJobDetail.JobDataMap[SettingsConstants.GetExecutionSummaryStatusActionPath]?.ToString() ?? OdataActionsConstants.GetExecutionSummaryStatusActionPath;
                getExecutionSummaryPageUrlPath        = ExecutionJobDetail.JobDataMap[SettingsConstants.GetExecutionSummaryPageUrlActionPath]?.ToString() ?? OdataActionsConstants.GetExecutionSummaryPageUrlActionPath;
                getImportTargetErrorKeysFileUrlPath   = ExecutionJobDetail.JobDataMap[SettingsConstants.GetImportTargetErrorKeysFileUrlPath]?.ToString() ?? OdataActionsConstants.GetImportTargetErrorKeysFileUrlPath;
                generateImportTargetErrorKeysFilePath = ExecutionJobDetail.JobDataMap[SettingsConstants.GenerateImportTargetErrorKeysFilePath]?.ToString() ?? OdataActionsConstants.GenerateImportTargetErrorKeysFilePath;

                downloadErrorKeysFileCheckBox.Checked =
                    (ExecutionJobDetail.JobDataMap[SettingsConstants.GetImportTargetErrorKeysFile] != null) &&
                    Convert.ToBoolean(ExecutionJobDetail.JobDataMap[SettingsConstants.GetImportTargetErrorKeysFile].ToString());
            }
        }
Example #4
0
        private void ExportJobForm_Load(object sender, EventArgs e)
        {
            Cancelled = false;
            //Few changes based on form mode (create or edit)
            Text = JobDetail == null
                ? Resources.Add_export_job
                : string.Format(Resources.Edit_job_0, JobDetail.Key.Name);
            addToolStripButton.Text = JobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job;
            jobName.Enabled         = JobDetail == null;

            jobGroupComboBox.DataSource    = Properties.Settings.Default.JobGroups;
            jobGroupComboBox.ValueMember   = null;
            jobGroupComboBox.DisplayMember = "Name";

            jobGroupComboBox.Enabled = JobDetail == null;

            instanceComboBox.DataSource    = Properties.Settings.Default.Instances;
            instanceComboBox.ValueMember   = null;
            instanceComboBox.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";

            startAtDateTimePicker.Value = DateTime.Now;

            errorsFolder.Text = Properties.Settings.Default.DownloadErrorsFolder;

            exportToPackageTextBox.Text           = PackageApiActions.ExportToPackageActionPath;
            getExecutionSummaryStatusTextBox.Text = PackageApiActions.GetExecutionSummaryStatusActionPath;
            getExportedPackageUrlTextBox.Text     = PackageApiActions.GetExportedPackageUrlActionPath;

            if ((JobDetail != null) && (Trigger != null))
            {
                jobName.Text = JobDetail.Key.Name;

                var jobGroup =
                    ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault(
                        x => x.Name == JobDetail.Key.Group);
                jobGroupComboBox.SelectedItem = jobGroup;

                jobDescription.Text = JobDetail.Description;

                downloadFolder.Text          = JobDetail.JobDataMap[SettingsConstants.DownloadSuccessDir]?.ToString() ?? string.Empty;
                errorsFolder.Text            = JobDetail.JobDataMap[SettingsConstants.DownloadErrorsDir]?.ToString() ?? string.Empty;
                useStandardSubfolder.Checked = false;

                unzipCheckBox.Checked = (JobDetail.JobDataMap[SettingsConstants.UnzipPackage] != null) &&
                                        Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.UnzipPackage].ToString());
                addTimestampCheckBox.Checked = (JobDetail.JobDataMap[SettingsConstants.AddTimestamp] != null) &&
                                               Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.AddTimestamp].ToString());
                deletePackageCheckBox.Checked = (JobDetail.JobDataMap[SettingsConstants.DeletePackage] != null) &&
                                                Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.DeletePackage].ToString());
                serviceAuthRadioButton.Checked = (JobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication] !=
                                                  null) &&
                                                 Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication]
                    .ToString());

                dataProject.Text = JobDetail.JobDataMap[SettingsConstants.DataProject]?.ToString() ?? string.Empty;

                legalEntity.Text = JobDetail.JobDataMap[SettingsConstants.Company]?.ToString() ?? string.Empty;

                delayBetweenStatusCheckNumericUpDown.Value = Math.Round(Convert.ToDecimal(JobDetail.JobDataMap[SettingsConstants.DelayBetweenStatusCheck]));

                delayBetweenAttemptsNumericUpDown.Value = Math.Round(Convert.ToDecimal(JobDetail.JobDataMap[SettingsConstants.DelayBetweenFiles]));

                if (!serviceAuthRadioButton.Checked)
                {
                    User axUser = null;
                    if (JobDetail.JobDataMap[SettingsConstants.UserName] != null)
                    {
                        axUser =
                            ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault(
                                x => x.Login == JobDetail.JobDataMap[SettingsConstants.UserName].ToString());
                    }
                    if (axUser == null)
                    {
                        var userName = JobDetail.JobDataMap[SettingsConstants.UserName];
                        if (userName != null)
                        {
                            axUser = new User
                            {
                                Login    = userName.ToString(),
                                Password = JobDetail.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 == JobDetail.JobDataMap[SettingsConstants.AadClientId].ToString());
                if (application == null)
                {
                    if (JobDetail.JobDataMap[SettingsConstants.AadClientSecret] == null)
                    {
                        application = new AadApplication
                        {
                            ClientId           = JobDetail.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           = JobDetail.JobDataMap[SettingsConstants.AadClientId].ToString(),
                            Secret             = JobDetail.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 axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x =>
                                                                                                      (x.AosUri == JobDetail.JobDataMap[SettingsConstants.AosUri].ToString()) &&
                                                                                                      (x.AadTenant == JobDetail.JobDataMap[SettingsConstants.AadTenant].ToString()) &&
                                                                                                      (x.AzureAuthEndpoint == JobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString()));
                if (axInstance == null)
                {
                    axInstance = new Instance
                    {
                        AosUri            = JobDetail.JobDataMap[SettingsConstants.AosUri].ToString(),
                        AadTenant         = JobDetail.JobDataMap[SettingsConstants.AadTenant].ToString(),
                        AzureAuthEndpoint = JobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString(),
                        Name = Resources.IMPORTED_CHANGE_THIS
                    };
                    Properties.Settings.Default.Instances.Add(axInstance);
                }
                instanceComboBox.SelectedItem = axInstance;

                pauseIndefinitelyCheckBox.Checked =
                    (JobDetail.JobDataMap[SettingsConstants.IndefinitePause] != null) &&
                    Convert.ToBoolean(JobDetail.JobDataMap[SettingsConstants.IndefinitePause].ToString());

                if (Trigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)Trigger;
                    simpleTriggerRadioButton.Checked = true;
                    hoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    minutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                }
                else if (Trigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)Trigger;
                    cronTriggerRadioButton.Checked = true;
                    cronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }
                if (JobDetail.JobDataMap[SettingsConstants.RetryCount] != null)
                {
                    retriesCountUpDown.Value = Convert.ToDecimal(JobDetail.JobDataMap[SettingsConstants.RetryCount]);
                }
                if (JobDetail.JobDataMap[SettingsConstants.RetryDelay] != null)
                {
                    retriesDelayUpDown.Value = Convert.ToDecimal(JobDetail.JobDataMap[SettingsConstants.RetryDelay]);
                }
                pauseOnExceptionsCheckBox.Checked =
                    (JobDetail.JobDataMap[SettingsConstants.PauseJobOnException] != null) &&
                    Convert.ToBoolean(JobDetail.JobDataMap[SettingsConstants.PauseJobOnException].ToString());

                exportToPackageTextBox.Text           = JobDetail.JobDataMap[SettingsConstants.ExportToPackageActionPath]?.ToString() ?? PackageApiActions.ExportToPackageActionPath;
                getExecutionSummaryStatusTextBox.Text = JobDetail.JobDataMap[SettingsConstants.GetExecutionSummaryStatusActionPath]?.ToString() ?? PackageApiActions.GetExecutionSummaryStatusActionPath;
                getExportedPackageUrlTextBox.Text     = JobDetail.JobDataMap[SettingsConstants.GetExportedPackageUrlActionPath]?.ToString() ?? PackageApiActions.GetExportedPackageUrlActionPath;

                verboseLoggingCheckBox.Checked =
                    (JobDetail.JobDataMap[SettingsConstants.LogVerbose] != null) &&
                    Convert.ToBoolean(JobDetail.JobDataMap[SettingsConstants.LogVerbose].ToString());

                Properties.Settings.Default.Save();
            }
        }
Example #5
0
        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);
        }
Example #6
0
        private void DownloadJobForm_Load(object sender, EventArgs e)
        {
            Cancelled = false;
            //Few changes based on form mode (create or edit)
            Text = JobDetail == null
                ? Resources.Add_download_job
                : string.Format(Resources.Edit_job_0, JobDetail.Key.Name);
            addToolStripButton.Text = JobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job;
            jobName.Enabled         = JobDetail == null;

            jobGroupComboBox.DataSource    = Properties.Settings.Default.JobGroups;
            jobGroupComboBox.ValueMember   = null;
            jobGroupComboBox.DisplayMember = "Name";

            jobGroupComboBox.Enabled = JobDetail == 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.Download).ToList();
            dataJobComboBox.ValueMember   = null;
            dataJobComboBox.DisplayMember = "Name";

            startAtDateTimePicker.Value = DateTime.Now;

            errorsFolder.Text = Properties.Settings.Default.DownloadErrorsFolder;

            if ((JobDetail != null) && (Trigger != null))
            {
                jobName.Text = JobDetail.Key.Name;

                var jobGroup = ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault(x => x.Name == JobDetail.Key.Group);
                jobGroupComboBox.SelectedItem = jobGroup;

                jobDescription.Text = JobDetail.Description;

                downloadFolder.Text          = JobDetail.JobDataMap.GetString(SettingsConstants.DownloadSuccessDir);
                errorsFolder.Text            = JobDetail.JobDataMap.GetString(SettingsConstants.DownloadErrorsDir);
                useStandardSubfolder.Checked = false;

                unzipCheckBox.Checked                = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.UnzipPackage);
                addTimestampCheckBox.Checked         = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.AddTimestamp);
                deletePackageCheckBox.Checked        = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.DeletePackage);
                serviceAuthRadioButton.Checked       = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.UseServiceAuthentication);
                delayBetweenFilesNumericUpDown.Value = JobDetail.JobDataMap.GetInt(SettingsConstants.DelayBetweenFiles);

                if (!serviceAuthRadioButton.Checked)
                {
                    User axUser = null;
                    if (!JobDetail.JobDataMap.GetString(SettingsConstants.UserName).IsNullOrWhiteSpace())
                    {
                        axUser = ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault(x => x.Login == JobDetail.JobDataMap.GetString(SettingsConstants.UserName));
                    }
                    if (axUser == null)
                    {
                        axUser = new User
                        {
                            Login    = JobDetail.JobDataMap.GetString(SettingsConstants.UserName),
                            Password = JobDetail.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 == JobDetail.JobDataMap.GetString(SettingsConstants.AadClientId));
                if (application == null)
                {
                    if (!serviceAuthRadioButton.Checked)
                    {
                        application = new AadApplication
                        {
                            ClientId           = JobDetail.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           = JobDetail.JobDataMap.GetString(SettingsConstants.AadClientId) ?? Guid.Empty.ToString(),
                            Secret             = JobDetail.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 == JobDetail.JobDataMap.GetString(SettingsConstants.ActivityId));
                if (dataJob == null)
                {
                    dataJob = new DataJob
                    {
                        ActivityId = JobDetail.JobDataMap.GetString(SettingsConstants.ActivityId),
                        Type       = DataJobType.Download,
                        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.Download).ToList();
                }
                dataJobComboBox.SelectedItem = dataJob;

                var axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x =>
                                                                                                      (x.AosUri == JobDetail.JobDataMap.GetString(SettingsConstants.AosUri)) &&
                                                                                                      (x.AadTenant == JobDetail.JobDataMap.GetString(SettingsConstants.AadTenant)) &&
                                                                                                      (x.AzureAuthEndpoint == JobDetail.JobDataMap.GetString(SettingsConstants.AzureAuthEndpoint)));
                if (axInstance == null)
                {
                    axInstance = new Instance
                    {
                        AosUri            = JobDetail.JobDataMap.GetString(SettingsConstants.AosUri),
                        AadTenant         = JobDetail.JobDataMap.GetString(SettingsConstants.AadTenant),
                        AzureAuthEndpoint = JobDetail.JobDataMap.GetString(SettingsConstants.AzureAuthEndpoint),
                        UseADAL           = JobDetail.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;

                pauseIndefinitelyCheckBox.Checked = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.IndefinitePause);

                if (Trigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)Trigger;
                    simpleTriggerRadioButton.Checked = true;
                    hoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    minutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                }
                else if (Trigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)Trigger;
                    cronTriggerRadioButton.Checked = true;
                    cronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }

                retriesCountUpDown.Value = JobDetail.JobDataMap.GetInt(SettingsConstants.RetryCount);
                retriesDelayUpDown.Value = JobDetail.JobDataMap.GetInt(SettingsConstants.RetryDelay);

                pauseOnExceptionsCheckBox.Checked = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.PauseJobOnException);

                verboseLoggingCheckBox.Checked = JobDetail.JobDataMap.GetBooleanValue(SettingsConstants.LogVerbose);

                Properties.Settings.Default.Save();
            }
            SetDropDownsWidth(this);
        }
Example #7
0
        private void DownloadJobForm_Load(object sender, EventArgs e)
        {
            Cancelled = false;
            //Few changes based on form mode (create or edit)
            Text = JobDetail == null
                ? Resources.Add_download_job
                : string.Format(Resources.Edit_job_0, JobDetail.Key.Name);
            addJobButton.Text = JobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job;
            jobName.Enabled   = JobDetail == null;

            jobGroupComboBox.DataSource    = Properties.Settings.Default.JobGroups;
            jobGroupComboBox.ValueMember   = null;
            jobGroupComboBox.DisplayMember = Resources.Name;

            jobGroupComboBox.Enabled = JobDetail == null;

            instanceComboBox.DataSource    = Properties.Settings.Default.Instances;
            instanceComboBox.ValueMember   = null;
            instanceComboBox.DisplayMember = Resources.Name;

            var dataJobs            = Properties.Settings.Default.DataJobs.Where(x => x.Type == DataJobType.Download);
            var dataJobsBindingList = new BindingList <DataJob>(dataJobs.ToList());

            dataJobComboBox.DataSource    = dataJobsBindingList;
            dataJobComboBox.ValueMember   = null;
            dataJobComboBox.DisplayMember = Resources.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 = Resources.Name;

            userComboBox.DataSource    = Properties.Settings.Default.Users;
            userComboBox.ValueMember   = null;
            userComboBox.DisplayMember = "Login";

            startAtDateTimePicker.Value = DateTime.Now;

            errorsFolder.Text = Properties.Settings.Default.DownloadErrorsFolder;

            if ((JobDetail != null) && (Trigger != null))
            {
                jobName.Text = JobDetail.Key.Name;

                var jobGroup =
                    ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault(
                        x => x.Name == JobDetail.Key.Group);
                jobGroupComboBox.SelectedItem = jobGroup;

                jobDescription.Text = JobDetail.Description;

                downloadFolder.Text = JobDetail.JobDataMap[SettingsConstants.DownloadSuccessDir]?.ToString() ??
                                      string.Empty;
                errorsFolder.Text = JobDetail.JobDataMap[SettingsConstants.DownloadErrorsDir]?.ToString() ??
                                    string.Empty;
                useStandardSubfolder.Checked = false;

                unzipCheckBox.Checked = (JobDetail.JobDataMap[SettingsConstants.UnzipPackage] != null) &&
                                        Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.UnzipPackage].ToString());
                addTimestampCheckBox.Checked = (JobDetail.JobDataMap[SettingsConstants.AddTimestamp] != null) &&
                                               Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.AddTimestamp].ToString());
                deletePackageCheckBox.Checked = (JobDetail.JobDataMap[SettingsConstants.DeletePackage] != null) &&
                                                Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.DeletePackage].ToString());
                serviceAuthRadioButton.Checked = (JobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication] !=
                                                  null) &&
                                                 Convert.ToBoolean(
                    JobDetail.JobDataMap[SettingsConstants.UseServiceAuthentication]
                    .ToString());

                if (!serviceAuthRadioButton.Checked)
                {
                    User axUser = null;
                    if (JobDetail.JobDataMap[SettingsConstants.UserName] != null)
                    {
                        axUser =
                            ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault(
                                x => x.Login == JobDetail.JobDataMap[SettingsConstants.UserName].ToString());
                    }
                    if (axUser == null)
                    {
                        var userName = JobDetail.JobDataMap[SettingsConstants.UserName];
                        if (userName != null)
                        {
                            axUser = new User
                            {
                                Login    = userName.ToString(),
                                Password = JobDetail.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 == JobDetail.JobDataMap[SettingsConstants.AadClientId].ToString());
                if (application == null)
                {
                    if (JobDetail.JobDataMap[SettingsConstants.AadClientSecret] == null)
                    {
                        application = new AadApplication
                        {
                            ClientId           = JobDetail.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 = Resources.Name;
                    }
                    else
                    {
                        application = new AadApplication
                        {
                            ClientId           = JobDetail.JobDataMap[SettingsConstants.AadClientId].ToString(),
                            Secret             = JobDetail.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 == JobDetail.JobDataMap[SettingsConstants.ActivityId].ToString());
                if (dataJob == null)
                {
                    dataJob = new DataJob
                    {
                        ActivityId = JobDetail.JobDataMap[SettingsConstants.ActivityId].ToString(),
                        Type       = DataJobType.Download,
                        Name       = Resources.IMPORTED_CHANGE_THIS
                    };
                    Properties.Settings.Default.DataJobs.Add(dataJob);
                    dataJobs                      = Properties.Settings.Default.DataJobs.Where(x => x.Type == DataJobType.Download);
                    dataJobsBindingList           = new BindingList <DataJob>(dataJobs.ToList());
                    dataJobComboBox.DataSource    = dataJobsBindingList;
                    dataJobComboBox.ValueMember   = null;
                    dataJobComboBox.DisplayMember = Resources.Name;
                }
                dataJobComboBox.SelectedItem = dataJob;

                var axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x =>
                                                                                                      (x.AosUri == JobDetail.JobDataMap[SettingsConstants.AosUri].ToString()) &&
                                                                                                      (x.AadTenant == JobDetail.JobDataMap[SettingsConstants.AadTenant].ToString()) &&
                                                                                                      (x.AzureAuthEndpoint == JobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString()));
                if (axInstance == null)
                {
                    axInstance = new Instance
                    {
                        AosUri            = JobDetail.JobDataMap[SettingsConstants.AosUri].ToString(),
                        AadTenant         = JobDetail.JobDataMap[SettingsConstants.AadTenant].ToString(),
                        AzureAuthEndpoint = JobDetail.JobDataMap[SettingsConstants.AzureAuthEndpoint].ToString(),
                        Name = Resources.IMPORTED_CHANGE_THIS
                    };
                    Properties.Settings.Default.Instances.Add(axInstance);
                }
                instanceComboBox.SelectedItem = axInstance;

                if (Trigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)Trigger;
                    simpleTriggerRadioButton.Checked = true;
                    hoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    minutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                }
                else if (Trigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)Trigger;
                    cronTriggerRadioButton.Checked = true;
                    cronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }
                Properties.Settings.Default.Save();
            }
        }
Example #8
0
        private void ImportJobForm_Load(object sender, EventArgs e)
        {
            Cancelled = false;
            //Few changes based on form mode (create or edit)
            Text = ImportJobDetail == null
                ? Resources.Add_import_job
                : string.Format(Resources.Edit_job_0, ImportJobDetail.Key.Name);
            addToolStripButton.Text = ImportJobDetail == null ? Resources.Add_to_schedule : Resources.Edit_job;
            jobName.Enabled         = ImportJobDetail == null;

            jobGroupComboBox.DataSource    = Properties.Settings.Default.JobGroups;
            jobGroupComboBox.ValueMember   = null;
            jobGroupComboBox.DisplayMember = "Name";

            jobGroupComboBox.Enabled = ImportJobDetail == 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";

            orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions));

            importJobStartAtDateTimePicker.Value     = DateTime.Now;
            monitoringJobStartAtDateTimePicker.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;

            importFromPackageTextBox.Text                 = PackageApiActions.ImportFromPackageActionPath;
            getAzureWriteUrlTextBox.Text                  = PackageApiActions.GetAzureWriteUrlActionPath;
            getExecutionSummaryStatusTextBox.Text         = PackageApiActions.GetExecutionSummaryStatusActionPath;
            getExecutionSummaryPageUrlTextBox.Text        = PackageApiActions.GetExecutionSummaryPageUrlActionPath;
            getImportTargetErrorKeysFileUrlTextBox.Text   = PackageApiActions.GetImportTargetErrorKeysFileUrlPath;
            generateImportTargetErrorKeysFileTextBox.Text = PackageApiActions.GenerateImportTargetErrorKeysFilePath;
            getExecutionErrorsTextBox.Text                = PackageApiActions.GetExecutionErrorsPath;

            if (ImportJobDetail != null)
            {
                jobName.Text = ImportJobDetail.Key.Name;

                var jobGroup = ((IEnumerable <JobGroup>)jobGroupComboBox.DataSource).FirstOrDefault(x => x.Name == ImportJobDetail.Key.Group);
                jobGroupComboBox.SelectedItem = jobGroup;

                jobDescription.Text             = ImportJobDetail.Description;
                useStandardSubfolder.Checked    = false;
                inputFolderTextBox.Text         = ImportJobDetail.JobDataMap.GetString(SettingsConstants.InputDir);
                uploadSuccessFolderTextBox.Text = ImportJobDetail.JobDataMap.GetString(SettingsConstants.UploadSuccessDir);
                uploadErrorsFolderTextBox.Text  = ImportJobDetail.JobDataMap.GetString(SettingsConstants.UploadErrorsDir);
                packageTemplateTextBox.Text     = ImportJobDetail.JobDataMap.GetString(SettingsConstants.PackageTemplate);
                legalEntityTextBox.Text         = ImportJobDetail.JobDataMap.GetString(SettingsConstants.Company);
                statusFileExtensionTextBox.Text = ImportJobDetail.JobDataMap.GetString(SettingsConstants.StatusFileExtension);
                dataProject.Text = ImportJobDetail.JobDataMap.GetString(SettingsConstants.DataProject);
                overwriteDataProjectCheckBox.Checked = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.OverwriteDataProject);
                executeImportCheckBox.Checked        = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.ExecuteImport);
                delayBetweenFilesNumericUpDown.Value = ImportJobDetail.JobDataMap.GetInt(SettingsConstants.DelayBetweenFiles);
                serviceAuthRadioButton.Checked       = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.UseServiceAuthentication);

                if (!serviceAuthRadioButton.Checked)
                {
                    User axUser = null;
                    if (!ImportJobDetail.JobDataMap.GetString(SettingsConstants.UserName).IsNullOrWhiteSpace())
                    {
                        axUser = ((IEnumerable <User>)userComboBox.DataSource).FirstOrDefault(x => x.Login == ImportJobDetail.JobDataMap.GetString(SettingsConstants.UserName));
                    }
                    if (axUser == null)
                    {
                        axUser = new User
                        {
                            Login    = ImportJobDetail.JobDataMap.GetString(SettingsConstants.UserName),
                            Password = ImportJobDetail.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 == ImportJobDetail.JobDataMap.GetString(SettingsConstants.AadClientId));
                if (application == null)
                {
                    if (!serviceAuthRadioButton.Checked)
                    {
                        application = new AadApplication
                        {
                            ClientId           = ImportJobDetail.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           = ImportJobDetail.JobDataMap.GetString(SettingsConstants.AadClientId) ?? Guid.Empty.ToString(),
                            Secret             = ImportJobDetail.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 axInstance = ((IEnumerable <Instance>)instanceComboBox.DataSource).FirstOrDefault(x =>
                                                                                                      (x.AosUri == ImportJobDetail.JobDataMap.GetString(SettingsConstants.AosUri)) &&
                                                                                                      (x.AadTenant == ImportJobDetail.JobDataMap.GetString(SettingsConstants.AadTenant)) &&
                                                                                                      (x.AzureAuthEndpoint == ImportJobDetail.JobDataMap.GetString(SettingsConstants.AzureAuthEndpoint)));
                if (axInstance == null)
                {
                    axInstance = new Instance
                    {
                        AosUri            = ImportJobDetail.JobDataMap.GetString(SettingsConstants.AosUri),
                        AadTenant         = ImportJobDetail.JobDataMap.GetString(SettingsConstants.AadTenant),
                        AzureAuthEndpoint = ImportJobDetail.JobDataMap.GetString(SettingsConstants.AzureAuthEndpoint),
                        UseADAL           = ImportJobDetail.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  = ImportJobDetail.JobDataMap.GetString(SettingsConstants.SearchPattern) ?? "*.*";
                orderByComboBox.DataSource = Enum.GetValues(typeof(OrderByOptions));
                var selectedOrderBy = OrderByOptions.FileName;
                if (!ImportJobDetail.JobDataMap.GetString(SettingsConstants.OrderBy).IsNullOrWhiteSpace())
                {
                    selectedOrderBy = (OrderByOptions)Enum.Parse(typeof(OrderByOptions), ImportJobDetail.JobDataMap.GetString(SettingsConstants.OrderBy));
                }
                orderByComboBox.SelectedItem = selectedOrderBy;

                orderDescendingRadioButton.Checked    = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.ReverseOrder);
                inputFilesArePackagesCheckBox.Checked = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.InputFilesArePackages);
                pauseIndefinitelyCheckBox.Checked     = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.IndefinitePause);

                if (ImportTrigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)ImportTrigger;
                    importJobSimpleTriggerRadioButton.Checked = true;
                    importJobHoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    importJobMinutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                    importJobStartAtDateTimePicker.Value      = localTrigger.StartTimeUtc.UtcDateTime.ToLocalTime();
                }
                else if (ImportTrigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)ImportTrigger;
                    importJobCronTriggerRadioButton.Checked = true;
                    importJobCronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }

                retriesCountUpDown.Value = ImportJobDetail.JobDataMap.GetInt(SettingsConstants.RetryCount);
                retriesDelayUpDown.Value = ImportJobDetail.JobDataMap.GetInt(SettingsConstants.RetryDelay);

                pauseOnExceptionsCheckBox.Checked = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.PauseJobOnException);

                importFromPackageTextBox.Text = ImportJobDetail.JobDataMap.GetString(SettingsConstants.ImportFromPackageActionPath) ?? PackageApiActions.ImportFromPackageActionPath;
                getAzureWriteUrlTextBox.Text  = ImportJobDetail.JobDataMap.GetString(SettingsConstants.GetAzureWriteUrlActionPath) ?? PackageApiActions.GetAzureWriteUrlActionPath;

                multicompanyCheckBox.Checked = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.MultiCompanyImport);
                getLegalEntityFromFilenameRadioButton.Checked = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.GetLegalEntityFromFilename);
                filenameSeparatorTextBox.Text = ImportJobDetail.JobDataMap.GetString(SettingsConstants.FilenameSeparator);

                legalEntityTokenPositionNumericUpDown.Value = ImportJobDetail.JobDataMap.GetInt(SettingsConstants.LegalEntityTokenPosition);

                verboseLoggingCheckBox.Checked = ImportJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.LogVerbose);

                Properties.Settings.Default.Save();
            }
            if ((ExecutionJobDetail != null) && (ExecutionTrigger != null))
            {
                useMonitoringJobCheckBox.Checked    = true;
                processingSuccessFolderTextBox.Text = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.ProcessingSuccessDir);
                processingErrorsFolderTextBox.Text  = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.ProcessingErrorsDir);

                if (ExecutionTrigger.GetType() == typeof(SimpleTriggerImpl))
                {
                    var localTrigger = (SimpleTriggerImpl)ExecutionTrigger;
                    monitoringJobSimpleTriggerRadioButton.Checked = true;
                    monitoringJobHoursDateTimePicker.Value        = DateTime.Now.Date + localTrigger.RepeatInterval;
                    monitoringJobMinutesDateTimePicker.Value      = DateTime.Now.Date + localTrigger.RepeatInterval;
                    monitoringJobStartAtDateTimePicker.Value      = localTrigger.StartTimeUtc.UtcDateTime.ToLocalTime();
                }
                else if (ExecutionTrigger.GetType() == typeof(CronTriggerImpl))
                {
                    var localTrigger = (CronTriggerImpl)ExecutionTrigger;
                    monitoringJobCronTriggerRadioButton.Checked = true;
                    monitoringJobCronExpressionTextBox.Text     = localTrigger.CronExpressionString;
                }

                getExecutionSummaryStatusTextBox.Text         = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.GetExecutionSummaryStatusActionPath) ?? PackageApiActions.GetExecutionSummaryStatusActionPath;
                getExecutionSummaryPageUrlTextBox.Text        = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.GetExecutionSummaryPageUrlActionPath) ?? PackageApiActions.GetExecutionSummaryPageUrlActionPath;
                getImportTargetErrorKeysFileUrlTextBox.Text   = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.GetImportTargetErrorKeysFileUrlPath) ?? PackageApiActions.GetImportTargetErrorKeysFileUrlPath;
                generateImportTargetErrorKeysFileTextBox.Text = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.GenerateImportTargetErrorKeysFilePath) ?? PackageApiActions.GenerateImportTargetErrorKeysFilePath;
                getExecutionErrorsTextBox.Text = ExecutionJobDetail.JobDataMap.GetString(SettingsConstants.GetExecutionErrorsPath) ?? PackageApiActions.GetExecutionErrorsPath;

                downloadErrorKeysFileCheckBox.Checked = ExecutionJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.GetImportTargetErrorKeysFile);
                getExecutionErrorsCheckBox.Checked    = ExecutionJobDetail.JobDataMap.GetBooleanValue(SettingsConstants.GetExecutionErrors);
                statusCheckDelayNumericUpDown.Value   = ExecutionJobDetail.JobDataMap.GetInt(SettingsConstants.DelayBetweenStatusCheck);
            }
            FormsHelper.SetDropDownsWidth(this);
        }