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(""); }
public IParameterCollection GetViewParams(string cshtmlId) { string json_params = GetString(cshtmlId, false); IParameterCollection Params = Util.DeserializeParams(json_params); if (Params.Contains("cshtml")) { string view_name = GetViewName(Params["cshtml"].Value.ToString()); Params.Remove("cshtml"); Params.Add("view_name", view_name); } return(Params); }
/// <summary> /// Remove the authorization HTTP header if it's not equal to the old one. /// </summary> /// <param name="parameters">List of HTTP headers</param> /// <param name="header">The type of the HTTP header that stores the authorization information</param> /// <param name="authValue">The authorization header value</param> /// <returns>true = header removed, false = same header already exists, null = header not found</returns> public static bool?RemoveAuthorizationHeader([NotNull, ItemNotNull] IParameterCollection parameters, AuthHeader header, [NotNull] string authValue) { var authParam = parameters.Find(ParameterType.HttpHeader, header.ToAuthorizationHeaderName()).FirstOrDefault(); if (authParam == null) { return(null); } var v = (string)authParam.Value; if (v != null && v == authValue) { return(false); } parameters.Remove(authParam); return(true); }
public ActionResult Report(string proc_name, string parameters) { DersaSqlManager M = new DersaSqlManager(); IParameterCollection Params = Util.DeserializeParams(parameters); if (Params.Contains("proc_name") || !string.IsNullOrEmpty(proc_name)) { if (Params.Contains("proc_name")) { proc_name = Params["proc_name"].Value.ToString(); Params.Remove("proc_name"); } System.Data.DataTable T = M.ExecuteSPWithParams(proc_name, Params); return(View(T)); } else { throw new System.Exception("procedure for report is not defined!"); } }
public void DownloadReport(int id, string parameters) { DersaSqlManager M = new DersaAnonimousSqlManager(); IParameterCollection Params = Util.DeserializeParams(parameters); if (Params.Contains("proc_name")) { StreamWriter SW = null; string proc_name = Params["proc_name"].Value.ToString(); Params.Remove("proc_name"); try { Response.ContentType = "application/force-download; charset =windows-1251"; string Header = "Filename=" + "report_" + id.ToString() + ".csv"; //Attachment; Response.AppendHeader("Content-Disposition", Header); //MemoryStream S = new MemoryStream(); //SW = new StreamWriter(S); SW = new StreamWriter(Response.OutputStream, System.Text.Encoding.Default); M.ExecSqlToStream(proc_name, SW, Params); SW.Close(); //string result = System.Text.Encoding.UTF8.GetString(S.ToArray()); //byte[] btres = System.Text.Encoding.Default.GetBytes(result); //Response.AppendHeader("Content-Length", btres.Length.ToString()); //Response.OutputStream.Write(btres, 0, btres.Length); Response.End(); } catch (Exception exc) { Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.ContentType = "TEXT/HTML"; Response.ClearHeaders(); Response.Write(exc.Message); } } else { throw new System.Exception("procedure for report is not defined!"); } }