private MozaicBootstrapComponent convertAjaxComponentToDbFormat(MozaicBootstrapAjaxComponent c, MozaicBootstrapPage page, MozaicBootstrapComponent parentComponent, int numOrder)
        {
            var newComponent = new MozaicBootstrapComponent
            {
                ElmId               = c.ElmId,
                Content             = c.Content,
                Tag                 = c.Tag,
                UIC                 = c.UIC,
                Properties          = c.Properties,
                Attributes          = c.Attributes,
                MozaicBootstrapPage = page,
                NumOrder            = numOrder
            };

            if (c.ChildComponents != null && c.ChildComponents.Count > 0)
            {
                int childNumOrder = 0;
                newComponent.ChildComponents = new List <MozaicBootstrapComponent>();
                foreach (var ajaxChildComponent in c.ChildComponents)
                {
                    newComponent.ChildComponents.Add(convertAjaxComponentToDbFormat(ajaxChildComponent, page, newComponent, ++childNumOrder));
                }
            }
            return(newComponent);
        }
Пример #2
0
        private string RenderForeach(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            
            string varName = GetAttribute(c.Attributes, "data-varname");
            string type = GetAttribute(c.Attributes, "data-type");
            string attrs = BuildAttributes(c, new List<string>() { "data-varname", "data-type" });
            string conversion;
            switch (type) {
                case "jtoken":
                    conversion = "(Newtonsoft.Json.Linq.JToken)";
                    break;
                case "dbitem":
                    conversion = "(IEnumerable<FSS.Omnius.Modules.Entitron.DB.DBItem>)";
                    break;
                case "object":
                    conversion = "(List<object>)";
                    break;
                default:
                    conversion = "(IEnumerable<object>)";
                    break;
            }

            html.Append($@"
@{{ if(ViewData.ContainsKey(""{varName}"")) {{
        foreach(var row in {conversion}ViewData[""{varName}""]) {{
            <{c.Tag} {attrs}>
                {GetContent(c, properties)}   
            </{c.Tag}>
        }}
    }}
}}");
            return html.ToString();
        }
Пример #3
0
        private string RenderAthena(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);
            properties["raw"] = "true";

            string property = "csv";
            string chartSource = !properties.ContainsKey(property) ? "{var1}" : properties[property].Replace("\\n", "\n");

            string[] kv = c.UIC.Split('|');
            string graphId = kv[1];

            Graph graph = COREobject.i.Context.Graph.FirstOrDefault(g => g.Ident == graphId);
            string gHtml = graph.Html.Replace("{ident}", c.ElmId + "_graph");
            string js = "<script>" + graph.Js.Replace("{data}", chartSource).Replace("{ident}", c.ElmId + "_graph") + "</script>";
            string css = !string.IsNullOrEmpty(graph.Css) ? "<style type=\"text/css\" rel=\"stylesheet\">" + graph.Css.Replace("{ident}", c.ElmId + "_graph") + "</style>" : "";

            Dictionary<string, string> replace = new Dictionary<string, string>();
            replace.Add("__AthenaHTML__", gHtml);
            replace.Add("__AthenaCSS__", css);
            replace.Add("__AthenaJS__", js);
            
            html.Append($"<{c.Tag} {attrs}>{GetContent(c, properties, replace)}</{c.Tag}>");

            return html.ToString();
        }
