Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string paraFID = context.Request["FID"];            //读取参数PageSize

            if (paraFID != null && paraFID.Trim() == "HomePic") //中心概括界面
            {
                Cultural.BLL.HomeImg homeBll = new Cultural.BLL.HomeImg();
                string paraImgDesc           = context.Request["ImgDesc"] == null ? "" : context.Request["ImgDesc"]; //读取参数图片描述
                string paraImgURL            = context.Request["ImgURL"] == null ? "" : context.Request["ImgURL"];   //读取参数图片路径
                if (paraImgURL != null && paraImgURL.ToString().Trim() != "")
                {
                    try
                    {
                        Cultural.Model.HomeImg homeImg = new Cultural.Model.HomeImg();
                        homeImg.ImgDesc = CommonFun.ClearHtml(paraImgDesc);
                        homeImg.ImgURL  = paraImgURL;
                        homeImg.Status  = "1";
                        homeBll.Add(homeImg);
                    }
                    catch
                    {
                        context.Response.Write(JsonHelper.Serialize("error"));
                    }
                }
                context.Response.Write(JsonHelper.Serialize("success"));
            }
            else if (paraFID != null && paraFID.Trim() == "DownInfo")
            {
                string Title   = context.Request["Title"] == null ? "" : context.Request["Title"];
                string Desc    = context.Request["Desc"] == null ? "" : context.Request["Desc"];
                int    BoardID = context.Request["BoardID"] == null ? 0 : int.Parse(context.Request["BoardID"]);
                int    Author  = context.Request["Author"] == null ? 0 : int.Parse(context.Request["Author"]);
                Cultural.BLL.DownCenter   downCBll   = new Cultural.BLL.DownCenter();
                Cultural.Model.DownCenter downCenter = new Cultural.Model.DownCenter();
                downCenter.Author    = Author;
                downCenter.BoardID   = BoardID;
                downCenter.DownDesc  = Desc;
                downCenter.DownTitle = Title;
                downCenter.PubTime   = string.Format("{0}-{1}-{2} {3}:{4}", DateTime.Now.Year, DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), DateTime.Now.Hour.ToString().PadLeft(2, '0'), DateTime.Now.Minute.ToString().PadLeft(2, '0'));
                downCenter.Status    = "1";
                try
                {
                    List <Cultural.Model.DownCenter> tdList = new List <Cultural.Model.DownCenter>();
                    tdList = downCBll.GetModelList(string.Format(" DownTitle='{0}' ", downCenter.DownTitle));
                    if (tdList != null && tdList.Count > 0)
                    {
                        context.Response.Write(JsonHelper.Serialize("error"));
                    }
                    else
                    {
                        downCBll.Add(downCenter);
                        List <Cultural.Model.DownCenter> dList = new List <Cultural.Model.DownCenter>();
                        dList = downCBll.GetModelList(string.Format(" Author={0} and BoardID={1} and  DownTitle='{2}' order by PubTime desc ", downCenter.Author, downCenter.BoardID, downCenter.DownTitle));
                        if (dList != null && dList.Count > 0)
                        {
                            context.Response.Write(JsonHelper.Serialize(dList[0].DownID));
                        }
                        else
                        {
                            context.Response.Write(JsonHelper.Serialize("error"));
                        }
                    }
                }
                catch
                {
                    context.Response.Write(JsonHelper.Serialize("error"));
                }
            }
            else if (paraFID != null && paraFID.Trim() == "DownFile")
            {
                string FileOriName = context.Request["FileOriName"] == null ? "" : context.Request["FileOriName"];
                string FilePath    = context.Request["FilePath"] == null ? "" : context.Request["FilePath"];
                int    DownID      = context.Request["DownID"] == null ? 0 : int.Parse(context.Request["DownID"]);
                if (DownID != 0)
                {
                    Cultural.BLL.DownFile   downFBll = new Cultural.BLL.DownFile();
                    Cultural.Model.DownFile downFile = new Cultural.Model.DownFile();
                    downFile.DownID      = DownID;
                    downFile.FileOriName = FileOriName;
                    downFile.FilePath    = FilePath;
                    downFile.Status      = "1";
                    try
                    {
                        downFBll.Add(downFile);
                        context.Response.Write(JsonHelper.Serialize("success"));
                    }
                    catch
                    {
                        context.Response.Write(JsonHelper.Serialize("error"));
                    }
                }
            }
            else
            {
                context.Response.Write(JsonHelper.Serialize("error"));
            }
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            Cultural.BLL.Information infoBLL = new Cultural.BLL.Information();
            context.Response.ContentType = "text/plain";
            string paraFID = context.Request["FID"];                                                                      //读取参数PageSize

            if (paraFID != null && paraFID.Trim() == "NL")                                                                //列表界面
            {
                int      paraIndex   = context.Request["Index"] == null ? 1 : int.Parse(context.Request["Index"]);        //读取参数PageSize
                int      paraSize    = context.Request["PageSize"] == null ? 10 : int.Parse(context.Request["PageSize"]); //读取参数PageSize
                string   paraBoardID = context.Request["BoardID"] == null ? "0" : context.Request["BoardID"].ToString();  //读取参数
                NewsInfo newsInfo    = new NewsInfo();
                newsInfo.Info     = infoBLL.DataTableToList(infoBLL.GetListByPage(string.Format(" BoardID={0} and Status!='0' ", paraBoardID), " Weight desc,PubTime desc ", (paraIndex - 1) * paraSize, paraIndex * paraSize).Tables[0]);
                newsInfo.TotalNum = infoBLL.GetRecordCount(string.Format(" BoardID={0} and Status!='0' ", paraBoardID));
                newsInfo.BoardID  = paraBoardID;
                for (int i = 0; i < newsInfo.Info.Count; i++)
                {
                    newsInfo.Info[i].Content = newsInfo.Info[i].Content == null ? "" : Maticsoft.Common.CommonFun.ClearHtml(newsInfo.Info[i].Content).Length > 230 ? Maticsoft.Common.CommonFun.ClearHtml(newsInfo.Info[i].Content).Substring(0, 229) + "…" :CommonFun.ClearHtml(newsInfo.Info[i].Content);
                }
                context.Response.Write(JsonHelper.Serialize(newsInfo));
            }
            else if (paraFID != null && paraFID.Trim() == "ND")                                            //详细界面
            {
                int paraID = context.Request["InfoID"] == null ? 1 : int.Parse(context.Request["InfoID"]); //读取参数PageSize
                if (paraID != null && paraID.ToString().Trim() != "")
                {
                    Cultural.Model.Information info = new Cultural.Model.Information();
                    info = infoBLL.GetModel(paraID);
                    NewsInfo newsInfo = new NewsInfo();
                    newsInfo.Info = new List <Cultural.Model.Information>();
                    if (info != null)
                    {
                        newsInfo.Info.Add(info);
                        //阅读次数更新
                        info.ReadNum += 1;
                        infoBLL.Update(info);
                        Cultural.BLL.Member memBll = new Cultural.BLL.Member();
                        newsInfo.Author = memBll.GetModel(int.Parse(info.Author.ToString().Trim())).MembName;
                        Cultural.BLL.Board   boardBll = new Cultural.BLL.Board();
                        Cultural.Model.Board board    = new Cultural.Model.Board();
                        board = boardBll.GetModel(int.Parse(info.BoardID.ToString()));
                        if (board != null && board.ParentID == 0)
                        {
                            newsInfo.BoardID   = board.BoardID.ToString();
                            newsInfo.BoardName = board.BoardName;
                            newsInfo.BName     = "";
                        }
                        else if (board != null && board.ParentID != 0)
                        {
                            Cultural.Model.Board board2 = new Cultural.Model.Board();
                            board2 = boardBll.GetModel(int.Parse(board.ParentID.ToString()));
                            if (board2 != null)
                            {
                                newsInfo.BoardID   = board2.BoardID.ToString();
                                newsInfo.BoardName = board2.BoardName;
                                newsInfo.BName     = board.BoardName;
                            }
                            else
                            {
                                newsInfo.BoardID   = board.BoardID.ToString();
                                newsInfo.BoardName = board.BoardName;
                                newsInfo.BName     = "";
                            }
                        }
                        else
                        {
                            newsInfo.BoardID   = board.BoardID.ToString();
                            newsInfo.BoardName = board.BoardName;
                            newsInfo.BName     = "";
                        }
                    }
                    context.Response.Write(JsonHelper.Serialize(newsInfo));
                }
                else
                {
                    context.Response.Write(JsonHelper.Serialize("error"));
                }
            }
            else if (paraFID != null && paraFID.Trim() == "CND")                                                  //中心概括界面  邹瑶修改20140225
            {
                int      paraID   = context.Request["InfoID"] == null ? 1 : int.Parse(context.Request["InfoID"]); //读取参数PageSize
                NewsInfo newsInfo = new NewsInfo();
                if (paraID != null && paraID.ToString().Trim() != "")
                {
                    newsInfo.Info = infoBLL.GetModelList(string.Format(" BoardID ={0} and  Status!='0' order by Weight desc,PubTime desc  ", paraID));
                }
                context.Response.Write(JsonHelper.Serialize(newsInfo));
            }
            else
            {
                context.Response.Write(JsonHelper.Serialize("error"));
            }
        }