Ejemplo n.º 1
0
        public IntegrationLog(IAppInfo appInfo, string id, DateTime instant, int duration, string source, string endpoint, string action, string type,
                              string errorId, string executedBy, bool isExpose)
        {
            log = new IntegrationLogDefinition();

            Id              = id;
            Instant         = instant;
            Duration        = duration;
            Source          = source?.Left(MAX_SOURCE_SIZE) ?? string.Empty;
            Endpoint        = endpoint?.Left(MAX_ENDPOINT_SIZE) ?? string.Empty;
            Action          = action;
            Type            = type;
            EspaceId        = appInfo?.eSpaceId ?? 0;
            TenantId        = appInfo?.TenantId ?? 0;
            ErrorId         = errorId;
            ExecutedBy      = executedBy;
            IsExpose        = isExpose;
            EspaceName      = appInfo?.eSpaceName;
            ApplicationName = appInfo?.ApplicationName;
            ApplicationKey  = appInfo?.ApplicationUIDAsKey;

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                RequestKey = reqTracer.RequestKey;
            }
        }
Ejemplo n.º 2
0
        public async Task Test_UndeployFunctionAsync(string jsonFileName, HttpStatusCode statusCode, Type exception)
        {
            using var response =
                      ResourceHelper.ReadResourceAsStream($@"Documents\Eventing\{jsonFileName}");
            var buffer = new byte[response.Length];

            response.Read(buffer, 0, buffer.Length);

            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = statusCode,
                Content    = new ByteArrayContent(buffer)
            };

            var serviceMock = new Mock <IEventingFunctionService>();

            serviceMock.Setup(x => x.PostAsync(It.IsAny <string>(), It.IsAny <IRequestSpan>(), It.IsAny <IRequestSpan>(), It.IsAny <CancellationToken>(), null))
            .Returns(Task.FromResult(httpResponseMessage));

            using var tracer   = new RequestTracer();
            using var listener = new XUnitLoggerListener(_loggerFactory.CreateLogger <ThresholdTracerTests>());
            tracer.Start(listener);

            var manager = new EventingFunctionManager(serviceMock.Object,
                                                      new Mock <ILogger <EventingFunctionManager> >().Object, tracer);

            try
            {
                await manager.UndeployFunctionAsync("case_1_enrich_ips");
            }
            catch (Exception e)
            {
                Assert.True(e.GetType() == exception, $"Expected {e.GetType().Name} but was {exception.Name}");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Action <code>Commandsort</code> that represents the Service Studio screen action <code>sort</code>
        ///  <p> Description: </p>
        /// </summary>
        private bool Commandsort(HeContext heContext)
        {
            Global.App.Context.Items["osPassedOnAction"] = true;
            CheckPermissions(heContext);
            RequestTracer perfTracer = heContext.RequestTracer; if (perfTracer != null)
            {
                perfTracer.RegisterAction("1d53c688-fa96-46eb-b3ec-86f2e20b3448", "List_SortColumn.sort");
            }
            lcvsort localVars = new lcvsort();

            try {
                if (heContext != null && heContext.RequestTracer != null)
                {
                    heContext.RequestTracer.RegisterInternalCall("iMZTHZb660az7Iby4gs0SA", "sort", "X0RMeX3yYU+0eg2nFEDfaA", "ContactManager");
                }
                // Direction
                // Direction = If
                localVars.varLcDirection = (((Functions.ActionList_SortColumn_GetOrderBy(heContext, varLctableRecordsId, "") == (inParamColumn + " ASC"))) ?("DESC"):("ASC"));
                explicitChangedVariables.Add(localVars.varLcDirection);

                // List_SortColumn_SetOrderBy
                Actions.ActionList_SortColumn_SetOrderBy(heContext, varLctableRecordsId, inParamColumn, localVars.varLcDirection);

                // Deprecated_NotifyWidget
                ExtendedActions.Deprecated_NotifyWidget(heContext, RuntimeID, ((inParamColumn + " ") + localVars.varLcDirection));

                // Update Screen
                return(true);
            } catch (System.Threading.ThreadAbortException) {
                return(false);
            }
        }
Ejemplo n.º 4
0
        private void Write(IAppInfo appInfo, ISessionInfo sessionInfo, DateTime instant, int duration, string screen, string msisdn,
                           string screenType, string accessMode, string executedBy, int viewstateBytes, int sessionBytes, int sessionRequests)
        {
            Instant         = instant;
            Duration        = duration;
            Screen          = screen;
            SessionId       = sessionInfo.SessionID;
            EspaceId        = appInfo.eSpaceId;
            TenantId        = appInfo.TenantId;
            UserId          = sessionInfo.UserId;
            Msisdn          = msisdn;
            ScreenType      = screenType;
            AccessMode      = ScreenLogDefinition.NotNullAccessMode(accessMode);
            ExecutedBy      = executedBy;
            ViewstateBytes  = viewstateBytes;
            SessionBytes    = sessionBytes;
            SessionRequests = sessionRequests;

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                RequestKey = reqTracer.RequestKey;
                ActionName = reqTracer.EntryActionName;
            }

            ClientIP        = RuntimePlatformUtils.GetRequestSourceForLogging()?.Left(MAX_CLIENT_IP_SIZE);
            EspaceName      = appInfo.eSpaceName;
            ApplicationName = appInfo.ApplicationName;
            ApplicationKey  = appInfo.ApplicationUIDAsKey;
            Username        = sessionInfo.UserName;

            log.Write();
        }
