Esempio n. 1
0
        /// <summary>
        /// 插入标签模板
        /// </summary>
        /// <param name="doc">文书代码</param>
        /// <param name="xmlDoc">标签模板</param>
        /// <returns></returns>
        public string InsertLableModel(int tid, string xmlDoc)
        {
            XmlDocument Doc = new XmlDocument();

            Doc.LoadXml(xmlDoc);
            XmlElement xmlElement  = Doc.DocumentElement;
            string     insertLable = "";
            int        message     = 0;

            try
            {
                foreach (XmlNode bodyNode in xmlElement.ChildNodes)
                {
                    if (bodyNode.Name == "body")
                    {
                        if (bodyNode.HasChildNodes)
                        {   //int i = 1;
                            foreach (XmlNode divNode in bodyNode.ChildNodes)
                            {
                                if (divNode.Name == "div")
                                {
                                    //i++;
                                    //string divModel = divNode.InnerText;
                                    string divTitle = "";
                                    for (int i = 0; i < divNode.Attributes.Count; i++)
                                    {
                                        if (divNode.Attributes[i].ToString().Trim() == "title")
                                        {
                                            divTitle = divNode.Attributes["title"].Value;
                                        }
                                    }

                                    if (divTitle.Trim() == "")
                                    {
                                        divTitle = "文本域";
                                    }
                                    int id = GenId("t_model_lable", "LID");
                                    //插入标签模块
                                    insertLable = "insert into t_model_lable(LID,TID,LABLEKIND,LABLE_MODEL)values(" + id + "," + tid + ",'" + divTitle + "',:divModel)";

                                    DBParameter[] xmlPars = new DBParameter[1];
                                    xmlPars[0] = new DBParameter();
                                    xmlPars[0].ParameterName = "divModel";
                                    xmlPars[0].Value         = divNode.OuterXml;
                                    xmlPars[0].DBType        = OracleType.Clob;
                                    //xmlPars[0].Direction = ParameterDirection.Input;
                                    message = ExecuteSQLWithParams(insertLable, xmlPars);

                                    foreach (XmlNode selectNode in divNode.ChildNodes)
                                    {
                                        if (selectNode.Name == "select")
                                        {
                                            string selName  = selectNode.Attributes["name"].Value;
                                            string selValue = selectNode.Attributes["value"].Value;
                                            string sid      = GenId("t_struct", "sid").ToString();
                                            ////插入结构化
                                            string insertStruct = "insert into t_struct values(" + sid + "," + id + ",'" + selName + "','" + selValue + "'," + tid + ")";
                                            message = ExecuteSQL(insertStruct);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (message != 0)
                {
                    return("成功!");
                }
                else
                {
                    return("失败!");
                }
            }
            catch (Exception ex)
            {
                return("数据库异常!----------------" + ex.ToString());
            }
            finally
            {
                //NClose();
            }
        }