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);
        }
Example #2
0
 /// <summary>
 /// Copies the provider's data.
 /// </summary>
 /// <param name="provider">The provider.</param>
 private static void CopyProviderData(ISettingsProvider provider)
 {
     foreach (string key in provider.Values.AllKeys)
     {
         settings.Add(key, provider.Values.Get(key));
     }
 }
Example #3
0
        protected override SettingsCollection createSettings(SettingsCollection settings)
        {
            settings.Add(new Setting("sermon_folder"));
            settings.Add(new Setting("folder_format",Path.Combine("YYYY", "MM", "DD")));

            return settings;
        }
        private void RunCommitServices(List <ValidationResult> repairList)
        {
            SettingsCollection _options = new SettingsCollection();

            foreach (ValidationResult itemToFix in repairList)
            {
                DateTimeRange _dateTimeRange    = new DateTimeRange();
                string        TargetPeriodStart = String.Empty;
                string        TargetPeriodEnd   = String.Empty;

                _dateTimeRange.Start = DateTimeSpecification.Parse(itemToFix.TargetPeriodStart.ToString());
                _dateTimeRange.End   = DateTimeSpecification.Parse(itemToFix.TargetPeriodEnd.ToString());

                string serviceName = Const.AdMetricsConst.WorkflowServices.CommitServiceName;
                ServiceClient <IScheduleManager> scheduleManager = new ServiceClient <IScheduleManager>();

                _options.Add("ConflictBehavior", "Ignore");
                _options.Add("DeliveryID", itemToFix.DeliveryID.ToString());

                //Run Service
                _options.Add(PipelineService.ConfigurationOptionNames.TimePeriod, _dateTimeRange.ToAbsolute().ToString());

                //bool result = _listner.FormAddToSchedule(serviceName, -1, DateTime.Now, _options, ServicePriority.Normal);
                //if (!result)
                //{
                //    MessageBox.Show(string.Format("Service {0} for account {1} did not run", serviceName, -1));
                //}
            }
        }
Example #5
0
        public void RunOrganicProfile(int accountID, int profileID)
        {
            List <string> serviceNames = new List <string>();


            using (DataManager.Current.OpenConnection())
            {
                // TODO: get names of services as single-column result arrray
                SqlCommand cmd = DataManager.CreateCommand("select distinct SE.ServiceName from dbo.User_GUI_SerpProfileSearchEngine PSE inner join Constant_SearchEngine SE on PSE.Search_Engine_ID = SE.Search_Engine_ID where account_id = @AccountID:Int and Profile_ID = @ProfileID:Int");
                cmd.Parameters["@AccountID"].Value = accountID;
                cmd.Parameters["@ProfileID"].Value = profileID;

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        serviceNames.Add(reader[0] as string);
                    }
                }
            }

            SettingsCollection settings = new SettingsCollection();

            settings.Add("ProfileID", profileID.ToString());

            using (ServiceClient <IScheduleManager> client = new ServiceClient <IScheduleManager>())
            {
                foreach (string serviceName in serviceNames)
                {
                    // Request the manager to build the schedule
                    client.Service.AddToSchedule(serviceName, accountID, DateTime.Now, settings);
                }
            }
        }
Example #6
0
    private SettingsCollection GetSubData(SettingsCollection Source, int start, int end)
    {
        int iTotalRecord             = Source.Count;
        SettingsCollection subSource = new SettingsCollection();

        if (Source != null)
        {
            for (int i = start; i < end; i++)
            {
                subSource.Add(Source[i]);
            }
        }
        return(subSource);
    }
        public void Test_GetCustomSetting_Found_Boolean()
        {
            const string key      = "Test Key";
            const string value    = "true";
            var          fixture  = new Fixture();
            var          settings = new SettingsCollection();

            fixture.AddManyTo(settings, 10);
            settings.Add(key, value);
            fixture.AddManyTo(settings, 8);

            var sut = settings.GetCustomSetting <bool>(key);

            Assert.True(sut);
        }
        public void Test_GetCustomSetting_Found_String()
        {
            const string key      = "Test Key";
            const string value    = "Test Value";
            var          fixture  = new Fixture();
            var          settings = new SettingsCollection();

            fixture.AddManyTo(settings, 10);
            settings.Add(key, value);
            fixture.AddManyTo(settings, 8);

            var sut = settings.GetCustomSetting <string>(key);

            Assert.Equal(value, sut);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> indicesDict = serializer.Deserialize<Dictionary<string, object>>(reader);

            SettingsCollection collection = new SettingsCollection(); 
            foreach (KeyValuePair<string, object> indexKvp in indicesDict)
            {
                Dictionary<string, object> indexDict = new Dictionary<string, object>();
                indexDict.Add(indexKvp.Key, indexKvp.Value);

                string indexJson = JsonConvert.SerializeObject(indexDict);
                collection.Add(JsonConvert.DeserializeObject<Settings>(indexJson));
            }

            return collection;
        }
