Exemplo n.º 1
0
 public void ResumeLogging()
 {
     if (state == LoggingState.paused)
     {
         state = LoggingState.logging;
     }
 }
Exemplo n.º 2
0
        public void Configure
        (
            IWin32Window Parent,
            ServerSettings Settings,
            string ServerDirectory
        )
        {
            using (LoggingModuleConfigurationManager configManager = new LoggingModuleConfigurationManager(false))
            {
                configManager.Load(ServerDirectory);

                LoggingState state = configManager.GetLoggingState( );

                EventLogOptions mainLoggingUI = new EventLogOptions( );

                EventLogConfigurationPresenter presenter = new EventLogConfigurationPresenter( );

                presenter.RunView(mainLoggingUI.EventLogConfigurationView, state);

                if (mainLoggingUI.ShowDialog( ) == DialogResult.OK)
                {
                    presenter.UpdateState( );

                    configManager.SetLoggingState(state);

                    configManager.Save( );
                }
                else
                {
                    presenter.ResetView( );
                }
            }
        }
Exemplo n.º 3
0
        public async Task Execute(Message message)
        {
            // Read Message
            ReadMessage(message);

            try
            {
                // Get DataLakePath from user properties
                var datalakeFile = GetDatalakePath(message);

                // Read Payload
                CurrentEvent = TelemetryEvent.ServiceBus_Topic_Read;
                var payload = message.ReadAsString();

                CurrentEvent = TelemetryEvent.DataLake_Write;
                await datalakeService.Write(payload, Convert.ToString(datalakeFile));

                TrackInfo($"{datalakeFile} was successfully added to datalake.", TelemetryEvent.DataLake_Write, "Write Confirmation");
            }
            catch (Exception ex)
            {
                // TODO: we need to consider how we will handle failed DataLake writes. My suggestion - mimic Microsoft's EventGrid implementation and have a backup Storage blob.
                Trace(ex.Message, CurrentEvent, "Failed");
                LoggingState.AddException(ex);
            }
            finally
            {
                LogFunctionEnd();
                Dispose();
            }
        }
Exemplo n.º 4
0
 // IF YOU PAUSE, YOU HAVE TO BE CAREFUL ABOUT TIME ELAPSED BETWEEN PAUSES!
 public void PauseLogging()
 {
     if (state == LoggingState.logging)
     {
         state = LoggingState.paused;
     }
 }
Exemplo n.º 5
0
        static void Logger_Logged(object sender, LogEventArgs e)
        {
            try
            {
                DicomLogEntry entry = e.LogEntry as DicomLogEntry;

                if (entry != null && entry.DicomDataset != null)
                {
                    LoggingModuleConfigurationManager loggingConfigManager = ServiceLocator.Retrieve <LoggingModuleConfigurationManager> ( );

                    if (null == loggingConfigManager)
                    {
                        return;
                    }

                    LoggingState state = loggingConfigManager.GetLoggingState( );

                    if (state.EnableLogging &&
                        state.EnableThreading &&
                        state.LogDicomDataSet &&
                        state.LogDicom)
                    {
                        try
                        {
                            entry.DicomDataset.Dispose();
                        }
                        catch { }
                    }
                }
            }
            catch {}
        }
Exemplo n.º 6
0
 // Experiment Descriptors are given and
 public void EndLogging()
 {
     if (state == LoggingState.logging)
     {
         Event_Experiment_Ended();
         state = LoggingState.complete;
     }
 }
Exemplo n.º 7
0
 public void BeginLogging()
 {
     if (state == LoggingState.not_started || state == LoggingState.complete)
     {
         state = LoggingState.logging;
         InitializeAllValues();
     }
 }
Exemplo n.º 8
0
        internal static LoggingState GetDefaultLoggingState( )
        {
            LoggingState state;


            state = new LoggingState( );

            state.EnableAutoSaveLog = false;

            return(state);
        }
