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;
            }
        }
示例#2
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();
        }
        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();
        }
        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);
        }
        protected void Application_PostAcquireRequestState(Object sender, EventArgs e)
        {
            RequestTracer perfTracer = RuntimePlatformUtils.GetRequestTracer();

            if (perfTracer != null)
            {
                perfTracer.RegisterSessionAcquisitionTime();
            }
        }
示例#6
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("");
        }
        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);
        }
        protected HttpWebRequest BuildServiceAPIMethodRequest(HeContext context, string sapimName, object inputs)
        {
            var    zoneSettings     = DeploymentZoneResolution.ByModuleKey(ProducerModuleKey);
            var    securityProtocol = zoneSettings.EnableHttps ? "https" : "http";
            var    sapimEndpoint    = $"{securityProtocol}://{zoneSettings.Address}/{ProducerModuleName}/serviceapi/{UrlEncode(sapimName)}";
            string httpMethod       = "POST";
            var    headers          = new Dictionary <string, string>();

            headers.Add("User-Agent", "OutSystemsPlatform");
            headers.Add("Content-Type", "application/json");
            headers.Add("Content-Language", context.CurrentLocale);

            var requestPayload = new CoreServicesApiController.Payload.RequestPayload();

            requestPayload.RequestKey      = RuntimePlatformUtils.GetRequestTracer()?.RequestKey ?? Guid.NewGuid().ToString();
            requestPayload.InputParameters = JObject.FromObject(inputs);
            string payloadString = JsonConvert.SerializeObject(requestPayload, Formatting.None);

            var stringToken = SecurityTokenAPI.GenerateJWTTokenString(
                settingsProvider: RuntimeSettingsProvider.Instance,
                consumerModuleKey: ObjectKeyUtils.DatabaseValue(ConsumerModuleKey),
                producerModuleKey: ObjectKeyUtils.DatabaseValue(ProducerModuleKey),
                userId: context.Session.UserId,
                tenantId: context.Session.TenantId,
                requestHash: SecurityTokenAPI.GeneratePayloadHash(RuntimeSettingsProvider.Instance, payloadString),
                requestLifetime: RuntimePlatformSettings.ServiceAPIs.RequestLifetime.GetValue()
                );

            headers.Add(AuthorizationHeaderKey, AuthorizationTokenType + stringToken);

            var request = (HttpWebRequest)HttpWebRequest.Create(sapimEndpoint);

            request.Method = httpMethod;
            // set the timeout for the request
            request.Timeout = DefaultTimeoutInSeconds * 1000;

            // set headers in request
            foreach (var header in headers.Keys)
            {
                SetRequestHeader(request, header, headers[header]);
            }

            // set request body
            using (Stream requestStream = request.GetRequestStream()) {
                var requestBody = Encoding.UTF8.GetBytes(payloadString);
                requestStream.Write(requestBody, 0, requestBody.Length);
            }

            return(request);
        }
示例#9
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);
        }
        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);
        }
示例#11
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));
        }
        public void doRefreshScreen(HeContext heContext)
        {
            ObjectKey oldCurrentESpaceKey = heContext.CurrentESpaceKey;

            try {
                heContext.CurrentESpaceKey = ssContactManager.Global.eSpaceKey;
                Title = "Invalid Permissions"; Page.DataBind();
                if (RuntimePlatformUtils.GetRequestTracer() != null)
                {
                    RuntimePlatformUtils.GetRequestTracer().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", "Screen", RuntimeEnvironment.MachineName, RuntimePlatformUtils.GetViewstateSize(), RuntimePlatformUtils.GetRetrievedSessionSize(), RuntimePlatformUtils.GetRetrievedSessionRequests());
                }
            } finally {
                heContext.CurrentESpaceKey = oldCurrentESpaceKey;
            }
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
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();
            }
        }