Example #10
0
        private void okButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;

            var settings = new SettingsCollection("outline");

            settings.Add("addNumbering", numberingBox.Checked);
            settings.Add("alphaNumbering", AlphaNumbering);
            settings.Add("numericNumbering", NumericNumbering);
            settings.Add("cleanupNumbering", CleanupNumbering);
            settings.Add("indent", Indent);
            settings.Add("indentTagged", IndentTagged);
            settings.Add("removeTags", RemoveTags);
            settings.Add("tagSymbol", TagSymbol);

            var provider = new SettingsProvider();

            provider.SetCollection(settings);
            provider.Save();
        }
Example #11
0
        private void InitCollection()
        {
            SettingsCollection.Add(new StringSetting
            {
                Name = "Author", Label = "Author", TextValue = "Registered User"
            }
                                   );

            SettingsCollection.Add(new StringSetting
            {
                Name = "Title", Label = "Title", TextValue = "Draft Letter"
            }
                                   );

            SettingsCollection.Add(new BooleanSetting
            {
                Name = "RemoveComments", Label = "Remove Comments", IsChecked = true
            }
                                   );

            SettingsCollection.Add(new BooleanSetting
            {
                Name = "RemoveHyperlinks", Label = "Remove Hyperlinks", IsChecked = true
            }
                                   );

            SettingsCollection.Add(new StringSetting
            {
                Name = "LastModifiedAuthor", Label = "Modified By", TextValue = "Michael Daniloff"
            }
                                   );

            //  SettingsCollection.Add(new StringSetting
            //  { Name = "Keywords", Label = "Keywords", TextValue = "Draft Proposal" }
            //);

            //  SettingsCollection.Add(new BooleanSetting
            //  { Name = "RemoveBookmarks", Label = "Remove Bookmarks", IsChecked = false }
            //);
        }
Example #12
0
        /*=========================*/
        #endregion

        #region Events
        /*=========================*/
        void watcher_Changed(object sender, FileSystemEventArgs e)
        {
            Log.Write(String.Format("{0} has been {1} ", e.Name, e.ChangeType), LogMessageType.Information);

            FileSystemWatcher watcher = (FileSystemWatcher)sender;
            string            handlerService;

            if (!_handlers.TryGetValue(watcher, out handlerService))
            {
                Log.Write(String.Format("Invalid handler specified for {0}.", e.Name), LogMessageType.Warning);
                return;
            }

            // Make the request to the schedule manager
            using (ServiceClient <IScheduleManager> scheduleManager = _scheduleManagerConfiguration != null && _scheduleManagerUrl != null ?
                                                                      new ServiceClient <IScheduleManager>(_scheduleManagerConfiguration, _scheduleManagerUrl):  new ServiceClient <IScheduleManager>())
            {
                SettingsCollection options = new SettingsCollection();
                options.Add("SourceFilePath", e.FullPath);

                //If we have the HandlerServiceParameters attribute in the configuration, append it
                //to the options we are sending to the service.
                foreach (DirectoryElement de in (DirectoryElementCollection)Instance.Configuration.ExtendedElements["Directories"])
                {
                    if (de.Path == e.FullPath &&
                        de.HandlerServiceParameters != String.Empty)
                    {
                        //This is the path. Get the additional information.
                        SettingsCollection sc = new SettingsCollection(de.HandlerServiceParameters);
                        options.Merge(sc);
                        break;
                    }
                }

                scheduleManager.Service.AddToSchedule(handlerService, -1, DateTime.Now, options);
            }
        }
