protected virtual string GetUrlPrefix(out bool prefixWithImagePath) { string osPageHeader = AppInfo.GetAppInfo().OsContext.OsISAPIFilter.GetPage(); prefixWithImagePath = osPageHeader != null && osPageHeader.IndexOf('/', 1) != -1; return(prefixWithImagePath ? GetAppUtils().getImagePath() : null); }
public override void OnRender() { if (databound || !AppInfo.GetAppInfo().OsContext.IsAjaxRequest) { if (Repeater.Count == 0 || appendHiddenRow) { // last hidden row doesn't exist // on first load append hidden row (to allow add new row to work properly) Repeater.Append(); appendHiddenRow = false; Repeater.DataSource.HasHiddenRow = true; StorePropertyValue(RowAppendedViewStateKey, true); } } else if (previousMaxRecords >= 0) { // restore the hidden row when rendering back the page to the browser Repeater.DataSource.MaxRecords = previousMaxRecords; previousMaxRecords = -1; StorePropertyValue(RowAppendedViewStateKey, true); } base.OnRender(); }
// Multi-language public static void SetCurrentLocale(HeContext heContext, string locale) { if (locale == "default" || !AppInfo.GetAppInfo().MultilingualEnabled) { locale = ""; } var wasSetLocale = false; if (heContext.CurrentLocale.ToLowerInvariant() != locale.ToLowerInvariant()) { new CultureInfo(locale); //assures that the Locale is known by .Net/Java heContext.CurrentLocale = locale; wasSetLocale = true; if (!heContext.IsWebServiceRequest) { heContext.AppInfo.InjectionCache.RunCallbacks(heContext.AppInfo, heContext.Session, Callbacks.CallbackEvent.ChangeLocale); } } // Traces #if !JAVA if (Settings.GetBool(Settings.Configs.DebugSetCurrentLocale)) { try { GeneralLog.StaticWrite(DateTime.Now, heContext.Session.SessionID, heContext.AppInfo.eSpaceId, heContext.AppInfo.Tenant.Id, heContext.Session.UserId, string.Format("did set current locale:{0}, locale:{1}\n{2}", wasSetLocale, locale, Environment.StackTrace), "DEBUG", "OSLOCALE", ""); } catch { } } #endif }
protected override string EntityToTablename(string entity, int tenantId) { string entityLC = entity.ToLowerInvariant(); switch (entityLC) { case "recentitem": return(ENRecentItemEntity.LocalViewName(AppInfo.GetAppInfo().Tenant.Id, BuiltInFunction.GetCurrentLocale())); case "messagetype": return(ENMessageTypeEntity.LocalViewName(AppInfo.GetAppInfo().Tenant.Id, BuiltInFunction.GetCurrentLocale())); case "menuitem": return(ENMenuItemEntity.LocalViewName(AppInfo.GetAppInfo().Tenant.Id, BuiltInFunction.GetCurrentLocale())); case "contact": return(ENContactEntity.LocalViewName(AppInfo.GetAppInfo().Tenant.Id, BuiltInFunction.GetCurrentLocale())); case "application": return(ENApplicationEntity.LocalViewName(AppInfo.GetAppInfo().Tenant.Id, BuiltInFunction.GetCurrentLocale())); case "user": return(ENUserEntity.LocalViewName(AppInfo.GetAppInfo().Tenant.Id, BuiltInFunction.GetCurrentLocale())); } throw new DataBaseException("'" + entity + "' found in 'Expand Inline' parameter is an unknown Entity"); }
/** * 读取配置 * * */ private void InitApp() { String infoPath = BaseConfig.CONFIG_PATH; INIHelper.CheckPath(infoPath); // 是否初始化 /** * String init = INIHelper.Read("Info", "Init", "false", infoPath); * LogHelper.ShowLog("App 是否初始化:{0}", init); * if (!Convert.ToBoolean(init)) * { * // 初始化数据库 * Task.Run(() => * { * string[] guns = new string[] { "98K", "AKM", "AUG", "AWM", "DP28", "G36C", "GROZA", "M16A4", "M249", "M416", "M762", * "MINI14", "MK14", "MK47", "MP5K", "PP19", "QBU", "QBZ", "S12K", "S1897", "S686", "SCAR", "SKS", "UMP45", "UZI", "VSS", "WIN94"}; * foreach (var a in guns) * { * InputData(a); * } * }); * init = "true"; * INIHelper.Write("Info", "Init", init, infoPath); * } **/ //InputData("M0SI", "30.mdb"); //InputCustom(); AppInfo appInfo = AppInfo.GetAppInfo(); appInfo.isInit = Convert.ToBoolean(true); }
public override object this[string name] { set { SiteProperty prop; var sitePropetiesCollection = GetSitePropertiesCollection(); if (sitePropetiesCollection.TryGetValueByName(name, out prop)) { // Check if it is a system var if (prop.Key == null) { throw (new ArgumentException("The site property '" + name + "' is a system property and cannot be changed.")); } if (prop.Value != value) { string databaseValue = prop.ChangeValue(value); HeContext heContext = AppInfo.GetAppInfo().OsContext; GenericExtendedActions.UpdateSiteProperty(heContext, prop.DefId, prop.IsShared, databaseValue); heContext.QueueEspaceToInvalidate(this.ESpaceId, prop.IsShared ? 0 : heContext.Session.TenantId); } } else { throw (new ArgumentException("The site property '" + name + "' does not exist.")); } } }
public void GetEspaceDetails(int eSpaceId, int userId, out string eSpaceName, out string applicationName, out ObjectKey applicationKey, out string username) { eSpaceName = null; applicationName = null; applicationKey = null; username = null; try { var appInfo = AppInfo.GetAppInfo(); var sessionInfo = appInfo?.OsContext?.Session; // ensure the AppInfo matches the eSpaceID passed as parameter if (appInfo?.eSpaceId == eSpaceId) { eSpaceName = eSpaceName ?? appInfo?.eSpaceName; applicationName = applicationName ?? appInfo?.ApplicationName; applicationKey = applicationKey ?? appInfo?.ApplicationUIDAsKey; } // ensure that the current user matches the userId defined in the log if (userId == sessionInfo?.UserId) { username = username ?? sessionInfo?.UserName; } } catch { } }
public void ShowInfo() { debugLogType = DebugLogType.None; text.text += "\n"; text.text += AppInfo.GetAppInfo(); text.rectTransform.sizeDelta = new Vector2(text.rectTransform.sizeDelta.x, text.preferredHeight > (text.transform.parent as RectTransform).sizeDelta.y ? text.preferredHeight : (text.transform.parent as RectTransform).sizeDelta.y); }
private byte[] GetAssociatedData() { string visitorId = null; string userId = null; if (Settings.GetBool(Settings.Configs.EncryptViewStateWithVisitorId)) { visitorId = AppInfo.GetAppInfo().VisitorId; } if (Settings.GetBool(Settings.Configs.EncryptViewStateWithUserId)) { var osContext = AppInfo.GetAppInfo().OsContext; if (osContext != null && osContext.Session != null) { userId = osContext.Session.UserId.ToString(); } } if (visitorId == null && userId == null) { return(null); } return(Encoding.UTF8.GetBytes((visitorId ?? "") + (userId ?? ""))); }
public override string getImagePath(bool forInternalAccess, bool includeSessionIdIfNeeded, string nameOverride) { HttpRequest request = HttpContext.Current.Request; try { HeContext heContext = Global.App.OsContext; string path = heContext.OsISAPIFilter.GetHostSuffix(request, ""); bool keepPTA = AppInfo.GetAppInfo().eSpaceId == Global.eSpaceId && nameOverride == null; if (!keepPTA || forInternalAccess) { path += RuntimePlatformUtils.GetEspacePrettyNamePath(nameOverride ?? "Address_CS", heContext); } else { path += (heContext.OsISAPIFilter.IsActiveInRequest(request) ? heContext.OsISAPIFilter.GetPath(request, "") + "/": "/Address_CS/"); } if (keepPTA) { path += AppInfo.GetAppInfo().PtaPath; } return(RuntimePlatformUtils.CheckUriSecurity(request, path)); } catch { return(""); } }
public static void Script_CreateOrUpdate(string name, string scriptOrUrl, string location, int order, string description) { if (name.IsNullOrEmpty()) { throw new Exception("The script name cannot be empty"); } if (order < 0) { throw new Exception("'{0}' is not a valid script order (must be greater or equal to 0)".F(order)); } if (ScriptLocations.IndexOf(location) == -1) { throw new Exception("'{0}' is not a valid script location".F(location)); } bool isUrl = Uri.IsWellFormedUriString(scriptOrUrl, UriKind.RelativeOrAbsolute); AppInfo info = AppInfo.GetAppInfo(); if (info != null) { info.CheckPlatformExtensibilityAPIs(); using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetRequestTransaction()) { DBRuntimePlatform.Instance.Script_CreateOrUpdate(tran, name, isUrl ? scriptOrUrl : "", isUrl ? "" : scriptOrUrl, location, order, description); info.InvalidateInjectionCache(); } } }
public static string StaticWrite(DateTime instant, string sessionId, int espaceId, int tenantId, int userId, string message, string stack, string environmentInformation, string moduleName) { string eSpaceName = null; string applicationName = null; ObjectKey applicationKey = null; string username = null; try { var appInfo = AppInfo.GetAppInfo(); var sessionInfo = appInfo?.OsContext?.Session; // ensure the AppInfo matches the eSpaceID passed as parameter if (appInfo?.eSpaceId == espaceId) { eSpaceName = appInfo?.eSpaceName; applicationName = appInfo?.ApplicationName; applicationKey = appInfo?.ApplicationUIDAsKey; } // ensure that the current user matches the userId defined in the log if (userId == sessionInfo?.UserId) { username = username ?? sessionInfo?.UserName; } } catch { } return(StaticWrite(instant, sessionId, espaceId, tenantId, userId, message, stack, environmentInformation, moduleName, eSpaceName, applicationName, applicationKey, username)); }
public override void OnException(HttpActionExecutedContext actionExecutedContext) { BuildErrorResponse(actionExecutedContext); bool isLoggable = true; Exception baseEx = actionExecutedContext.Exception; ExposeRestException restException = baseEx as ExposeRestException; if (restException != null) { baseEx = restException.InnerException ?? baseEx; // use the base Exception so that we don't get the async stacks added in the trace if (!restException.IsLoggable) { isLoggable = false; var loggingContext = LoggingHelper.GetLoggingContext(); if (loggingContext != null) { loggingContext.LogRequest = isLoggable; } } } if (isLoggable) { // Create log as soon as possible, or it will be done without the errorLogId inside the OnActionExecuted (since that is the normal logging place) string errorLogId = ErrorLog.LogApplicationError(baseEx, AppInfo.GetAppInfo().OsContext, "REST (Expose)"); LoggingHelper.LogResponse(actionExecutedContext, errorLogId); } try { if (actionExecutedContext.ActionContext.ControllerContext != null) { var controller = actionExecutedContext.ActionContext.ControllerContext.Controller; if (controller != null) { var responseFilters = actionExecutedContext.ActionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes <OnResponseFilter>(); foreach (var filter in responseFilters) { filter.OnActionExecuted(actionExecutedContext); } } } } catch (Exception exceptionInsideExceptionHandler) { ExposeRestException restExceptionInsideExceptionHandler = exceptionInsideExceptionHandler as ExposeRestException; if (restExceptionInsideExceptionHandler != null) { // use the base Exception so that we don't get the async stacks added in the trace exceptionInsideExceptionHandler = restExceptionInsideExceptionHandler.InnerException ?? exceptionInsideExceptionHandler; } // lets log the second error as well, just so it doesn't get lost. The one associated with the Integration Log will be the original one ErrorLog.LogApplicationError(exceptionInsideExceptionHandler, AppInfo.GetAppInfo().OsContext, "REST (Expose)"); // If an exception occurs in the ResponseFilter, build a new error response and don't let it "bubble up" // The new exception will override the old one as the user might change the error message actionExecutedContext.Exception = restExceptionInsideExceptionHandler; BuildErrorResponse(actionExecutedContext); } }
public void Remove(string name) { var appInfo = AppInfo.GetAppInfo(); appInfo.Configurations.Remove(appInfo.GetConfiguration(name, true)); AppInfo.SaveAppInfo(appInfo); }
public static string GetStringResource(string key, string defaultValue) { // set current thread's culture Thread.CurrentThread.CurrentUICulture = AppInfo.GetAppInfo().OsContext.CurrentCulture; // get resource manager if (embeddedResourceManager == null) { lock (embeddedResourceManagerLock) { if (embeddedResourceManager == null) { string baseResourceName = "Address_CS" + "Language"; embeddedResourceManager = new EmbeddedResourceManager( baseResourceName, Assembly.GetExecutingAssembly(), delegate(Exception exception, int retries, string k) { SmartErrorLog.LogError(exception, new StackTrace().ToString(), k, retries); }); } } } // get resource return(embeddedResourceManager.GetString(key) ?? defaultValue); }
public static void InitializeRunningInfo() { if (initialized) { return; } lock (typeof(RunningInfo)) { if (initialized) { return; } AppInfo appInfo = AppInfo.GetAppInfo(); if (appInfo == null) { InitializingErrorMessage = "AppInfo is null"; return; } try { using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetCommitableTransaction()) { EspaceName = appInfo.eSpaceName; PAName = appInfo.PtaName; PAUserName = appInfo.PtaUserName; tenantId = appInfo.Tenant.Id; espaceId = DBRuntimePlatform.Instance.GetEspaceId(tran, EspaceName); if (espaceId == 0) { initialized = false; } if (PAName == "") { PAName = null; } if (PAUserName == "") { PAUserName = null; } else if (PAUserName != null) { int scTenantId = DBRuntimePlatform.Instance.GetTenantIdByName(tran, Constants.ServiceCenterName, Constants.ServiceCenterName); userId = DBRuntimePlatform.Instance.GetUserId(tran, scTenantId, PAUserName); } } } catch (Exception e) { initialized = false; InitializingErrorMessage = "An exception ocurred during RunningInfo initialization: " + e.Message; Log.ErrorLog.LogApplicationError(InitializingErrorMessage, e.StackTrace, null, "InitializeRunningInfo"); OSTrace.Error(InitializingErrorMessage, e); throw; } initialized = true; } }
public static string GetPersonalAreaName() { try { return(AppInfo.GetAppInfo().PtaName); } catch { return(string.Empty); } }
public static string GetExceptionURL() { try { return((string)AppInfo.GetAppInfo().OsContext.Session[BuiltInFunction.ExceptionURLSessionName] ?? ""); } catch { return(string.Empty); } }
public static bool CurrentThemeIsMobile() { try { var page = AppInfo.GetAppInfo().OsContext.CurrentScreen as IBookmarkableURL; return(page != null && page.IsUsingMobileTheme); } catch { return(false); } }
public RequestEventsGenerator(RequestTracer tracer) { this.tracer = tracer; AppInfo info = AppInfo.GetAppInfo(); IsPerformanceMonitorEnabled = () => (info == null) ? false : info.Properties.PerformanceMonitoringEnabled; EventCreationThreshold = (type) => GetEventThreshold(type); }
protected virtual string GetRequestInfoJavaScript(string webScreenKey, string webScreenName) { var info = AppInfo.GetAppInfo(); using (var writer = new StringWriter()) { writer.Write(" <script id=\"_OSrequestInfoScript\" type=\"text/javascript\">(function(global) { "); writer.Write("global.outsystems = global.outsystems || {};"); writer.Write("global.outsystems.internal = global.outsystems.internal || {};"); if (Settings.GetBool(Settings.Configs.JavascriptAPI_ShowHiddenFields)) { writer.Write("global.outsystems.internal.showHiddenFields = true;"); } writer.Write("global.outsystems.internal.requestInfo = {"); // #564602 OSVisit and OSVisitor cookies allow HTML injection -check if cookies' value was modified writer.Write("visitorKey:'{0}',", GuidUtils.IsGuid(info.VisitorId) ? info.VisitorId : ""); writer.Write("visitKey:'{0}',", GuidUtils.IsGuid(info.VisitId) ? info.VisitId : ""); writer.Write("sessionKey:'{0}',", info.OsContext.Session.SessionIDHash); writer.Write("userKey:'{0}',", info.OsContext.Session.UserIdGuid); var perfTracer = info.OsContext.RequestTracer; bool perfTracerExists = perfTracer != null; writer.Write("requestKey:'{0}',", (perfTracerExists) ? perfTracer.RequestKey : ""); writer.Write("webScreenKey:'{0}',", ObjectKeyUtils.DatabaseValue(ObjectKey.Parse(webScreenKey))); writer.Write("webScreenName:'{0}',", webScreenName); writer.Write("espaceKey:'{0}',", (perfTracerExists) ? perfTracer.ModuleKey : info.eSpaceUID); writer.Write("espaceName:'{0}',", (perfTracerExists) ? perfTracer.ModuleName : info.eSpaceName); writer.Write("applicationKey:'{0}',", (perfTracerExists) ? perfTracer.ApplicationKey : info.ApplicationUID); writer.Write("applicationName:'{0}',", (perfTracerExists) ? perfTracer.ApplicationName : info.ApplicationName); writer.Write("tenantKey:'{0}',", (perfTracerExists) ? perfTracer.TenantKey : info.Tenant.Id_Guid); writer.Write("tenantName:'{0}',", (perfTracerExists) ? perfTracer.TenantName : info.Tenant.Name); writer.Write("environmentKey:'{0}',", (perfTracerExists) ? perfTracer.EnvironmentKey : info.EnvironmentKey); writer.Write("environmentName:'{0}',", (perfTracerExists) ? perfTracer.EnvironmentName : info.EnvironmentName); if (Settings.GetBool(Settings.Configs.JavascriptAPI_ShowHiddenFields)) { writer.Write("username:'******',", info.OsContext.Session.UserName); writer.Write("frontendName:'{0}',", (perfTracerExists) ? perfTracer.FrontEndName : info.FrontendName); } // #664816 - When the host serial on OSSYS_SERVER is different from the one in the windows registry the FrontendName will not be read from the DB. // We do a null check here to prevent this not vital information from stopping the application load. string value = null; if (perfTracerExists) { value = string.IsNullOrEmpty(perfTracer.FrontEndName) ? "" : SecureConfidentialInformationEncryption.EncryptWithAlgorithm(perfTracer.FrontEndName, SecureConfidentialInformationEncryption.FixedKeyAES128.Instance); } else { value = string.IsNullOrEmpty(info.FrontendName) ? "" : SecureConfidentialInformationEncryption.EncryptWithAlgorithm(info.FrontendName, SecureConfidentialInformationEncryption.FixedKeyAES128.Instance); } writer.Write("frontendKey:'{0}'", value); writer.Write("}"); writer.Write("})(this);"); writer.Write("</script>\n"); return(writer.ToString()); } }
public void Pack() { var configs = AppInfo.GetAppInfo().Configurations; foreach (var c in configs) { Pack(c.Name); } }
private void PrintSessionInit() { var appInfo = AppInfo.GetAppInfo(_context); var console = _context.Console; console.WriteLine($"{_appName} {appInfo.Version}"); console.WriteLine("Type 'help' to see interactive options"); console.WriteLine("Type '-h' or '--help' to options for commands"); console.WriteLine("Type 'exit', 'quit' or 'Ctrl+C' to exit."); }
public static string LogApplicationError(DateTime instant, Exception excep, HeContext context, string moduleName) { var message = excep.Message; if (excep is OSException) { message = ((OSException)excep).MessageForLogging(); } return(LogApplicationError(instant, message, excep, AppInfo.GetAppInfo(), context, moduleName, null, -1, -1)); }
public static void Script_DisableScriptInScreen(string scriptName) { AppInfo info = AppInfo.GetAppInfo(); if (info != null) { info.CheckPlatformExtensibilityAPIs(); info.OsContext.AddDisabledScript(scriptName ?? ""); } }
private void SetInternal(int?major, int?minor, int?build) { var appInfo = AppInfo.GetAppInfo(); var pathCommand = App.Commands.Get <PathCommand>(); AssemblyInfoUpdater.Update(pathCommand.TargetProjectAssemblyInfoPath, PathCommand.AssemblyVersionAttr, major.ToString(), minor.ToString(), "*", null); AssemblyInfoUpdater.Update(pathCommand.TargetProjectAssemblyInfoPath, PathCommand.AssemblyFileVersionAttr, major.ToString(), minor.ToString(), build.ToString(), ""); AssemblyInfoUpdater.Update(pathCommand.TargetProjectAssemblyInfoPath, PathCommand.AssemblyInformationalVersionAttr, major.ToString(), minor.ToString(), build.ToString(), ""); AppInfo.SaveAppInfo(appInfo); }
protected override void OnInit(EventArgs e) { HeContext heContext = AppInfo.GetAppInfo().OsContext; heContext.CurrentScreen = this; try { heContext.CurrentExecutionFileName = Path.GetFileName(Request.CurrentExecutionFilePath); } catch {} InitializeComponent(heContext); base.OnInit(e); }
public void Delete(string name) { var appInfo = AppInfo.GetAppInfo(); var exists = appInfo.GetConfiguration(name); if (exists != null) { appInfo.Configurations.Remove(exists); AppInfo.SaveAppInfo(appInfo); } }
public static SmsNode GetSmsEntry(HeContext heContext) { string largeaccount = heContext.MOMsg.LargeAccount; SmsNode wNode = null; foreach (ObjectKey nodeName in AppInfo.GetAppInfo().Tenant.GetPhoneNodes(largeaccount, Global.eSpaceId)) { return(null); } return(wNode); }
public string GetCallbackDebug() { if (Request.HttpMethod == "GET" && Request.QueryString["__CALLBACK_DEBUG"] != null && Request.QueryString["__CALLBACK_DEBUG"] != "") { if (Request.QueryString["__CALLBACK_DEBUG"] == RuntimePlatformSettings.Misc.CallbackDebugInformationKey.GetValue()) { return(AppInfo.GetAppInfo().GetCallbackDebugInformation()); } } return(""); }