Exemplo n.º 9
0
        public void CheckPermissions(LoggingState loggingState)
        {
            WindowsIdentity   identity = WindowsIdentity.GetCurrent();
            DirectorySecurity security;
            FileSystemRights  rights;
            string            message = string.Empty;

            try
            {
                if (Directory.Exists(loggingState.AutoSaveDirectory))
                {
                    security = Directory.GetAccessControl(loggingState.AutoSaveDirectory);
                    rights   = GetDirectoryRights(security, identity);
                    message  = string.Format("PERMISSIONS => Auto Log Location ({0}): \r\n{1}", loggingState.AutoSaveDirectory, rights);
                    Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                      LogType.Information, MessageDirection.None, message, null, null);
                }
                else
                {
                    message = string.Format("Auto Log directory ({0}) doesn't exist.  Cannot determine permissions.", loggingState.AutoSaveDirectory);
                    Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                      LogType.Information, MessageDirection.None, message, null, null);
                }
            }
            catch (Exception e)
            {
                Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                  LogType.Information, MessageDirection.None, e.Message, null, null);
            }

            try
            {
                if (Directory.Exists(loggingState.DataSetDirectory))
                {
                    security = Directory.GetAccessControl(loggingState.DataSetDirectory);
                    rights   = GetDirectoryRights(security, identity);
                    message  = string.Format("PERMISSIONS => Auto Log Dataset Location ({0}): \r\n{1}", loggingState.DataSetDirectory, rights);
                    Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                      LogType.Information, MessageDirection.None, message, null, null);
                }
                else
                {
                    message = string.Format("Auto Log dataset directory ({0}) doesn't exist.  Cannot determine permissions.", loggingState.DataSetDirectory);
                    Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                      LogType.Information, MessageDirection.None, message, null, null);
                }
            }
            catch (Exception e)
            {
                Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                  LogType.Information, MessageDirection.None, e.Message, null, null);
            }
        }
Exemplo n.º 10
0
        private void SetNextLogDate(DateTime nextLogDate, LoggingState logState, IOptionsDataAccessAgent optionsDataAccess)
        {
            nextLogDate = new DateTime(nextLogDate.Year,
                                       nextLogDate.Month,
                                       nextLogDate.Day,
                                       logState.AutoSaveTime.Hour,
                                       logState.AutoSaveTime.Minute,
                                       logState.AutoSaveTime.Second);


            optionsDataAccess.Set <string> (NextLogDateSettingsName, nextLogDate.ToString( ), new Type[0]);
        }
Exemplo n.º 11
0
        public static void ConfigureLogger(Logger logger, LoggingState loggingState, ILoggingDataAccessAgent2 dataAccess)
        {
            logger.Enabled         = loggingState.EnableLogging;
            logger.EnableThreading = loggingState.EnableThreading;

            if (logger.Filter is EventLogFilter)
            {
                EventLogFilter filter = ( EventLogFilter )logger.Filter;


                filter.LogErrors      = loggingState.LogErrors;
                filter.LogInformation = loggingState.LogInformation;
                filter.LogWarnings    = loggingState.LogWarnings;
                filter.LogDebug       = loggingState.LogDebug;
                filter.LogAudit       = loggingState.LogAudit;
            }

            DataAccessLoggingChannel[] channels = logger.LoggingChannels.OfType <DataAccessLoggingChannel>().ToArray();

            if (channels.Length > 0)
            {
                foreach (DataAccessLoggingChannel channel in logger.LoggingChannels.OfType <DataAccessLoggingChannel> ( ))
                {
                    channel.LogDataAccessAgent = dataAccess;

                    channel.LogDicomDataSet = loggingState.LogDicomDataSet;

                    channel.LogDicomCommunication = loggingState.LogDicom;

                    ConfigureLoggingChannel(channel, loggingState);
                }
            }
            else
            {
                DataAccessLoggingChannel channel = new DataAccessLoggingChannel(dataAccess);

                channel.LogDicomDataSet = loggingState.LogDicomDataSet;

                channel.LogDicomCommunication = loggingState.LogDicom;

                ConfigureLoggingChannel(channel, loggingState);

                logger.LoggingChannels.Clear( );
                logger.LoggingChannels.Add(channel);
            }

            logger.Logging -= new EventHandler <LogEventArgs> (Logger_Logging);
            logger.Logged  -= new EventHandler <LogEventArgs>  (Logger_Logged);

            logger.Logging += new EventHandler <LogEventArgs> (Logger_Logging);
            logger.Logged  += new EventHandler <LogEventArgs>  (Logger_Logged);
        }
Exemplo n.º 12
0
        private static DateTime GetDueDate(LoggingState logState)
        {
            DateTime dueDate;

            dueDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, logState.AutoSaveTime.Hour, logState.AutoSaveTime.Minute, logState.AutoSaveTime.Second);

            if (DateTime.Now > dueDate)
            {
                dueDate = dueDate.AddDays(logState.AutoSaveDaysPeriod);
            }

            return(dueDate);
        }
Exemplo n.º 13
0
        public void SetLoggingState(LoggingState state)
        {
            string addInKeyName;
            string loggingStateKey;


            if (null == _advancedSettings)
            {
                throw new InvalidOperationException("Service has not been initialized. Call the Load method");
            }

            addInKeyName    = typeof(LoggingConfigurationSession).Name;
            loggingStateKey = typeof(LoggingState).Name;

            _advancedSettings.SetAddInCustomData <LoggingState> (addInKeyName, loggingStateKey, state);
        }
