private void btnCreate_Click(object sender, EventArgs e) { var scheduledJob = new ScheduledJobDto(); scheduledJob.TaskMode = ScheduledTaskMode.BillingStatement; scheduledJob.Name = scheduledJobName.Text; scheduledJob.Enabled = scheduledJobEnabled.Checked; scheduledJob.StartDate = scheduledJobStartDate.DateTime.ToUniversalTime(); using (var apt = DevExpress.XtraScheduler.Compatibility.StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern)) { apt.RecurrenceInfo.Type = RecurrenceType.Daily; apt.RecurrenceInfo.Start = scheduledJob.StartDate; apt.RecurrenceInfo.WeekDays = WeekDays.WorkDays; scheduledJob.SerializedRecurrenceInfo = apt.RecurrenceInfo.ToXml(); } scheduledJob.SchedulerParameters = new SchedulerParameters() { Binding = new ParametersBinding() { DataModelId = 1, DataMember = "vwEmployees", EmailField = "Email", DisplayNameField = "DisplayName" } }; scheduledJob.InternalSubscribers = null; scheduledJob.ExternalSubscribers = externalSubscribers.Text; scheduledJob.ExportToSharedFolder = exportToSharedFolder.Text; int selectedReportId; if (int.TryParse(reportId.Text, out selectedReportId)) { scheduledJob.ReportId = selectedReportId; } else { scheduledJob.ReportId = null; } serverConnection .DoWithScheduledJobAsync(x => x.CreateScheduledJobAsync(scheduledJob, null)) .ContinueWith(taskFunc => { if (taskFunc.IsFaulted) { MessageBox.Show(taskFunc.Exception.GetBaseException().Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { id.Text = taskFunc.Result.ToString(); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
Appointment CreateAppointment(ScheduledJobDto scheduledJob) { if (string.IsNullOrEmpty(scheduledJob.SerializedRecurrenceInfo)) { return(null); } var appointment = DevExpress.XtraScheduler.Compatibility.StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); appointment.Start = scheduledJob.StartDate.ToLocalTime(); appointment.RecurrenceInfo.FromXml(scheduledJob.SerializedRecurrenceInfo); appointment.RecurrenceInfo.Start = appointment.Start; return(appointment); }
void FillScheduledJob(ScheduledJobDto scheduledJob) { id.Text = string.Format("{0}", scheduledJob.Id); scheduledJobName.Text = scheduledJob.Name; scheduledJobEnabled.Checked = scheduledJob.Enabled; scheduledJobStartDate.DateTime = scheduledJob.StartDate.ToLocalTime(); reportId.Text = string.Format("{0}", scheduledJob.ReportId); FillRecurrencyInfo(scheduledJob); FillParametersBinding(scheduledJob); FillParameters(scheduledJob); FillExternalSubscribers(scheduledJob); FillExportToShared(scheduledJob); }
void FillParameters(ScheduledJobDto scheduledJob) { var parameters = new List <Parameter>(); foreach (var item in scheduledJob.SchedulerParameters.Parameters) { parameters.Add(new Parameter() { Name = item.Key, Source = item.Value.Source, Value = item.Value.Value }); } reportParametersGrid.DataSource = parameters; reportParametersView.BestFitColumns(); }
void FillRecurrencyInfo(ScheduledJobDto scheduledJob) { recurrencyInfo.Text = string.Empty; var appointment = CreateAppointment(scheduledJob); if (appointment == null) { return; } var culture = Thread.CurrentThread.CurrentUICulture; var infos = new List <Info>(); infos.Add(new Info { Name = "Description", Value = RecurrenceInfo.GetDescription(appointment, culture.DateTimeFormat.FirstDayOfWeek) }); infos.Add(new Info { Name = "Next start", Value = GetNextDateDisplayText(appointment) }); recurrencyInfoGrid.DataSource = infos; recurrencyInfoView.BestFitColumns(); }
void FillParametersBinding(ScheduledJobDto scheduledJob) { var infos = new List <Info>(); if (scheduledJob.SchedulerParameters.Binding != null) { infos.Add(new Info { Name = "Data Model (id)", Value = scheduledJob.SchedulerParameters.Binding.DataModelId }); infos.Add(new Info { Name = "Data Member", Value = scheduledJob.SchedulerParameters.Binding.DataMember }); infos.Add(new Info { Name = "Email Field", Value = scheduledJob.SchedulerParameters.Binding.EmailField }); infos.Add(new Info { Name = "Recipient Name Field", Value = scheduledJob.SchedulerParameters.Binding.DisplayNameField }); parametersBindingGrid.DataSource = infos; parametersBindingView.BestFitColumns(); } }
void FillExportToShared(ScheduledJobDto scheduledJob) { exportToSharedFolder.Text = scheduledJob.ExportToSharedFolder; }
void FillExternalSubscribers(ScheduledJobDto scheduledJob) { externalSubscribers.Text = scheduledJob.ExternalSubscribers; }