Example #13
0
        protected override SettingsCollection createSettings(SettingsCollection settings)
        {
            settings = base.createSettings(settings);

            Setting new_setting = new Setting("backup_path", null, "paths", "backup");

            new_setting.addAdditionalNotification("IsBackupPathSet");
            new_setting.addAdditionalNotification("backup_path_not_set");
            settings.Add(new_setting);

            new_setting = new Setting("sync_path", null, "paths", "sync");
            new_setting.addAdditionalNotification("any_sync_enabled");
            new_setting.addAdditionalNotification("sync_path_set");
            settings.Add(new_setting);


            new_setting = new Setting("steam_override", null, "paths", "steam_override");
            new_setting.addAdditionalNotification("steam_path");
            settings.Add(new_setting);

            new_setting = new Setting("save_paths", null, "paths", "saves");
            settings.Add(new_setting);


            settings.Add(new Setting("IgnoreDateCheck", false, "date_check", "ignore"));

            settings.Add(new Setting("MonitoredGames", null, "games", "monitor"));

            settings.Add(new Setting("VersioningEnabled", false, "versioning", "enabled"));
            settings.Add(new Setting("VersioningUnit", VersioningUnit.Hours, "versioning", "unit"));
            settings.Add(new Setting("VersioningFrequency", 5, "versioning", "frequency"));
            settings.Add(new Setting("VersioningMax", 100, "versioning", "max"));

            settings.Add(new Setting("SuppressSubmitRequests", false, "suppress", "submit_requests"));
            settings.Add(new Setting("SuppressElevationWarnings", false, "suppress", "elevation_warnings"));

            return(settings);
        }
