コード例 #1
0
        /// <summary>
        /// When implemented in a derived class, executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically). Specifies actions to take when the service starts.
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            EventLog.WriteEntry("Starting service");
            try
            {
                settings = InitlizeSettings();
                InitilizeWatcher(settings.FileSettings.DeafultWatchLocation);
                StartTimer();
            }
            catch (Exception exception)
            {
                EventLog.WriteEntry(exception.Message);
            }

            ////WriteLog("Starting service completed");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: codeno47/efc
        /// <summary>
        /// Initlizes the settings.
        /// </summary>
        /// <returns></returns>
        private static void InitlizeSettings()
        {
            settings = LoadSettings();

            if (settings == null)
            {
                var mailSettings = new MailInfo
                {
                    Body         = "sample",
                    FromEmail    = "*****@*****.**",
                    IsSslEnabled = true,
                    MailServer   = "smtp.gmail.com",
                    Password     = "******",
                    Port         = 25,
                    Subject      = "Public Folder Cleanup",
                    UserName     = "******"
                };

                mailSettings.ToAddress.Add("*****@*****.**");

                var settingData = new FileManagerSection
                {
                    MailSettings = mailSettings,

                    FileSettings = new FileManagerSettingsInfo
                    {
                        DeafultWatchLocation = FileManagerConstants.WatcherPath,
                        FileDeleteDuration   = 1,
                        Filters = new List <string> {
                            "SOFTWARES"
                        }
                    }
                };
                settingService.SaveSettings(settingData, FileManagerConstants.SettingsFile);
                settingData.EnableEventLog = false;

                settings = settingData;
            }

            return;
        }
コード例 #3
0
ファイル: SettingService.cs プロジェクト: codeno47/efc
 /// <summary>
 /// Saves the settings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 public void SaveSettings(FileManagerSection settings, string fileName)
 {
     Serialize(settings, fileName);
 }