Exemplo n.º 14
0
        private static void StartStopService(LoggingState logState, CommandAsyncProcessor service)
        {
            if (service.Disposed)
            {
                return;
            }

            if (logState.EnableAutoSaveLog)
            {
                service.Start( );
            }
            else
            {
                service.Stop( );
            }
        }
Exemplo n.º 15
0
        private void ReadMessage(Message message)
        {
            message = message ?? new Message(new byte[0]);

            // Read state to remove previous run values.
            LoggingState.OperationName = GetType().Name;

            // TODO: Because DataLake function is used by our internal code, if we don't have a TransactionId, we have a SERIOUS problem. We should NOT be creating a NewGuid here!
            LoggingState.TransactionId = message.UserProperties.TryGetValue("transactionId", out object transactionId) ? transactionId.ToString() : Guid.NewGuid().ToString("D");

            // This will jelp us to find if the message was processed by application or a User
            LoggingState.AddOrReplaceTelemetryProperty("UserName", message.UserProperties.TryGetValue("UserName", out object userName) ? userName.ToString() : "Unknown");

            LoggingState.AddOrReplaceTelemetryProperty("MessageId", message.MessageId);
            LoggingState.ParentOperationName = message.UserProperties.TryGetValue("sourceSystem", out object _sourceSystem) ? _sourceSystem.ToString() : "Unknown";
            LogFunctionStart();
        }
Exemplo n.º 16
0
        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( );
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        public void Unlock()
        {
            try
            {
                //
                this.IsLocked = LockState.Unlocked;
                //log state change in computer
                LoggingState.ComputerLogChangeState("CarUnlocked");

                ///event for state change
                onStateChange("CarUnlocked");
            }
            catch (Exception)
            {
                ///
                LoggingException.LogExceptionOccurs("There was an error unlocking the car!");

                ///evnt for exception occur
                onExceptionOccur("There was an error unlocking the car!");
            }
        }
Exemplo n.º 19
0
        private LoggingState GetLoggingStateInternal( )
        {
            string       addInName;
            string       loggingStateKey;
            LoggingState state;


            if (null == _advancedSettings)
            {
                throw new InvalidOperationException("Service has not been initialized. Call the Load method");
            }

            addInName       = typeof(LoggingConfigurationSession).Name;
            loggingStateKey = typeof(LoggingState).Name;

            if (null == (state = _advancedSettings.GetAddInCustomData <LoggingState> (addInName, loggingStateKey)))
            {
                state = new LoggingState( );
            }

            return(state);
        }
Exemplo n.º 20
0
 public AutoSaveLogCommand(LoggingState loggingState)
 {
     LoggingState = loggingState;
 }
Exemplo n.º 21
0
 public void SetLoggingState(LoggingState state)
 {
     logger.Trace("SetLoggingState {0}", state);
 }
Exemplo n.º 22
0
        private static void ConfigureLoggingChannel(DataAccessLoggingChannel channel, LoggingState logginState)
        {
            if (channel.LogDataAccessAgent is LoggingSqlDataAccessAgent)
            {
                LoggingSqlDataAccessAgent agent = (LoggingSqlDataAccessAgent)channel.LogDataAccessAgent;

                agent.CopyDicomDataSetOnDisk = true;

                agent.DataSetFolder = logginState.DataSetDirectory;
            }
        }
Exemplo n.º 23
0
 public void SetLoggingState(LoggingState state)
 {
     logger.Trace("SetLoggingState {0}", state);
 }