Ejemplo n.º 5
0
        public static string StaticWrite(IAppInfo appInfo, ISessionInfo sessionInfo, DateTime instant, string loginId, string errorId,
                                         string executedBy, string action, int duration, string source, string endpoint, string originalRequestKey)
        {
            ServiceAPILogDefinition logDef = new ServiceAPILogDefinition {
                Id                 = ServiceAPILogDefinition.GenerateLogId(),
                Instant            = instant,
                SessionId          = sessionInfo.SessionID,
                UserId             = sessionInfo.UserId,
                LoginId            = loginId,
                EspaceId           = appInfo.eSpaceId,
                TenantId           = appInfo.TenantId,
                ErrorId            = errorId,
                ExecutedBy         = executedBy,
                Action             = action,
                Duration           = duration,
                Source             = source,
                Endpoint           = endpoint,
                EspaceName         = appInfo.eSpaceName,
                ApplicationName    = appInfo.ApplicationName,
                ApplicationKey     = appInfo.ApplicationUIDAsKey,
                Username           = sessionInfo.UserName,
                OriginalRequestKey = originalRequestKey
            };

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                logDef.RequestKey = reqTracer.RequestKey;
            }

            logDef.Write();
            return(logDef.Id);
        }
Ejemplo n.º 6
0
        private static ContextInfoForStack FillContextInfoStruct(HeContext context)
        {
            ContextInfoForStack contextForStack = new ContextInfoForStack();

            if (context != null)
            {
                try { contextForStack.sessionId = context.Session.SessionID; } catch { }
                try { contextForStack.userId = context.Session.UserId; } catch { }
                try { contextForStack.username = context.Session.UserName; } catch { }
                try {
                    if (context.RequestTracer != null)
                    {
                        RequestTracer requestTracer = context.RequestTracer;
                        contextForStack.requestKey     = requestTracer.RequestKey;
                        contextForStack.actionName     = requestTracer.EntryActionName;
                        contextForStack.entryPointName = requestTracer.EntryEndpointName;
                        requestTracer.RegisterError();
                    }
                } catch { }
                try { contextForStack.requestUrl = context.Context.Request.Url.ToString(); } catch { }
                try { contextForStack.requestMethod = context.Context.Request.HttpMethod; } catch { }
                try {
                    contextForStack.requestQuery = context.Context.Request.QueryString != null?context.Context.Request.QueryString.ToString() : "";
                } catch { }
                try { contextForStack.currentLocale = context.CurrentLocale; } catch { }
                try { contextForStack.clientIp = RuntimePlatformUtils.GetClientIpForLogging(); } catch { }
                try { contextForStack.deviceUuid = RuntimePlatformUtils.GetDeviceUuidForLogging(); } catch { }
                try { contextForStack.CurrentExecutionFileName = context.CurrentExecutionFileName; } catch { }
            }

            return(contextForStack);
        }
        protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            var appInfo = App;

            if (appInfo == null)
            {
                // Try again
                Application_Start(sender, e);
            }

            appInfo = App;
            if (appInfo != null)
            {
                RequestTracer perfTracer = new RequestTracer(appInfo.ApplicationUID, appInfo.ApplicationName, appInfo.eSpaceUID, App.eSpaceName,
                                                             appInfo.Tenant.Id_Guid, appInfo.Tenant.Name, appInfo.EnvironmentKey, appInfo.EnvironmentName, appInfo.FrontendName);
                perfTracer.RegisterBeginRequest(DateTime.Now);
                appInfo.OsContext.RequestTracer = perfTracer;
                HttpCompressionModule.OnBeginRequest(sender, e);
                appInfo.NotifyBeginRequest();
            }
            if (!forTestAction)
            {
                const string PreferredEncoding = "preferredEncoding";
                if (Request.Browser[PreferredEncoding] != null)
                {
                    Request.ContentEncoding  = System.Text.Encoding.GetEncoding(Request.Browser[PreferredEncoding]);
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding(Request.Browser[PreferredEncoding]);
                }
            }
        }
