コード例 #1
0
 void FinishJob(DataJob g)
 {
     finishedJobs.Enqueue(new JobFinished
     {
         x         = g.x,
         y         = g.y,
         z         = g.z,
         chunkSize = g.chunkSize,
         vertices  = g.vertices.ToArray(),
         tris      = g.tris.ToArray(),
         col       = g.col.ToArray(),
         lengths   = g.lengths.ToArray()
     });
 }
コード例 #2
0
 private void ButtonOK_Click(object sender, EventArgs e)
 {
     if (InputIsValid())
     {
         DataJob = new DataJob
         {
             Name       = textBox1.Text,
             ActivityId = textBox2.Text,
             EntityName = textBox3.Text,
             Type       = (DataJobType)comboBox1.SelectedItem
         }
     }
     ;
     else
     {
         DialogResult = DialogResult.None;
     }
 }
コード例 #3
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";

            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;
                }
            }
        }
コード例 #4
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);
        }
コード例 #5
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";

            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 = "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;

            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());
                delayBetweenFilesNumericUpDown.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 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 = "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;

                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());

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

                Properties.Settings.Default.Save();
            }
        }
コード例 #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);
        }
コード例 #7
0
ファイル: Services.cs プロジェクト: hjrnz1/NewsData
        private Sresponse getSentiment(DataJob.Doc d)
        {
            this.client = new WebClient();
            this.s = new Sresponse();
            s = JsonConvert.DeserializeObject<Sresponse>(client.DownloadString(sService + sQuery + d.source.enriched.url.url + "&apikey=" + apiKey));

            if (s.status == "OK" && s.results != null)
            {
                Sentiment r = s.results[0].sentiment;

                using (Context db = new Context())
                {
                    r.docid = d.id;
                    r.timestamp = d.timestamp;
                    r.url = d.source.enriched.url.url;
                    r.title = d.source.enriched.url.title;

                    db.Sentiment.Add(r);
                    db.SaveChanges();
                    Console.WriteLine("Added new article: " + r.url);
                }
            }

            return s;
        }