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); } }
/// <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); }