protected override Core.Services.ServiceOutcome DoPipelineWork() { string serviceName = Instance.Configuration.Options["ServiceToRun"]; if (String.IsNullOrWhiteSpace(serviceName)) { throw new ConfigurationErrorsException("ServiceToRun parameter is not defined on Rerun service.", Instance.Configuration.ElementInformation.Source, Instance.Configuration.ElementInformation.LineNumber); } using (ServiceClient <IScheduleManager> scheduleManager = new ServiceClient <IScheduleManager>()) { DateTime fromDate = this.TargetPeriod.Start.ToDateTime(); DateTime toDate = this.TargetPeriod.End.ToDateTime(); while (fromDate <= toDate) { // {start: {base : '2009-01-01', h:0}, end: {base: '2009-01-01', h:'*'}} var subRange = new DateTimeRange() { Start = new DateTimeSpecification() { BaseDateTime = fromDate, Hour = new DateTimeTransformation() { Type = DateTimeTransformationType.Exact, Value = 0 }, Alignment = DateTimeSpecificationAlignment.Start }, End = new DateTimeSpecification() { BaseDateTime = fromDate, Hour = new DateTimeTransformation() { Type = DateTimeTransformationType.Max }, Alignment = DateTimeSpecificationAlignment.End } }; SettingsCollection options = new SettingsCollection(); options.Add(PipelineService.ConfigurationOptionNames.TargetPeriod, subRange.ToAbsolute().ToString()); options.Add(PipelineService.ConfigurationOptionNames.ConflictBehavior, DeliveryConflictBehavior.Ignore.ToString()); foreach (var option in Instance.Configuration.Options) { if (!options.ContainsKey(option.Key)) { options.Add(option.Key, option.Value); } } //run the service scheduleManager.Service.AddToSchedule(serviceName, this.Instance.AccountID, DateTime.Now, options); fromDate = fromDate.AddDays(1); } } return(Core.Services.ServiceOutcome.Success); }
private void run_btn_Click(object sender, EventArgs e) { if (_attributes.ContainsKey("Name")) { string serviceName = _attributes["Name"]; ServiceClient <IScheduleManager> scheduleManager = new ServiceClient <IScheduleManager>(); foreach (ListViewItem item in AttributesToRunList.Items) { _options.Add(item.SubItems[0].Text.Trim(), item.SubItems[1].Text.Trim()); } if (ConflictBehavior.Checked && !optionsListView.Items.ContainsKey("ConflictBehavior")) { _options.Add("ConflictBehavior", "Ignore"); } //Run Service if (!_options.ContainsKey(PipelineService.ConfigurationOptionNames.TimePeriod)) { _options.Add(PipelineService.ConfigurationOptionNames.TimePeriod, _dateTimeRange.ToAbsolute().ToString()); } _listener.AddToSchedule(serviceName, _accountId, DateTime.Now, _options); } }
private void run_btn_Click(object sender, EventArgs e) { if (_attributes.ContainsKey("Name")) { string serviceName = _attributes["Name"]; ServiceClient <IScheduleManager> scheduleManager = new ServiceClient <IScheduleManager>(); foreach (ListViewItem item in AttributesToRunList.Items) { _options.Add(item.SubItems[0].Text.Trim(), item.SubItems[1].Text.Trim()); } if (ConflictBehavior.Checked && !optionsListView.Items.ContainsKey("ConflictBehavior")) { _options.Add("ConflictBehavior", "Ignore"); } //Run Service if (!_options.ContainsKey(PipelineService.ConfigurationOptionNames.TimePeriod)) { _options.Add(PipelineService.ConfigurationOptionNames.TimePeriod, _dateTimeRange.ToAbsolute().ToString()); } bool result = _listner.FormAddToSchedule(serviceName, _accountId, DateTime.Now, _options, ServicePriority.Normal); MessageBox.Show("Service has been submited"); if (!result) { MessageBox.Show(string.Format("Service {0} for account {1} did not run", serviceName, _accountId)); } } }
/// <summary>Gets the custom setting from the settings collection with the settingName. If the setting is not found, return the defaultValue.</summary> /// <typeparam name="T">The type of the setting.</typeparam> /// <param name="settings">The settings collection to search for a setting with the settingName.</param> /// <param name="settingName">Name of the setting to search for in the settings collection.</param> /// <param name="defaultValue">The default value to use if the settingName is not found in the settings collection.</param> /// <returns>T.</returns> public static T GetCustomSetting <T>(this SettingsCollection settings, string settingName, T defaultValue = default(T)) { if (settings.ContainsKey(settingName)) { return(settings[settingName].Convert <T>()); } return(defaultValue); }