public static void SetAttribute(DersaSqlManager DM, AttributeOwnerType ownerType, string entityId, string paramName, string paramValue, int attrType) { string userName = HttpContext.Current.User.Identity.Name; Util.SetAttributeValue(DM, userName, ownerType, entityId, paramName, attrType, paramValue); //DM.ExecuteSPWithParams(procName, new object[] { entityId, paramName, paramValue, userName, Util.GetPassword(userName) }); }
public static string SetAttributeValue(DersaSqlManager DM, string userName, AttributeOwnerType ownerType, string entityId, string attrName, int attrType, string attrValue) { string procName = ""; switch (ownerType) { case AttributeOwnerType.Entity: procName = "ENTITY$SetAttribute"; break; case AttributeOwnerType.Relation: procName = "RELATION$SetAttribute"; break; } IParameterCollection Params = new ParameterCollection(); Params.Add("@entity", entityId); Params.Add("@attr_name", attrName); Params.Add("@attr_value", attrValue); Params.Add("@login", userName); Params.Add("@password", Util.GetPassword(userName)); Params.Add("@attr_type", attrType); int res = DM.ExecuteSPWithResult(procName, false, Params); if (res == 5) { Params["@attr_type"].Value = 5; Params["@attr_value"].Value = Cryptor.Encrypt(attrValue, userName); res = DM.ExecuteSPWithResult(procName, false, Params); } return(""); }
public string SetProperties(string json_params) { Dersa.Common.CachedObjects.ClearCache(); IParameterCollection Params = Util.DeserializeParams(json_params); string key = "-1"; //string procName = ""; AttributeOwnerType ownerType = AttributeOwnerType.Entity; if (Params.Contains("entity")) { key = Params["entity"].Value.ToString(); //procName = "ENTITY$SetAttribute"; ownerType = AttributeOwnerType.Entity; Params.Remove("entity"); if (Params.Count < 1) { return("no data"); } } if (Params.Contains("relation")) { key = Params["relation"].Value.ToString(); //procName = "RELATION$SetAttribute"; ownerType = AttributeOwnerType.Relation; Params.Remove("relation"); if (Params.Count < 1) { return("no data"); } } DersaSqlManager DM = new DersaSqlManager(); foreach (IParameter Param in Params) { try { if (Param.Value != null) { string strVal = Param.Value.ToString().Replace("$lt$", "<").Replace("$gt$", ">"); Param.Value = strVal; } SetAttribute(DM, ownerType, key, Param.Name, Param.Value?.ToString(), 0); } catch { throw; } } return(""); }