public JsonResult data(FormCollection form, string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName = "[VWGraphListView]";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            tohide.Add("queryGraphID");
            table.hideColumns = tohide.ToArray();

            table.PrimaryKey      = "id";
            table.SearchCondition = " id like '%{0}%' OR query like '%{0}%' OR name like '%{0}%' OR title like '%{0}%' ";
            table.VarName         = "csGraphs";
            table.ReferenceText   = "BaseGraphs";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseGraphs", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseGraphs", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form, string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseController]";
            table.PrimaryKey = "id";
            table.ReplacedText.Add("id", "Id");
            table.ReplacedText.Add("name", "Name");
            table.ReplacedText.Add("fullName", "Full Name");
            table.ReplacedText.Add("infoName", "Info Name");
            table.ReplacedText.Add("Discriminator", "Discriminator");
            table.SearchCondition = " id like '%{0}%' OR name like '%{0}%' OR fullName like '%{0}%' OR infoName like '%{0}%' OR Discriminator like '%{0}%' ";
            table.VarName         = "csBaseController";
            table.ReferenceText   = "seController";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.link, Href = URLHelper.getUrl("BaseController", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseController", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseDiagnostic]";
            table.PrimaryKey = "TableOrColumn";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("TableOrColumn", ("Table Or Column"));
            table.ReplacedText.Add("Input", ("Input"));
            table.ReplacedText.Add("endWithS", ("End With S"));
            table.ReplacedText.Add("isKeyWord", ("Is Key Word"));
            table.ReplacedText.Add("hasUnderScore", ("Has Under Score"));
            table.ReplacedText.Add("correctNameRelation", ("Correct Name Relation"));
            table.ReplacedText.Add("noHasPrimaryKey", ("No Has Primary Key"));
            table.ReplacedText.Add("hasActiveField", ("Has Active Field"));
            table.SearchCondition = " TableOrColumn like '%{0}%'  OR  Input like '%{0}%'  OR  endWithS like '%{0}%'  OR  isKeyWord like '%{0}%'  OR  hasUnderScore like '%{0}%'  OR  correctNameRelation like '%{0}%'  OR  noHasPrimaryKey like '%{0}%'  OR  hasActiveField like '%{0}%' ";
            table.VarName         = "csBaseDiagnostic";
            table.ReferenceText   = "BaseDiagnostic";
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
            }
            wb.Worksheets.Add(table.Data, "Diagnostic");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Diagnostic BUZZSPY {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[RDClient]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("active", ("Active"));
            table.ReplacedText.Add("creationDate", ("Creation Date"));
            table.ReplacedText.Add("email", ("Email"));
            table.ReplacedText.Add("name", ("Name"));
            table.ReplacedText.Add("lastName", ("Last Name"));
            table.ReplacedText.Add("birthDate", ("Birth Date"));
            table.ReplacedText.Add("location", ("Location"));
            table.ReplacedText.Add("device", ("Device"));
            table.SearchCondition = " id like '%{0}%'  OR  active like '%{0}%'  OR  creationDate like '%{0}%'  OR  email like '%{0}%'  OR  name like '%{0}%'  OR  lastName like '%{0}%'  OR  birthDate like '%{0}%'  OR  location like '%{0}%'  OR  device like '%{0}%' ";
            table.VarName         = "csRDClient" + from.Split(':')[0];
            table.ReferenceText   = "Client";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("RDClient"), Href = URLHelper.getActionUrlRelation("RDClient", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.functionButton, Href = URLHelper.getActionUrl("RDClient", "ToggleActive"), Title = "Active/Inactive", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_asterisk
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("RDClient", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["active"] != null)
                {
                    item["active"] = (item["active"].ToString() == "1" || item["active"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseAudit]";
            table.PrimaryKey = "Execute at";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("Execute at", ("Execute at"));
            table.ReplacedText.Add("Entity", ("Entity"));
            table.ReplacedText.Add("RecordID", ("Record"));
            table.ReplacedText.Add("User", ("User"));
            table.ReplacedText.Add("Action", ("Action"));
            table.SearchCondition = " Execute at like '%{0}%'  OR  Entity like '%{0}%'  OR  RecordID like '%{0}%'  OR  User like '%{0}%'  OR  Action like '%{0}%' ";
            table.VarName         = "csBaseAudit";
            table.ReferenceText   = "BaseAudit";
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
            }
            wb.Worksheets.Add(table.Data, "Audit");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Audit BUZZSPY {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseEmail]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("code", ("Code"));
            table.ReplacedText.Add("subject", ("Subject"));
            table.ReplacedText.Add("bodyHTML", ("Body HTML"));
            table.ReplacedText.Add("isHtml", ("Is Html"));
            table.SearchCondition = " id like '%{0}%'  OR  code like '%{0}%'  OR  subject like '%{0}%'  OR  bodyHTML like '%{0}%'  OR  isHtml like '%{0}%' ";
            table.VarName         = "csBaseEmail" + from.Split(':')[0];
            table.ReferenceText   = "seEmail";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("BaseEmail"), Href = URLHelper.getActionUrlRelation("BaseEmail", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseEmail", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["isHtml"] != null)
                {
                    item["isHtml"] = (item["isHtml"].ToString() == "1" || item["isHtml"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #7
0
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseViewRelation]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("tableFrom", ("Table From"));
            table.ReplacedText.Add("fkColumn", ("Fk Column"));
            table.ReplacedText.Add("pkColumn", ("Pk Column"));
            table.ReplacedText.Add("pkColumnName", ("Pk Column Name"));
            table.ReplacedText.Add("tableTo", ("Table To"));
            table.SearchCondition = " id like '%{0}%'  OR  tableFrom like '%{0}%'  OR  fkColumn like '%{0}%'  OR  pkColumn like '%{0}%'  OR  pkColumnName like '%{0}%'  OR  tableTo like '%{0}%' ";
            table.VarName         = "csBaseViewRelation";
            table.ReferenceText   = "seViewRelation";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("BaseViewRelation"), Href = URLHelper.getActionUrlRelation("BaseViewRelation", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseViewRelation", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseAudit]";
            table.PrimaryKey = "Execute at";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("Execute at", ("Execute at"));
            table.ReplacedText.Add("Entity", ("Entity"));
            table.ReplacedText.Add("RecordID", ("Record"));
            table.ReplacedText.Add("User", ("User"));
            table.ReplacedText.Add("Action", ("Action"));
            table.SearchCondition = " Execute at like '%{0}%'  OR  Entity like '%{0}%'  OR  RecordID like '%{0}%'  OR  User like '%{0}%'  OR  Action like '%{0}%' ";
            table.VarName         = "csBaseAudit" + from.Split(':')[0];
            table.ReferenceText   = "BaseAudit";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("BSExample"), Href = URLHelper.getActionUrlRelation("BSExample", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["RecordID"] != null)
                {
                    item["RecordID"] = $"<button data-loading-text=\"<i class='fa fa-refresh fa-spin'></i>\" title=\"{item["RecordID"]}\" class=\"btn btn-warning btn-circle refreshTable baseDynamicModal\" data-action=\"{URLHelper.getActionUrl(item["Entity"].ToString(), "Form") + "/" + item["RecordID"]}\">{item["RecordID"]}</button>";
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form, int controllerIDT = 0)
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseAction]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            tohide.Add("controllerID");
            table.hideColumns = tohide.ToArray();
            if (controllerIDT != 0)
            {
                table.AdditionalWhere = " controllerID=" + controllerIDT;
            }
            table.ReplacedText.Add("id", "Id");
            table.ReplacedText.Add("controllerID", "Controller I D");
            table.ReplacedText.Add("name", "Name");
            table.ReplacedText.Add("displayName", "Display Name");
            table.ReplacedText.Add("isSystem", "Is System");
            table.SearchCondition = " id like '%{0}%' OR controllerID like '%{0}%' OR name like '%{0}%' OR displayName like '%{0}%' OR isSystem like '%{0}%' OR";
            table.VarName         = "csBaseAction";
            table.ReferenceText   = "seAction";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseAction", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseAction", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable();
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["isSystem"] != null)
                {
                    item["isSystem"] = (item["isSystem"].ToString() == "1" || item["isSystem"].ToString() == "True") ? "Yes" : "No";
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form)
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName         = "[VWUserStatu]";
            table.PrimaryKey        = "ID";
            table.ReplaceUnderScore = true;
            table.SearchCondition   = " (Nombre like '%{0}%' OR Celular like '%{0}%' OR [Primer Apellido] like '%{0}%' OR [Segundo Apellido] like '%{0}%' OR [Tipo Documento] like '%{0}%' OR Identificacion like '%{0}%' OR Teléfono like '%{0}%' OR [Correo Electrónico] like '%{0}%' OR Estado like '%{0}%' OR [Última IP] like '%{0}%') AND";
            table.VarName           = "csVWUserStatu";
            table.ReferenceText     = "VWUserStatu";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseUserStatus", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            //table.Links.Add(new CsTableLink() { ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseUserStatus", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o });
            table.buildDataTableUser();
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form, string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseMessage]";
            table.PrimaryKey = "id";
            table.ReplacedText.Add("id", "Id");
            table.ReplacedText.Add("code", "Code");
            table.ReplacedText.Add("message", "Message");
            table.ReplacedText.Add("messageCategory", "Message Category");
            table.SearchCondition = " id like '%{0}%' OR code like '%{0}%' OR message like '%{0}%' OR messageCategory like '%{0}%' ";
            table.VarName         = "csBaseMessage";
            table.ReferenceText   = "Message";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseMessage", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseMessage", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["messageCategory"] != null)
                {
                    if (item["messageCategory"].ToString() != "")
                    {
                        int messageCategory = int.Parse(item["messageCategory"].ToString());
                        item["messageCategory"] = db.BaseMessageCategories.FirstOrDefault(d => d.id == messageCategory).name;
                    }
                    else
                    {
                        item["messageCategory"] = "N/A";
                    }
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #12
0
        public JsonResult data(FormCollection form, string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName       = "[VWUser]";
            table.PrimaryKey      = "id";
            table.SearchCondition = " ID like '%{0}%' OR fullName like '%{0}%' OR Type like '%{0}%' OR Location like '%{0}%' OR Roles like '%{0}%'";
            table.VarName         = "csSMEmployeesReport";
            table.ReferenceText   = "User";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseUsers", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseUsers", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #13
0
        public JsonResult data(FormCollection form)
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName       = "[BaseWidget]";
            table.PrimaryKey      = "id";
            table.SearchCondition = " id like '%{0}%' OR name like '%{0}%' OR description like '%{0}%' OR actionID like '%{0}%' OR width like '%{0}%' OR actionContent like '%{0}%' OR html like '%{0}%' OR";
            table.VarName         = "csBaseWidget";
            table.ReferenceText   = "BaseWidget";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseWidget", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseWidget", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable();
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #14
0
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseDiagnostic]";
            table.PrimaryKey = "TableOrColumn";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("TableOrColumn", ("Table Or Column"));
            table.ReplacedText.Add("Input", ("Input"));
            table.ReplacedText.Add("endWithS", ("End With S"));
            table.ReplacedText.Add("isKeyWord", ("Is Key Word"));
            table.ReplacedText.Add("hasUnderScore", ("Has Under Score"));
            table.ReplacedText.Add("correctNameRelation", ("Correct Name Relation"));
            table.ReplacedText.Add("noHasPrimaryKey", ("No Has Primary Key"));
            table.ReplacedText.Add("hasActiveField", ("Has Active Field"));
            table.SearchCondition = " TableOrColumn like '%{0}%'  OR  Input like '%{0}%'  OR  endWithS like '%{0}%'  OR  isKeyWord like '%{0}%'  OR  hasUnderScore like '%{0}%'  OR  correctNameRelation like '%{0}%'  OR  noHasPrimaryKey like '%{0}%'  OR  hasActiveField like '%{0}%' ";
            table.VarName         = "csBaseDiagnostic" + from.Split(':')[0];
            table.ReferenceText   = "BaseDiagnostic";
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
            }
            table.buildDefaultJson();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #15
0
        public JsonResult data(FormCollection form, string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName       = "[VWBaseProfile]";
            table.PrimaryKey      = "id";
            table.SearchCondition = " id like '%{0}%' OR name like '%{0}%' OR description like '%{0}%' OR displayName like '%{0}%' ";
            table.VarName         = "csBaseProfile";
            table.ReferenceText   = "Profile";
            table.ReplacedText.Add("displayName", ("Default Page"));
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.link, Href = URLHelper.getActionUrlWithBaseHome("BasePermissions", "Index2"), Title = "Configuration", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseProfiles", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form)
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName       = "[VWBaseDynamicList]";
            table.AdditionalWhere = "enableControl = 1 AND ID != 0";
            table.PrimaryKey      = "id";
            table.SearchCondition = " id like '%{0}%' OR name like '%{0}%' OR";
            table.VarName         = "csBaseDynamicList";
            table.ReferenceText   = "Control";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseColumns", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                FullText = "¿Desea Delete este control?", ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseColumns", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable();
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseWebSocketChannelBlackListProfiles]";
            table.PrimaryKey = "Id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("ProfileId", ("Profile Id"));
            table.ReplacedText.Add("WebSocketChannelId", ("Web Socket Channel Id"));
            table.SearchCondition = " Id like '%{0}%'  OR  (select top 1 name from [BaseProfile] where id=ProfileId) like '%{0}%'  OR  (select top 1 Name from [BaseWebSocketChannels] where id=WebSocketChannelId) like '%{0}%' ";
            table.VarName         = "csBaseWebSocketChannelBlackListProfiles" + from.Split(':')[0];
            table.ReferenceText   = "WebSocketChannelBlackListProfiles";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("BaseWebSocketChannelBlackListProfiles"), Href = URLHelper.getActionUrlRelation("BaseWebSocketChannelBlackListProfiles", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseWebSocketChannelBlackListProfiles", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["ProfileId"] != null)
                {
                    if (item["ProfileId"].ToString() != "")
                    {
                        int ProfileId = int.Parse(item["ProfileId"].ToString());
                        item["ProfileId"] = db.BaseProfiles.FirstOrDefault(d => d.id == ProfileId).name;
                    }
                    else
                    {
                        item["ProfileId"] = "Not Set";
                    }
                }
                if (item["WebSocketChannelId"] != null)
                {
                    if (item["WebSocketChannelId"].ToString() != "")
                    {
                        int WebSocketChannelId = int.Parse(item["WebSocketChannelId"].ToString());
                        item["WebSocketChannelId"] = db.BaseWebSocketChannels.FirstOrDefault(d => d.Id == WebSocketChannelId).Name;
                    }
                    else
                    {
                        item["WebSocketChannelId"] = "Not Set";
                    }
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #18
0
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseLog]";
            table.PrimaryKey = "created";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("created", ("Created"));
            table.ReplacedText.Add("basedynamicList_entity", ("Basedynamic List_entity"));
            table.ReplacedText.Add("entityId", ("Entity Id"));
            table.ReplacedText.Add("entityIdU", ("Entity Id U"));
            table.ReplacedText.Add("entityIdS", ("Entity Id S"));
            table.ReplacedText.Add("date", ("Date"));
            table.ReplacedText.Add("baseUser_user", ("Base User_user"));
            table.ReplacedText.Add("baseLogAction_action", ("Base Log Action_action"));
            table.ReplacedText.Add("version", ("Version"));
            table.SearchCondition = " created like '%{0}%'  OR  (select top 1 name from [BaseDynamicList] where id=basedynamicList_entity) like '%{0}%'  OR  entityId like '%{0}%'  OR  entityIdU like '%{0}%'  OR  entityIdS like '%{0}%'  OR  date like '%{0}%'  OR  (select top 1 username from [BaseUser] where ID=baseUser_user) like '%{0}%'  OR  (select top 1 name from [BaseLogAction] where id=baseLogAction_action) like '%{0}%'  OR  version like '%{0}%' ";
            table.VarName         = "csBaseLog";
            table.ReferenceText   = "BaseLog";
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["basedynamicList_entity"] != null)
                {
                    if (item["basedynamicList_entity"].ToString() != "")
                    {
                        int basedynamicList_entity = int.Parse(item["basedynamicList_entity"].ToString());
                        item["basedynamicList_entity"] = db.BaseDynamicLists.FirstOrDefault(d => d.id == basedynamicList_entity).name;
                    }
                    else
                    {
                        item["basedynamicList_entity"] = "Not Set";
                    }
                }
                if (item["baseUser_user"] != null)
                {
                    if (item["baseUser_user"].ToString() != "")
                    {
                        int baseUser_user = int.Parse(item["baseUser_user"].ToString());
                        item["baseUser_user"] = db.BaseUsers.FirstOrDefault(d => d.ID == baseUser_user).username;
                    }
                    else
                    {
                        item["baseUser_user"] = "******";
                    }
                }
                if (item["baseLogAction_action"] != null)
                {
                    if (item["baseLogAction_action"].ToString() != "")
                    {
                        int baseLogAction_action = int.Parse(item["baseLogAction_action"].ToString());
                        item["baseLogAction_action"] = db.BaseLogActions.FirstOrDefault(d => d.id == baseLogAction_action).name;
                    }
                    else
                    {
                        item["baseLogAction_action"] = "Not Set";
                    }
                }
            }
            wb.Worksheets.Add(table.Data, "Log");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Log BUZZSPY {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseWebSocketChannelBlackListProfiles]";
            table.PrimaryKey = "Id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("ProfileId", ("Profile Id"));
            table.ReplacedText.Add("WebSocketChannelId", ("Web Socket Channel Id"));
            table.SearchCondition = " Id like '%{0}%'  OR  (select top 1 name from [BaseProfile] where id=ProfileId) like '%{0}%'  OR  (select top 1 Name from [BaseWebSocketChannels] where id=WebSocketChannelId) like '%{0}%' ";
            table.VarName         = "csBaseWebSocketChannelBlackListProfiles";
            table.ReferenceText   = "WebSocketChannelBlackListProfiles";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseWebSocketChannelBlackListProfiles", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseWebSocketChannelBlackListProfiles", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["UserId"] != null)
                {
                    if (item["UserId"].ToString() != "")
                    {
                        int UserId = int.Parse(item["UserId"].ToString());
                        item["UserId"] = db.BaseUsers.FirstOrDefault(d => d.ID == UserId).username;
                    }
                    else
                    {
                        item["UserId"] = "Not Set";
                    }
                }
                if (item["WebSocketChannelId"] != null)
                {
                    if (item["WebSocketChannelId"].ToString() != "")
                    {
                        int WebSocketChannelId = int.Parse(item["WebSocketChannelId"].ToString());
                        item["WebSocketChannelId"] = db.BaseWebSocketChannels.FirstOrDefault(d => d.Id == WebSocketChannelId).Name;
                    }
                    else
                    {
                        item["WebSocketChannelId"] = "Not Set";
                    }
                }
            }
            wb.Worksheets.Add(table.Data, "Web Socket Channel Black List Profiles");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Web Socket Channel Black List Profiles SMSChat {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
Example #20
0
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            form.Remove("limit");
            form.Remove("offset");
            table.TableName  = "[BaseViewRelation]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("tableFrom", ("Table From"));
            table.ReplacedText.Add("fkColumn", ("Fk Column"));
            table.ReplacedText.Add("pkColumn", ("Pk Column"));
            table.ReplacedText.Add("pkColumnName", ("Pk Column Name"));
            table.ReplacedText.Add("tableTo", ("Table To"));
            table.SearchCondition = " id like '%{0}%'  OR  tableFrom like '%{0}%'  OR  fkColumn like '%{0}%'  OR  pkColumn like '%{0}%'  OR  pkColumnName like '%{0}%'  OR  tableTo like '%{0}%' ";
            table.VarName         = "csBaseViewRelation";
            table.ReferenceText   = "seViewRelation";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseViewRelation", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseViewRelation", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
            }
            wb.Worksheets.Add(table.Data, "View Relation");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("View Relation Viya Spark {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
Example #21
0
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[VWBaseLog]";
            table.PrimaryKey = "Execute at";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("created", ("Created"));
            table.ReplacedText.Add("basedynamicList_entity", ("Entity"));
            table.ReplacedText.Add("entityId", ("Entity Id"));
            table.ReplacedText.Add("entityIdU", ("Entity Id U"));
            table.ReplacedText.Add("entityIdS", ("Entity Id S"));
            table.ReplacedText.Add("date", ("Date"));
            table.ReplacedText.Add("baseUser_user", ("User"));
            table.ReplacedText.Add("baseLogAction_action", ("Action"));
            table.ReplacedText.Add("version", ("Version"));
            table.SearchCondition = " [Execute at] like '%{0}%'  OR  (select top 1 name from [BaseDynamicList] where id=basedynamicList_entity) like '%{0}%'  OR  entityId like '%{0}%'  OR  entityIdU like '%{0}%'  OR  entityIdS like '%{0}%'  OR  date like '%{0}%'  OR  (select top 1 username from [BaseUser] where ID=baseUser_user) like '%{0}%'  OR  (select top 1 name from [BaseLogAction] where id=baseLogAction_action) like '%{0}%'  OR  version like '%{0}%' ";
            table.VarName         = "csBaseLog" + from.Split(':')[0];
            table.ReferenceText   = "BaseLog";
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["basedynamicList_entity"] != null)
                {
                    if (item["basedynamicList_entity"].ToString() != "")
                    {
                        int basedynamicList_entity = int.Parse(item["basedynamicList_entity"].ToString());
                        item["basedynamicList_entity"] = db.BaseDynamicLists.FirstOrDefault(d => d.id == basedynamicList_entity).name;
                    }
                    else
                    {
                        item["basedynamicList_entity"] = "Not Set";
                    }
                }
                if (item["baseUser_user"] != null)
                {
                    if (item["baseUser_user"].ToString() != "")
                    {
                        int baseUser_user = int.Parse(item["baseUser_user"].ToString());
                        item["baseUser_user"] = db.BaseUsers.FirstOrDefault(d => d.ID == baseUser_user).username;
                    }
                    else
                    {
                        item["baseUser_user"] = "******";
                    }
                }
                if (item["baseLogAction_action"] != null)
                {
                    if (item["baseLogAction_action"].ToString() != "")
                    {
                        int baseLogAction_action = int.Parse(item["baseLogAction_action"].ToString());
                        item["baseLogAction_action"] = db.BaseLogActions.FirstOrDefault(d => d.id == baseLogAction_action).name;
                    }
                    else
                    {
                        item["baseLogAction_action"] = "Not Set";
                    }
                }
            }
            table.buildDefaultJson();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #22