示例#16
0
        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, "InternalError", (string)heContext.Session["MSISDN"], "WEB", "Ajax", RuntimeEnvironment.MachineName, RuntimePlatformUtils.GetViewstateSize(), RuntimePlatformUtils.GetRetrievedSessionSize(), RuntimePlatformUtils.GetRetrievedSessionRequests());
                }
            } finally {
                heContext.CurrentESpaceKey = oldCurrentESpaceKey;
            }
            StoreWebScreenStackViewState();
        }
            /// <summary>
            /// Query Function "GetCurrentApplication" of Action "GetApplicationName"
            /// </summary>
            public static RLApplicationRecordList datasetGetCurrentApplication(HeContext heContext, int maxRecords, IterationMultiplicity multiplicity, out long outParamCount, int qpinESpaceId)
            {
                // Query Iterations: Never {-unbound-}
                // Uses binary data: False
                if (multiplicity == IterationMultiplicity.Never)
                {
                    maxRecords = 1;
                }
                outParamCount = -1;
                CacheHelper myCacheHelper = new CacheHelper();

                myCacheHelper.AddValue(Global.eSpaceId);
                myCacheHelper.AddValue("8ncuMQL0nf3wuIPtCEpJMw");
                myCacheHelper.AddValue(heContext.AppInfo.Tenant.Id.ToString());
                myCacheHelper.AddValue(Convert.ToString(maxRecords));
                myCacheHelper.AddValue(Convert.ToString(qpinESpaceId));
                string cacheHash = myCacheHelper.GetHash();

                OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long> temp = RuntimeCache.Instance.Get(new CacheKey(cacheHash)) as OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>;
                if (temp == null)
                {
                    bool          useMainTransaction = (multiplicity != IterationMultiplicity.Single || (maxRecords > 0 && maxRecords <= 150));
                    Transaction   trans          = useMainTransaction? DatabaseAccess.ForCurrentDatabase.GetRequestTransaction(): DatabaseAccess.ForCurrentDatabase.GetReadOnlyTransaction();
                    Command       sqlCmd         = trans.CreateCommand();
                    string        sql            = "";
                    StringBuilder selectBuilder  = new StringBuilder();
                    StringBuilder fromBuilder    = new StringBuilder();
                    StringBuilder whereBuilder   = new StringBuilder();
                    StringBuilder orderByBuilder = new StringBuilder();
                    StringBuilder groupByBuilder = new StringBuilder();
                    StringBuilder havingBuilder  = new StringBuilder();
                    selectBuilder.Append("SELECT ");
                    if (maxRecords > 0)
                    {
                        selectBuilder.Append("TOP (");
                        selectBuilder.Append(maxRecords);
                        selectBuilder.Append(") ");
                    }
                    selectBuilder.Append("NULL o0, ENApplication.[NAME] o1, NULL o2, NULL o3, NULL o4, NULL o5, NULL o6, NULL o7, NULL o8, NULL o9, NULL o10, NULL o11, NULL o12, NULL o13");
                    fromBuilder.Append(" FROM {Application} ENApplication");
                    whereBuilder.Append(" WHERE (");
                    if (qpinESpaceId != 0)
                    {
                        whereBuilder.Append("((ENApplication.[ENTRY_ESPACE_ID] = @qpinESpaceId) AND (ENApplication.[ENTRY_ESPACE_ID] IS NOT NULL))");
                        sqlCmd.CreateParameterWithoutReplacements("@qpinESpaceId", DbType.Int32, qpinESpaceId);
                    }
                    else
                    {
                        whereBuilder.Append("(ENApplication.[ENTRY_ESPACE_ID] IS NULL)");
                    }
                    whereBuilder.Append(" OR ");
                    if (qpinESpaceId != 0)
                    {
                        whereBuilder.Append("((ENApplication.[BACKOFFICE_ESPACE_ID] = @qpinESpaceId) AND (ENApplication.[BACKOFFICE_ESPACE_ID] IS NOT NULL))");
                        sqlCmd.CreateParameterWithoutReplacements("@qpinESpaceId", DbType.Int32, qpinESpaceId);
                    }
                    else
                    {
                        whereBuilder.Append("(ENApplication.[BACKOFFICE_ESPACE_ID] IS NULL)");
                    }
                    whereBuilder.Append(")");

                    sql = selectBuilder.ToString() + fromBuilder.ToString() + whereBuilder.ToString() + groupByBuilder.ToString() + havingBuilder.ToString() + orderByBuilder.ToString();
                    string advSql = sql;
                    sql = AppUtils.Instance.ReplaceEntityReferences(heContext, advSql);
                    sqlCmd.CommandText = sql;
                    try {
                        RLApplicationRecordList outParamList = new RLApplicationRecordList();
                        outParamList.Transaction = trans;
                        BitArray[] opt = new BitArray[1];
                        opt[0] = new BitArray(new bool[] {
                            true, false, true, true, true, true, true, true, true, true, true, true, true, true
                        });
                        outParamList.AllOptimizedAttributes = opt;
                        if (multiplicity == IterationMultiplicity.Multiple)
                        {
                            RLApplicationRecordList _tmp = new RLApplicationRecordList();
                            _tmp.Transaction            = trans;
                            _tmp.AllOptimizedAttributes = opt;
                            _tmp.MaxRecords             = maxRecords;
                            try {
                                DateTime startTime = DateTime.Now;
                                DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query GetApplicationName.GetCurrentApplication.List");
                                int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                         );
                                RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                                if (reqTracer != null)
                                {
                                    reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                                }
                                outParamList = (RLApplicationRecordList)_tmp.Duplicate();
                                _tmp.CloseDataReader();
                                RuntimeCache.Instance.Add(new CacheKey(cacheHash), new OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>((RLApplicationRecordList)(outParamList.Duplicate()), -1), new EspaceTenantDependency(Global.eSpaceId, Global.App.Tenant.Id), DateTime.UtcNow.AddMinutes(60), CacheUtils.NoSliding, OutSystems.RuntimeCommon.Caching.CacheItemPriority.Removable);
                                return(outParamList);
                            } finally {
                                _tmp.CloseDataReader();
                            }
                        }
                        else if (multiplicity == IterationMultiplicity.Never)
                        {
                            try {
                                DateTime startTime = DateTime.Now;
                                DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query GetApplicationName.GetCurrentApplication.List");
                                int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                         );
                                RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                                if (reqTracer != null)
                                {
                                    reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                                }
                                outParamList.MaxRecords = maxRecords;
                                RuntimeCache.Instance.Add(new CacheKey(cacheHash), new OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>((RLApplicationRecordList)(outParamList.Duplicate()), -1), new EspaceTenantDependency(Global.eSpaceId, Global.App.Tenant.Id), DateTime.UtcNow.AddMinutes(60), CacheUtils.NoSliding, OutSystems.RuntimeCommon.Caching.CacheItemPriority.Removable);
                                return(outParamList);
                            } finally {
                                outParamList.CloseDataReader();
                            }
                        }
                        else
                        {
                            if (maxRecords > 0 && maxRecords <= 150)
                            {
                                RLApplicationRecordList _tmp = new RLApplicationRecordList();
                                _tmp.Transaction            = trans;
                                _tmp.AllOptimizedAttributes = opt;
                                try {
                                    DateTime startTime = DateTime.Now;
                                    DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query GetApplicationName.GetCurrentApplication.List");
                                    int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                             );
                                    RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                                    if (reqTracer != null)
                                    {
                                        reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                                    }
                                    outParamList = (RLApplicationRecordList)_tmp.Duplicate();
                                    outParamList.AllOptimizedAttributes = opt;
                                    _tmp.CloseDataReader();
                                    return(outParamList);
                                } finally {
                                    _tmp.CloseDataReader();
                                }
                            }
                            else
                            {
                                try {
                                    DateTime startTime = DateTime.Now;
                                    DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query GetApplicationName.GetCurrentApplication.List");
                                    int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                             );
                                    RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                                    if (reqTracer != null)
                                    {
                                        reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                                    }
                                    outParamList.MaxRecords = maxRecords;
                                    RuntimeCache.Instance.Add(new CacheKey(cacheHash), new OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>((RLApplicationRecordList)(outParamList.Duplicate()), -1), new EspaceTenantDependency(Global.eSpaceId, Global.App.Tenant.Id), DateTime.UtcNow.AddMinutes(60), CacheUtils.NoSliding, OutSystems.RuntimeCommon.Caching.CacheItemPriority.Removable);
                                    return(outParamList);
                                } finally {
                                    if (maxRecords == 1)
                                    {
                                        outParamList.CloseDataReader();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        throw new DataBaseException("Error executing query.", e);
                    }
                }
                else
                {
                    lock (temp) {
                        return((RLApplicationRecordList)temp.First.Duplicate());
                    }
                }
            }