Пример #4
0
        private string RenderSelect(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            string sortMode = "key";
            foreach(KeyValuePair<string, string> kp in properties) {
                if(kp.Key.ToLower() == "sortby" && kp.Value.ToLower() == "value") {
                    sortMode = "value";
                }
            }

            string sort = sortMode == "value" ? ".OrderBy(p => p.Value)" : "";
            properties.Add("raw", "true");

            html.Append($@"
<{c.Tag} {attrs}>
    {GetContent(c, properties)}
    @{{ if(ViewData[""dropdownData_{c.ElmId}""] != null) {{
            foreach(var option in ((Dictionary<int, string>)ViewData[""dropdownData_{c.ElmId}""]){sort}) {{
                <option value=""@(option.Key)"" @(ViewData.ContainsKey(""dropdownSelection_{ c.ElmId}"") && ViewData[""dropdownSelection_{c.ElmId}""].ToString() == option.Key.ToString() ? ""selected"" : """")>
                    @(option.Value)
                </option>
            }}
        }}
    }}    
</{c.Tag}>");
            
            return html.ToString();
        }
Пример #5
0
        private string RenderForm(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            html.Append($"<{c.Tag} {attrs}>{c.Content}@Html.AntiForgeryToken()</{c.Tag}>");
            return html.ToString();
        }
Пример #6
0
        private string RenderEmbed(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            html.Append($"<{c.Tag} {attrs}>{(HttpUtility.HtmlDecode(c.Content))}</{c.Tag}>");
            return html.ToString();
        }
Пример #7
0
        private string RenderLabel(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            html.Append($"<{c.Tag} {attrs}>{GetContent(c, properties)}</{c.Tag}>");

            return html.ToString();
        }
Пример #8
0
        private string RenderTextarea(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            html.Append($"<{c.Tag} {attrs}>@(formState.ContainsKey(\"{c.ElmId}\") ? formState[\"{c.ElmId}\"] : ViewData[\"inputData_{c.ElmId}\"])</{c.Tag}>");
            
            return html.ToString();
        }
Пример #9
0
        private string RenderCheckbox(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            html.Append($"<input {attrs} @((formState.ContainsKey(\"{c.ElmId}\") && formState[\"{c.ElmId}\"] == \"on\") || (ViewData.ContainsKey(\"checkboxData_{c.ElmId}\") && (ViewData[\"checkboxData_{c.ElmId}\"] as bool? == true)) ? \" checked\" : \"\") />");

            return html.ToString();
        }
Пример #10
0
        private string RenderDataTable(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c, new List<string>() { "data-actions" });
            string actions = GetAttribute(c.Attributes, "data-actions");
            string cellContentTemplate = properties.ContainsKey("allowHtml") ? $"@Html.Raw(cell.ToString())" : $"@cell.ToString()";

            string actionsHeader = actions != null ? "<th>Akce</th>" : "";
            string actionsFooter = actions != null ? "<th>Akce</th>" : "";
            string actionsIcons = "";

            if(actions != null) {
                List<string> actionsIconsList = new List<string>();
                JToken jActions = JToken.Parse(actions.Replace('\'', '"'));
                foreach(JToken a in jActions) {
                    actionsIconsList.Add($"<i title=\"{(string)a["title"]}\" class=\"{(string)a["icon"]}\" data-action=\"{(string)a["action"]}\" data-idparam=\"{(string)a["idParam"]}\" data-confirm=\"{(string)a["confirm"]}\"></i>");
                }
                actionsIcons = "<td class=\"actionIcons\">" + string.Join(" ", actionsIconsList) + "</td>";
            }

            html.Append($@"
@{{ if(ViewData.ContainsKey(""tableData_{c.ElmId}"") && ((System.Data.DataTable)(ViewData[""tableData_{c.ElmId}""])).Rows.Count > 0) {{
    <{c.Tag} {attrs}>
        <thead>
            <tr>
            @foreach (System.Data.DataColumn col in ((System.Data.DataTable)(ViewData[""tableData_{c.ElmId}""])).Columns) {{
                <th>@col.Caption</th>
            }}
                {actionsHeader}
            </tr>
        </thead>
        <tfoot>
            <tr>@foreach (System.Data.DataColumn col in ((System.Data.DataTable)(ViewData[""tableData_{c.ElmId}""])).Columns) {{
                <th>@col.Caption</th>
            }}
                {actionsFooter}
            </tr>
        </tfoot>
        <tbody>
        @foreach(System.Data.DataRow row in ((System.Data.DataTable)(ViewData[""tableData_{c.ElmId}""])).Rows) {{
            <tr>@foreach (var cell in row.ItemArray) {{
                <td>{cellContentTemplate}</td>
            }}
                {actionsIcons}
            </tr>
        }}
        </tbody>
    </{c.Tag}>
}} else {{
    <div class=""alert alert-info empty-table-label"">Tabulka neobsahuje žádná data</div>
}} }}
<input type=""hidden"" name=""{c.ElmId}"" />
");
            
            return html.ToString();
        }
Пример #11
0
        private string RenderButton(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            var wfItem = e.TapestryDesignerWorkflowItems.Where(i => i.ComponentName == c.ElmId && i.IsBootstrap == true).OrderByDescending(i => i.Id).FirstOrDefault();
            html.Append($"<{c.Tag} {attrs} {(wfItem != null && wfItem.isAjaxAction != null && wfItem.isAjaxAction.Value ? " data-ajax=\"true\"" : "")}>{GetContent(c, properties)}</{c.Tag}>");

            return html.ToString();
        }
Пример #12
0
        private string RenderCountdown(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);
            string targetDate = $@"@(ViewData.ContainsKey(""countdownTargetData_{c.ElmId}"") ? @ViewData[""countdownTargetData_{c.ElmId}""] : """")";

            html.Append($@"<{c.Tag} {attrs} countdownTarget=""{targetDate}"">{GetContent(c, properties)}</{c.Tag}>");

            return html.ToString();
        }
Пример #13
0
        private string RenderInput(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();

            Dictionary<string, string> mergeAttrs = new Dictionary<string, string>();
            mergeAttrs.Add("value", $"@(formState.ContainsKey(\"{c.ElmId}\") ? formState[\"{c.ElmId}\"] : (ViewData.ContainsKey(\"inputData_{c.ElmId}\") ? @ViewData[\"inputData_{c.ElmId}\"] : \"\"))");

            string attrs = BuildAttributes(c, new List<string>(), mergeAttrs);

            html.Append($"<{c.Tag} {attrs} />");
                
            return html.ToString();
        }
Пример #14
0
 private string RenderDefault(MozaicBootstrapComponent c, Dictionary<string, string> properties)
 {
     StringBuilder html = new StringBuilder();
     string attrs = BuildAttributes(c);
     
     if (properties.ContainsKey("raw") && properties["raw"].ToLower() == "true") {
         html.Append($"<{c.Tag} {attrs}>{GetContent(c, properties)}</{c.Tag}>");
     }
     else {
         html.Append($"<{c.Tag} {attrs}>{(HttpUtility.HtmlDecode(GetContent(c, properties)))}</{c.Tag}>");
     }
     return html.ToString();
 }
Пример #15
0
        private string RenderIf(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);
            string varName = GetAttribute(c.Attributes, "data-varname");

            html.Append($@"
@if((ViewData.ContainsKey(""{varName}"") && (bool)ViewData[""{varName}""]) == true) {{
<{c.Tag} {attrs}>{GetContent(c, properties)}</{c.Tag}>
}}");

            return html.ToString();
        }
Пример #16
0
        private string RenderNVList(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string attrs = BuildAttributes(c);

            html.Append($"<{c.Tag} {attrs}>");
                html.Append($"@{{if(ViewData.ContainsKey(\"tableData_{c.ElmId}\")) {{ var tableData = (System.Data.DataTable)ViewData[\"tableData_{c.ElmId}\"];");
                    html.Append($"foreach (System.Data.DataColumn col in tableData.Columns) {{ if (!col.Caption.StartsWith(\"hidden__\")){{<tr><td class=\"name-cell\">@col.Caption</td>");
                    html.Append($"<td class=\"value-cell\">@(tableData.Rows.Count>0?tableData.Rows[0][col.ColumnName]:\"no data\")</td></tr>");
                html.Append($"}} }} }} }}");
            html.Append($"</{c.Tag}>");
            
            return html.ToString();
        }
Пример #17
0
        private string GetVariableReplace(MozaicBootstrapComponent c, string html)
        {

            if (!string.IsNullOrEmpty(c.ElmId)) {
                MatchCollection inputVars = vars.Matches(html);
                if (inputVars.Count > 0) {
                    foreach (Match var in inputVars) {
                        string index = var.Groups[1].Value;
                        string suffix = index == "1" ? "" : $"_{index}";

                        html += $".Replace(\"{var.Value}\", (ViewData.FirstOrDefault(v => v.Key.EndsWith(\"{c.ElmId}{suffix}\")).Value ?? \"\").ToString())";
                    }
                }
            }
            
            return html;
        }
Пример #18
0
        private string BuildAttributes(MozaicBootstrapComponent c, List<string> ignoreAttrs, Dictionary<string, string> mergeAttrs)
        {
            JToken jAttrs = JToken.Parse(c.Attributes);
            List<string> attrList = new List<string>();
            
            foreach(JToken t in jAttrs) {
                if(ignoreAttrs.Contains((string)t["name"])) {
                    continue;
                }
                
                string value = (string)t["value"];
                if (value.StartsWith("@row")) {
                    value = $"@(Convert.ToString({value.TrimStart('@').Replace('\'', '"')}))";
                }
                if (value.StartsWith("@item")) {
                    value = $"@(Convert.ToString(FSS.Omnius.Modules.Tapestry.KeyValueString.ParseValue(\"{value.Replace("@item", "row")}\", new Dictionary<string, object>() {{ {{ \"row\", row }} }} )))";
                }

                if (mergeAttrs.ContainsKey((string)t["name"])) {
                    value = mergeAttrs[(string)t["name"]];
                    mergeAttrs.Remove((string)t["name"]);
                }

                if(value.IndexOf("{var") != -1) {
                    value = $"@(@\"{value}\"";
                    value = GetVariableReplace(c, value);
                    value += ")";
                }

                attrList.Add($"{(string)t["name"]}=\"{value}\"");
            }

            if(mergeAttrs.Count > 0) {
                foreach(KeyValuePair<string, string> kp in mergeAttrs) {
                    attrList.Add($"{kp.Key}=\"{kp.Value}\"");
                }
            }

            return string.Join(" ", attrList);
        }
Пример #19
0
        private string RenderPanel(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();

            string generatedAttributes = "";
            string attrs = BuildAttributes(c);

            if (!string.IsNullOrEmpty(c.Properties)) {
                string[] tokenPairs = c.Properties.Split(';');
                foreach (string tokens in tokenPairs) {
                    string[] nameValuePair = tokens.Split('=');
                    if (nameValuePair.Length == 2) {
                        if (nameValuePair[0].ToLower() == "hiddenby")
                            generatedAttributes += $" panelHiddenBy=\"{nameValuePair[1]}\"";
                        else if (nameValuePair[0].ToLower() == "clone")
                            generatedAttributes += $" panelClonedBy=\"{nameValuePair[1]}\"";
                    }
                }
            }
            html.Append($"<{c.Tag} {attrs} {generatedAttributes}>{GetContent(c, properties)}</{c.Tag}>");
            return html.ToString();
        }
Пример #20
0
        private string RenderDateInput(MozaicBootstrapComponent c, Dictionary<string, string> properties)
        {
            StringBuilder html = new StringBuilder();
            string type = GetAttribute(c.Attributes, "type");
            string format = "";

            Dictionary<string, string> mergeAttrs = new Dictionary<string, string>();

            switch(type) {
                case "date": format = "yyyy-MM-dd"; break;
                case "time": format = "HH:mm"; break;
                case "datetime-local": format = "yyyy-MM-dd HH:mm:ss"; break;
                case "month": format = "yyyy-MM"; break;
            }
            mergeAttrs.Add("value", $"@(formState.ContainsKey(\"{c.ElmId}\") ? formState[\"{c.ElmId}\"] : ((ViewData.ContainsKey(\"inputData_{c.ElmId}\") && ViewData[\"inputData_{c.ElmId}\"] is DateTime) ? ((DateTime)ViewData[\"inputData_{c.ElmId}\"]).ToString(\"{format}\") : \"\"))");

            string attrs = BuildAttributes(c, new List<string>(), mergeAttrs);

            html.Append($"<{c.Tag} {attrs} />");

            return html.ToString();
        }
        private MozaicBootstrapAjaxComponent convertComponentToAjaxFormat(MozaicBootstrapComponent c)
        {
            var ajaxComponent = new MozaicBootstrapAjaxComponent
            {
                Id              = c.Id,
                ElmId           = c.ElmId ?? "",
                Tag             = c.Tag,
                UIC             = c.UIC,
                Attributes      = c.Attributes ?? "",
                Content         = c.Content,
                Properties      = c.Properties ?? "",
                ChildComponents = new List <MozaicBootstrapAjaxComponent>()
            };

            if (c.ChildComponents.Count > 0)
            {
                foreach (var childComponent in c.ChildComponents)
                {
                    ajaxComponent.ChildComponents.Add(convertComponentToAjaxFormat(childComponent));
                }
            }

            return(ajaxComponent);
        }
Пример #22
0
        private string GetContent(MozaicBootstrapComponent c, Dictionary<string, string> properties, Dictionary<string, string> replace)
        {
            if(string.IsNullOrEmpty(c.Content)) {
                return "";
            }

            string html = c.Content;
            if(replace.Count > 0) {
                foreach(KeyValuePair<string, string> kv in replace) {
                    html = html.Replace(kv.Key, kv.Value);
                }
            } 

            MatchCollection uicMatches = uics.Matches(html);
            if(uicMatches.Count > 0) {
                for(int i = 0; i < uicMatches.Count; i++) {
                    Match m = uicMatches[i];
                    int startIndex = m.Index + m.Length;
                    int endIndex = i + 1 < uicMatches.Count ? uicMatches[i + 1].Index : html.Length;

                    if (startIndex < endIndex) {
                        string subStr = html.Substring(startIndex, endIndex - startIndex);

                        if (subStr.StartsWith("@row")) {
                            subStr = $"@({subStr.TrimStart('@')}.ToString())";
                        }
                        else if (subStr.StartsWith("@item")) {
                            subStr = $"@(Convert.ToString(FSS.Omnius.Modules.Tapestry.KeyValueString.ParseValue(\"{subStr.Replace("@item", "row")}\", new Dictionary<string, object>() {{ {{ \"row\", row }} }} )))";
                        }
                        else if (properties.ContainsKey("razer") && properties["razer"].ToLower() == "true") {
                            // do nothing
                        }
                        else {
                            subStr = $"@{(properties.ContainsKey("raw") && properties["raw"].ToLower() == "true" ? "Html.Raw" : "")}(@\"" + subStr.EscapeVerbatim() + "\"";
                            subStr = GetVariableReplace(c, subStr);
                            subStr += ")";
                        }

                        html.Remove(startIndex, endIndex - startIndex);
                        html.Insert(startIndex, subStr);
                    }
                }
            }
            else {
                if (c.Content.StartsWith("@row")) {
                    html = $"@({c.Content.TrimStart('@')}.ToString())";
                }
                else if (c.Content.StartsWith("@item")) {
                    html = $"@(Convert.ToString(FSS.Omnius.Modules.Tapestry.KeyValueString.ParseValue(\"{c.Content.Replace("@item", "row")}\", new Dictionary<string, object>() {{ {{ \"row\", row }} }} )))";
                }
                else if(properties.ContainsKey("razer") && properties["razer"].ToLower() == "true") {
                    // do nothing
                }
                else {
                    html = $"@{(properties.ContainsKey("raw") && properties["raw"].ToLower() == "true" ? "Html.Raw" : "")}(@\"" + html.EscapeVerbatim() + "\"";
                    html = GetVariableReplace(c, html);
                    html += ")";
                }
            }
            
            return html;
        }
Пример #23
0
 private string GetContent(MozaicBootstrapComponent c, Dictionary<string, string> properties)
 {
     return GetContent(c, properties, new Dictionary<string, string>());
 }
Пример #24
0
        public static JToken DataTableResponse(COREobject core, List <DBItem> Data, int BootstrapPageId, string Columns, string Search, string Order, int draw, int start = -1, int length = -1)
        {
            // Init
            DBEntities    context         = core.Context;
            List <DBItem> ds              = new List <DBItem>();
            string        orderColumnName = null;

            if (Data.Count() > 0)
            {
                /**********************************************************************************/
                /* Vytvoříme si datasource - všechny sloupce jako string, přidáme hiddenId a akce */
                /**********************************************************************************/
                // Musíme znovu vytvořit sloupec s akcema
                string actionIcons           = "";
                MozaicBootstrapComponent uic = context.MozaicBootstrapComponents.Where(c => c.ElmId == core.Executor && c.MozaicBootstrapPageId == BootstrapPageId).FirstOrDefault();

                if (uic != null)
                {
                    JToken attributes = JToken.Parse(uic.Attributes);
                    foreach (JToken attr in attributes)
                    {
                        if ((string)attr["name"] == "data-actions")
                        {
                            string actionsString = ((string)attr["value"]).Replace('\'', '"');
                            JToken actions       = JToken.Parse(actionsString);

                            List <string> actionsIconsList = new List <string>();
                            foreach (JToken a in actions)
                            {
                                actionsIconsList.Add($"<i title=\"{(string)a["title"]}\" class=\"{(string)a["icon"]}\" data-action=\"{(string)a["action"]}\" data-idparam=\"{(string)a["idParam"]}\" data-confirm=\"{(string)a["confirm"]}\"></i>");
                            }
                            if (actionsIconsList.Count() > 0)
                            {
                                actionIcons = "<span class=\"text-nowrap\">" + string.Join(" ", actionsIconsList) + "</span>";
                            }
                            break;
                        }
                    }
                }

                List <string> displayNames = new List <string>();
                List <string> columnsNames = Data[0].getColumnNames();
                try
                {
                    displayNames = Data[0].getColumnDisplayNames().ToList();
                }
                catch (NullReferenceException)
                {
                    displayNames = columnsNames;
                }

                foreach (DBItem row in Data)
                {
                    DBItem newRow = new DBItem(null, null);
                    int    i      = 0;

                    foreach (string prop in columnsNames)
                    {
                        var value       = row[prop];
                        var displayName = displayNames[columnsNames.IndexOf(prop)];
                        if (i == 0)
                        {
                            orderColumnName = displayName;
                        }

                        // Převedeme všechny hodnoty na string
                        if (value is bool)
                        {
                            newRow[displayName] = (bool)value ? "Ano" : "Ne";
                        }
                        else if (value is DateTime)
                        {
                            newRow[displayName] = ((DateTime)value).ToString("d. M. yyyy H:mm:ss");
                        }
                        else if (value is string)
                        {
                            newRow[displayName] = (string)value;
                        }
                        else
                        {
                            newRow[displayName] = value.ToString();
                        }

                        // pokud je sloupec id nebo Id nastavíme hiddenId
                        if (prop == "id" || prop == "Id")
                        {
                            i++;
                            newRow["hiddenId"] = value.ToString();
                        }
                        i++;
                    }
                    // Pokud existují akce, přidáme je
                    if (!string.IsNullOrEmpty(actionIcons))
                    {
                        newRow["Akce"] = actionIcons;
                    }

                    ds.Add(newRow);
                }
            }

            /**********************************************************************************/
            /* Filtr dat                                                                      */
            /**********************************************************************************/
            List <DBItem> filteredData  = new List <DBItem>();
            JToken        columnsSearch = JToken.Parse(Columns);
            JToken        search        = JToken.Parse(Search);

            filteredData.AddRange(ds);

            foreach (JToken cs in JToken.Parse(Columns))
            {
                string searchFor = (string)cs["search"]["value"];
                if (!string.IsNullOrEmpty(searchFor))
                {
                    string columnName = (string)cs["data"];
                    filteredData = filteredData.Where(r => ((string)r[columnName]).ToLowerInvariant().Contains(searchFor.ToLowerInvariant())).ToList();
                }
            }
            string globalSearchFor = (string)search["value"];

            if (!string.IsNullOrEmpty(globalSearchFor))
            {
                filteredData.Clear();

                foreach (DBItem row in ds)
                {
                    foreach (string prop in row.getColumnNames())
                    {
                        if (prop == "id" || prop == "Id" || prop == "hiddenId" || prop == "Akce")
                        {
                            continue;
                        }

                        List <DBItem> found = ds.Where(r => ((string)r[prop]).ToLowerInvariant().Contains(globalSearchFor.ToLowerInvariant())).ToList();
                        if (found.Count() > 0)
                        {
                            foreach (DBItem item in found)
                            {
                                if (!filteredData.Contains(item))
                                {
                                    filteredData.Add(item);
                                }
                            }
                        }
                    }
                }
            }

            /**********************************************************************************/
            /* Zpracujeme řazení                                                              */
            /**********************************************************************************/
            JToken order = JToken.Parse(Order);
            int    j     = 0;
            IOrderedEnumerable <DBItem> tmpData = filteredData.OrderBy(r => r[r.getColumnNames().First()]);
            var comparer = new NaturalComparer <string>(CompareNatural);

            foreach (JToken by in order)
            {
                string columnName = (string)columnsSearch[(int)by["column"]]["data"];
                string dir        = (string)by["dir"];

                if (j == 0)
                {
                    tmpData = dir == "desc" ?
                              filteredData.OrderByDescending(r => (string)r[columnName], comparer) :
                              filteredData.OrderBy(r => (string)r[columnName], comparer);
                }
                else
                {
                    tmpData = dir == "desc" ?
                              tmpData.ThenByDescending(r => (string)r[columnName], comparer) :
                              tmpData.ThenBy(r => (string)r[columnName], comparer);
                }
                j++;
            }
            filteredData = tmpData.ToList();

            /**********************************************************************************/
            /* Zpracujeme stránkování                                                         */
            /**********************************************************************************/

            var pagedData = length == -1 ? filteredData.ToList() : filteredData.Skip(start).Take(length).ToList();

            /**********************************************************************************/
            /* Vrátíme výsledek                                                               */
            /**********************************************************************************/
            ListJson <DBItem> finalDS = new ListJson <DBItem>();

            finalDS.AddRange(pagedData);

            JToken response = new JObject();

            response["draw"]            = draw;
            response["recordsTotal"]    = Data.Count();
            response["recordsFiltered"] = filteredData.Count();
            response["data"]            = finalDS.ToJson();

            return(response);
        }
Пример #25
0
 private string BuildAttributes(MozaicBootstrapComponent c)
 {
     return BuildAttributes(c, new List<string>(), new Dictionary<string, string>());
 }
Пример #26
0
 private string BuildAttributes(MozaicBootstrapComponent c, List<string> ignoreAttrs)
 {
     return BuildAttributes(c, ignoreAttrs, new Dictionary<string, string>());
 }
Пример #27
0
 private string RenderVueApp(MozaicBootstrapComponent c, Dictionary<string, string> properties)
 {
     //include vue.min.js
     isVueJsApp = true;
     return RenderDefault(c, properties);
 }