Ejemplo n.º 8
0
        public void Write(IAppInfo appInfo, string id, DateTime instant, int duration, string source, string endpoint, string action, string type,
                          string errorId, bool isExpose)
        {
            Id              = id;
            Instant         = instant;
            Duration        = duration;
            Source          = source?.Left(MAX_SOURCE_SIZE) ?? string.Empty;
            Endpoint        = endpoint?.Left(MAX_ENDPOINT_SIZE) ?? string.Empty;
            Action          = action;
            Type            = type;
            EspaceId        = appInfo?.eSpaceId ?? 0;
            TenantId        = appInfo?.TenantId ?? 0;
            ErrorId         = errorId;
            ExecutedBy      = RuntimeEnvironment.MachineName;
            IsExpose        = isExpose;
            EspaceName      = appInfo?.eSpaceName;
            ApplicationName = appInfo?.ApplicationName;
            ApplicationKey  = appInfo?.ApplicationUIDAsKey;

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                RequestKey = reqTracer.RequestKey;
            }

            log.Write();
        }
Ejemplo n.º 9
0
        public void NoTracer_PassThrough()
        {
            RequestTracer middleware = new RequestTracer(env =>
            {
                return(TaskHelpers.Completed());
            });

            middleware.Invoke(Request.Create().Environment).Wait();
        }
        protected void Application_PostAcquireRequestState(Object sender, EventArgs e)
        {
            RequestTracer perfTracer = RuntimePlatformUtils.GetRequestTracer();

            if (perfTracer != null)
            {
                perfTracer.RegisterSessionAcquisitionTime();
            }
        }
Ejemplo n.º 11
0
        public void NoTracer_PassThrough()
        {
            RequestTracer middleware = new RequestTracer(env =>
            {
                return TaskHelpers.Completed();
            });

            middleware.Invoke(Request.Create().Environment).Wait();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Returns the current RequestKey, consistent with RequestEvents being logged in the database for the current request.
        /// If there is no RequestKey available in the current context, an empty string is returned.
        /// </summary>
        /// <returns>A string containing the request key.</returns>
        public static string GetRequestKey()
        {
            RequestTracer tracer = RuntimePlatformUtils.GetRequestTracer();

            if (tracer != null)
            {
                return(tracer.RequestKey);
            }

            return("");
        }
Ejemplo n.º 13
0
        public void Write(IAppInfo appInfo, string id, DateTime instant, string screen, string endpoint, string source, int duration,
                          string executedBy, string errorId, string loginId, int userId, string username)
        {
            string        requestKey = RequestKey;
            RequestTracer reqTracer  = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                requestKey = reqTracer.RequestKey;
            }

            log.Write(id, instant, appInfo.eSpaceId, appInfo.TenantId, screen, endpoint, source, duration, executedBy, errorId, loginId, userId, requestKey,
                      appInfo.eSpaceName, appInfo.ApplicationName, appInfo.ApplicationUIDAsKey, username);
        }
Ejemplo n.º 14
0
        public void Write(DateTime instant, int duration, ObjectKey cyclicJobKey, int espaceId, int tenantId,
                          string executedBy, string errorId, DateTime shouldHaveRunAt, DateTime nextRun, string eSpaceName, string applicationName,
                          ObjectKey applicationKey, string cyclicJobName)
        {
            string        requestKey = RequestKey;
            RequestTracer reqTracer  = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                requestKey = reqTracer.RequestKey;
            }

            log.Write(instant, duration, cyclicJobKey, espaceId, tenantId, executedBy, errorId, shouldHaveRunAt, nextRun, requestKey,
                      eSpaceName, applicationName, applicationKey, cyclicJobName);
        }