示例#18
0
            /// <summary>
            /// Query Function "GetContacts" of Action "BootstrapContacts"
            /// </summary>
            public static RLContactRecordList datasetGetContacts(HeContext heContext, int maxRecords, IterationMultiplicity multiplicity, out long outParamCount)
            {
                // Query Iterations: Never {-unbound-}
                // Uses binary data: False
                if (multiplicity == IterationMultiplicity.Never)
                {
                    maxRecords = 1;
                }
                outParamCount = -1;
                bool          useMainTransaction = (multiplicity != IterationMultiplicity.Single || (maxRecords > 0 && maxRecords <= 150));
                Transaction   trans          = useMainTransaction? DatabaseAccess.ForCurrentDatabase.GetRequestTransaction(): DatabaseAccess.ForCurrentDatabase.GetReadOnlyTransaction();
                Command       sqlCmd         = trans.CreateCommand();
                string        sql            = "";
                StringBuilder selectBuilder  = new StringBuilder();
                StringBuilder fromBuilder    = new StringBuilder();
                StringBuilder whereBuilder   = new StringBuilder();
                StringBuilder orderByBuilder = new StringBuilder();
                StringBuilder groupByBuilder = new StringBuilder();
                StringBuilder havingBuilder  = new StringBuilder();

                selectBuilder.Append("SELECT ");
                if (maxRecords > 0)
                {
                    selectBuilder.Append("TOP (");
                    selectBuilder.Append(maxRecords);
                    selectBuilder.Append(") ");
                }
                selectBuilder.Append("NULL o0, NULL o1, NULL o2, NULL o3, NULL o4, NULL o5");
                fromBuilder.Append(" FROM {Contact} ENContact");

                sql = selectBuilder.ToString() + fromBuilder.ToString() + whereBuilder.ToString() + groupByBuilder.ToString() + havingBuilder.ToString() + orderByBuilder.ToString();
                string advSql = sql;

                sql = AppUtils.Instance.ReplaceEntityReferences(heContext, advSql);
                sqlCmd.CommandText = sql;
                try {
                    RLContactRecordList outParamList = new RLContactRecordList();
                    outParamList.Transaction = trans;
                    BitArray[] opt = new BitArray[1];
                    opt[0] = new BitArray(new bool[] {
                        true, true, true, true, true, true
                    });
                    outParamList.AllOptimizedAttributes = opt;
                    if (multiplicity == IterationMultiplicity.Multiple)
                    {
                        RLContactRecordList _tmp = new RLContactRecordList();
                        _tmp.Transaction            = trans;
                        _tmp.AllOptimizedAttributes = opt;
                        _tmp.MaxRecords             = maxRecords;
                        try {
                            DateTime startTime = DateTime.Now;
                            DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query BootstrapContacts.GetContacts.List");
                            int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                     );
                            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                            if (reqTracer != null)
                            {
                                reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                            }
                            outParamList = (RLContactRecordList)_tmp.Duplicate();
                            _tmp.CloseDataReader();
                            return(outParamList);
                        } finally {
                            _tmp.CloseDataReader();
                        }
                    }
                    else if (multiplicity == IterationMultiplicity.Never)
                    {
                        try {
                            DateTime startTime = DateTime.Now;
                            DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query BootstrapContacts.GetContacts.List");
                            int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                     );
                            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                            if (reqTracer != null)
                            {
                                reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                            }
                            outParamList.MaxRecords = maxRecords;
                            return(outParamList);
                        } finally {
                            outParamList.CloseDataReader();
                        }
                    }
                    else
                    {
                        if (maxRecords > 0 && maxRecords <= 150)
                        {
                            RLContactRecordList _tmp = new RLContactRecordList();
                            _tmp.Transaction            = trans;
                            _tmp.AllOptimizedAttributes = opt;
                            try {
                                DateTime startTime = DateTime.Now;
                                DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query BootstrapContacts.GetContacts.List");
                                int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                         );
                                RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                                if (reqTracer != null)
                                {
                                    reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                                }
                                outParamList = (RLContactRecordList)_tmp.Duplicate();
                                outParamList.AllOptimizedAttributes = opt;
                                _tmp.CloseDataReader();
                                return(outParamList);
                            } finally {
                                _tmp.CloseDataReader();
                            }
                        }
                        else
                        {
                            try {
                                DateTime startTime = DateTime.Now;
                                DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query BootstrapContacts.GetContacts.List");
                                int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                         );
                                RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                                if (reqTracer != null)
                                {
                                    reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now);
                                }
                                outParamList.MaxRecords = maxRecords;
                                return(outParamList);
                            } finally {
                                if (maxRecords == 1)
                                {
                                    outParamList.CloseDataReader();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    throw new DataBaseException("Error executing query.", e);
                }
            }