Example #14
0
        protected virtual SettingsCollection createSettings(SettingsCollection settings) {
            settings.Add(new Setting("EmailSender", null, "email", "sender"));
            settings.Add(new Setting("EmailRecipient", null, "email", "recipient"));
            settings.Add(new Setting("last_drive", current_drive, "portable_settings", "last_drive"));
            settings.Add(new Setting("WindowX", null, "window", "x"));
            settings.Add(new Setting("WindowY", null, "window", "y"));
            settings.Add(new Setting("WindowW", null, "window", "h"));
            settings.Add(new Setting("WindowH", null, "window", "w"));
            settings.Add(new Setting("WindowState", null, "window", "state"));

            return settings;
        }
        void watcher_Changed(object sender, FileSystemEventArgs e)
        {
            Log.Write(LogSource, String.Format("{0} has been {1} ", e.Name, e.ChangeType), LogMessageType.Information);

            FileSystemWatcher  watcher = (FileSystemWatcher)sender;
            DirectoryWatchInfo info;

            if (!_watchers.TryGetValue(watcher, out info))
            {
                Log.Write(LogSource, String.Format("No watcher found for {0} - check your configuration.", e.Name), LogMessageType.Warning);
                return;
            }

            ServiceClient <IScheduleManager> scheduler;

            try
            {
                scheduler =
                    !String.IsNullOrWhiteSpace(info.Config.SchedulerUrl) || !String.IsNullOrWhiteSpace(info.Config.SchedulerConfiguration) ?
                    new ServiceClient <IScheduleManager>(info.Config.SchedulerConfiguration, info.Config.SchedulerUrl) :
                    new ServiceClient <IScheduleManager>();
            }
            catch (Exception ex)
            {
                Log.Write(LogSource, String.Format(
                              "Could not create a connection to the scheduler{0}.",
                              String.IsNullOrWhiteSpace(info.Config.SchedulerUrl) ? string.Empty : " at " + info.Config.SchedulerUrl
                              ), ex);
                return;
            }

            // Make the request to the schedule manager
            using (scheduler)
            {
                var options = new SettingsCollection();

                try
                {
                    foreach (var option in info.Config.ServiceOptions)
                    {
                        options.Add(option.Key, option.Value.Replace("{" + DirectoryWatcher.FilePath + "}", e.FullPath));
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(LogSource, "Error creating options for the service from the <Directory> configuration.", ex);
                }

                try
                {
                    scheduler.Service.AddToSchedule(info.Config.ServiceName, info.Config.AccountID, DateTime.Now, options);
                }
                catch (Exception ex)
                {
                    Log.Write(LogSource, String.Format(
                                  "Error trying to call AddToSchedule on the scheduler{0}.",
                                  String.IsNullOrWhiteSpace(info.Config.SchedulerUrl) ? string.Empty : " at " + info.Config.SchedulerUrl
                                  ), ex);
                }
            }
        }
Example #16
0
        protected override SettingsCollection createSettings(SettingsCollection settings)
        {
            settings = base.createSettings(settings);

            Setting new_setting = new Setting("backup_path", null, "paths", "backup");
            new_setting.addAdditionalNotification("IsBackupPathSet");
            new_setting.addAdditionalNotification("backup_path_not_set");
            settings.Add(new_setting);

            new_setting = new Setting("sync_path", null, "paths", "sync");
            new_setting.addAdditionalNotification("any_sync_enabled");
            new_setting.addAdditionalNotification("sync_path_set");
            settings.Add(new_setting);

            new_setting = new Setting("steam_override", null, "paths", "steam_override");
            new_setting.addAdditionalNotification("steam_path");
            settings.Add(new_setting);

            new_setting = new Setting("save_paths", null, "paths", "saves");
            settings.Add(new_setting);

            settings.Add(new Setting("IgnoreDateCheck", false, "date_check", "ignore"));

            settings.Add(new Setting("MonitoredGames", null, "games", "monitor"));

            settings.Add(new Setting("VersioningEnabled", false, "versioning", "enabled"));
            settings.Add(new Setting("VersioningUnit", VersioningUnit.Hours, "versioning", "unit"));
            settings.Add(new Setting("VersioningFrequency", 5, "versioning", "frequency"));
            settings.Add(new Setting("VersioningMax", 100, "versioning", "max"));

            settings.Add(new Setting("SuppressSubmitRequests", false, "suppress", "submit_requests"));
            settings.Add(new Setting("SuppressElevationWarnings", false, "suppress", "elevation_warnings"));

            return settings;
        }
Example #17
0
        public void UpdateForm(long parentInstanceId, string instanceName, string accountId)
        {
            string deliveryId = string.Empty;

            this.instaceIDValue.Text  = parentInstanceId.ToString();
            this.SourceNameValue.Text = instanceName;
            this.AccountIdValue.Text  = accountId;
            this._accountId           = Convert.ToInt32(accountId);
            FromPicker.Value          = FromPicker.Value.AddDays(-1);
            ToPicker.Value            = ToPicker.Value.AddDays(-1);

            #region Getting Instaces
            _instances = GetWorkFlowServicesInstaceIdList(parentInstanceId);
            if (_instances.Count > 0)
            {
                InstancesListBox.Items.Clear();
                foreach (var instance in _instances)
                {
                    InstancesListBox.Items.Add(string.Format("{0} ({1})", instance.Value, instance.Key));
                }

                if (TryGetDeliveryId(_instances, out deliveryId))
                {
                    deliveryID_lbl.Text = deliveryId;
                }
                else
                {
                    deliveryID_lbl.Text = "No Delivery";
                }
            }
            #endregion

            #region Setting instances List in overview
            InstanceEntity parent = GetInstanceLogById(parentInstanceId);
            if (!string.IsNullOrEmpty(parent.Message))
            {
                this.instacesSummaryDataGrid.Rows.Add(
                    parent.Id, parent.Source, string.Format("{0} {1}", parent.Message, parent.ExceptionDetails), parent.MessageType);
            }
            #endregion

            #region Setting instances Summary Grid
            foreach (var id in _instances)
            {
                InstanceEntity entity = GetInstanceLogById(id.Key);
                this.instacesSummaryDataGrid.Rows.Add(
                    entity.Id, entity.Source, string.Format("{0} {1}", entity.Message, entity.ExceptionDetails), entity.MessageType);
            }
            #endregion

            #region Service Configuration
            //Loading Service Configuration
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                string xmlContent = GetConfigurationFromDB(parentInstanceId);
                xmlDoc.LoadXml(xmlContent);
                foreach (XmlAttribute attribute in xmlDoc.DocumentElement.Attributes)
                {
                    _attributes.Add(attribute.Name, attribute.Value);

                    if (!attribute.Name.Equals(PipelineService.ConfigurationOptionNames.TimePeriod))
                    {
                        optionsListView.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Value }));
                    }
                    else
                    {
                        AttributesToRunList.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Value }));
                    }
                }
            }
            catch
            {
                //TO DO : throw exception
            }

            //Getting TimePeriod
            if (TryGetDeliveryTargetPeriod(deliveryId, out _dateTimeRange))
            {
                _options.Add(PipelineService.ConfigurationOptionNames.TimePeriod, _dateTimeRange.ToAbsolute().ToString());
                FromPicker.Value = _dateTimeRange.Start.ToDateTime();
                ToPicker.Value   = _dateTimeRange.End.ToDateTime();
            }
            else
            {
                this.deliveryID_lbl.Text = "Unavailable";
                this.run_btn.Enabled     = false;
                MessageBox.Show("\"Run Service Again\" button has been disabled due the following reason : Cannot find target period in delivery data base");
            }

            #endregion
        }