Ejemplo n.º 15
0
        public MobileRequestLog(string id, DateTime instant, int espaceId, int tenantId, string screen, string endpoint,
                                string source, int duration, string executedBy, string errorId, string loginId, int userId,
                                string eSpaceName, string applicationName, ObjectKey applicationKey, string username)
        {
            string        requestKey = string.Empty;
            RequestTracer reqTracer  = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                requestKey = reqTracer.RequestKey;
            }

            log = new MobileRequestLogDefinition(id, instant, espaceId, tenantId, screen, endpoint, source, duration, executedBy, errorId,
                                                 requestKey, loginId, userId, eSpaceName, applicationName, applicationKey, username);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Action <code>Preparation</code> that represents the Service Studio preparation
        ///  <code>Preparation</code> <p> Description: </p>
        /// </summary>
        public void Preparation(HeContext heContext)
        {
            CheckPermissions(heContext);
            RequestTracer perfTracer = heContext.RequestTracer; perfTracer.RegisterAction("880d45a3-6187-4921-9cbb-09673652cb86.#Preparation", "List_SortColumn.Preparation");

            try {
                if (heContext != null && heContext.RequestTracer != null)
                {
                    heContext.RequestTracer.RegisterInternalCall("o0UNiIdhIUmcuwlnNlLLhg.#Preparation", "Preparation", "X0RMeX3yYU+0eg2nFEDfaA", "ContactManager");
                }
                // GetPageName
                Actions.ActionGetPageName(heContext, out resGetPageName_outParamPageName);
            } catch (System.Threading.ThreadAbortException) {
                throw;
            }
        }
        public void Test2()
        {
            using var tracer   = new RequestTracer();
            using var listener = new ThresholdTraceListener(_loggerFactory, new ThresholdOptions());
            tracer.Start(listener);

            using var parentSpan = tracer.RequestSpan("get");
            using var child      = tracer.RequestSpan("get-dispatch", parentSpan);

            var foo = new Foo(parentSpan)
            {
                Bar = new Bar(child)
            };

            foo.WriteTags();
            foo.Bar.WriteTags();
        }
        public void Test()
        {
            using var tracer   = new RequestTracer();
            using var listener = new XUnitLoggerListener(_loggerFactory.CreateLogger <ThresholdTracerTests>());
            tracer.Start(listener);

            using var parentSpan = tracer.RequestSpan("get");
            using var child      = tracer.RequestSpan("get-dispatch", parentSpan);

            var foo = new Foo(parentSpan)
            {
                Bar = new Bar(child)
            };

            foo.WriteTags();
            foo.Bar.WriteTags();
        }
Ejemplo n.º 19
0
        public void Tracer_Traced()
        {
            RequestTracer middleware = new RequestTracer(env =>
            {
                return TaskHelpers.Completed();
            });

            StringWriter writer = new StringWriter();
            TextWriterTraceListener textListener = new TextWriterTraceListener(writer, "TestTracer");
            TraceSource traceSource = new TraceSource("TestSource", SourceLevels.All);
            traceSource.Listeners.Add(textListener);

            Request request = Request.Create();
            request.Environment["host.TraceSource"] = traceSource;
            middleware.Invoke(request.Environment).Wait();
            Assert.That(writer.GetStringBuilder().ToString(), Is.Not.EqualTo(string.Empty));
        }
Ejemplo n.º 20
0
        public void Tracer_Traced()
        {
            RequestTracer middleware = new RequestTracer(env =>
            {
                return(TaskHelpers.Completed());
            });

            StringWriter            writer       = new StringWriter();
            TextWriterTraceListener textListener = new TextWriterTraceListener(writer, "TestTracer");
            TraceSource             traceSource  = new TraceSource("TestSource", SourceLevels.All);

            traceSource.Listeners.Add(textListener);

            Request request = Request.Create();

            request.Environment["host.TraceSource"] = traceSource;
            middleware.Invoke(request.Environment).Wait();
            Assert.That(writer.GetStringBuilder().ToString(), Is.Not.EqualTo(string.Empty));
        }
        /// <summary>
        /// Action <code>Preparation</code> that represents the Service Studio preparation
        ///  <code>Preparation</code> <p> Description: </p>
        /// </summary>
        public void Preparation(HeContext heContext)
        {
            CheckPermissions(heContext);
            RequestTracer perfTracer = heContext.RequestTracer; perfTracer.RegisterAction("1014d26c-abd5-4d61-a920-4895012b921b.#Preparation", "List_Counter.Preparation");

            try {
                if (heContext != null && heContext.RequestTracer != null)
                {
                    heContext.RequestTracer.RegisterInternalCall("bNIUENWrYU2pIEiVASuSGw.#Preparation", "Preparation", "X0RMeX3yYU+0eg2nFEDfaA", "ContactManager");
                }
                // SetValues
                // FirstRecord = StartIndex + 1
                varLcFirstRecord = (inParamStartIndex + 1);
                // LastRecord = TextToInteger
                varLcLastRecord = BuiltInFunction.TextToInteger(Convert.ToString(((((inParamStartIndex + inParamLineCount) < inParamTotalRowCount)) ?((inParamStartIndex + inParamLineCount)):(inParamTotalRowCount))));
            } catch (System.Threading.ThreadAbortException) {
                throw;
            }
        }
