public static void ChangeSiteProperty(HeContext heContext, ObjectKey propKey, string name, object val)
        {
            string propValue;

            string[] nameparts = name.Split('.');

            int tenantId = heContext.AppInfo.Tenant.Id;
            int eSpaceId;

            using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetRequestTransaction()) {
                if (nameparts.Length == 1 || nameparts[0] == heContext.AppInfo.eSpaceName)
                {
                    eSpaceId = heContext.AppInfo.eSpaceId;
                }
                else
                {
                    //it's a consumed one, use producer IDs
                    eSpaceId = DBRuntimePlatform.Instance.GetEspaceId(tran, nameparts[0]);
                }

                propValue = RuntimePlatformUtils.ConvertToString(val);

                // Get the site property id
                bool isShared;
                int  propId = DBRuntimePlatform.Instance.GetSitePropertyId(tran, propKey, eSpaceId, out isShared);

                if (propId == 0)
                {
                    throw (new ArgumentException("Could not find property '" + propKey + "' or non customizable entity."));
                }

                DBRuntimePlatform.Instance.UpdateSiteProperty(tran, propId, isShared, tenantId, propValue);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Sets the new Value of the site property and returns the correspondent Database Value string.
 /// </summary>
 /// <param name="newValue">New value for the property</param>
 /// <returns></returns>
 public string ChangeValue(object newValue)
 {
     databaseValue = RuntimePlatformUtils.ConvertToString(newValue);
     value         = newValue;
     if (owner != null)
     {
         owner.OnModified(this);
     }
     return(databaseValue);
 }
Esempio n. 3
0
        private TDeploymentControllerInterface InnerGetDeploymentControllerInterface <TDeploymentControllerInterface>(string uriToUse)
            where TDeploymentControllerInterface : class
        {
            string compilerPort = Settings.Get(Settings.Configs.CompilerService_Port);

            return(InnerGetDeploymentControllerInterface <TDeploymentControllerInterface>(
                       uriToUse,
                       Settings.Get(Settings.Configs.CompilerService_HostName),
                       compilerPort,
                       (RuntimePlatformUtils.IsJava() ? Settings.Get(Settings.Configs.RMI_RegistryPort) : compilerPort)
                       ));
        }
Esempio n. 4
0
        public override int ExecuteNonQueryGetIdentity(Command cmd, string idColumnName)
        {
            bool plSqlNeeded = RuntimePlatformUtils.IsJava();

            cmd.CommandText = ((plSqlNeeded ? "begin " : String.Empty) + cmd.CommandText + " RETURNING " + idColumnName.ToUpper() + " INTO @id"
                               + (plSqlNeeded ? " ;end;" : String.Empty));

            DataParameter IdParamenter = cmd.CreateOutputParameter("@id", DbType.Int32);

            cmd.ExecuteNonQuery();
            return(DataReaderUtils.SafeGet <int>(IdParamenter.Value));
        }
Esempio n. 5
0
 public static void PushProfilerMetricsToLogServer()
 {
     RuntimePlatformUtils.SetupCurrentThreadCulture();
     while (true)
     {
         try {
             ProfilerData oldProfilerData = profilerData;
             profilerData = new ProfilerData();
             ServerLog.PushProfilerMetricsToLogServer(oldProfilerData);
         } catch (System.Net.Sockets.SocketException) { }
         Thread.Sleep(Settings.GetInt(Settings.Configs.Profiler_PushMetricsToLogServerIntervalMs));
     }
 }
 public static string GetBookmarkableURL()
 {
     try {
         var page = AppInfo.GetAppInfo().OsContext.CurrentScreen as IBookmarkableURL;
         if (page != null)
         {
             var url = page.GetBookmarkableURL();
             if (url != null)
             {
                 return(RuntimePlatformUtils.CheckUriSecurity(HttpContext.Current.Request, url));
             }
         }
     } catch { }
     return(string.Empty);
 }
Esempio n. 7
0
        private static void InnerActivityOpen(HeContext heContext, int activityId, bool onlyGetUrl, out bool success, out string failureMessage, out string handlingUrl, Func <ActivityKind, bool> activityKindCheck, string actionName)
        {
            string SSKey;
            string url;
            int    tenantId;

            int          processId;
            ActivityKind activityKind;
            string       activityName;
            string       espaceSSKey;

            BPMRuntime.GetActivityDataForWS(activityId, out processId, out activityKind, out activityName, out SSKey, out url, out tenantId, out espaceSSKey);

            int userId = tenantId == heContext.Session.TenantId ? heContext.Session.UserId : 0;

            if (!activityKindCheck(activityKind))
            {
                throw new InvalidOperationException("Activity '" + activityName + "' (#" + activityId + ") cannot be opened.");
            }

            if (!onlyGetUrl)
            {
                if (userId == 0)
                {
                    throw new SecurityException(actionName + " requires a logged user");
                }

                using (Transaction tran = DatabaseAccess.ForRuntimeDatabase.GetReadOnlyTransaction()) {
                    int allowedActivity = BPMRuntime.GetAllowedActivities(heContext, tran, new int[] { activityId }, userId).FirstIfSingleOrDefault();
                    if (allowedActivity != activityId)
                    {
                        throw new SecurityException("The user in session does not have the correct permissions to open the activity or the activity is already open by another user.");
                    }
                }
            }

            using (ActivityHandler activityHandler = new ActivityHandler(url, tenantId, userId, heContext.AppInfo.eSpaceUID, espaceSSKey)) {
                //ToDo: activityHandler.Timeout = (int)(1.2 * TimeoutInSec) * 1000;
                success     = activityHandler.ExecuteOnOpen(SSKey, activityId, processId, tenantId, userId, BuiltInFunction.GetCurrentLocale(), heContext.Session.SessionID, heContext.Context.Request.IsSecureConnection, heContext.Context.Request.Url.Host, onlyGetUrl, out failureMessage, out handlingUrl);
                handlingUrl = BuiltInFunction.AddPersonalAreaToURLPath(handlingUrl);
            }
            handlingUrl = RuntimePlatformUtils.CheckUriSecurity(HttpContext.Current.Request, handlingUrl);
        }
Esempio n. 8
0
        public static void EspaceInvalidate(HeContext heContext, int espaceId, int tenantId)
        {
            try {
                RuntimeCache.Instance.Invalidate(new EspaceTenantInvalidationKey(espaceId, tenantId));

                if (heContext != null)
                {
                    AppInfo appInfo = heContext.AppInfo;
                    if (appInfo != null)
                    {
                        // #RRCT-2055 review this 'extraInfo' logic
                        string     extraInfo = "Invalidated by espace '" + appInfo.eSpaceName + "'";
                        GeneralLog log       = RuntimePlatformUtils.GenerateEspaceInvalidateMessage(heContext.SessionID, espaceId, tenantId, heContext.Session.UserId, appInfo.eSpaceId, appInfo.Tenant.Id, extraInfo);
                        log.Write();
                    }
                }
            } catch (Exception e) {
                Log.ErrorLog.LogApplicationError(e, heContext, "INVALIDATECACHE");
            }
        }
        public string MakeRelative(HttpRequest request)
        {
            Uri    u = null;
            string s = request.RawUrl;

            try {
                u = new Uri(s);
            } catch (UriFormatException) {
                if ((s.StartsWith("/")) || (s.StartsWith("\\")))
                {
                    s = (RuntimePlatformUtils.RequestIsHttps(request) ? "https" : "http") + "://localhost" + s;
                }
                else
                {
                    s = (RuntimePlatformUtils.RequestIsHttps(request) ? "https" : "http") + "://localhost/" + s;
                }
                u = new Uri(s);
            }
            return(MakeRelative(u));
        }
Esempio n. 10
0
        public static TObject GetObjectForRemoting <TObject>(string host, string portAndPath)
        {
            string uri = "tcp://" + RuntimePlatformUtils.FixHostIPForIPV6(host) + ":" + portAndPath;

            return((TObject)Activator.GetObject(typeof(TObject), uri));
        }
Esempio n. 11
0
        public static string GetPageName(HeContext heContext, int eSpaceId, string page, IList <Pair <string, string> > parameters, bool useParamsOnlyIfNeededForRule)
        {
            string pageTransform = null;
            IList <Pair <string, string> > leftoverParams = parameters;
            List <string> rules = RuntimePlatformUtils.GetPageRules(eSpaceId, page, heContext);

            if (rules != null)
            {
                foreach (string transform in rules)
                {
                    pageTransform  = transform.Substring(1);
                    leftoverParams = new List <Pair <string, string> >();
                    foreach (Pair <string, string> parm in parameters)
                    {
                        string markedParam = "{" + parm.First + "}";
                        int    paramPos    = pageTransform.IndexOf(markedParam);

                        if (paramPos == -1)
                        {
                            leftoverParams.Add(parm);
                        }
                        else
                        {
                            // It shouldn't be possible to get here with parm.Second == null (these should always be leftoverParms)
                            //  but just to be on the safe side...
                            pageTransform = pageTransform.Replace(markedParam, parm.Second != null ? parm.Second : "");
                        }
                    }

                    if (pageTransform.IndexOf('{') == -1)
                    {
                        break;
                    }
                    else
                    {
                        pageTransform = null;
                    }
                }
            }

            if (pageTransform == null)
            {
                pageTransform  = page + RuntimePlatformUtils.WebPageExtension;
                leftoverParams = parameters;
            }

            if (leftoverParams.Count > 0 && !useParamsOnlyIfNeededForRule)
            {
                pageTransform += "?";

                foreach (Pair <string, string> parm in leftoverParams)
                {
                    if (!string.IsNullOrEmpty(parm.First))
                    {
                        pageTransform += parm.First + "=" + (parm.Second ?? string.Empty) + "&";
                    }
                }

                pageTransform = pageTransform.TrimEnd('&', '?');
            }

            return(pageTransform);
        }
Esempio n. 12
0
 public SiteProperty(int defId, string name, ObjectKey key, bool isShared, string databaseValue, string rttype)
     : this(defId, name, key, isShared, databaseValue, RuntimePlatformUtils.ConvertFromString(databaseValue, rttype), DatabaseTypeToSitePropertyType(rttype))
 {
 }
        public void Parse(Uri uri)
        {
            _protocol = uri.Scheme;
            if (uri.Scheme == "http" && RuntimePlatformUtils.RequestIsHttps(HttpContext.Current.Request))
            {
                _protocol = "https";
            }
            _server      = uri.Host;
            _session     = "";
            _sessionless = true;
            _multitenant = false;
            _tenant      = "";
            _path        = "";
            _file        = "";
            if (!uri.IsDefaultPort)
            {
                _server += ":" + uri.Port.ToString();
            }
            int index = 1;

            _espace = CleanLastSlash(uri.Segments[index++]);
            if (uri.Segments.Length > 2)
            {
                if (uri.Segments[index].StartsWith(RuntimePlatformUtils.SessionPrefix))                    // #49674
                {
                    _session     = CleanLastSlash(uri.Segments[index++]);
                    _sessionless = false;
                }
                if (uri.Segments[index].IndexOf(".") < 0)
                {
                    _tenant = CleanLastSlash(uri.Segments[index++]);
                    if (_tenant == "img")
                    {
                        _path   = _tenant + "/";
                        _tenant = "";
                    }
                    else
                    {
                        _multitenant = true;
                    }
                }
                while ((index < uri.Segments.Length) && (uri.Segments[index].IndexOf(".") < 0))
                {
                    _path += uri.Segments[index++];
                }
                _path = CleanLastSlash(_path);

                if (index < uri.Segments.Length)
                {
                    _file = CleanLastSlash(uri.Segments[index++]);
                }
            }

            // Check that the img we earlier assumed to be from an image request lives
            // up to the hype.
            if (_path.StartsWith("img"))
            {
                // If a file wasn't request the "img" part this is a tenant default request
                // and not an image request.
                bool bImageReq = true;

                if (_file == String.Empty)
                {
                    bImageReq = false;
                }
                else
                {
                    int    pos = _file.LastIndexOf(".");
                    string ext = _file.Substring(pos, _file.Length - pos);
                    switch (ext.ToLower())
                    {
                    case ".gif":
                    case ".jpg":
                    case ".jpeg":
                    case ".png":
                    case ".bmp":
                    case ".wbmp": {
                        break;
                    }

                    default: {
                        bImageReq = false;
                        break;
                    }
                    }
                }

                if (!bImageReq)
                {
                    _tenant      = "img";
                    _multitenant = true;
                    _path        = _path.Substring(3, _path.Length - 3);
                    if (_path.StartsWith("/"))
                    {
                        _path = _path.Substring(1, _path.Length - 1);
                    }
                }
            }
            _query = uri.Query;
        }
 public static void LogSlowExtensionCall(DateTime startTime, string description)
 {
     RuntimePlatformUtils.LogSlowExtensionCall(startTime, description);
 }
 public void RegisterViewStateSize()
 {
     this.ViewStateSize = RuntimePlatformUtils.GetViewstateSize();
 }
 public void RegisterSessionSize()
 {
     this.SessionSize = RuntimePlatformUtils.GetRetrievedSessionSize();
 }