Exemplo n.º 24
0
        public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
        {
            if (!Configuration.Enabled)
            {
                return(null);
            }

            //var via = channel.Via;
            //var inputSession = channel.InputSession;
            //var outputSession = channel.OutputSession;
            //var SessionId = channel.SessionId;
            //var LocalAddress = channel.LocalAddress;
            //var state = channel.State;

            var context = HttpContext.Current;
            var page    = HttpContext.Current?.Handler as Page;

            var loggingState = new LoggingState()
            {
                Context     = context,
                Page        = page,
                GUID        = LoggingHelper.GetInstanceGUID(context, () => Guid.NewGuid()).GetValueOrDefault(),
                SessionGUID = LoggingHelper.GetSessionGUID(context, page, () => new Guid()).GetValueOrDefault(),
                PageGUID    = LoggingHelper.GetPageGUID(context, page, null).GetValueOrDefault(),
                BundleGUID  = LoggingHelper.GetBundleGUID(context, () => Guid.NewGuid()).GetValueOrDefault(),
                Url         = LoggingHelper.StripUrlForLRAP(channel.Via.ToString()),
                Action      = request.Headers.Action,
                ServerGUID  = LoggingHelper.GetServerGUID(HttpContext.Current, null, page?.Request?.Params)
            };

            var logType = LogType.OnWCFServiceRequest;

            //OperationContext.Current.SessionId

            string messageBody   = GetMessageBody(request);
            var    newLogElement = new LogElementDTO(
                guid: loggingState.GUID,
                sessionGUID: loggingState.SessionGUID,
                pageGUID: loggingState.PageGUID,
                bundleGUID: loggingState.BundleGUID,
                progressGUID: null,
                unixTimestamp: TimeHelper.UnixTimestamp(),
                logType: logType,
                element: Path.GetFileName(loggingState.Action),
                element2: null,
                value: messageBody,
                times: 1,
                unixTimestampEnd: null,
                instanceTime: DateTime.Now,
                stackTrace: null
                );

            if (LoggingHelper.IsPlaying(context, page?.Request.Params))
            {
                if (LoggingHelper.FetchAndExecuteLogElement(loggingState.ServerGUID.Value, loggingState.SessionGUID, loggingState.PageGUID, logType, (logElement) =>
                {
                    TimeHelper.SetNow(context, logElement.InstanceTime);

                    var loggedMessageBody = logElement.Value;
                    if (loggedMessageBody != null && messageBody != null && loggedMessageBody != messageBody)
                    {
                        var useLoggedElement = PlayerCommunicationHelper.ReportDifference(loggingState.ServerGUID.Value, logElement, newLogElement);
                        if (useLoggedElement)
                        {
                            messageBody = loggedMessageBody;
                        }
                    }

                    PlayerCommunicationHelper.SetLogElementAsDone(loggingState.ServerGUID.Value, loggingState.SessionGUID, loggingState.PageGUID, logElement.GUID, new JobStatus()
                    {
                        Success = true
                    });                                                                                                                                                                                 //, async: false);
                }))
                {
                }
            }
            else
            {
                LoggingHelper.LogElement(newLogElement);
            }

            request = BuildMessage(messageBody, request);

            return(loggingState);
        }
Exemplo n.º 25
0
        public AdvancedTests()
        {
            // Statemachine 'a'
            LoggingState a1 = new LoggingState("a1");
            LoggingState a2 = new LoggingState("a2");
            LoggingState a3 = new LoggingState("a3");
            Sub          a  = new LoggingSub("a", new StateMachine(
                                                 a1, a2, a3
                                                 ));

            a1.AddHandler("TI", a1, TransitionKind.Internal, data => {
                log.Add("a1:action(TI)");
            });


            a1.AddHandler("T1", a2);
            a2.AddHandler("T2", a3, TransitionKind.External, data => {
                log.Add("a2:action(T2)");
                sm.handleEvent("T3");
            });

            a3.AddHandler("T3", a1);

            // Statemachine 'b'
            var b1  = new LoggingState("b1");
            var b21 = new LoggingState("b21");
            var b22 = new LoggingState("b22");

            var b2 = new LoggingSub("b2", new StateMachine(
                                        b21, b22
                                        ));

            var b311 = new LoggingState("b311");
            var b312 = new LoggingState("b312");
            var b321 = new LoggingState("b321");
            var b322 = new LoggingState("b322");
            var b3   = new LoggingParallel("b3",
                                           new StateMachine(b311, b312),
                                           new StateMachine(b321, b322)
                                           );

            var b = new LoggingSub("b", new StateMachine(
                                       b1, b2, b3
                                       ));

            a.AddHandler("T4", b2);
            a.AddHandler("T5", b);
            b.AddHandler("T6", b22, TransitionKind.Local);
            b22.AddHandler("T7", b, TransitionKind.Local);

            a1.AddHandler("T8", b322);
            b311.AddHandler("T9", a1);

            a.AddHandler("T10", b3);

            b311.AddHandler("T11", b311, TransitionKind.Internal, data => {
                log.Add("b311:action(T11)");
            });
            b321.AddHandler("T11", b321, TransitionKind.Internal, data => {
                log.Add("b321:action(T11)");
            });

            b311.AddHandler("T12", b312, data => {
                return(data["v"] == null);
            });
            b321.AddHandler("T12", b322, data => {
                return(data["v"] != null);
            });

            sm = new StateMachine(a, b);
        }