Ejemplo n.º 22
0
        public static string StaticWrite(DateTime instant, string sessionId, int espaceId, int tenantId, int userId, string message,
                                         string stack, string environmentInformation, string moduleName,
                                         string eSpaceName, string applicationName, ObjectKey applicationKey, string username)
        {
            string requestKey, actionName, entryPointName;

            requestKey = actionName = entryPointName = String.Empty;

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                requestKey     = reqTracer.RequestKey;
                actionName     = reqTracer.EntryActionName;
                entryPointName = reqTracer.EntryEndpointName;
            }

            return(ErrorLogDefinition.StaticWrite(instant, sessionId, espaceId, tenantId, userId, message, stack, environmentInformation, moduleName, requestKey, entryPointName, actionName,
                                                  eSpaceName, applicationName, applicationKey, username));
        }
Ejemplo n.º 23
0
        public static void MssStringBuilder_Create(HeContext heContext, int inParamInitialCapacity, out object outParamStringBuilder)
        {
            DateTime startTime  = DateTime.Now;
            String   errorLogId = "";

            try {
                issText.MssStringBuilder_Create(inParamInitialCapacity, out outParamStringBuilder);
            } catch (Exception ex) {
                errorLogId = ErrorLog.LogApplicationError(ex, heContext, "Extension method execution: Text.StringBuilder_Create");
                throw ex;
            } finally {
                if (errorLogId != string.Empty || (!heContext.AppInfo.SelectiveLoggingEnabled ||
                                                   (heContext.AppInfo.ExtensionProperties.AllowLogging("b69aa077-acf4-4bdc-bcd5-9def81d7ddcd") && heContext.AppInfo.Properties.AllowLogging)))
                {
                    int extLogCount = heContext.ExtensionLogCount;
                    if (extLogCount == _maxExtensionLogsPerRequest)
                    {
                        // issue warning
                        GeneralLog.StaticWrite(
                            DateTime.Now, heContext.Session.SessionID, heContext.AppInfo.eSpaceId, heContext.AppInfo.Tenant.Id,
                            heContext.Session.UserId, "The maximum number (" + _maxExtensionLogsPerRequest + ") of allowed Extension Log entries per request has been exceeded. No more entries will be logged in this request.",
                            "WARNING", "SLOWEXTENSION", "");
                        heContext.ExtensionLogCount = extLogCount + 1;
                    }
                    else if (extLogCount < _maxExtensionLogsPerRequest)
                    {
                        DateTime instant           = DateTime.Now;
                        int      executionDuration = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds);
                        ExtensionLog.StaticWrite(heContext.AppInfo, heContext.Session,
                                                 instant, executionDuration, "StringBuilder_Create", errorLogId, 20, "Text");
                        heContext.ExtensionLogCount = extLogCount + 1;
                        RequestTracer reqTracer = heContext.RequestTracer;
                        if (reqTracer != null)
                        {
                            reqTracer.RegisterExtensionExecuted("f13768e4-0fbe-4be7-a870-51b5c8362fed", "StringBuilder_Create", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", executionDuration, instant);
                        }
                    }
                }
                RuntimePlatformUtils.LogSlowExtensionCall(startTime, "Text.StringBuilder_Create");
            }
        }
