Example #1
0
        /// <summary>
        /// 编辑一条数据
        /// </summary>
        /// <returns>"true"/"false"</returns>
        private string doUpdate()
        {
            try
            {
                //int newsid = IRequest.GetQueryInt("newsid", 0);
                int newsid = IRequest.GetFormInt("News_Id", 0);
                if (newsid > 0)
                {
                    using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                    {
                        SqlDb.Dcms_News         news     = new SqlDb.Dcms_News();
                        IQuery                  query    = session.GetQuery(news).Where(SqlDb.Dcms_News._NEWS_ID_.EqulesExp(newsid));
                        IList <SqlDb.Dcms_News> newslist = query.GetList <SqlDb.Dcms_News>();
                        if (newslist.Count > 0)
                        {
                            news = newslist[0];
                            UpdateModelByForm(news, Request.Form);

                            session.Update(news);
                            return("true");
                        }
                    }
                }
                return("false");
            }
            catch
            {
                return("false");
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            iframeid = IRequest.GetQueryString("iframeid");
            int CateId = IRequest.GetQueryInt("cateid", 0);
            int Id = IRequest.GetQueryInt("id", -1);
            string cateName = IRequest.GetQueryString("catename");
            if (CateId > 0)
            {
                using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                {
                    SqlDb.Dcms_Cate cate = new SqlDb.Dcms_Cate();
                    cate.Cate_Id = CateId;
                    IQuery query = session.GetQuery(cate).Where(SqlDb.Dcms_Cate._CATE_ID_.EqulesExp());
                    List<SqlDb.Dcms_Cate> cateList = query.GetList<SqlDb.Dcms_Cate>();
                    if (cateList.Count > 0)
                    {
                        cateName = cateList[0].Cate_Title;
                        News_CateName.Value = cateName;
                        News_CateId.Value = CateId.ToString();
                        News_CateName.Value = cateName;
                    }
                }
            }
            if (Id == 0)
            {
                this.Page.Title = "新建" + cateName;
                this.lit_Title.Text = "新建" + cateName;
                News_Id.Value = "0";
            }
            else if (Id > 0)
            {

                this.Page.Title = "编辑" + cateName;
                this.lit_Title.Text = "编辑" + cateName;
                lit_id.Text = Id.ToString();
                News_Id.Value = Id.ToString();
            }
            else
            {
                int thisId = 0;
                using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                {
                    SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                    news.News_CateId = CateId;
                    IQuery query = session.GetQuery(news).Where(SqlDb.Dcms_News._NEWS_CATEID_.EqulesExp());
                    IList<SqlDb.Dcms_News> newslist = query.GetList<SqlDb.Dcms_News>();
                    if (newslist.Count > 0)
                    {
                        thisId = newslist[0].News_Id;
                    }
                }
                this.Page.Title = "编辑" + cateName;
                this.lit_Title.Text = "编辑" + cateName;
                lit_id.Text = thisId.ToString();
                News_Id.Value = thisId.ToString();
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            iframeid = IRequest.GetQueryString("iframeid");
            int    CateId   = IRequest.GetQueryInt("cateid", 0);
            int    Id       = IRequest.GetQueryInt("id", -1);
            string cateName = IRequest.GetQueryString("catename");

            if (CateId > 0)
            {
                using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                {
                    SqlDb.Dcms_Cate cate = new SqlDb.Dcms_Cate();
                    cate.Cate_Id = CateId;
                    IQuery query = session.GetQuery(cate).Where(SqlDb.Dcms_Cate._CATE_ID_.EqulesExp());
                    List <SqlDb.Dcms_Cate> cateList = query.GetList <SqlDb.Dcms_Cate>();
                    if (cateList.Count > 0)
                    {
                        cateName            = cateList[0].Cate_Title;
                        News_CateName.Value = cateName;
                        News_CateId.Value   = CateId.ToString();
                        News_CateName.Value = cateName;
                    }
                }
            }
            if (Id == 0)
            {
                this.Page.Title     = "新建" + cateName;
                this.lit_Title.Text = "新建" + cateName;
                News_Id.Value       = "0";
            }
            else if (Id > 0)
            {
                this.Page.Title     = "编辑" + cateName;
                this.lit_Title.Text = "编辑" + cateName;
                lit_id.Text         = Id.ToString();
                News_Id.Value       = Id.ToString();
            }
            else
            {
                int thisId = 0;
                using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                {
                    SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                    news.News_CateId = CateId;
                    IQuery query = session.GetQuery(news).Where(SqlDb.Dcms_News._NEWS_CATEID_.EqulesExp());
                    IList <SqlDb.Dcms_News> newslist = query.GetList <SqlDb.Dcms_News>();
                    if (newslist.Count > 0)
                    {
                        thisId = newslist[0].News_Id;
                    }
                }
                this.Page.Title     = "编辑" + cateName;
                this.lit_Title.Text = "编辑" + cateName;
                lit_id.Text         = thisId.ToString();
                News_Id.Value       = thisId.ToString();
            }
        }
Example #4
0
        /// <summary>
        /// 插入一条数据
        /// </summary>
        /// <returns>"true"/"false"</returns>
        private string doInsert()
        {
            //try
            //{
            using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
            {
                SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                news.News_AddTime = DateTime.Now;
                UpdateModelByForm(news, Request.Form);

                session.Create(news);
                return("true");
            }

            //}
            //catch
            //{
            //    return "false";
            //}
        }
Example #5
0
        /// <summary>
        /// 编辑一条数据
        /// </summary>
        /// <returns>"true"/"false"</returns>
        private string doUpdate()
        {
            try
            {
                //int newsid = IRequest.GetQueryInt("newsid", 0);
                int newsid = IRequest.GetFormInt("News_Id", 0);
                if (newsid > 0)
                {
                    using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                    {
                        SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                        IQuery query = session.GetQuery(news).Where(SqlDb.Dcms_News._NEWS_ID_.EqulesExp(newsid));
                        IList<SqlDb.Dcms_News> newslist = query.GetList<SqlDb.Dcms_News>();
                        if (newslist.Count > 0)
                        {
                            news = newslist[0];
                            UpdateModelByForm(news, Request.Form);

                            session.Update(news);
                            return "true";
                        }
                    }
                }
                return "false";
            }
            catch
            {
                return "false";
            }
        }
Example #6
0
        /// <summary>
        /// 按页取数据
        /// </summary>
        /// <returns>json</returns>
        private string doSelect()
        {
            StringBuilder sb = new StringBuilder();
            //取Grid提交来的数据开始
            //int uploadId = IRequest.GetQueryInt("id", 0);
            int rp = IRequest.GetFormInt("rp", 10);
            int page = IRequest.GetFormInt("page", 1);
            string keyword = Utils.chkSQL(IRequest.GetFormString("query"));
            string qtype = IRequest.GetFormString("qtype");
            int cateid = IRequest.GetQueryInt("cateid", 0);
            //string path = getUploadPathByUploadId(uploadId).Replace("\\", "/");
            //取Grid提交来的数据结束
            using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
            {
                SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                //创建查询
                if (keyword.Length > 0)
                {
                    news.News_Title = keyword;
                }
                IQuery query = session.GetQuery(news);

                if (keyword.Length > 0)
                {
                    if (cateid > 0)
                    {
                        query.Where(SqlDb.Dcms_News._NEWS_TITLE_.Like('%', keyword, '%').AND(SqlDb.Dcms_News._NEWS_CATEID_.EqulesExp(cateid)));
                    }
                    else
                    {
                        query.Where(SqlDb.Dcms_News._NEWS_TITLE_.Like('%', keyword, '%'));
                    }
                }
                else
                {
                    if (cateid > 0)
                    {
                        query.Where(SqlDb.Dcms_News._NEWS_CATEID_.EqulesExp(cateid));
                    }
                }
                query.OrderBy(SqlDb.Dcms_News._NEWS_ID_, Direction.DESC);
                //取总记录
                int totalCount = query.Count();
                List<SqlDb.Dcms_News> newsList = query.GetList<SqlDb.Dcms_News>(page, rp);
                //Json格式
                sb.Append("{\n");
                sb.Append("\"page\":" + page.ToString() + ",\n");
                sb.Append("\"total\":" + totalCount.ToString() + ",\n");
                sb.Append("\"rows\": [\n");
                for (int i = 0; i < newsList.Count; i++)
                {
                    string state = (newsList[i].News_State == "1") ? "显示" : "关闭";
                    sb.Append("{");
                    sb.Append(string.Format("\"id\":\"{0}\",\"cell\":[\"{1}\",\"{2}\",\"{3}\",\"{4}\"]", newsList[i].News_Id.ToString(), newsList[i].News_Id.ToString(), FormatJsonData(newsList[i].News_Title.ToString()), state, newsList[i].News_AddTime.ToString("yyyy/MM/dd")));
                    if ((i + 1) == newsList.Count)
                    {
                        sb.Append("}\n");
                    }
                    else
                    {
                        sb.Append("},\n");
                    }
                }
                sb.Append("]\n");
                sb.Append("}");
            }

            return sb.ToString();
        }
Example #7
0
        /// <summary>
        /// 插入一条数据
        /// </summary>
        /// <returns>"true"/"false"</returns>
        private string doInsert()
        {
            //try
            //{
                using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
                {
                    SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                    news.News_AddTime = DateTime.Now;
                    UpdateModelByForm(news, Request.Form);

                    session.Create(news);
                    return "true";
                }

            //}
            //catch
            //{
            //    return "false";
            //}
        }
Example #8
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;
                }
            }
        }
