public static string GetOutputDateFormatString()
 {
     return(FormatInfoLogic.GetOutputDateFormatString());
 }
Example #2
0
        public static string GetStackEnvironmentInfo(AppInfoForStack info, ContextInfoForStack context)
        {
            // safely get all environment parameters
            string requestUrl = "", requestMethod = "", requestQuery = "", applicationPath = "", processName = "", processStartTime = "", currentLocale = "", filePath = "", dateFormat = "", dotNetVersion = "", appDomain = "", compiledWithVersion = "", clientIp = "", deviceUuid = "";
            int    espaceVersionId = 0, espaceVersion = 0, espaceVersionPublishingId = 0, processId = 0;
            long   privateMBytes = 0, virtualMBytes = 0, threadId = 0;
            string threadName = "";

            espaceVersionId = info.espaceVersionId;
            espaceVersion   = info.espaceVersion;

            requestUrl    = context.requestUrl;
            requestMethod = context.requestMethod;
            requestQuery  = context.requestQuery;
            currentLocale = context.currentLocale;
            clientIp      = context.clientIp;
            deviceUuid    = context.deviceUuid;

            try {
                applicationPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                applicationPath = applicationPath.Replace("Program Files\\OutSystems\\Service Center", "...\\SC")
                                  .Replace("Program Files\\OutSystems\\Platform Server", "...\\PS")
                                  .Replace("Program Files\\OutSystems\\Hub Server", "...\\HS");
            } catch { }

            try { privateMBytes = Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024; } catch { }

            try { virtualMBytes = Process.GetCurrentProcess().VirtualMemorySize64 / 1024 / 1024; } catch { }

            try { processId = Process.GetCurrentProcess().Id; } catch { }

            try { processName = Process.GetCurrentProcess().ProcessName; } catch { }

            try { processStartTime = Process.GetCurrentProcess().StartTime.ToUniversalTime().ToString(); } catch { }
            try { threadId = Thread.CurrentThread.ManagedThreadId; } catch { }

            try { threadName = Thread.CurrentThread.Name; } catch { }

            if (context.CurrentExecutionFileName != null)
            {
                filePath = ScriptableBuiltInFunction.NewLine() + "FilePath: " + applicationPath + context.CurrentExecutionFileName;
            }

            try { dateFormat = FormatInfoLogic.GetOutputDateFormatString(); } catch { }

            try { dotNetVersion = Environment.Version.ToString(); } catch { }

            try { appDomain = AppDomain.CurrentDomain.FriendlyName; } catch { }

            try { compiledWithVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); } catch { }

            string environmentInformation;

            if (EnvironmentInformationOverride != null)
            {
                environmentInformation = EnvironmentInformationOverride; // ScriptableBuiltInFunction.NewLine() + EnvironmentInformationOverride;
            }
            else
            {
                environmentInformation =
                    "eSpaceVer: " + espaceVersion + " (Id=" + espaceVersionId + ", PubId=" + espaceVersionPublishingId + ", CompiledWith=" + compiledWithVersion + ")" +
                    ScriptableBuiltInFunction.NewLine() + "RequestUrl: " + requestUrl + " (Method: " + requestMethod + ")" +
                    ScriptableBuiltInFunction.NewLine() + "AppDomain: " + appDomain +
                    ((filePath.IsNullOrEmpty()) ? ScriptableBuiltInFunction.NewLine() + "Path: " + applicationPath : filePath) +
                    ((clientIp.IsNullOrEmpty()) ? "" : (ScriptableBuiltInFunction.NewLine() + "ClientIp: " + clientIp)) +
                    ((deviceUuid.IsNullOrEmpty()) ? "" : (ScriptableBuiltInFunction.NewLine() + deviceUuid)) +
                    ScriptableBuiltInFunction.NewLine() + "Locale: " + currentLocale +
                    ScriptableBuiltInFunction.NewLine() + "DateFormat: " + dateFormat +
                    ScriptableBuiltInFunction.NewLine() + "PID: " + processId + " ('" + processName + "', Started='" + processStartTime + "', Priv=" + privateMBytes + "Mb, Virt=" + virtualMBytes + "Mb)" +
                    ScriptableBuiltInFunction.NewLine() + "TID: " + threadId +
                    ScriptableBuiltInFunction.NewLine() + "Thread Name: " + threadName +
                    ScriptableBuiltInFunction.NewLine() + ".NET: " + dotNetVersion;
            }

            return(environmentInformation);
        }