Ejemplo n.º 24
0
        public static void MssIsAjaxRequest(HeContext heContext, out bool outParamIsAjaxRequest)
        {
            DateTime startTime  = DateTime.Now;
            String   errorLogId = "";

            try {
                issHTTPRequestHandler.MssIsAjaxRequest(out outParamIsAjaxRequest);
            } catch (Exception ex) {
                errorLogId = ErrorLog.LogApplicationError(ex, heContext, "Extension method execution: HTTPRequestHandler.IsAjaxRequest");
                throw ex;
            } finally {
                if (errorLogId != string.Empty || (!heContext.AppInfo.SelectiveLoggingEnabled ||
                                                   (heContext.AppInfo.ExtensionProperties.AllowLogging("b1ef216b-d67f-454e-9f01-a7f0274608d6") && heContext.AppInfo.Properties.AllowLogging)))
                {
                    int extLogCount = heContext.ExtensionLogCount;
                    if (extLogCount == _maxExtensionLogsPerRequest)
                    {
                        // issue warning
                        GeneralLog.StaticWrite(
                            DateTime.Now, heContext.Session.SessionID, heContext.AppInfo.eSpaceId, heContext.AppInfo.Tenant.Id,
                            heContext.Session.UserId, "The maximum number (" + _maxExtensionLogsPerRequest + ") of allowed Extension Log entries per request has been exceeded. No more entries will be logged in this request.",
                            "WARNING", "SLOWEXTENSION", "");
                        heContext.ExtensionLogCount = extLogCount + 1;
                    }
                    else if (extLogCount < _maxExtensionLogsPerRequest)
                    {
                        DateTime instant           = DateTime.Now;
                        int      executionDuration = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds);
                        ExtensionLog.StaticWrite(heContext.AppInfo, heContext.Session,
                                                 instant, executionDuration, "IsAjaxRequest", errorLogId, 13, "HTTPRequestHandler");
                        heContext.ExtensionLogCount = extLogCount + 1;
                        RequestTracer reqTracer = heContext.RequestTracer;
                        if (reqTracer != null)
                        {
                            reqTracer.RegisterExtensionExecuted("42593b4a-86fc-4724-8a21-f53e64e0e175", "IsAjaxRequest", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", executionDuration, instant);
                        }
                    }
                }
                RuntimePlatformUtils.LogSlowExtensionCall(startTime, "HTTPRequestHandler.IsAjaxRequest");
            }
        }
Ejemplo n.º 25
0
        public static void MssRegex_Search(HeContext heContext, string inParamText, string inParamPattern, bool inParamIgnoreCase, bool inParamMultiLine, bool inParamSingleLine, out bool outParamFound, out string outParamPatternResult, out int outParamFirstIndex)
        {
            DateTime startTime  = DateTime.Now;
            String   errorLogId = "";

            try {
                issText.MssRegex_Search(inParamText, inParamPattern, inParamIgnoreCase, inParamMultiLine, inParamSingleLine, out outParamFound, out outParamPatternResult, out outParamFirstIndex);
            } catch (Exception ex) {
                errorLogId = ErrorLog.LogApplicationError(ex, heContext, "Extension method execution: Text.Regex_Search");
                throw ex;
            } finally {
                if (errorLogId != string.Empty || (!heContext.AppInfo.SelectiveLoggingEnabled ||
                                                   (heContext.AppInfo.ExtensionProperties.AllowLogging("b69aa077-acf4-4bdc-bcd5-9def81d7ddcd") && heContext.AppInfo.Properties.AllowLogging)))
                {
                    int extLogCount = heContext.ExtensionLogCount;
                    if (extLogCount == _maxExtensionLogsPerRequest)
                    {
                        // issue warning
                        GeneralLog.StaticWrite(
                            DateTime.Now, heContext.Session.SessionID, heContext.AppInfo.eSpaceId, heContext.AppInfo.Tenant.Id,
                            heContext.Session.UserId, "The maximum number (" + _maxExtensionLogsPerRequest + ") of allowed Extension Log entries per request has been exceeded. No more entries will be logged in this request.",
                            "WARNING", "SLOWEXTENSION", "");
                        heContext.ExtensionLogCount = extLogCount + 1;
                    }
                    else if (extLogCount < _maxExtensionLogsPerRequest)
                    {
                        DateTime instant           = DateTime.Now;
                        int      executionDuration = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds);
                        ExtensionLog.StaticWrite(heContext.AppInfo, heContext.Session,
                                                 instant, executionDuration, "Regex_Search", errorLogId, 20, "Text");
                        heContext.ExtensionLogCount = extLogCount + 1;
                        RequestTracer reqTracer = heContext.RequestTracer;
                        if (reqTracer != null)
                        {
                            reqTracer.RegisterExtensionExecuted("5c204ebc-821d-48a8-aa5f-b3412dcd2696", "Regex_Search", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", executionDuration, instant);
                        }
                    }
                }
                RuntimePlatformUtils.LogSlowExtensionCall(startTime, "Text.Regex_Search");
            }
        }
