Exemple #1
0
        private Queue <Link> GetLink(string strID, bool isButtonList)
        {
            Queue <Link> linkQueue;

            string[]          arrID;            // 保存配置文件中节点ID
            string            configPath;       // 链接配置文件路径
            string            xpath;
            XPathNodeIterator navNodeXPath;     // 链接/按钮配置根节点指针
            XPathNodeIterator currentNav;       // 临时指针

            linkQueue = new Queue <Link>();

            arrID      = strID.Split(new char[] { ',' });
            configPath = AppDomain.CurrentDomain.BaseDirectory + Utils.GetResourcesValue("Model", "ListPath");

            if (isButtonList)
            {
                xpath = "/config/listbutton";
            }
            else
            {
                xpath = "/config/listlink";
            }

            navNodeXPath = ModelManage.GetNodeIterator(configPath, xpath);
            navNodeXPath.MoveNext();

            foreach (string strItem in arrID)
            {
                if (string.IsNullOrEmpty(strItem))
                {
                    continue;
                }

                currentNav = navNodeXPath.Current.Select("link[@id=" + strItem + "]");

                if (currentNav != null && currentNav.Count > 0)
                {
                    try
                    {
                        Link lnk = new Link();

                        currentNav.MoveNext();
                        lnk.Text  = currentNav.Current.GetAttribute("text", "");
                        lnk.Value = currentNav.Current.SelectSingleNode("value").InnerXml;
                        lnk.Value = lnk.Value.Replace("{#EditUrlParam#}", this.keepUrlParam);
                        linkQueue.Enqueue(lnk);
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            return(linkQueue);
        }
        private bool EditSysField(ref StringBuilder sbSysFields, string sysFieldID)
        {
            string            controlHtml;       // 当前节点的HTML代码
            string            itemHtml;          // 临时变量
            string            configPath;        // 链接配置文件路径
            string            xpath;
            XPathNodeIterator navNodeXPath;      // 链接/按钮配置根节点指针
            XPathNodeIterator currentNav;        // 临时指针
            Regex             reg;               // 用于配置字段标签如{FieldName}
            MatchCollection   matchCollection;   // 配置的字段标签集合
            bool isSuccess;                      // 解析是否成功

            isSuccess    = true;
            reg          = new Regex(@"(?<1>\{\$(?<2>([0-9a-zA-Z_]+))\$\})");
            configPath   = AppDomain.CurrentDomain.BaseDirectory + Utils.GetResourcesValue("Model", "SysFieldPath");
            xpath        = "/config";
            navNodeXPath = ModelManage.GetNodeIterator(configPath, xpath);
            navNodeXPath.MoveNext();
            currentNav = navNodeXPath.Current.Select("field[@id=" + sysFieldID + "]/edit");

            if (currentNav != null && currentNav.Count > 0)
            {
                currentNav.MoveNext();
                controlHtml     = currentNav.Current.InnerXml;
                controlHtml     = controlHtml.Replace("{#TableName#}", this.hsModel["TableName"].ToString()); // 解析预定义标签
                matchCollection = reg.Matches(controlHtml);

                foreach (Match match in matchCollection)                                                    // 字段标签替换成绑定标签
                {
                    controlHtml = controlHtml.Replace(match.Groups[1].Value, "<%=hsFieldValue[\"" + match.Groups[2].Value + "\"] %>");
                }

                controlHtml = containerItemTemplate.Replace(containerContent, controlHtml);                      // 加标签如 <li>
                currentNav  = navNodeXPath.Current.Select("field[@id=" + sysFieldID + "]");

                if (currentNav != null && currentNav.Count > 0)                                                  // 配置节点在编辑页显示
                {
                    itemHtml    = SetFieldParam(currentNav);                                                     // 设置缺省值并获取显示标题
                    itemHtml    = containerItemHeaderTemplate.Replace(containerContent, itemHtml);               // 标题
                    controlHtml = containerTemplate.Replace(containerContent, itemHtml + controlHtml);
                    sbSysFields.Append(controlHtml);
                }
            }
            else
            {
                isSuccess = false;
            }

            return(isSuccess);
        }
        private bool SysFieldSearch(DataRowView dr, ref StringBuilder sbSearchHtml)
        {
            StringBuilder sbSysFieldSearchHtml;  // 保存解析后的自定义字段解析搜索代码

            string            controlHtml;       // 当前节点的HTML代码
            string            itemHtml;          // 临时变量
            string            configPath;        // 链接配置文件路径
            string            xpath;
            XPathNodeIterator navNodeXPath;      // 链接/按钮配置根节点指针
            XPathNodeIterator currentNav;        // 临时指针
            string            styleWidth;        // {#StyleWidth#}标签(控件的宽度)值
            bool result;                         // 处理结果

            sbSysFieldSearchHtml = new StringBuilder();
            styleWidth           = "0";
            result       = true;
            configPath   = AppDomain.CurrentDomain.BaseDirectory + Utils.GetResourcesValue("Model", "SysFieldPath");
            xpath        = "/config";
            navNodeXPath = ModelManage.GetNodeIterator(configPath, xpath);
            navNodeXPath.MoveNext();
            currentNav = navNodeXPath.Current.Select("field[@id=" + dr["SystemFirerdHtml"].ToString() + "]/search");

            if (currentNav != null && currentNav.Count > 0)
            {
                currentNav.MoveNext();
                controlHtml = currentNav.Current.InnerXml;
                controlHtml = searchContainerItemTemplate.Replace(containerContent, controlHtml);                      // 加标签如 <li>
                currentNav  = navNodeXPath.Current.Select("field[@id=" + dr["SystemFirerdHtml"].ToString().Trim() + "]");
                itemHtml    = GetSysFieldSearchParam(currentNav, ref styleWidth);                                      // 设置缺省值并获取显示标题
                itemHtml    = searchContainerItemHeaderTemplate.Replace(containerContent, itemHtml);                   // 标题
                controlHtml = searchContainerTemplate.Replace(containerContent, itemHtml + controlHtml);
                controlHtml = controlHtml.Replace("{#StyleWidth#}", styleWidth);
                sbSysFieldSearchHtml.Append(controlHtml);
            }
            else
            {
                result = false;
            }

            if (result)     // 解析成功
            {
                sbSearchHtml.Append(sbSysFieldSearchHtml);
            }

            return(result);
        }
Exemple #4
0
        private void GetOperationColumn(ref StringBuilder sbOperationColumn, ref string columnWidth)
        {
            string operationColumn;             // 当前模型中的操作

            string[]          arrOperationColumn;
            string            configPath;       // 配置文件路径
            string            xpath;
            XPathNodeIterator navNodeXPath;     // 字段配置根节点指针

            XPathNodeIterator currentNav;       // 临时指针
            string            link;             // 临时变量

            operationColumn    = this.hsModel["OperationColumn"].ToString();
            arrOperationColumn = operationColumn.Split(new char[] { ',' });

            configPath   = AppDomain.CurrentDomain.BaseDirectory + Utils.GetResourcesValue("Model", "ListPath");
            xpath        = "/config/rptbutton";
            navNodeXPath = ModelManage.GetNodeIterator(configPath, xpath);
            navNodeXPath.MoveNext();

            columnWidth = navNodeXPath.Current.GetAttribute("width", "");

            foreach (string nodeID in arrOperationColumn)   // 遍历所有当前模型中的配置节点

            {
                if (!string.IsNullOrEmpty(nodeID))
                {
                    currentNav = navNodeXPath.Current.Select("link[@id=" + nodeID + "]");

                    if (currentNav != null && currentNav.Count > 0)
                    {
                        currentNav.MoveNext();
                        link = currentNav.Current.GetAttribute("btName", "");
                        link = "<input type=\"button\"  value=\"" + link + "\" />";
                        sbOperationColumn.Append(link);
                    }
                }
            }
        }
Exemple #5
0
        public string Save(string modelID)
        {
            string            effectRow;        // 操作受影响行数
            Hashtable         hsListWidth;      // 列表列宽更新参数
            Hashtable         hsListOrder;      // 列表列顺序更新参数
            string            operColumnWidth;  // 操作列宽度
            string            configPath;       // 配置文件路径
            string            xpath;
            XPathNodeIterator navNodeXPath;     // 字段配置根节点指针
            XPathNodeIterator currentNav;       // 临时指针
            Hashtable         advancedConfig;   // 高级设置参数,对应k_ModelManage中的字段

            hsListWidth    = new Hashtable();
            hsListOrder    = new Hashtable();
            advancedConfig = new Hashtable();

            operColumnWidth = string.Empty;
            configPath      = AppDomain.CurrentDomain.BaseDirectory + Utils.GetResourcesValue("Model", "SysFieldPath");
            xpath           = "/config";
            navNodeXPath    = ModelManage.GetNodeIterator(configPath, xpath);
            navNodeXPath.MoveNext();

            // 高级设置赋值
            advancedConfig.Add("ListHeight", HttpContext.Current.Request.Form["ListHeight"]);                               // 列表高
            advancedConfig.Add("DeliverAndSearchUrlParam", HttpContext.Current.Request.Form["DeliverAndSearchUrlParam"]);   // URL传递且参与查询的参数
            advancedConfig.Add("DeliverUrlParam", HttpContext.Current.Request.Form["DeliverUrlParam"]);                     // URL传递参数
            advancedConfig.Add("FieldFromUrlParamValue", HttpContext.Current.Request.Form["FieldFromUrlParamValue"]);       // 字段值来源于URL参数值的字段
            advancedConfig.Add("BackDeliverUrlParam", HttpContext.Current.Request.Form["BackDeliverUrlParam"]);             // 页面返回时需传递的参数
            advancedConfig.Add("NotSearchField", HttpContext.Current.Request.Form["NotSearchField"]);                       // 不参与列表显示查询的字段

            foreach (string key in HttpContext.Current.Request.Form.AllKeys)
            {
                string fieldName;       // 字段名

                string fieldValue;      // 字段值


                fieldValue = HttpContext.Current.Request.Form[key];
                if (key.Contains("HQB_ListWidth_0_"))     // 基本字段列宽设置
                {
                    fieldName = key.Replace("HQB_ListWidth_0_", "");
                    hsListWidth.Add(fieldName, fieldValue);
                    continue;
                }

                if (key.Contains("HQB_Orders_0_"))        // 基本字段顺序设置
                {
                    fieldName = key.Replace("HQB_Orders_0_", "");
                    hsListOrder.Add(fieldName, fieldValue);
                    continue;
                }

                if (key.Contains("HQB_ListWidth_1_"))      // 自定义系统字段列宽

                {
                    string   sysFieldID;
                    string[] arrFieldName;
                    sysFieldID = key.Replace("HQB_ListWidth_1_", "");
                    currentNav = navNodeXPath.Current.Select("field[@id=" + sysFieldID + "]");
                    currentNav.MoveNext();

                    if (currentNav.Current.SelectSingleNode("name") != null)
                    {
                        arrFieldName = currentNav.Current.SelectSingleNode("name").Value.Split(new char[] { '|' });

                        foreach (string field in arrFieldName)
                        {
                            if (!string.IsNullOrEmpty(field))
                            {
                                hsListWidth.Add(field, fieldValue);
                            }
                        }
                    }
                    continue;
                }

                if (key.Contains("HQB_ListOrders_1_"))     // 自定义系统字段顺序设置

                {
                    string   sysFieldID;
                    string[] arrFieldName;
                    sysFieldID = key.Replace("HQB_ListOrders_1_", "");

                    if (!string.IsNullOrEmpty(sysFieldID))
                    {
                        currentNav = navNodeXPath.Current.Select("field[@id=" + sysFieldID + "]");
                        currentNav.MoveNext();

                        if (currentNav.Current.SelectSingleNode("name") != null)
                        {
                            arrFieldName = currentNav.Current.SelectSingleNode("name").Value.Split(new char[] { '|' });

                            foreach (string field in arrFieldName)
                            {
                                if (!string.IsNullOrEmpty(field))
                                {
                                    hsListOrder.Add(field, fieldValue);
                                }
                            }
                        }
                    }
                    continue;
                }

                if (key.Contains("HQB_ListWidth_OpColumn"))  // 列表操作列宽度

                {
                    operColumnWidth = fieldValue;
                }
            }

            effectRow = dal.SaveConfig(hsListWidth, hsListOrder, modelID, operColumnWidth, advancedConfig);

            return(effectRow);
        }
Exemple #6
0
        /// <summary>
        /// sysFieldID为模型表ModelManage
        // 中的系统字段SysField的值

        /// </summary>
        /// <returns></returns>
        private void ListSysField(string sysFieldID, ref StringBuilder sbHeaderHtml, ref StringBuilder sbItemHtml, ref StringBuilder sbListWidth, ref StringBuilder sbListItemOrder, string order)
        {
            string            configPath;       // 配置文件路径
            string            xpath;
            XPathNodeIterator navNodeXPath;     // 字段配置根节点指针

            XPathNodeIterator currentNav;       // 临时指针

            configPath   = AppDomain.CurrentDomain.BaseDirectory + Utils.GetResourcesValue("Model", "SysFieldPath");
            xpath        = "/config";
            navNodeXPath = ModelManage.GetNodeIterator(configPath, xpath);
            navNodeXPath.MoveNext();

            currentNav = navNodeXPath.Current.Select("field[@id=" + sysFieldID + "]");
            // 节点存在
            if (currentNav != null && currentNav.Count > 0)
            {
                string itemHeader;  // 列表标题
                string width;       // 列显示宽
                string title;       // 列显示标题

                string[] fieldName; // 字段名


                currentNav.MoveNext();
                try
                {
                    title     = currentNav.Current.GetAttribute("title", "");
                    width     = currentNav.Current.SelectSingleNode("list").GetAttribute("width", "");
                    fieldName = currentNav.Current.SelectSingleNode("name").Value.Split(new char[] { '|' });
                    DataRow[] currentDR = dtField.Select("Name='" + fieldName[0] + "'");

                    // 配置节点只有一个字段,时列表表题引用字段表中的标题
                    if (fieldName.Length < 2)
                    {
                        if (currentDR.Length > 0 && !string.IsNullOrEmpty(currentDR[0]["FieldAlias"].ToString()))
                        {
                            title = currentDR[0]["FieldAlias"].ToString();
                        }
                    }

                    if (!string.IsNullOrEmpty(currentDR[0]["ListWidth"].ToString()))  // 优选采用页面配置的值

                    {
                        width = currentDR[0]["ListWidth"].ToString();
                    }
                }
                catch
                {
                    return;
                }


                // 列表标题
                if (width.Contains("%"))
                {
                    itemHeader = "<li  style=\"width:" + width + "; ";
                }
                else
                {
                    itemHeader = "<li  style=\"width:" + width + "px; ";
                }
                sbHeaderHtml.Append(itemHeader + "\">");
                sbHeaderHtml.Append(title);
                sbHeaderHtml.Append("</li>");

                // 列表项

                sbItemHtml.Append(itemHeader + this.listHeight + "\">" + "</li>");

                // 列表列宽设置
                sbListWidth.Append("<li>" + title + ":<input type=\"text\"  value=\"" + width + "\" name=\"HQB_ListWidth_1_" + sysFieldID + "\" /></li>");

                // 列表列顺序设置

                sbListItemOrder.Append("<li>" + title + ":<input type=\"text\"  value=\"" + order + "\" name=\"HQB_ListOrders_1_" + sysFieldID + "\" /></li>");
            }
        }