Exemple #1
0
        /// <summary>
        /// 获取对象 给控件赋值
        /// </summary>
        public void SetInitControl()
        {
            StringBuilder sbxml = new StringBuilder();

            base_interfacemanage = base_interfacemanageibll.GetEntity(_key);
            ControlBindHelper.SetWebControls(this.Page, base_interfacemanage);
            int   rowindex = 1;
            IList List     = base_interfacemanageibll.GetListDetails(_key);//获取接口参数列表

            sbxml.Append("<Request>\r\n");
            sbxml.Append("\t<data  code='" + Code.Value + "'>\r\n");
            sbxml.Append("\t\t<no>\r\n");
            if (List.Count > 0)
            {
                foreach (BASE_InterfaceManageDetails item in List)
                {
                    Sb_Table_Out.Append("<tr>");
                    Sb_Table_Out.Append("<td class=\"td-div\" style=\"width: 50px; text-align: left;\"><div style=\"padding-left:5px;\">" + rowindex + "</div></td>");
                    Sb_Table_Out.Append("<td style=\"width: 250px;\"><input value=\"" + item.Field + "\" dbfield=\"true\" id=\"Field➩" + rowindex + "\"  type=\"text\" class=\"txt\" onkeyup=\"CheckingInterfaceDetailse(this.id," + rowindex + ")\" /></td>");
                    Sb_Table_Out.Append("<td style=\"width: 100px;text-align: center;\"><select dbfield=\"true\" id=\"FieldType➩" + rowindex + "\" class=\"txtselect\"  datacol=\"No\" err=\"数据类型\" checkexpession=\"NotNull\"><option value=\"\">==请选择==</option><option value=\"字符串\" " + IsSelected(item.FieldType, "字符串") + ">字符串</option><option value=\"数字\" " + IsSelected(item.FieldType, "数字") + ">数字</option><option value=\"日期\" " + IsSelected(item.FieldType, "日期") + ">日期</option><option value=\"金额\" " + IsSelected(item.FieldType, "金额") + ">金额</option></select></td>");
                    Sb_Table_Out.Append("<td style=\"width: 80px;\"><input value=\"" + item.FieldMaxLength + "\" dbfield=\"true\" id=\"FieldMaxLength➩" + rowindex + "\" type=\"text\" class=\"txt\" style=\"text-align: center;\"  datacol=\"No\" err=\"长度\" checkexpession=\"Num\" onkeyup=\"Keypress(this.id)\"/></td>");
                    Sb_Table_Out.Append("<td style=\"width: 80px;text-align: center;\"><input value=\"" + item.FieldMinLength + "\" dbfield=\"true\" id=\"FieldMinLength➩" + rowindex + "\" type=\"checkbox\" " + IsChecked(item.FieldMinLength.ToString()) + " /></td>");
                    Sb_Table_Out.Append("<td style=\"width: 80px;\"><input value=\"" + item.SortCode + "\" dbfield=\"true\" id=\"SortCode➩" + rowindex + "\" type=\"text\" class=\"txt\" style=\"text-align: center;\" datacol=\"No\" err=\"显示顺序\" checkexpession=\"Num\" value=\"" + rowindex + "\" /></td>");
                    Sb_Table_Out.Append("<td style=\"width: 80px;text-align: center;\"><input dbfield=\"true\" id=\"Enabled➩" + rowindex + "\" type=\"checkbox\" " + IsChecked(item.Enabled.ToString()) + " /></td>");
                    Sb_Table_Out.Append("<td ><input value=\"" + item.FieldMemo + "\" dbfield=\"true\" id=\"FieldMemo➩" + rowindex + "\" type=\"text\" class=\"txt\" /></td>");
                    Sb_Table_Out.Append("</tr>");
                    sbxml.Append("\t\t\t<" + item.Field + ">" + item.FieldMemo + "</" + item.Field + ">\r\n");
                    rowindex++;
                }
            }
            sbxml.Append("\t\t</no>\r\n");
            sbxml.Append("\t</data>\r\n");
            sbxml.Append("</Request>\r\n");
            int j = rowindex;

            for (int i = rowindex; i < 100; i++)
            {
                string IsDisabled = "disabled";
                if (i == j)
                {
                    IsDisabled = "";
                }
                Sb_Table_Out.Append("<tr>");
                Sb_Table_Out.Append("<td class=\"td-div\" style=\"width: 50px; text-align: left;\"><div style=\"padding-left:5px;\">" + rowindex + "</div></td>");
                Sb_Table_Out.Append("<td style=\"width: 250px;\"><input " + IsDisabled + " dbfield=\"true\" id=\"Field➩" + rowindex + "\"  type=\"text\" class=\"txt\" onkeyup=\"CheckingInterfaceDetailse(this.id," + rowindex + ")\" /></td>");
                Sb_Table_Out.Append("<td style=\"width: 100px;text-align: center;\"><select " + IsDisabled + " dbfield=\"true\" id=\"FieldType➩" + rowindex + "\" class=\"txtselect\" datacol=\"No\" err=\"数据类型\" checkexpession=\"NotNull\"><option value=\"\">==请选择==</option><option value=\"字符串\">字符串</option><option value=\"数字\">数字</option><option value=\"日期\">日期</option><option value=\"金额\">金额</option></select></td>");
                Sb_Table_Out.Append("<td style=\"width: 80px;\"><input " + IsDisabled + " dbfield=\"true\" id=\"FieldMaxLength➩" + rowindex + "\" type=\"text\" class=\"txt\" style=\"text-align: center;\"  datacol=\"No\" err=\"长度\" checkexpession=\"Num\" onkeyup=\"Keypress(this.id)\"/></td>");
                Sb_Table_Out.Append("<td style=\"width: 80px;text-align: center;\"><input " + IsDisabled + " dbfield=\"true\" id=\"FieldMinLength➩" + rowindex + "\" type=\"checkbox\" /></td>");
                Sb_Table_Out.Append("<td style=\"width: 80px;\"><input " + IsDisabled + " dbfield=\"true\" id=\"SortCode➩" + rowindex + "\" type=\"text\" class=\"txt\" style=\"text-align: center;\" datacol=\"No\" err=\"显示顺序\" checkexpession=\"Num\" value=\"" + rowindex + "\" /></td>");
                Sb_Table_Out.Append("<td style=\"width: 80px;text-align: center;\"><input " + IsDisabled + " dbfield=\"true\" id=\"Enabled➩" + rowindex + "\" type=\"checkbox\" checked=\"checked\" /></td>");
                Sb_Table_Out.Append("<td ><input " + IsDisabled + " dbfield=\"true\" id=\"FieldMemo➩" + rowindex + "\" type=\"text\" class=\"txt\" /></td>");
                Sb_Table_Out.Append("</tr>");
                rowindex++;
            }
            txtXML.Value = sbxml.ToString();
        }