Ejemplo n.º 26
0
        public GeneralLog(DateTime instant, string sessionId, int espaceId, int tenantId, int userId, string message, string messageType, string moduleName, string errorId)
        {
            string requestKey, actionName, entryPointName, clientIp;

            requestKey = actionName = entryPointName = clientIp = String.Empty;

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                requestKey     = reqTracer.RequestKey;
                actionName     = reqTracer.EntryActionName;
                entryPointName = reqTracer.EntryEndpointName;
            }
            clientIp = RuntimePlatformUtils.GetRequestSourceForLogging();

            GetEspaceDetails(espaceId, userId, out string eSpaceName, out string applicationName, out ObjectKey applicationKey, out string username);

            log = new GeneralLogDefinition(instant, sessionId, espaceId, tenantId, userId, message, messageType, moduleName,
                                           errorId, requestKey, actionName, entryPointName, clientIp,
                                           eSpaceName, applicationName, applicationKey, username);
        }
Ejemplo n.º 27
0
        public async Task Test_FunctionStatus()
        {
            using var response =
                      ResourceHelper.ReadResourceAsStream(@"Documents\Eventing\200_ok_status.json");
            var buffer = new byte[response.Length];

            response.Read(buffer, 0, buffer.Length);

            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new ByteArrayContent(buffer)
            };

            var serviceMock = new Mock <IEventingFunctionService>();

            serviceMock.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <IRequestSpan>(), It.IsAny <IRequestSpan>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(httpResponseMessage));

            using var tracer   = new RequestTracer();
            using var listener = new XUnitLoggerListener(_loggerFactory.CreateLogger <ThresholdTracerTests>());
            tracer.Start(listener);

            var manager = new EventingFunctionManager(serviceMock.Object,
                                                      new Mock <ILogger <EventingFunctionManager> >().Object, tracer);

            var functionStatus = await manager.FunctionsStatus();

            Assert.Equal(1, functionStatus.NumEventingNodes);

            var function = functionStatus.Functions.First();

            Assert.Equal(EventingFunctionStatus.Undeployed, function.Status);
            Assert.Equal(EventingFunctionDeploymentStatus.Undeployed, function.DeploymentStatus);
            Assert.Equal(EventingFunctionProcessingStatus.Paused, function.ProcessingStatus);
            Assert.Equal(0, function.NumDeployedNodes);
            Assert.Equal(0, function.NumBootstrappingNodes);
            Assert.Equal("case_1_enrich_ips", function.Name);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Action <code>CommandClose</code> that represents the Service Studio screen action
        ///  <code>Close</code> <p> Description: </p>
        /// </summary>
        private bool CommandClose(HeContext heContext)
        {
            Global.App.Context.Items["osPassedOnAction"] = true;
            CheckPermissions(heContext);
            RequestTracer perfTracer = heContext.RequestTracer; if (perfTracer != null)

            {
                perfTracer.RegisterAction("13dadb09-1482-4c8b-a858-9ffef470f1ef", "Close");
            }
            try {
                if (heContext != null && heContext.RequestTracer != null)
                {
                    heContext.RequestTracer.RegisterInternalCall("CdvaE4IUi0yoWJ_+9HDx7w", "Close", "X0RMeX3yYU+0eg2nFEDfaA", "ContactManager");
                }
                // Popup_Editor_Close
                Actions.ActionPopup_Editor_Close(heContext);

                // Update Screen
                return(true);
            } catch (System.Threading.ThreadAbortException) {
                return(false);
            }
        }
Ejemplo n.º 29
0
        public void Write(DateTime instant, string sessionId, int espaceId, int tenantId, int userId,
                          string message, string messageType, string moduleName, string errorId,
                          string eSpaceName, string applicationName, ObjectKey applicationKey, string username)
        {
            string requestKey     = RequestKey;
            string actionName     = ActionName;
            string entryPointName = EntrypointName;
            string clientIp       = ClientIP;

            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();

            if (reqTracer != null)
            {
                requestKey     = reqTracer.RequestKey;
                actionName     = reqTracer.EntryActionName;
                entryPointName = reqTracer.EntryEndpointName;
            }
            clientIp = RuntimePlatformUtils.GetRequestSourceForLogging();

            log.Write(instant, sessionId, espaceId, tenantId, userId, message, messageType, moduleName,
                      errorId, requestKey, actionName, entryPointName, clientIp,
                      eSpaceName, applicationName, applicationKey, username);
        }
