in Scheduler/Forms/DownloadJobV3.cs [45:206]
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;
startAtDateTimePicker.Value = localTrigger.StartTimeUtc.UtcDateTime.ToLocalTime();
}
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();
}
FormsHelper.SetDropDownsWidth(this);
}