/// <summary>
        /// 根据菜单子节点或父节点获得 菜单下的分类信息。
        /// </summary>
        /// <param name="context"></param>
        public void GetPageListForMenuId(HttpContext context)
        {
            HttpRequest request = context.Request;

            PMSModel.JsonModel jsonModel = new PMSModel.JsonModel();
            try
            {
                HashtableCustom ht = new HashtableCustom();
                ht.Add_Key(PageIndex, request);
                ht.Add_Key(PageSize, request);
                ht.Add_Key(isPush, request);
                if (!Null_Check(request, isAll))
                {
                    ht.Add(isAll, Convert.ToBoolean(request[isAll]));
                }
                if (!Null_Check(request, MenuId))
                {
                    int    mid  = Convert.ToInt32(request[MenuId]);
                    string pids = GetMenuChild(mid);
                    if (!string.IsNullOrWhiteSpace(pids))
                    {
                        ht.Add(MenuId, pids);
                        jsonModel = BllAdvert.GetAdvertData(ht);
                    }
                }
                else
                {
                    jsonModel = BllAdvert.GetAdvertData(ht);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg  = ex.Message,
                    retData = "",
                    status  = "no"
                };
            }
            finally
            {
                context.Response.Write("{\"result\":" + Hander_C.jss.Serialize(jsonModel) + "}");
            }
        }
        /// <summary>
        /// 统计文章访问率
        /// </summary>
        /// <param name="context"></param>
        public void GetStatistics(HttpContext context)
        {
            PMSModel.JsonModel jsonModel = new PMSModel.JsonModel();
            HttpRequest        request   = context.Request;

            try
            {
                HashtableCustom ht = new HashtableCustom();
                ht.Add_Key(PageIndex, request);
                ht.Add_Key(PageSize, request);
                string where = string.Empty;
                ht.Add(TableName, Advertising);

                where += " and IsDelete =" + (int)PMSUtility.SysStatus.正常;

                string notIn    = string.Empty;
                string _NotItem = Convert.ToString(request["NotItem"]);
                if (!string.IsNullOrEmpty(_NotItem))
                {
                    notIn = string.Format(" and MenuId not in ({0})", _NotItem);
                }

                if (!Null_Check(request, isPush))
                {
                    where += " and isPush=" + request[isPush].SafeToString() + notIn;
                }
                ht.Add(Order, "ClickNum desc ");
                jsonModel = BllAdvert.GetPage(ht, true, where);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg  = ex.Message,
                    retData = "",
                    status  = "no"
                };
            }
            finally
            {
                context.Response.Write("{\"result\":" + Hander_C.jss.Serialize(jsonModel) + "}");
            }
        }