示例#19
0
            /// <summary>
            /// Query Function "GetAddressTypesByLabel" of Action "AddressType_GetOrCreateByLabel"
            /// </summary>
            public static RLAddressTypeRecordList datasetGetAddressTypesByLabel(HeContext heContext, int maxRecords, IterationMultiplicity multiplicity, out long outParamCount, string qpstLabel)
            {
                // Query Iterations: Never {-unbound-}
                // Uses binary data: False
                if (multiplicity == IterationMultiplicity.Never)
                {
                    maxRecords = 1;
                }
                outParamCount = -1;
                bool          useMainTransaction = (multiplicity != IterationMultiplicity.Single || (maxRecords > 0 && maxRecords <= 150));
                Transaction   trans          = useMainTransaction? DatabaseAccess.ForCurrentDatabase.GetRequestTransaction(): DatabaseAccess.ForCurrentDatabase.GetReadOnlyTransaction();
                Command       sqlCmd         = trans.CreateCommand();
                string        sql            = "";
                StringBuilder selectBuilder  = new StringBuilder();
                StringBuilder fromBuilder    = new StringBuilder();
                StringBuilder whereBuilder   = new StringBuilder();
                StringBuilder orderByBuilder = new StringBuilder();
                StringBuilder groupByBuilder = new StringBuilder();
                StringBuilder havingBuilder  = new StringBuilder();

                selectBuilder.Append("SELECT ");
                if (maxRecords > 0)
                {
                    selectBuilder.Append("TOP (");
                    selectBuilder.Append(maxRecords);
                    selectBuilder.Append(") ");
                }
                selectBuilder.Append("ENAddressType.[ID] o0, ENAddressType.[LABEL] o1, ENAddressType.[ORDER] o2, ENAddressType.[ACTIVE] o3, ENAddressType.[CREATEDDATE] o4, ENAddressType.[CREATEDBY] o5, ENAddressType.[LASTUPDATEDDATE] o6, ENAddressType.[LASTUPDATEDBY] o7");
                fromBuilder.Append(" FROM {AddressType} ENAddressType");
                whereBuilder.Append(" WHERE (ENAddressType.[LABEL] = @qpstLabel)");
                orderByBuilder.Append(" ORDER BY ENAddressType.[LABEL] ASC ");
                sqlCmd.CreateParameterWithoutReplacements("@qpstLabel", DbType.String, qpstLabel);

                sql = selectBuilder.ToString() + fromBuilder.ToString() + whereBuilder.ToString() + groupByBuilder.ToString() + havingBuilder.ToString() + orderByBuilder.ToString();
                string advSql = sql;

                sql = AppUtils.Instance.ReplaceEntityReferences(heContext, advSql);
                sqlCmd.CommandText = sql;
                RLAddressTypeRecordList outParamList = new RLAddressTypeRecordList();

                outParamList.Transaction = trans;
                BitArray[] opt = new BitArray[1];
                opt[0] = new BitArray(new bool[] {
                    false, false, false, false, false, false, false, false
                });
                outParamList.AllOptimizedAttributes = opt;
                if (multiplicity == IterationMultiplicity.Multiple)
                {
                    RLAddressTypeRecordList _tmp = new RLAddressTypeRecordList();
                    _tmp.Transaction            = trans;
                    _tmp.AllOptimizedAttributes = opt;
                    _tmp.MaxRecords             = maxRecords;
                    try {
                        DateTime startTime = DateTime.Now;
                        DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List");
                        int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                 );
                        RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                        if (reqTracer != null)
                        {
                            reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now);
                        }
                        outParamList = (RLAddressTypeRecordList)_tmp.Duplicate();
                        _tmp.CloseDataReader();
                        return(outParamList);
                    } finally {
                        _tmp.CloseDataReader();
                    }
                }
                else if (multiplicity == IterationMultiplicity.Never)
                {
                    try {
                        DateTime startTime = DateTime.Now;
                        DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List");
                        int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                 );
                        RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                        if (reqTracer != null)
                        {
                            reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now);
                        }
                        outParamList.MaxRecords = maxRecords;
                        return(outParamList);
                    } finally {
                        outParamList.CloseDataReader();
                    }
                }
                else
                {
                    if (maxRecords > 0 && maxRecords <= 150)
                    {
                        RLAddressTypeRecordList _tmp = new RLAddressTypeRecordList();
                        _tmp.Transaction            = trans;
                        _tmp.AllOptimizedAttributes = opt;
                        try {
                            DateTime startTime = DateTime.Now;
                            DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List");
                            int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                     );
                            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                            if (reqTracer != null)
                            {
                                reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now);
                            }
                            outParamList = (RLAddressTypeRecordList)_tmp.Duplicate();
                            outParamList.AllOptimizedAttributes = opt;
                            _tmp.CloseDataReader();
                            return(outParamList);
                        } finally {
                            _tmp.CloseDataReader();
                        }
                    }
                    else
                    {
                        try {
                            DateTime startTime = DateTime.Now;
                            DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List");
                            int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds
                                                                     );
                            RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer();
                            if (reqTracer != null)
                            {
                                reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now);
                            }
                            outParamList.MaxRecords = maxRecords;
                            return(outParamList);
                        } finally {
                            if (maxRecords == 1)
                            {
                                outParamList.CloseDataReader();
                            }
                        }
                    }
                }
            }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // init vars
            AppInfo appInfo = Global.App;

            if (appInfo != null)
            {
                heContext = appInfo.OsContext;
            }
            Response.ContentType = "text/html; charset=" + Response.ContentEncoding.WebName;

            // No session SessionFixationValidation because screen is accessible by anonymous users or uses a readonly session.

            if (appInfo != null)
            {
                heContext = appInfo.OsContext; heContext.RequestTracer.MainEventType = RequestTracerEventType.WebScreenServerExecuted; heContext.RequestTracer.RegisterEndpoint("2dcd742c-96b7-4e62-ae6f-1644bcab95a5", "InvalidPermissions");
            }
            OutSystems.HubEdition.RuntimePlatform.Web.JavaScriptManager.CheckRelativeJavaScriptPrefix(AppUtils.Instance.getImagePath());
            appInfo.IsLoadingScreen = !IsPostBack;
            if (!IsPostBack)
            {
                ArrayList screenParameters          = (ArrayList)Global.App.OsContext.Session["ContactManager._ScreenParameters_InvalidPermissions"];
                bool      screenParametersInSession = false;
                object    screenParametersKey       = heContext.Session["_ScreenParametersKey"];
                if ((screenParametersKey == null || this.Key.Equals(ObjectKey.Parse(Convert.ToString(screenParametersKey)))) && screenParameters != null)
                {
                    try {
                        screenParametersInSession = true;
                    } catch (Exception parametersException) {
                        ErrorLog.LogApplicationError("Failed to load Screen Input Parameters from session.", "ScreenParametersKey = " + screenParametersKey + ", Count = " + screenParameters.Count + "\r\n" + parametersException.StackTrace, heContext, "Global");
                    } finally {
                        Global.App.OsContext.Session["ContactManager._ScreenParameters_InvalidPermissions"] = null;
                        heContext.Session["_ScreenParametersKey"] = null;
                    }
                }
                else if (Request.HttpMethod == "GET")
                {
                }
                else if (Request.HttpMethod == "POST")
                {
                }
            }
            if (!appInfo.IsApplicationEnabled)
            {
                ErrorLog.LogApplicationError(message: "eSpace " + appInfo.eSpaceName + " is disabled", stackTrace: Environment.StackTrace, context: heContext, moduleName: "Global");
                String contact = RuntimePlatformUtils.GetAdministrationEmail();
                try {
                    Context.Items[Constants.AppOfflineCustomHandler.ContactKey]   = contact;
                    Context.Items[Constants.AppOfflineCustomHandler.ErrorCodeKey] = "APPLICATION_OFFLINE";
                    Server.Transfer("/ContactManager/CustomHandlers/app_offline.aspx");
                }
                catch (System.Threading.ThreadAbortException) {}
                catch {
                    Response.Redirect("/ContactManager/CustomHandlers/internalerror.aspx");
                }
            }
            InitializeUrls();
            Actions.ActionOnBeginWebRequest(heContext);
            if (appInfo.IsForcingSecurityForScreens() && !RuntimePlatformUtils.RequestIsSecure(Request))
            {
                Response.Redirect("https://" + Request.Url.Host + "" + AppUtils.Instance.getImagePath() + "InvalidPermissions.aspx" + Request.Url.Query);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            if (!IsPostBack)
            {
                CheckPermissions(heContext);
                bool bindEditRecords = !IsPostBack;
                Title = "Invalid Permissions"; Page.DataBind();
                if (RuntimePlatformUtils.GetRequestTracer() != null)
                {
                    RuntimePlatformUtils.GetRequestTracer().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", "Screen", RuntimeEnvironment.MachineName, RuntimePlatformUtils.GetViewstateSize(), RuntimePlatformUtils.GetRetrievedSessionSize(), RuntimePlatformUtils.GetRetrievedSessionRequests());
                }
            }
            else
            {
                if (heContext.AppInfo.IsForcingSecurityForScreens() && !RuntimePlatformUtils.RequestIsSecure(Request))
                {
                    Response.Redirect("https://" + Request.Url.Host + "" + AppUtils.Instance.getImagePath() + "InvalidPermissions.aspx" + Request.Url.Query);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
                FetchViewState();
            }
        }