コード例 #1
0
ファイル: AddInsSession.cs プロジェクト: sakpung/webstudy
        void service_CommandsExecuted(object sender, EventArgs e)
        {
            try
            {
                LoggingModuleConfigurationManager configurationManager = ServiceLocator.Retrieve <LoggingModuleConfigurationManager> ( );
                CommandAsyncProcessor             service = ServiceLocator.Retrieve <CommandAsyncProcessor> ( );

                IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent> ( );
                if (optionsAgent != null)
                {
                    if (null != service && configurationManager.GetLoggingState().EnableAutoSaveLog)
                    {
                        DateTime nextLogDate = DateTime.Now.AddDays(service.Interval.Days);

                        SetNextLogDate(nextLogDate,
                                       configurationManager.GetLoggingState(),
                                       optionsAgent);
                    }
                }
            }
            catch (Exception exception)
            {
                Log(LogType.Error, "Logging Config Error: " + exception.Message);
            }
        }
コード例 #2
0
ファイル: AddInsSession.cs プロジェクト: sakpung/webstudy
        void loggingConfigManager_SettingsUpdated(object sender, EventArgs e)
        {
            try
            {
                LoggingModuleConfigurationManager loggingConfigManager = ServiceLocator.Retrieve <LoggingModuleConfigurationManager> ( );
                CommandAsyncProcessor             service = ServiceLocator.Retrieve <CommandAsyncProcessor> ( );

                ConfigureLogger(Logger.Global,
                                loggingConfigManager.GetLoggingState( ),
                                DataAccessServices.GetDataAccessService <ILoggingDataAccessAgent2> ( ));

                StartStopService(loggingConfigManager.GetLoggingState( ),
                                 service);

                IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent> ( );
                if (optionsAgent != null)
                {
                    ConfigureServiceIntervals(loggingConfigManager.GetLoggingState(),
                                              service, optionsAgent);
                }
            }
            catch (Exception exception)
            {
                Log(LogType.Error, "Logging Config Error: " + exception.Message);
            }
        }
コード例 #3
0
ファイル: AddInsSession.cs プロジェクト: sakpung/webstudy
        private static void StartStopService(LoggingState logState, CommandAsyncProcessor service)
        {
            if (service.Disposed)
            {
                return;
            }

            if (logState.EnableAutoSaveLog)
            {
                service.Start( );
            }
            else
            {
                service.Stop( );
            }
        }
コード例 #4
0
ファイル: SessionShutdown.cs プロジェクト: sakpung/webstudy
        public void Break(BreakType type)
        {
            if (type == BreakType.Shutdown)
            {
                if (ServiceLocator.IsRegistered <CommandAsyncProcessor> ( ))
                {
                    CommandAsyncProcessor processor = ServiceLocator.Retrieve <CommandAsyncProcessor> ( );

                    if (processor != null)
                    {
                        processor.Stop( );

                        processor.Dispose( );
                    }
                }
            }
        }
コード例 #5
0
ファイル: AddInsSession.cs プロジェクト: sakpung/webstudy
        private void ConfigureServiceIntervals
        (
            LoggingState logState,
            CommandAsyncProcessor service,
            IOptionsDataAccessAgent optionsDataAccess
        )
        {
            DateTime dueDate = GetDueDate(logState);

            SetNextLogDate(dueDate, logState, optionsDataAccess);

            TimeSpan due      = dueDate.Subtract(DateTime.Now);
            TimeSpan interval = new TimeSpan(logState.AutoSaveDaysPeriod, 0, 0, 0);

            service.DueTime  = due;
            service.Interval = interval;

            service.RefreshDueIntervalTimes( );
        }
コード例 #6
0
ファイル: AddInsSession.cs プロジェクト: sakpung/webstudy
        private CommandAsyncProcessor RegisterAutoSaveLogService(LoggingState logState)
        {
            AutoSaveLogCommand      autoSaveCommand;
            CommandAsyncProcessor   service           = null;
            IOptionsDataAccessAgent optionsDataAccess = null;

            optionsDataAccess = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>();

            if (optionsDataAccess != null)
            {
                autoSaveCommand = new AutoSaveLogCommand(logState);
                service         = new CommandAsyncProcessor();

                if (logState.EnableAutoSaveLog)
                {
                    string nextLogDate;


                    nextLogDate = optionsDataAccess.Get <string>(NextLogDateSettingsName, null, new Type[0]);

                    if (!string.IsNullOrEmpty(nextLogDate))
                    {
                        DateTime nextLog = DateTime.Parse(nextLogDate);

                        if (DateTime.Now > nextLog)
                        {
                            autoSaveCommand.Execute();
                        }
                    }
                }

                service.Commands.Add(autoSaveCommand);

                ConfigureServiceIntervals(logState, service, optionsDataAccess);

                service.CommandsExecuted += new EventHandler(service_CommandsExecuted);

                ServiceLocator.Register <CommandAsyncProcessor>(service);
            }

            return(service);
        }