Exemple #2
0
        /// <summary>
        /// 解析XML字符串格式
        /// </summary>
        /// <param name="Xml">xml字符串格式</param>
        /// <returns></returns>
        private void AnalysisXml(string Xml, out ArrayList arrSql, out ArrayList arrParam, out int Type)
        {
            ArrayList _arrSql   = new ArrayList();
            ArrayList _arrParam = new ArrayList();
            int       _Type     = -1;

            try
            {
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(Xml);
                foreach (XmlNode node in xd.ChildNodes)
                {
                    if (node.Name.Trim() == "Request")
                    {
                        foreach (XmlNode subnode in node.ChildNodes)
                        {
                            if (subnode.Name.Trim() == "data")
                            {
                                base_interfacemanage = base_interfacemanageibll.GetEntityByCode(subnode.Attributes["code"].Value);//根据接口代码获取对象
                                if (base_interfacemanage.InterfaceId != null)
                                {
                                    _Type = CommonHelper.GetInt(base_interfacemanage.Type);                           //动作类型:0-新增,1-修改,2-删除,3-查询,4-存储过程-DataTableProc,5-存储过程-GetDataSetProc,6-存储过程-ExecuteByProc,7-存储过程-BatchExecuteByProc
                                    string PermissionConstraint = base_interfacemanage.PermissionConstraint;          //约束达式
                                    foreach (XmlNode node_data in subnode.ChildNodes)
                                    {
                                        if (node_data.Name.Trim() == "no")
                                        {
                                            string pkName;
                                            string pkVal;
                                            switch (_Type)
                                            {
                                            case 0:    //新增
                                                Hashtable ht_add = this.XmlNodeToHashtable(node_data);
                                                _arrSql.Add(DbCommon.InsertSql(PermissionConstraint.Trim(), ht_add));
                                                _arrParam.Add(DbCommon.GetParameter(ht_add));
                                                break;

                                            case 1:    //修改
                                                Hashtable ht_edit = this.XmlNodeToHashtable(node_data, out pkName, out pkVal);
                                                _arrSql.Add(new StringBuilder(PermissionConstraint.Trim()));
                                                _arrParam.Add(DbCommon.GetParameter(ht_edit));
                                                break;

                                            case 2:    //删除
                                                Hashtable ht_Delete = this.XmlNodeToHashtable(node_data, out pkName, out pkVal);
                                                _arrSql.Add(DbCommon.DeleteSql(PermissionConstraint.Trim(), pkName));
                                                _arrParam.Add(new SqlParam[] { new SqlParam("@" + pkName, pkVal) });
                                                break;

                                            case 3:    //查询
                                                Hashtable ht_Param = this.XmlNodeToHashtable(node_data);
                                                _arrSql.Add(PermissionConstraint.Trim());
                                                _arrParam.Add(DbCommon.GetParameter(ht_Param));
                                                break;

                                            case 4:    //存储过程-DataTableProc
                                                Hashtable DataTableProc = this.XmlNodeToHashtable(node_data);
                                                _arrSql.Add(PermissionConstraint.Trim());
                                                _arrParam.Add(DataTableProc);
                                                break;

                                            case 5:    //存储过程-DataSetProc
                                                Hashtable DataSetProc = this.XmlNodeToHashtable(node_data);
                                                _arrSql.Add(PermissionConstraint.Trim());
                                                _arrParam.Add(DataSetProc);
                                                break;

                                            case 6:    //存储过程-ExecuteByProc
                                                Hashtable ExecuteByProc = this.XmlNodeToHashtable(node_data);
                                                _arrSql.Add(PermissionConstraint.Trim());
                                                _arrParam.Add(ExecuteByProc);
                                                break;

                                            case 7:    //存储过程-BatchExecuteByProc
                                                Hashtable BatchExecuteByProc = this.XmlNodeToHashtable(node_data);
                                                _arrSql.Add(PermissionConstraint.Trim());
                                                _arrParam.Add(DbCommon.GetParameter(BatchExecuteByProc));
                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Logger.WriteLog(Xml.ToString() + "\r\n接口不存在\r\n");
                                }
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog(Xml.ToString() + "\r\n" + e.Message + "\r\n");
            }
            finally
            {
                arrSql   = _arrSql;
                arrParam = _arrParam;
                Type     = _Type;
            }
        }