Exemple #3
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            HashtableCustom ht = new HashtableCustom();

            ht.Add("PageIndex", "1");
            ht.Add("PageSize", "7");
            ht.Add("ImgUrl", "/Common.ashx");

            ht.Add("IsDelete", "0");
            ht.Add("MenuIdList", "11,20,35,45");



            Dictionary <string, object> diclist = new Dictionary <string, object>();

            PMSModel.JsonModel jsonModel = null;
            try
            {
                var menuids = ht["MenuIdList"].ToString().Split(new char[] { ',' });
                if (menuids.Length > 0)
                {
                    foreach (var item in menuids)
                    {
                        var moder = BllAdvert.GetDataInfo(ht);
                        diclist.Add(item, moder.retData);
                    }
                }
            }
            catch (Exception ex)
            {
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg = ex.Message,
                };
            }
        }
        /// <summary>
        /// 新闻导读上移、下移
        /// </summary>
        /// <param name="context"></param>
        public void UpOrDownAdvert(HttpContext context)
        {
            HttpRequest request = context.Request;

            PMSModel.JsonModel jsonModel = new PMSModel.JsonModel();
            try
            {
                HashtableCustom ht = new HashtableCustom();
                ht.Add_Key(upOrdown, request);
                if (!Null_Check(request, MenuId))
                {
                    ht.Add(MenuId, GetMenuChild(Convert.ToInt32(request[MenuId])));
                }
                else
                {
                    ht.Add_Key(MenuId, request);
                }


                ht.Add_Key(isPush, request);
                ht.Add_Key(Id, request);
                ht.Add_Key(SortId, request);
                jsonModel = BllAdvert.UpdateAdertSort(ht);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg = ex.Message,
                };
            }
            finally
            {
                context.Response.Write("{\"result\":" + Hander_C.jss.Serialize(jsonModel) + "}");
            }
        }
        public void GetMenuOwnLevel(HttpContext context)
        {
            PMSModel.JsonModel jsonModel = null;
            PMSModel.JsonModel Model     = null;
            HttpRequest        request   = context.Request;

            try
            {
                if (menu == null)
                {
                    HashtableCustom ht1 = new HashtableCustom();

                    ht1.Add(TableName, PortalTreeData);
                    string where = string.Empty;
                    bool isPage = false;
                    if (!string.IsNullOrWhiteSpace(request["MenuLevelIndex"]))
                    {
                        where += " and MenuLevelIndex=" + request["MenuLevelIndex"];
                    }
                    if (!string.IsNullOrWhiteSpace(request[Display]))
                    {
                        where += " and Display=" + request[Display];
                    }
                    if (!string.IsNullOrWhiteSpace(request[IsDelete]))
                    {
                        where += " and IsDelete=" + request[IsDelete];
                    }

                    ht1.Add(Order, " SortId desc ,CreateTime desc,ShowIndexSort desc ");
                    //获取菜单数据
                    Model = BllPTDS.GetPage(ht1, isPage, where);
                    List <Dictionary <string, object> > dic  = Model.retData as List <Dictionary <string, object> >;
                    List <MenuLevelModel> menuLevelModelList = new List <MenuLevelModel>();
                    foreach (var item in dic)
                    {
                        #region 获取数据或IDs

                        HashtableCustom ht2 = new HashtableCustom();
                        ht2.Add_Key(Display, request);
                        ht2.Add_Key(IsDelete, request);
                        ht2.Add(TableName, PortalTreeData);
                        ht2.Add(Order, " SortId asc ,CreateTime desc ");
                        string where2 = string.Empty;

                        if (!string.IsNullOrWhiteSpace(request[Display]))
                        {
                            where2 += " and Display=" + request[Display];
                        }
                        if (!string.IsNullOrWhiteSpace(request[IsDelete]))
                        {
                            where2 += " and IsDelete=" + request[IsDelete];
                        }

                        //跳级获取,listChild 如果为null 说明只有两级(获取三级数据)
                        where2 = string.Format(" and Id in(select pid from PortalTreeData where pid in(select id from PortalTreeData where PId ={0}) group by PId)", item[Id]);
                        ht2.Add(MenuIds, item[Id]);
                        var moder = BllPTDS.GetPage(ht2, isPage, where2);

                        string ids = BllAdvert.GetIDS(ht2);

                        #endregion

                        //菜单级别数据(携带跳级数据)
                        MenuLevelModel menLevelModel = null;
                        if (Convert.ToString(moder.retData) != string.Empty)
                        {
                            menLevelModel = new MenuLevelModel()
                            {
                                ChildList = moder.retData, IsMore2Level = true
                            };
                        }
                        else
                        {
                            menLevelModel = new MenuLevelModel()
                            {
                                IsMore2Level = false
                            };
                        }

                        menLevelModel.Id_Bottom_List = ids;

                        #region 实体属性

                        menLevelModel.Id         = Convert.ToInt32(item[Id]);
                        menLevelModel.Name       = Convert.ToString(item[Name]);
                        menLevelModel.CreateTime = Convert.ToDateTime(item[CreateTime]);

                        menLevelModel.Creator     = Convert.ToString(item["Creator"]);
                        menLevelModel.PId         = Convert.ToInt32(item["PId"]);
                        menLevelModel.BeforeUrl   = Convert.ToString(item["BeforeUrl"]);
                        menLevelModel.BeforeAfter = Convert.ToInt32(item["BeforeAfter"]);
                        menLevelModel.AfterUrl    = Convert.ToString(item["AfterUrl"]);
                        menLevelModel.SortId      = Convert.ToInt32(item[SortId]);

                        menLevelModel.DisplayCount   = Convert.ToInt32(item["DisplayCount"]);
                        menLevelModel.DisplayType    = Convert.ToString(item["DisplayType"]);
                        menLevelModel.MenuLevelIndex = Convert.ToInt32(item["MenuLevelIndex"]);
                        menLevelModel.ShowIndexSort  = Convert.ToInt32(item["ShowIndexSort"]);


                        #endregion

                        menuLevelModelList.Add(menLevelModel);
                    }

                    jsonModel = new PMSModel.JsonModel()
                    {
                        retData = menuLevelModelList, errMsg = "success"
                    };

                    menu = jsonModel;
                }
                else
                {
                    jsonModel = menu;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg  = ex.Message,
                    retData = "",
                    status  = "no"
                };
            }
            finally
            {
                if (jsonModel == null)
                {
                    jsonModel = new JsonModel();
                }
                context.Response.Write("{\"result\":" + Hander_C.jss.Serialize(jsonModel) + "}");
            }
        }
        /// <summary>
        /// 不需要传IDS和PageSize(根据菜单获取所有数据)
        /// </summary>
        /// <param name="context"></param>
        public void GetMenusItemsData(HttpContext context)
        {
            HttpRequest     request = context.Request;
            HashtableCustom ht1     = new HashtableCustom();

            List <IndexModelEntity> IndexModelEntityList = new List <IndexModelEntity>();

            PMSModel.JsonModel jsonModel = new PMSModel.JsonModel();
            PMSModel.JsonModel Model     = new PMSModel.JsonModel();
            try
            {
                #region 获取首页导读的一级菜单(包括了三级的菜单)||获取指定菜单ID的二级菜单(通过一级菜单的ID去获取)

                ht1.Add(TableName, PortalTreeData);
                string where = string.Empty;
                bool isPage = false;

                if (!string.IsNullOrWhiteSpace(request[Display]))
                {
                    where += " and Display=" + request[Display];
                }
                if (!string.IsNullOrWhiteSpace(request[IsDelete]))
                {
                    where += " and IsDelete=" + request[IsDelete];
                }
                if (!string.IsNullOrWhiteSpace(request[IsShowIndex]))
                {
                    where += " and IsShowIndex=" + request[IsShowIndex];
                }
                else if (!string.IsNullOrWhiteSpace(request[MenuIds]))
                {
                    where += string.Format(" and PId in({0})  ", request[MenuIds]);
                }
                //获取显示在首页导读工作区域的菜单
                ht1.Add(Order, " ShowIndexSort asc, SortId desc ,CreateTime desc ");
                Model = BllPTDS.GetPage(ht1, isPage, where);

                #endregion

                List <Dictionary <string, object> > dic = Model.retData as List <Dictionary <string, object> >;
                foreach (var item in dic)
                {
                    IndexModelEntity indexModielEntity = new IndexModelEntity();

                    #region 实体属性

                    indexModielEntity.Id         = Convert.ToInt32(item[Id]);
                    indexModielEntity.Name       = Convert.ToString(item[Name]);
                    indexModielEntity.CreateTime = Convert.ToDateTime(item[CreateTime]);

                    indexModielEntity.Creator     = Convert.ToString(item["Creator"]);
                    indexModielEntity.PId         = Convert.ToInt32(item["PId"]);
                    indexModielEntity.BeforeUrl   = Convert.ToString(item["BeforeUrl"]);
                    indexModielEntity.BeforeAfter = Convert.ToInt32(item["BeforeAfter"]);
                    indexModielEntity.AfterUrl    = Convert.ToString(item["AfterUrl"]);
                    indexModielEntity.SortId      = Convert.ToInt32(item[SortId]);


                    indexModielEntity.DisplayCount   = Convert.ToInt32(item["DisplayCount"]);
                    indexModielEntity.DisplayType    = Convert.ToString(item["DisplayType"]);
                    indexModielEntity.MenuLevelIndex = Convert.ToInt32(item["MenuLevelIndex"]);
                    indexModielEntity.ShowIndexSort  = Convert.ToInt32(item["ShowIndexSort"]);


                    #endregion

                    #region 获取导读数据(后台获取限制数据的条数)

                    int displayCount = 0;
                    if (request["DisplayCount"] != null)
                    {
                        displayCount = Convert.ToInt32(request["DisplayCount"]);
                    }
                    else
                    {
                        displayCount = Convert.ToInt32(item["DisplayCount"]);
                    }

                    HashtableCustom ht2 = new HashtableCustom();
                    ht2.Add(MenuIds, item[Id]);
                    ht2.Add(MenuId, item[Id]);
                    ht2.Add(PageSize, displayCount);
                    ht2.Add_Key(IsDelete, request);
                    ht2.Add_Key(isPush, request);
                    ht2.Add(PageIndex, 1);

                    if (!string.IsNullOrWhiteSpace(request[IsShowIndex]))
                    {
                        //获取三级数据,没有则获取二级数据
                        var moder = BllAdvert.GetDataMore_LevelInfo(ht2);
                        indexModielEntity.ListData = moder.retData;
                    }
                    else if (!string.IsNullOrWhiteSpace(request[MenuIds]))
                    {
                        //获取直接二级数据,没有则获取二级数据
                        var moder = BllAdvert.GetAdvertData(ht2);
                        indexModielEntity.ListData = moder.retData;
                    }



                    #endregion

                    IndexModelEntityList.Add(indexModielEntity);
                }
                jsonModel = new PMSModel.JsonModel()
                {
                    retData = IndexModelEntityList, errMsg = "success"
                };
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg = ex.Message,
                };
            }
            finally
            {
                context.Response.Write("{\"result\":" + Hander_C.jss.Serialize(jsonModel) + "}");
            }
        }
        /// <summary>
        /// 获得新闻或菜单下的分类信息。
        /// </summary>
        /// <param name="context"></param>
        public void GetPageList(HttpContext context)
        {
            HttpRequest request = context.Request;

            PMSModel.JsonModel jsonModel = null;
            HashtableCustom    ht        = new HashtableCustom();

            try
            {
                bool is_Page = true;
                bool is_All  = false;

                ht.Add_Key(PageIndex, request);
                ht.Add_Key(PageSize, request);
                if (!Null_Check(request, isPage))
                {
                    is_Page = Convert.ToBoolean(request[isPage]);
                }
                if (!Null_Check(request, isAll))
                {
                    is_All = Convert.ToBoolean(request[isAll]);
                }
                if (is_All)
                {
                    ht.Add_Key(MenuId, request);
                    ht.Add(IsDelete, (int)PMSUtility.SysStatus.正常);
                    ht.Add_Key(isPush, request);
                    jsonModel = BllAdvert.GetAdvertPageList(ht);
                }
                else
                {
                    ht.Add(TableName, Advertising);
                    string where = string.Empty;
                    if (!Null_Check(request, MenuId))
                    {
                        where += " and [MenuId]=" + request[MenuId];
                    }
                    where += " and IsDelete =" + (int)PMSUtility.SysStatus.正常;
                    if (!Null_Check(request, isPush))
                    {
                        where += " and isPush=" + request[isPush].SafeToString();
                    }
                    if (!Null_Check(request, MenuIds))
                    {
                        where += " and [MenuId] in (" + request[MenuIds].SafeToString() + ")";
                    }
                    if (!Null_Check(request, ImageUrl))
                    {
                        where += " and(ImageUrl is not null and ImageUrl != '')";
                    }
                    ht.Add(Order, " MenuId asc,SortId desc ,CreateTime desc ");
                    jsonModel = BllAdvert.GetPage(ht, is_Page, where);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                jsonModel = new PMSModel.JsonModel()
                {
                    errMsg  = ex.Message,
                    retData = "",
                    status  = "no"
                };
            }
            finally
            {
                if (jsonModel == null)
                {
                    jsonModel = new PMSModel.JsonModel();
                }
                ht.Clear();
                string js = Hander_C.jss.Serialize(jsonModel);
                context.Response.Write("{\"result\":" + js + "}");
            }
        }