0
        public JsonResult previewData(FormCollection form, string query, string namequery)
        {
            //var re = db.Reports.Find(queryid);
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);
            JsonCsTable       json  = new JsonCsTable();

            if (!string.IsNullOrEmpty(query))
            {
                table.TableName     = "[Report]";
                table.VarName       = "csReport";
                table.ReferenceText = "Report";
                table.Links.Add(new CsTableLink()
                {
                    ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("Report", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
                });

                string searchCondition   = "";
                string primaryKey        = "";
                string tablename         = "";
                string tablenameOriginal = "";
                string where = "";
                string    consulta         = "";
                string    consultaOriginal = "";
                string    consultaColumns  = "";
                DataTable data             = new DataTable();

                string[] filterAllowed = { };

                consulta          = createView(query, namequery);
                consultaOriginal  = "SELECT * FROM " + consulta;
                tablename         = consulta;
                tablenameOriginal = tablename;
                DataTable cols = Helper.getData("SELECT * FROM " + consulta, db);

                foreach (DataColumn item in cols.Columns)
                {
                    primaryKey = item.ColumnName;
                    break;
                }

                foreach (DataColumn item in cols.Columns)
                {
                    searchCondition += " " + item.ColumnName + " like '%{0}%' OR";
                    consultaColumns += "[" + item.ColumnName + "],";
                }
                consultaColumns += (consultaColumns != "") ? "*" : "";
                consultaColumns  = consultaColumns.Replace(",*", "");

                int current = 0;
                if (form["offset"] != null)
                {
                    current = int.Parse(form["offset"]);
                }
                int limit = 0;
                if (form["limit"] != null)
                {
                    limit = int.Parse(form["limit"]);
                }
                string order  = form["order"];
                string search = form["cstable_search"];

                string conditions = "", orders = "";
                if (!string.IsNullOrEmpty(search) && !string.IsNullOrEmpty(searchCondition))
                {
                    conditions = string.Format("Where " + searchCondition, search);
                }
                if (!string.IsNullOrEmpty(order))
                {
                    orders = string.Format("{0}", order);
                }
                else
                {
                    orders = string.Format("{0} ASC", primaryKey);
                }


                DataTable columns = Helper.getData(string.Format("select * from VWBaseNiiAll where tableName='{0}' and type!='sysname' order by column_id", tablename.Replace("[", "").Replace("]", "")), db);
                foreach (DataRow item in columns.Rows)
                {
                    Admin.Controllers.BaseDeveloperController.dbProperties properties = new
                                                                                        Admin.Controllers.BaseDeveloperController.dbProperties(item);

                    if (form.AllKeys.Contains(properties.Name) || form.AllKeys.Contains("filter_" + properties.Name))
                    {
                        string finalKey = "";
                        if (!string.IsNullOrEmpty(form[properties.Name]))
                        {
                            finalKey = properties.Name;
                        }
                        else if (!string.IsNullOrEmpty(form["filter_" + properties.Name]))
                        {
                            finalKey = "filter_" + properties.Name;
                        }

                        if (!string.IsNullOrEmpty(finalKey))
                        {
                            if (filterAllowed.Contains(finalKey.Replace("filter_", "")) || filterAllowed.Length == 0)
                            {
                                if (!string.IsNullOrEmpty(form[finalKey].ToString()))
                                {
                                    string finalValue = form[finalKey];
                                    if (properties.Type == "bit")
                                    {
                                        finalValue = finalValue.Replace("true", "1").Replace("false", "0");
                                    }

                                    conditions += !conditions.Contains("Where") ? "Where " : "";
                                    conditions += string.Format(" {0} like '%{1}%' OR", properties.Name, finalValue);
                                }
                            }
                        }
                    }
                }

                conditions += "*$*";
                conditions  = conditions.Replace("OR*$*", "");
                conditions  = conditions.Replace("*$*", "");

                if (string.IsNullOrEmpty(where))
                {
                    string c = "";
                    if (!string.IsNullOrEmpty(consultaColumns))
                    {
                        c = string.Format(" SELECT {0} FROM ", consultaColumns);
                    }
                    else
                    {
                        tablename = "SELECT * FROM " + consulta;
                    }
                    //consulta = string.Format("SELECT * FROM ({3} {4}) AS DATA ORDER BY {0} OFFSET {1} ROWS FETCH NEXT {2} ROWS ONLY", primaryKey, current, limit, consulta, conditions);
                    consulta = string.Format("SELECT * FROM ( {5} {3} {4}) AS DATA ORDER BY {0} OFFSET {1} ROWS FETCH NEXT {2} ROWS ONLY", (primaryKey == "") ? "1" : primaryKey, current, limit, tablename, conditions, c);
                    data     = Helper.getData(consulta, db);
                }
                else
                {
                    string c = "";
                    if (!string.IsNullOrEmpty(consultaColumns))
                    {
                        c = string.Format(" SELECT {0} FROM ", consultaColumns);
                    }
                    else
                    {
                        tablename = "SELECT * FROM " + consulta;
                    }
                    //consulta = string.Format("SELECT * FROM ({3} {4}) AS DATA WHERE {5} ORDER BY {0} OFFSET {1} ROWS FETCH NEXT {2} ROWS ONLY", primaryKey, current, limit, consulta, conditions, where);
                    consulta = string.Format("SELECT * FROM ({6} {3} {4}) AS DATA WHERE {5} ORDER BY {0} OFFSET {1} ROWS FETCH NEXT {2} ROWS ONLY", (primaryKey == "") ? "1" : primaryKey, current, limit, tablename, conditions, where, c);
                    data     = Helper.getData(consulta, db);
                }
                DataTable counts = Helper.getData(string.Format("SELECT count(*) FROM {1} {0}", conditions, tablenameOriginal), db);
                json.count = counts.Rows[0][0].ToString();

                DataTable columns2 = Helper.getData(string.Format("select * from VWBaseNiiAll where tableName='{0}' and type!='sysname' order by column_id", tablenameOriginal.Replace("[", "").Replace("]", "")), db);
                foreach (DataRow item in columns2.Rows)
                {
                    Admin.Controllers.BaseDeveloperController.dbProperties properties = new
                                                                                        Admin.Controllers.BaseDeveloperController.dbProperties(item);

                    if (consultaOriginal.ToLower().Contains(properties.Name.ToLower()) || consultaOriginal.Contains("*"))
                    {
                        json.columns.Add(new Column()
                        {
                            t = Helper.firstUpperCaseAndTs(properties.Name), p = "", n = properties.Name
                        });
                    }
                }
                foreach (DataRow row in data.Rows)
                {
                    Row    newRow = new Row();
                    string key    = "";
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        object item = row.ItemArray[i];

                        Admin.Controllers.BaseDeveloperController.dbProperties properties = new
                                                                                            Admin.Controllers.BaseDeveloperController.dbProperties(columns2.Rows[i]);

                        if (properties.Name == primaryKey)
                        {
                            key = item.ToString();
                        }
                        newRow.d.Add(new D()
                        {
                            d = (item == null ? "" : item.ToString()), p = ""
                        });
                    }
                    newRow.p = "";
                    json.rows.Add(newRow);
                }
            }
            table.Json = json;
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[RDEvent]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("active", ("Active"));
            table.ReplacedText.Add("creationDate", ("Creation Date"));
            table.ReplacedText.Add("name", ("Name"));
            table.ReplacedText.Add("description", ("Description"));
            table.ReplacedText.Add("channel_channel", ("Channel"));
            table.ReplacedText.Add("dateFrom", ("Date From"));
            table.ReplacedText.Add("dateTo", ("Date To"));
            table.ReplacedText.Add("timeFrom", ("Time From"));
            table.ReplacedText.Add("timeTo", ("Time To"));
            table.ReplacedText.Add("isAllDay", ("Is All Day"));
            table.SearchCondition = " id like '%{0}%'  OR  active like '%{0}%'  OR  creationDate like '%{0}%'  OR  name like '%{0}%'  OR  description like '%{0}%'  OR  (select top 1 name from [RDChannel] where id=channel_channel) like '%{0}%'  OR  dateFrom like '%{0}%'  OR  dateTo like '%{0}%'  OR  timeFrom like '%{0}%'  OR  timeTo like '%{0}%'  OR  isAllDay like '%{0}%' ";
            table.VarName         = "csRDEvent" + from.Split(':')[0];
            table.ReferenceText   = "Event";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("RDEvent"), Href = URLHelper.getActionUrlRelation("RDEvent", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.functionButton, Href = URLHelper.getActionUrl("RDEvent", "ToggleActive"), Title = "Active/Inactive", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_asterisk
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("RDEvent", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["active"] != null)
                {
                    item["active"] = (item["active"].ToString() == "1" || item["active"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["channel_channel"] != null)
                {
                    if (item["channel_channel"].ToString() != "")
                    {
                        int channel_channel = int.Parse(item["channel_channel"].ToString());
                        item["channel_channel"] = db.RDChannels.FirstOrDefault(d => d.id == channel_channel).name;
                    }
                    else
                    {
                        item["channel_channel"] = "Not Set";
                    }
                }
                if (item["isAllDay"] != null)
                {
                    item["isAllDay"] = (item["isAllDay"].ToString() == "1" || item["isAllDay"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #24
0
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseWebSocketChannels]";
            table.PrimaryKey = "Id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("Name", ("Name"));
            table.ReplacedText.Add("IsGlobal", ("Is Global"));
            table.ReplacedText.Add("ServerCode", ("Server Code"));
            table.ReplacedText.Add("ParametersName", ("Parameters Name"));
            table.ReplacedText.Add("StartDate", ("Start Date"));
            table.ReplacedText.Add("EndDate", ("End Date"));
            table.ReplacedText.Add("StartTime", ("Start Time"));
            table.ReplacedText.Add("EndTime", ("End Time"));
            table.ReplacedText.Add("DataEmitExample", ("Data Emit Example"));
            table.ReplacedText.Add("ClientCode", ("Client Code"));
            table.ReplacedText.Add("NoDateLimit", ("No Date Limit"));
            table.ReplacedText.Add("NoTimeLimit", ("No Time Limit"));
            table.SearchCondition = " Id like '%{0}%'  OR  Name like '%{0}%'  OR  IsGlobal like '%{0}%'  OR  ServerCode like '%{0}%'  OR  ParametersName like '%{0}%'  OR  StartDate like '%{0}%'  OR  EndDate like '%{0}%'  OR  StartTime like '%{0}%'  OR  EndTime like '%{0}%'  OR  DataEmitExample like '%{0}%'  OR  ClientCode like '%{0}%' OR  NoDateLimit like '%{0}%' OR  NoTimeLimit like '%{0}%' ";
            table.VarName         = "csBaseWebSocketChannels";
            table.ReferenceText   = "WebSocketChannels";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseWebSocketChannels", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseWebSocketChannels", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["IsGlobal"] != null)
                {
                    item["IsGlobal"] = (item["IsGlobal"].ToString() == "1" || item["IsGlobal"].ToString() == "True") ? ("Yes") : ("No");
                }

                if (item["NoDateLimit"] != null)
                {
                    item["NoDateLimit"] = (item["NoDateLimit"].ToString() == "1" || item["NoDateLimit"].ToString() == "True") ? ("Yes") : ("No");
                }

                if (item["NoTimeLimit"] != null)
                {
                    item["NoTimeLimit"] = (item["NoTimeLimit"].ToString() == "1" || item["NoTimeLimit"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            wb.Worksheets.Add(table.Data, "Web Socket Channels");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Web Socket Channels SMSChat {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
Example #25
0
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseColumn]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("basetable_table", ("Table"));
            table.ReplacedText.Add("columnName", ("Column Name"));
            table.ReplacedText.Add("dataType", ("Data Type"));
            table.ReplacedText.Add("allowNull", ("Allow Null"));
            table.ReplacedText.Add("defaultValue", ("Default Value"));
            table.ReplacedText.Add("ordinalPosition", ("Ordinal Position"));
            table.ReplacedText.Add("characterMaximumLength", ("Character Maximum Length"));
            table.ReplacedText.Add("numericPrecision", ("Numeric Precision"));
            table.ReplacedText.Add("numericScale", ("Numeric Scale"));
            table.ReplacedText.Add("isIndex", ("Is Index"));
            table.ReplacedText.Add("isUnique", ("Is Unique"));
            table.ReplacedText.Add("active", ("Active"));
            table.ReplacedText.Add("referenceTable", ("Reference Table"));
            table.ReplacedText.Add("referenceField", ("Reference Field"));
            table.SearchCondition = " id like '%{0}%'  OR  (select top 1 name from [BaseTable] where id=basetable_table) like '%{0}%'  OR  columnName like '%{0}%'  OR  dataType like '%{0}%'  OR  allowNull like '%{0}%'  OR  defaultValue like '%{0}%'  OR  ordinalPosition like '%{0}%'  OR  characterMaximumLength like '%{0}%'  OR  numericPrecision like '%{0}%'  OR  numericScale like '%{0}%'  OR  isIndex like '%{0}%'  OR  isUnique like '%{0}%'  OR  active like '%{0}%'  OR  referenceTable like '%{0}%'  OR  referenceField like '%{0}%' ";
            table.VarName         = "csBaseColumn" + from.Split(':')[0];
            table.ReferenceText   = "seColumn";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("BaseColumn"), Href = URLHelper.getActionUrlRelation("BaseColumn", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.functionButton, Href = URLHelper.getActionUrl("BaseColumn", "ToggleActive"), Title = "Active/Inactive", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_asterisk
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseColumn", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["basetable_table"] != null)
                {
                    if (item["basetable_table"].ToString() != "")
                    {
                        int basetable_table = int.Parse(item["basetable_table"].ToString());
                        item["basetable_table"] = db.BaseTables.FirstOrDefault(d => d.id == basetable_table).name;
                    }
                    else
                    {
                        item["basetable_table"] = "Not Set";
                    }
                }
                if (item["allowNull"] != null)
                {
                    item["allowNull"] = (item["allowNull"].ToString() == "1" || item["allowNull"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["isIndex"] != null)
                {
                    item["isIndex"] = (item["isIndex"].ToString() == "1" || item["isIndex"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["isUnique"] != null)
                {
                    item["isUnique"] = (item["isUnique"].ToString() == "1" || item["isUnique"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["active"] != null)
                {
                    item["active"] = (item["active"].ToString() == "1" || item["active"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }
Example #26
0
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseColumn]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("basetable_table", ("Basetable_table"));
            table.ReplacedText.Add("columnName", ("Column Name"));
            table.ReplacedText.Add("dataType", ("Data Type"));
            table.ReplacedText.Add("allowNull", ("Allow Null"));
            table.ReplacedText.Add("defaultValue", ("Default Value"));
            table.ReplacedText.Add("ordinalPosition", ("Ordinal Position"));
            table.ReplacedText.Add("characterMaximumLength", ("Character Maximum Length"));
            table.ReplacedText.Add("numericPrecision", ("Numeric Precision"));
            table.ReplacedText.Add("numericScale", ("Numeric Scale"));
            table.ReplacedText.Add("isIndex", ("Is Index"));
            table.ReplacedText.Add("isUnique", ("Is Unique"));
            table.ReplacedText.Add("active", ("Active"));
            table.ReplacedText.Add("referenceTable", ("Reference Table"));
            table.ReplacedText.Add("referenceField", ("Reference Field"));
            table.SearchCondition = " id like '%{0}%'  OR  (select top 1 name from [BaseTable] where id=basetable_table) like '%{0}%'  OR  columnName like '%{0}%'  OR  dataType like '%{0}%'  OR  allowNull like '%{0}%'  OR  defaultValue like '%{0}%'  OR  ordinalPosition like '%{0}%'  OR  characterMaximumLength like '%{0}%'  OR  numericPrecision like '%{0}%'  OR  numericScale like '%{0}%'  OR  isIndex like '%{0}%'  OR  isUnique like '%{0}%'  OR  active like '%{0}%'  OR  referenceTable like '%{0}%'  OR  referenceField like '%{0}%' ";
            table.VarName         = "csBaseColumn";
            table.ReferenceText   = "seColumn";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseColumn", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseColumn", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["basetable_table"] != null)
                {
                    if (item["basetable_table"].ToString() != "")
                    {
                        int basetable_table = int.Parse(item["basetable_table"].ToString());
                        item["basetable_table"] = db.BaseTables.FirstOrDefault(d => d.id == basetable_table).name;
                    }
                    else
                    {
                        item["basetable_table"] = "Not Set";
                    }
                }
                if (item["allowNull"] != null)
                {
                    item["allowNull"] = (item["allowNull"].ToString() == "1" || item["allowNull"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["isIndex"] != null)
                {
                    item["isIndex"] = (item["isIndex"].ToString() == "1" || item["isIndex"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["isUnique"] != null)
                {
                    item["isUnique"] = (item["isUnique"].ToString() == "1" || item["isUnique"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["active"] != null)
                {
                    item["active"] = (item["active"].ToString() == "1" || item["active"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            wb.Worksheets.Add(table.Data, "Column");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Column BUZZSPY {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
        public FileResult getCSV(string from = "")
        {
            FormCollection form = new FormCollection();

            foreach (string key in Request.QueryString.AllKeys)
            {
                if (key != "limit" && key != "offset")
                {
                    form.Add(key, Request.QueryString[key]);
                }
            }
            var wb = new XLWorkbook();
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[RDEvent]";
            table.PrimaryKey = "id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();

            //tohide.Add("column");
            //tohide.Remove("creationDate");
            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("id", ("Id"));
            table.ReplacedText.Add("active", ("Active"));
            table.ReplacedText.Add("creationDate", ("Creation Date"));
            table.ReplacedText.Add("name", ("Name"));
            table.ReplacedText.Add("description", ("Description"));
            table.ReplacedText.Add("channel_channel", ("Channel_channel"));
            table.ReplacedText.Add("dateFrom", ("Date From"));
            table.ReplacedText.Add("dateTo", ("Date To"));
            table.ReplacedText.Add("timeFrom", ("Time From"));
            table.ReplacedText.Add("timeTo", ("Time To"));
            table.ReplacedText.Add("isAllDay", ("Is All Day"));
            table.SearchCondition = " id like '%{0}%'  OR  active like '%{0}%'  OR  creationDate like '%{0}%'  OR  name like '%{0}%'  OR  description like '%{0}%'  OR  (select top 1 name from [RDChannel] where id=channel_channel) like '%{0}%'  OR  dateFrom like '%{0}%'  OR  dateTo like '%{0}%'  OR  timeFrom like '%{0}%'  OR  timeTo like '%{0}%'  OR  isAllDay like '%{0}%' ";
            table.VarName         = "csRDEvent";
            table.ReferenceText   = "Event";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("RDEvent", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("RDEvent", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            if (Request.QueryString.AllKeys.Contains("filter"))
            {
                table.buildDataTable(Request.QueryString["filter"]);
            }
            else
            {
                table.buildDataTable("");
            }
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["active"] != null)
                {
                    item["active"] = (item["active"].ToString() == "1" || item["active"].ToString() == "True") ? ("Yes") : ("No");
                }
                if (item["channel_channel"] != null)
                {
                    if (item["channel_channel"].ToString() != "")
                    {
                        int channel_channel = int.Parse(item["channel_channel"].ToString());
                        item["channel_channel"] = db.RDChannels.FirstOrDefault(d => d.id == channel_channel).name;
                    }
                    else
                    {
                        item["channel_channel"] = "Not Set";
                    }
                }
                if (item["isAllDay"] != null)
                {
                    item["isAllDay"] = (item["isAllDay"].ToString() == "1" || item["isAllDay"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            wb.Worksheets.Add(table.Data, "Event");
            using (var memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                byte[] byteInfo = memoryStream.ToArray();
                return(File(byteInfo, System.Net.Mime.MediaTypeNames.Application.Octet, String.Format("Event StreamToo {0}.xlsx", DateTime.Now.ToShortDateString())));
            }
        }
Example #28
0
        public JsonResult data(FormCollection form, string from = "", string filter = "")
        {
            JsonCsTableHelper table = new JsonCsTableHelper(db, form, Request.QueryString);

            table.TableName  = "[BaseWebSocketChannels]";
            table.PrimaryKey = "Id";
            string[]      hides  = table.hideColumns;
            List <string> tohide = hides.ToList();
            //tohide.Add("column");
            //tohide.Remove("creationDate");
            string extraRelation = "";

            if (!string.IsNullOrEmpty(from))
            {
                string[] relation = from.Split(':');
                table.AdditionalWhere = $"{relation[0]}='{relation[1]}'";
                extraRelation         = $"?from={from}";
                tohide.Add(relation[0]);
            }
            table.hideColumns = tohide.ToArray();
            table.ReplacedText.Add("Name", ("Name"));
            table.ReplacedText.Add("IsGlobal", ("Is Global"));
            table.ReplacedText.Add("ServerCode", ("Server Code"));
            table.ReplacedText.Add("ParametersName", ("Parameters Name"));
            table.ReplacedText.Add("StartDate", ("Start Date"));
            table.ReplacedText.Add("EndDate", ("End Date"));
            table.ReplacedText.Add("StartTime", ("Start Time"));
            table.ReplacedText.Add("EndTime", ("End Time"));
            table.ReplacedText.Add("DataEmitExample", ("Data Emit Example"));
            table.ReplacedText.Add("ClientCode", ("Client Code"));
            table.ReplacedText.Add("NoDateLimit", ("No Date Limit"));
            table.ReplacedText.Add("NoTimeLimit", ("No Time Limit"));
            table.SearchCondition = " Id like '%{0}%'  OR  Name like '%{0}%'  OR  IsGlobal like '%{0}%'  OR  ServerCode like '%{0}%'  OR  ParametersName like '%{0}%'  OR  StartDate like '%{0}%'  OR  EndDate like '%{0}%'  OR  StartTime like '%{0}%'  OR  EndTime like '%{0}%'  OR  DataEmitExample like '%{0}%'  OR  ClientCode like '%{0}%' OR  NoDateLimit like '%{0}%' OR  NoTimeLimit like '%{0}%' ";
            table.VarName         = "BaseWebSocketChannels" + from.Split(':')[0];
            table.ReferenceText   = "BaseWebSocketChannels";
            table.Links.Add(new CsTableLink()
            {
                ButtonType = URLHelper.buttonType("BaseWebSocketChannels"), Href = URLHelper.getActionUrlRelation("BaseWebSocketChannels", "Form"), Title = "Edit", Css = "btn btn-warning btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_pencil, Extra = extraRelation
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.button, Href = URLHelper.getActionUrl("BaseWebSocketChannels", "FormEmit"), Title = "Make Test Emit", Css = "btn btn-warning btn-circle", Icon = BaseUIIconText.fa.fa_fa_envelope
            });
            table.Links.Add(new CsTableLink()
            {
                ButtonType = CsTableLinkType.deleteButton, Href = URLHelper.getActionUrl("BaseWebSocketChannels", "Delete"), Title = "Delete", Css = "btn btn-danger btn-circle refreshTable", Icon = BaseUIIconText.fa.fa_fa_trash_o
            });
            table.buildDataTable(filter);
            foreach (DataRow item in table.Data.Rows)
            {
                if (item["IsGlobal"] != null)
                {
                    item["IsGlobal"] = (item["IsGlobal"].ToString() == "1" || item["IsGlobal"].ToString() == "True") ? ("Yes") : ("No");
                }

                if (item["NoDateLimit"] != null)
                {
                    item["NoDateLimit"] = (item["NoDateLimit"].ToString() == "1" || item["NoDateLimit"].ToString() == "True") ? ("Yes") : ("No");
                }

                if (item["NoTimeLimit"] != null)
                {
                    item["NoTimeLimit"] = (item["NoTimeLimit"].ToString() == "1" || item["NoTimeLimit"].ToString() == "True") ? ("Yes") : ("No");
                }
            }
            table.buildDefaultJson();
            table.buildLinks();
            return(Json(table.Json, JsonRequestBehavior.AllowGet));
        }