Ejemplo n.º 30
0
        protected void Application_EndRequest(Object sender, EventArgs e)
        {
            RequestTracer perfTracer = RuntimePlatformUtils.GetRequestTracer();

            if (perfTracer != null)
            {
                perfTracer.RegisterViewStateSize();
            }

            if (App != null && App.OsContext != null)
            {
                App.OsContext.OnEndRequest();
            }
            DatabaseAccess.FreeupResources(true);
            HttpCompressionModule.OnEndRequest(sender, e);

            if (perfTracer != null)
            {
                perfTracer.RegisterEndRequest();
                perfTracer.CreateEvents();
                perfTracer.EmitEvents();
            }
        }
        public void doAJAXRefreshScreen(HeContext heContext)
        {
            ObjectKey oldCurrentESpaceKey = heContext.CurrentESpaceKey;

            try {
                heContext.CurrentESpaceKey = ssContactManager.Global.eSpaceKey;
                // Perform the partial databind
                Page.DataBind();
                RequestTracer perfTracer = RuntimePlatformUtils.GetRequestTracer(); if (perfTracer != null)
                {
                    perfTracer.RegisterSessionSize(); if (heContext.Session != null)
                    {
                        RuntimePlatformUtils.GetRequestTracer().RegisterUserId(heContext.Session.UserId);
                    }
                }
                if (!heContext.AppInfo.SelectiveLoggingEnabled || heContext.AppInfo.Properties.AllowLogging)
                {
                    ScreenLog.StaticWrite(heContext.AppInfo, heContext.Session, heContext.StartInstant, (int)((TimeSpan)(DateTime.Now - heContext.StartInstant)).TotalMilliseconds, "InvalidPermissions", (string)heContext.Session["MSISDN"], "WEB", "Ajax", RuntimeEnvironment.MachineName, RuntimePlatformUtils.GetViewstateSize(), RuntimePlatformUtils.GetRetrievedSessionSize(), RuntimePlatformUtils.GetRetrievedSessionRequests());
                }
            } finally {
                heContext.CurrentESpaceKey = oldCurrentESpaceKey;
            }
            StoreWebScreenStackViewState();
        }
Ejemplo n.º 32
0
        public async Task Test_GetFunctionAsync_Ok()
        {
            using var response =
                      ResourceHelper.ReadResourceAsStream(@"Documents\Eventing\getfunction-response.json");
            var buffer = new byte[response.Length];

            response.Read(buffer, 0, buffer.Length);

            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new ByteArrayContent(buffer)
            };

            var serviceMock = new Mock <IEventingFunctionService>();

            serviceMock.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <IRequestSpan>(), It.IsAny <IRequestSpan>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(httpResponseMessage));

            using var tracer   = new RequestTracer();
            using var listener = new XUnitLoggerListener(_loggerFactory.CreateLogger <ThresholdTracerTests>());
            tracer.Start(listener);

            var manager = new EventingFunctionManager(serviceMock.Object,
                                                      new Mock <ILogger <EventingFunctionManager> >().Object, tracer);

            var eventingFunctions = await manager.GetFunctionAsync("case_1_enrich_ips");

            var eventingFunction = eventingFunctions;

            Assert.Equal("function OnUpdate(doc, meta) {\n  log('document', doc);\n  doc[\"ip_num_start\"] = get_numip_first_3_octets(doc[\"ip_start\"]);\n  doc[\"ip_num_end\"]   = get_numip_first_3_octets(doc[\"ip_end\"]);\n  tgt[meta.id]=doc;\n}\nfunction get_numip_first_3_octets(ip) {\n  var return_val = 0;\n  if (ip) {\n    var parts = ip.split('.');\n    //IP Number = A x (256*256*256) + B x (256*256) + C x 256 + D\n    return_val = (parts[0]*(256*256*256)) + (parts[1]*(256*256)) + (parts[2]*256) + parseInt(parts[3]);\n    return return_val;\n  }\n}", eventingFunction.Code);
            Assert.Equal("UhEbm2", eventingFunction.FunctionInstanceId);
            Assert.Equal("evt-7.0.0-5071-ee", eventingFunction.Version);
            Assert.False(eventingFunction.EnforceSchema);
            Assert.Equal(2908133798, eventingFunction.HandlerUuid);
        }