Example #9
0
        /// <summary>
        /// 按页取数据
        /// </summary>
        /// <returns>json</returns>
        private string doSelect()
        {
            StringBuilder sb = new StringBuilder();
            //取Grid提交来的数据开始
            //int uploadId = IRequest.GetQueryInt("id", 0);
            int    rp      = IRequest.GetFormInt("rp", 10);
            int    page    = IRequest.GetFormInt("page", 1);
            string keyword = Utils.chkSQL(IRequest.GetFormString("query"));
            string qtype   = IRequest.GetFormString("qtype");
            int    cateid  = IRequest.GetQueryInt("cateid", 0);

            //string path = getUploadPathByUploadId(uploadId).Replace("\\", "/");
            //取Grid提交来的数据结束
            using (ISession session = dbContext.Current().GetContext("SqlDb").GetSession())
            {
                SqlDb.Dcms_News news = new SqlDb.Dcms_News();
                //创建查询
                if (keyword.Length > 0)
                {
                    news.News_Title = keyword;
                }
                IQuery query = session.GetQuery(news);

                if (keyword.Length > 0)
                {
                    if (cateid > 0)
                    {
                        query.Where(SqlDb.Dcms_News._NEWS_TITLE_.Like('%', keyword, '%').AND(SqlDb.Dcms_News._NEWS_CATEID_.EqulesExp(cateid)));
                    }
                    else
                    {
                        query.Where(SqlDb.Dcms_News._NEWS_TITLE_.Like('%', keyword, '%'));
                    }
                }
                else
                {
                    if (cateid > 0)
                    {
                        query.Where(SqlDb.Dcms_News._NEWS_CATEID_.EqulesExp(cateid));
                    }
                }
                query.OrderBy(SqlDb.Dcms_News._NEWS_ID_, Direction.DESC);
                //取总记录
                int totalCount = query.Count();
                List <SqlDb.Dcms_News> newsList = query.GetList <SqlDb.Dcms_News>(page, rp);
                //Json格式
                sb.Append("{\n");
                sb.Append("\"page\":" + page.ToString() + ",\n");
                sb.Append("\"total\":" + totalCount.ToString() + ",\n");
                sb.Append("\"rows\": [\n");
                for (int i = 0; i < newsList.Count; i++)
                {
                    string state = (newsList[i].News_State == "1") ? "显示" : "关闭";
                    sb.Append("{");
                    sb.Append(string.Format("\"id\":\"{0}\",\"cell\":[\"{1}\",\"{2}\",\"{3}\",\"{4}\"]", newsList[i].News_Id.ToString(), newsList[i].News_Id.ToString(), FormatJsonData(newsList[i].News_Title.ToString()), state, newsList[i].News_AddTime.ToString("yyyy/MM/dd")));
                    if ((i + 1) == newsList.Count)
                    {
                        sb.Append("}\n");
                    }
                    else
                    {
                        sb.Append("},\n");
                    }
                }
                sb.Append("]\n");
                sb.Append("}");
            }

            return(sb.ToString());
        }
Example #10
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);
                }
            }
        }