Beispiel #1
0
        ///<summary>
        ///导入测试数据
        ///</summary>
        ///<returns>"true"/"false"</returns>
        private string testData()
        {
            using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
            {
                try
                {
                    string xmlpath = HttpContext.Current.Server.MapPath(@"~/sysconfig/TestData.xml");
                    XmlDocument objXmlDoc = new XmlDocument();
                    objXmlDoc.Load(xmlpath);
                    XmlNode rootNode = objXmlDoc.SelectSingleNode("root");

                    //记录测试数据
                    string xmlPathTestData = HttpContext.Current.Server.MapPath(@"~/sysconfig/TestRecord.xml");
                    XmlDocument objXmlDocTestData = new XmlDocument();
                    objXmlDocTestData.Load(xmlPathTestData);
                    XmlNode rootTestData = objXmlDocTestData.DocumentElement;

                    SqlDb.Dcms_Cate cate = new SqlDb.Dcms_Cate();
                    IQuery query = session.GetQuery(cate).Where(SqlDb.Dcms_Cate._CATE_MODULE_.NotEquls("guestbook").AND(SqlDb.Dcms_Cate._CATE_MANAGEURL_.NotNull()));
                    List<SqlDb.Dcms_Cate> catelist = query.GetList<SqlDb.Dcms_Cate>();

                    if (catelist.Count > 0)
                    {
                        session.BeginTrans();
                        for (int i = 0; i < catelist.Count; i++)
                        {
                            if (catelist[i].Cate_ManageUrl.Equals("baseinfo_update.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[0];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_BaseInfo baseinfo = new SqlDb.Dcms_BaseInfo();
                                session.simple("DELETE FROM [Dcms_BaseInfo] WHERE [BaseInfo_CateId] IN(" + catelist[i].Cate_Id + ")");
                                baseinfo.BaseInfo_CateId = catelist[i].Cate_Id;
                                baseinfo.BaseInfo_CateName = catelist[i].Cate_Title;
                                baseinfo.BaseInfo_Title = catelist[i].Cate_Title;
                                baseinfo.BaseInfo_Content = "<p>" + xn.Attributes["title"].Value + "测试内容</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                baseinfo.BaseInfo_AddTime = DateTime.Now;
                                baseinfo.BaseInfo_State = "1";
                                session.Create(baseinfo);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("baseinfo_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[0];
                                XmlNode xn = objNode.ChildNodes[0];

                                SqlDb.Dcms_BaseInfo baseinfo = new SqlDb.Dcms_BaseInfo();
                                baseinfo.BaseInfo_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    baseinfo.BaseInfo_CateName = catelist[i].Cate_Title;
                                    baseinfo.BaseInfo_Title = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    baseinfo.BaseInfo_Content = "<p>" + xn.Attributes["title"].Value + "测试内容" + j.ToString() + "</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                    baseinfo.BaseInfo_AddTime = DateTime.Now;
                                    baseinfo.BaseInfo_State = "1";
                                    session.Create(baseinfo);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(BaseInfo_Id) from Dcms_BaseInfo");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_BaseInfo");
                                        element.SetAttribute("keyColumn", "BaseInfo_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }

                                }

                            }
                            if (catelist[i].Cate_ManageUrl.Equals("news_update.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[1];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                                session.simple("DELETE FROM [Dcms_News] WHERE [News_CateId] IN(" + catelist[i].Cate_Id + ")");
                                news.News_CateId = catelist[i].Cate_Id;
                                news.News_CateName = catelist[i].Cate_Title;
                                news.News_Title = catelist[i].Cate_Title;
                                news.News_Content = "<p>" + catelist[i].Cate_Title + "测试内容</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                news.News_AddTime = DateTime.Now;
                                news.News_State = "1";
                                session.Create(news);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("news_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[1];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                                news.News_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    news.News_CateName = catelist[i].Cate_Title;
                                    news.News_Title = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    news.News_Content = "<p>" + catelist[i].Cate_Title + "测试内容" + j.ToString() + "</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                    news.News_AddTime = DateTime.Now;
                                    news.News_State = "1";
                                    session.Create(news);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(News_Id) from Dcms_News");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_News");
                                        element.SetAttribute("keyColumn", "News_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }

                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("products_update.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[2];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Products products = new SqlDb.Dcms_Products();
                                session.simple("DELETE FROM [Dcms_Products] WHERE [Products_CateID] IN(" + catelist[i].Cate_Id + ")");
                                products.Products_CateID = catelist[i].Cate_Id;
                                products.Products_CateName = catelist[i].Cate_Title;
                                products.Products_Title = catelist[i].Cate_Title;
                                products.Products_MinImage = xn.Attributes["minimage"].Value;
                                products.Products_BigImage = xn.Attributes["bigimage"].Value;
                                products.Products_Introduction = xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                products.Products_AddTime = DateTime.Now;
                                products.Products_State = "1";
                                products.Products_CodeName = "00001";
                                products.Products_IsHot = "1";
                                products.Products_IsNew = "1";
                                session.Create(products);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("products_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[2];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Products products = new SqlDb.Dcms_Products();
                                products.Products_CateID = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    products.Products_CateName = catelist[i].Cate_Title;
                                    products.Products_Title = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    products.Products_MinImage = xn.Attributes["minimage"].Value;
                                    products.Products_BigImage = xn.Attributes["bigimage"].Value;
                                    products.Products_Introduction = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                    products.Products_AddTime = DateTime.Now;
                                    products.Products_State = "1";
                                    products.Products_CodeName = "0000" + j.ToString();
                                    products.Products_IsHot = "1";
                                    products.Products_IsNew = "1";
                                    session.Create(products);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(Products_Id) from Dcms_Products");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Products");
                                        element.SetAttribute("keyColumn", "Products_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("link_update.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[3];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Link link = new SqlDb.Dcms_Link();
                                session.simple("DELETE FROM [Dcms_Link] WHERE [Link_CateId] IN(" + catelist[i].Cate_Id + ")");
                                link.Link_CateId = catelist[i].Cate_Id;
                                link.Link_CateName = catelist[i].Cate_Title;
                                link.Link_Title = catelist[i].Cate_Title;
                                link.Link_Url = xn.Attributes["linkurl"].Value;
                                link.Link_AddTime = DateTime.Now;
                                link.Link_State = "1";
                                session.Create(link);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("link_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[3];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Link link = new SqlDb.Dcms_Link();
                                link.Link_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    link.Link_CateName = catelist[i].Cate_Title;
                                    link.Link_Title = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    link.Link_Url = xn.Attributes["linkurl"].Value;
                                    link.Link_AddTime = DateTime.Now;
                                    link.Link_State = "1";
                                    session.Create(link);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(link_Id) from Dcms_Link");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Link");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("down_update.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[4];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Down down = new SqlDb.Dcms_Down();
                                session.simple("DELETE FROM [Dcms_Down] WHERE [Down_CateID] IN(" + catelist[i].Cate_Id + ")");
                                down.Down_CateID = catelist[i].Cate_Id;
                                down.Down_CateName = catelist[i].Cate_Title;
                                down.Down_Title = catelist[i].Cate_Title;
                                down.Down_FileType = xn.Attributes["filetype"].Value;
                                down.Down_LocalPath = xn.Attributes["localpath"].Value;
                                down.Down_AddTime = DateTime.Now;
                                down.Down_State = "1";
                                session.Create(down);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("down_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[4];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Down down = new SqlDb.Dcms_Down();
                                down.Down_CateID = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    down.Down_CateName = catelist[i].Cate_Title;
                                    down.Down_Title = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    down.Down_FileType = xn.Attributes["filetype"].Value;
                                    down.Down_LocalPath = xn.Attributes["localpath"].Value;
                                    down.Down_AddTime = DateTime.Now;
                                    down.Down_State = "1";
                                    session.Create(down);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(Down_Id) from Dcms_Down");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Down");
                                        element.SetAttribute("keyColumn", "Down_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("position_update.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[5];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Position position = new SqlDb.Dcms_Position();
                                session.simple("DELETE FROM [Dcms_Position] WHERE [Position_CateId] IN(" + catelist[i].Cate_Id + ")");
                                position.Position_CateId = catelist[i].Cate_Id;
                                position.Position_CateName = catelist[i].Cate_Title;
                                position.Position_Title = xn.Attributes["title"].Value;
                                position.Position_Num = xn.Attributes["num"].Value;
                                position.Position_Departments = xn.Attributes["departments"].Value;
                                position.Position_Area = xn.Attributes["area"].Value;
                                position.Position_AddTime = DateTime.Now;
                                position.Position_ValidTime = Convert.ToDateTime(xn.Attributes["validtime"].Value);
                                position.Position_Conditions = xn.Attributes["conditions"].Value.Replace("[BR]", "<br /><br />");
                                position.Position_Description = xn.Attributes["description"].Value.Replace("[BR]", "<br /><br />");
                                position.Position_Contact = xn.Attributes["contact"].Value.Replace("[BR]", "<br /><br />");
                                position.Position_State = "1";
                                session.Create(position);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("position_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[5];
                                XmlNode xn = objNode.ChildNodes[0];
                                SqlDb.Dcms_Position position = new SqlDb.Dcms_Position();
                                position.Position_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    position.Position_CateName = catelist[i].Cate_Title;
                                    position.Position_Title = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    position.Position_Num =xn.Attributes["num"].Value;
                                    position.Position_Departments = xn.Attributes["departments"].Value + "(" + j.ToString() + ")";
                                    position.Position_Area = xn.Attributes["area"].Value + "(" + j.ToString() + ")";
                                    position.Position_AddTime = DateTime.Now;
                                    position.Position_ValidTime = Convert.ToDateTime(xn.Attributes["validtime"].Value);
                                    position.Position_Conditions = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["conditions"].Value.Replace("[BR]", "<br /><br />");
                                    position.Position_Description = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["description"].Value.Replace("[BR]", "<br /><br />");
                                    position.Position_Contact = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["contact"].Value.Replace("[BR]", "<br /><br />");
                                    position.Position_State = "1";
                                    session.Create(position);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(Position_Id) from Dcms_Position");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Position");
                                        element.SetAttribute("keyColumn", "Position_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                        }
                        session.CommitTrans();
                        //记录测试数据
                        objXmlDocTestData.Save(xmlPathTestData);
                        return "生成成功!";
                    }

                    return "false";
                }

                catch(Exception ex)
                {
                    session.RollbackTrans();
                    return "生成失败!"+ex.Message;
                }
            }
        }
Beispiel #2
0
        ///<summary>
        ///导入测试数据
        ///</summary>
        ///<returns>"true"/"false"</returns>
        private string testData()
        {
            using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
            {
                try
                {
                    string      xmlpath   = HttpContext.Current.Server.MapPath(@"~/sysconfig/TestData.xml");
                    XmlDocument objXmlDoc = new XmlDocument();
                    objXmlDoc.Load(xmlpath);
                    XmlNode rootNode = objXmlDoc.SelectSingleNode("root");

                    //记录测试数据
                    string      xmlPathTestData   = HttpContext.Current.Server.MapPath(@"~/sysconfig/TestRecord.xml");
                    XmlDocument objXmlDocTestData = new XmlDocument();
                    objXmlDocTestData.Load(xmlPathTestData);
                    XmlNode rootTestData = objXmlDocTestData.DocumentElement;


                    SqlDb.Dcms_Cate        cate     = new SqlDb.Dcms_Cate();
                    IQuery                 query    = session.GetQuery(cate).Where(SqlDb.Dcms_Cate._CATE_MODULE_.NotEquls("guestbook").AND(SqlDb.Dcms_Cate._CATE_MANAGEURL_.NotNull()));
                    List <SqlDb.Dcms_Cate> catelist = query.GetList <SqlDb.Dcms_Cate>();

                    if (catelist.Count > 0)
                    {
                        session.BeginTrans();
                        for (int i = 0; i < catelist.Count; i++)
                        {
                            if (catelist[i].Cate_ManageUrl.Equals("baseinfo_update.aspx"))
                            {
                                XmlNode             objNode  = rootNode.ChildNodes[0];
                                XmlNode             xn       = objNode.ChildNodes[0];
                                SqlDb.Dcms_BaseInfo baseinfo = new SqlDb.Dcms_BaseInfo();
                                session.simple("DELETE FROM [Dcms_BaseInfo] WHERE [BaseInfo_CateId] IN(" + catelist[i].Cate_Id + ")");
                                baseinfo.BaseInfo_CateId   = catelist[i].Cate_Id;
                                baseinfo.BaseInfo_CateName = catelist[i].Cate_Title;
                                baseinfo.BaseInfo_Title    = catelist[i].Cate_Title;
                                baseinfo.BaseInfo_Content  = "<p>" + xn.Attributes["title"].Value + "测试内容</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                baseinfo.BaseInfo_AddTime  = DateTime.Now;
                                baseinfo.BaseInfo_State    = "1";
                                session.Create(baseinfo);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("baseinfo_list.aspx"))
                            {
                                XmlNode objNode = rootNode.ChildNodes[0];
                                XmlNode xn      = objNode.ChildNodes[0];

                                SqlDb.Dcms_BaseInfo baseinfo = new SqlDb.Dcms_BaseInfo();
                                baseinfo.BaseInfo_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    baseinfo.BaseInfo_CateName = catelist[i].Cate_Title;
                                    baseinfo.BaseInfo_Title    = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    baseinfo.BaseInfo_Content  = "<p>" + xn.Attributes["title"].Value + "测试内容" + j.ToString() + "</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                    baseinfo.BaseInfo_AddTime  = DateTime.Now;
                                    baseinfo.BaseInfo_State    = "1";
                                    session.Create(baseinfo);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(BaseInfo_Id) from Dcms_BaseInfo");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_BaseInfo");
                                        element.SetAttribute("keyColumn", "BaseInfo_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("news_update.aspx"))
                            {
                                XmlNode         objNode = rootNode.ChildNodes[1];
                                XmlNode         xn      = objNode.ChildNodes[0];
                                SqlDb.Dcms_News news    = new SqlDb.Dcms_News();
                                session.simple("DELETE FROM [Dcms_News] WHERE [News_CateId] IN(" + catelist[i].Cate_Id + ")");
                                news.News_CateId   = catelist[i].Cate_Id;
                                news.News_CateName = catelist[i].Cate_Title;
                                news.News_Title    = catelist[i].Cate_Title;
                                news.News_Content  = "<p>" + catelist[i].Cate_Title + "测试内容</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                news.News_AddTime  = DateTime.Now;
                                news.News_State    = "1";
                                session.Create(news);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("news_list.aspx"))
                            {
                                XmlNode         objNode = rootNode.ChildNodes[1];
                                XmlNode         xn      = objNode.ChildNodes[0];
                                SqlDb.Dcms_News news    = new SqlDb.Dcms_News();
                                news.News_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    news.News_CateName = catelist[i].Cate_Title;
                                    news.News_Title    = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    news.News_Content  = "<p>" + catelist[i].Cate_Title + "测试内容" + j.ToString() + "</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                    news.News_AddTime  = DateTime.Now;
                                    news.News_State    = "1";
                                    session.Create(news);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(News_Id) from Dcms_News");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_News");
                                        element.SetAttribute("keyColumn", "News_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("products_update.aspx"))
                            {
                                XmlNode             objNode  = rootNode.ChildNodes[2];
                                XmlNode             xn       = objNode.ChildNodes[0];
                                SqlDb.Dcms_Products products = new SqlDb.Dcms_Products();
                                session.simple("DELETE FROM [Dcms_Products] WHERE [Products_CateID] IN(" + catelist[i].Cate_Id + ")");
                                products.Products_CateID       = catelist[i].Cate_Id;
                                products.Products_CateName     = catelist[i].Cate_Title;
                                products.Products_Title        = catelist[i].Cate_Title;
                                products.Products_MinImage     = xn.Attributes["minimage"].Value;
                                products.Products_BigImage     = xn.Attributes["bigimage"].Value;
                                products.Products_Introduction = xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                products.Products_AddTime      = DateTime.Now;
                                products.Products_State        = "1";
                                products.Products_CodeName     = "00001";
                                products.Products_IsHot        = "1";
                                products.Products_IsNew        = "1";
                                session.Create(products);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("products_list.aspx"))
                            {
                                XmlNode             objNode  = rootNode.ChildNodes[2];
                                XmlNode             xn       = objNode.ChildNodes[0];
                                SqlDb.Dcms_Products products = new SqlDb.Dcms_Products();
                                products.Products_CateID = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    products.Products_CateName     = catelist[i].Cate_Title;
                                    products.Products_Title        = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    products.Products_MinImage     = xn.Attributes["minimage"].Value;
                                    products.Products_BigImage     = xn.Attributes["bigimage"].Value;
                                    products.Products_Introduction = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["content"].Value.Replace("[BR]", "<br /><br />");
                                    products.Products_AddTime      = DateTime.Now;
                                    products.Products_State        = "1";
                                    products.Products_CodeName     = "0000" + j.ToString();
                                    products.Products_IsHot        = "1";
                                    products.Products_IsNew        = "1";
                                    session.Create(products);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(Products_Id) from Dcms_Products");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Products");
                                        element.SetAttribute("keyColumn", "Products_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("link_update.aspx"))
                            {
                                XmlNode         objNode = rootNode.ChildNodes[3];
                                XmlNode         xn      = objNode.ChildNodes[0];
                                SqlDb.Dcms_Link link    = new SqlDb.Dcms_Link();
                                session.simple("DELETE FROM [Dcms_Link] WHERE [Link_CateId] IN(" + catelist[i].Cate_Id + ")");
                                link.Link_CateId   = catelist[i].Cate_Id;
                                link.Link_CateName = catelist[i].Cate_Title;
                                link.Link_Title    = catelist[i].Cate_Title;
                                link.Link_Url      = xn.Attributes["linkurl"].Value;
                                link.Link_AddTime  = DateTime.Now;
                                link.Link_State    = "1";
                                session.Create(link);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("link_list.aspx"))
                            {
                                XmlNode         objNode = rootNode.ChildNodes[3];
                                XmlNode         xn      = objNode.ChildNodes[0];
                                SqlDb.Dcms_Link link    = new SqlDb.Dcms_Link();
                                link.Link_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    link.Link_CateName = catelist[i].Cate_Title;
                                    link.Link_Title    = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    link.Link_Url      = xn.Attributes["linkurl"].Value;
                                    link.Link_AddTime  = DateTime.Now;
                                    link.Link_State    = "1";
                                    session.Create(link);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(link_Id) from Dcms_Link");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Link");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("down_update.aspx"))
                            {
                                XmlNode         objNode = rootNode.ChildNodes[4];
                                XmlNode         xn      = objNode.ChildNodes[0];
                                SqlDb.Dcms_Down down    = new SqlDb.Dcms_Down();
                                session.simple("DELETE FROM [Dcms_Down] WHERE [Down_CateID] IN(" + catelist[i].Cate_Id + ")");
                                down.Down_CateID    = catelist[i].Cate_Id;
                                down.Down_CateName  = catelist[i].Cate_Title;
                                down.Down_Title     = catelist[i].Cate_Title;
                                down.Down_FileType  = xn.Attributes["filetype"].Value;
                                down.Down_LocalPath = xn.Attributes["localpath"].Value;
                                down.Down_AddTime   = DateTime.Now;
                                down.Down_State     = "1";
                                session.Create(down);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("down_list.aspx"))
                            {
                                XmlNode         objNode = rootNode.ChildNodes[4];
                                XmlNode         xn      = objNode.ChildNodes[0];
                                SqlDb.Dcms_Down down    = new SqlDb.Dcms_Down();
                                down.Down_CateID = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    down.Down_CateName  = catelist[i].Cate_Title;
                                    down.Down_Title     = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    down.Down_FileType  = xn.Attributes["filetype"].Value;
                                    down.Down_LocalPath = xn.Attributes["localpath"].Value;
                                    down.Down_AddTime   = DateTime.Now;
                                    down.Down_State     = "1";
                                    session.Create(down);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(Down_Id) from Dcms_Down");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Down");
                                        element.SetAttribute("keyColumn", "Down_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("position_update.aspx"))
                            {
                                XmlNode             objNode  = rootNode.ChildNodes[5];
                                XmlNode             xn       = objNode.ChildNodes[0];
                                SqlDb.Dcms_Position position = new SqlDb.Dcms_Position();
                                session.simple("DELETE FROM [Dcms_Position] WHERE [Position_CateId] IN(" + catelist[i].Cate_Id + ")");
                                position.Position_CateId      = catelist[i].Cate_Id;
                                position.Position_CateName    = catelist[i].Cate_Title;
                                position.Position_Title       = xn.Attributes["title"].Value;
                                position.Position_Num         = xn.Attributes["num"].Value;
                                position.Position_Departments = xn.Attributes["departments"].Value;
                                position.Position_Area        = xn.Attributes["area"].Value;
                                position.Position_AddTime     = DateTime.Now;
                                position.Position_ValidTime   = Convert.ToDateTime(xn.Attributes["validtime"].Value);
                                position.Position_Conditions  = xn.Attributes["conditions"].Value.Replace("[BR]", "<br /><br />");
                                position.Position_Description = xn.Attributes["description"].Value.Replace("[BR]", "<br /><br />");
                                position.Position_Contact     = xn.Attributes["contact"].Value.Replace("[BR]", "<br /><br />");
                                position.Position_State       = "1";
                                session.Create(position);
                            }
                            if (catelist[i].Cate_ManageUrl.Equals("position_list.aspx"))
                            {
                                XmlNode             objNode  = rootNode.ChildNodes[5];
                                XmlNode             xn       = objNode.ChildNodes[0];
                                SqlDb.Dcms_Position position = new SqlDb.Dcms_Position();
                                position.Position_CateId = catelist[i].Cate_Id;
                                for (int j = 1; j < 6; j++)
                                {
                                    position.Position_CateName    = catelist[i].Cate_Title;
                                    position.Position_Title       = xn.Attributes["title"].Value + "(" + j.ToString() + ")";
                                    position.Position_Num         = xn.Attributes["num"].Value;
                                    position.Position_Departments = xn.Attributes["departments"].Value + "(" + j.ToString() + ")";
                                    position.Position_Area        = xn.Attributes["area"].Value + "(" + j.ToString() + ")";
                                    position.Position_AddTime     = DateTime.Now;
                                    position.Position_ValidTime   = Convert.ToDateTime(xn.Attributes["validtime"].Value);
                                    position.Position_Conditions  = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["conditions"].Value.Replace("[BR]", "<br /><br />");
                                    position.Position_Description = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["description"].Value.Replace("[BR]", "<br /><br />");
                                    position.Position_Contact     = "<p>测试内容" + j.ToString() + "</p>" + xn.Attributes["contact"].Value.Replace("[BR]", "<br /><br />");
                                    position.Position_State       = "1";
                                    session.Create(position);

                                    //记录测试数据
                                    string addID = session.ExecuteScalar("select max(Position_Id) from Dcms_Position");
                                    if (!string.IsNullOrEmpty(addID))
                                    {
                                        XmlElement element = objXmlDocTestData.CreateElement("data");
                                        element.SetAttribute("table", "Dcms_Position");
                                        element.SetAttribute("keyColumn", "Position_Id");
                                        element.SetAttribute("id", addID);
                                        rootTestData.AppendChild(element);
                                    }
                                }
                            }
                        }
                        session.CommitTrans();
                        //记录测试数据
                        objXmlDocTestData.Save(xmlPathTestData);
                        return("生成成功!");
                    }

                    return("false");
                }

                catch (Exception ex)
                {
                    session.RollbackTrans();
                    return("生成失败!" + ex.Message);
                }
            }
        }