예제 #1
0
        /// <summary>
        /// 获取客户端首页所有配置信息
        /// </summary>
        public string GetHomePageConfigInfo()
        {
            var responseData = new ResponseData();

            try
            {
                var homeBll  = new MobileHomeBLL(this.CurrentUserInfo);
                var homeList = homeBll.QueryByEntity(new MobileHomeEntity {
                    CustomerId = this.CurrentUserInfo.ClientID
                }, null);

                if (homeList != null && homeList.Length > 0)
                {
                    var homeEntity = homeList.FirstOrDefault();

                    var adAreaBll = new MHAdAreaBLL(this.CurrentUserInfo);
                    var content   = new GetHomePageConfigInfoRespContentData
                    {
                        adList       = new List <AdEntity>(),
                        eventList    = new List <EventAreaEntity>(),
                        categoryList = new List <CategoryEntity>()
                    };  //客户端首页所有配置信息

                    #region 广告集合 A 图片广告 B活动集合 C 商品分类和商品

                    var dsAd = adAreaBll.GetAdList(homeEntity.HomeId.ToString());
                    if (dsAd != null && dsAd.Tables.Count > 0 && dsAd.Tables[0].Rows.Count > 0)
                    {
                        content.adList = DataTableToObject.ConvertToList <AdEntity>(dsAd.Tables[0]);
                    }

                    #endregion

                    #region 活动集合

                    var dsEvent = adAreaBll.GetEventInfo(homeEntity.HomeId.ToString());
                    if (dsEvent != null && dsEvent.Tables.Count > 0 && dsEvent.Tables[0].Rows.Count > 0)
                    {
                        content.eventList = DataTableToObject.ConvertToList <EventAreaEntity>(dsEvent.Tables[0]);
                    }

                    #endregion

                    #region 分类集合

                    //获取分组ID
                    var dsGroup = adAreaBll.GetCategoryGroupId(homeEntity.HomeId.ToString());
                    if (dsGroup != null && dsGroup.Tables.Count > 0 && dsGroup.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in dsGroup.Tables[0].Rows)
                        {
                            var category = new CategoryEntity
                            {
                                groupId  = dr[0].ToString(),
                                itemList = new List <ItemEntity>()
                            };

                            var dsItem = adAreaBll.GetItemList(category.groupId, homeEntity.HomeId.ToString());
                            if (dsItem != null && dsItem.Tables.Count > 0 && dsItem.Tables[0].Rows.Count > 0)
                            {
                                DataSet modelDs = adAreaBll.GetModelTypeIdByGroupId(category.groupId);
                                if (modelDs.Tables[0].Rows.Count > 0)
                                {
                                    category.modelTypeId   = Convert.ToInt32(modelDs.Tables[0].Rows[0]["modelTypeId"]);
                                    category.modelTypeName = Convert.ToString(modelDs.Tables[0].Rows[0]["modelTypeName"]);
                                }

                                category.itemList = DataTableToObject.ConvertToList <ItemEntity>(dsItem.Tables[0]);
                            }

                            content.categoryList.Add(category);
                        }
                    }

                    #endregion

                    responseData.success = true;
                    responseData.data    = content;
                    return(responseData.ToJSON());
                }
                else
                {
                    //添加移动终端首页主表MobileHome
                    homeBll.Create(new MobileHomeEntity
                    {
                        HomeId     = Guid.NewGuid(),
                        Title      = "客户端首页",
                        CustomerId = this.CurrentUserInfo.ClientID
                    });

                    responseData.success = true;
                    responseData.msg     = string.Empty;
                    return(responseData.ToJSON());
                }
            }
            catch (Exception ex)
            {
                responseData.success = false;
                responseData.msg     = ex.ToString();
                return(responseData.ToJSON());
            }
        }
예제 #2
0
        public string UpdateMHCategoryAreaByGroupId()
        {
            var responseData = new ResponseData();

            //请求参数
            var groupIDFrom = FormatParamValue(Request("groupIDFrom"));
            var groupIDTo   = Utils.GetIntVal(FormatParamValue(Request("groupIDTo")));
            var itemService = new ItemService(this.CurrentUserInfo);

            if (Convert.ToInt32(groupIDFrom) == Convert.ToInt32(groupIDTo))
            {
                responseData.success = false;
                responseData.msg     = "位置相同,不能移动";
                return(responseData.ToJSON());
            }
            else
            {
                //update MHItemArea groupid
                itemService.UpdateMHCategoryAreaByGroupId(this.CurrentUserInfo.ClientID, Convert.ToInt32(groupIDFrom), Convert.ToInt32(groupIDTo));
                //get MHItemArea info

                var content = new GetMHCategoryAreaInfoRespContentData {
                    categoryList = new List <CategoryEntity>()
                };
                try
                {
                    var homeBll  = new MobileHomeBLL(this.CurrentUserInfo);
                    var homeList = homeBll.QueryByEntity(new MobileHomeEntity {
                        CustomerId = this.CurrentUserInfo.ClientID
                    }, null);
                    if (homeList != null && homeList.Length > 0)
                    {
                        var homeEntity = homeList.FirstOrDefault();
                        var adAreaBll  = new MHAdAreaBLL(this.CurrentUserInfo);
                        var dsGroup    = adAreaBll.GetCategoryGroupId(homeEntity.HomeId.ToString());

                        if (dsGroup != null && dsGroup.Tables.Count > 0 && dsGroup.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow dr in dsGroup.Tables[0].Rows)
                            {
                                var category = new CategoryEntity
                                {
                                    groupId  = dr[0].ToString(),
                                    itemList = new List <ItemEntity>()
                                };

                                var dsItem = adAreaBll.GetItemList(category.groupId, homeEntity.HomeId.ToString());
                                if (dsItem != null && dsItem.Tables.Count > 0 && dsItem.Tables[0].Rows.Count > 0)
                                {
                                    category.itemList = DataTableToObject.ConvertToList <ItemEntity>(dsItem.Tables[0]);
                                }
                                content.categoryList.Add(category);
                            }
                        }
                    }



                    responseData.success = true;
                    responseData.data    = content;
                    return(responseData.ToJSON());
                }
                catch (Exception ex)
                {
                    responseData.success = false;
                    responseData.msg     = ex.ToString();
                    return(responseData.ToJSON());
                }
            }
        }
예제 #3
0
        protected override HomePageConfigV2RD ProcessRequest(APIRequest <HomePageConfigV2RP> pRequest)
        {
            //创建连接用户对象
            var logginUserInfo    = base.CurrentUserInfo;
            HomePageConfigV2RD RD = new HomePageConfigV2RD();
            var adBll             = new MHAdAreaBLL(logginUserInfo); //广告部分

            #region 1.获取首页layout模块
            List <layoutList> ArrlayoutList = new List <layoutList> {
            };                                                                            //用于填充layoutList数据集合
            MHCategoryAreaGroupBLL mhBLL    = new MHCategoryAreaGroupBLL(logginUserInfo); //Layout部分
            DataSet layout = mhBLL.GetLayoutList(logginUserInfo.ClientID);
            if (layout != null && layout.Tables[0].Rows.Count > 0)
            {
                layoutList layoutinfo = new layoutList();
                layoutinfo.layoutid = "001";
                layoutinfo.x        = 0;
                layoutinfo.y        = 0;
                layoutinfo.width    = 320;
                layoutinfo.height   = 101;
                layoutinfo.type     = "ad_1"; //广告
                ArrlayoutList.Add(layoutinfo);
                int strhight = layoutinfo.height;
                int bY       = 0;
                for (int i = 0; i < layout.Tables[0].Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        layoutinfo          = new layoutList();
                        layoutinfo.layoutid = layout.Tables[0].Rows[i]["GroupValue"].ToString();
                        layoutinfo.x        = 0;
                        layoutinfo.y        = strhight;
                        layoutinfo.width    = 320;
                        layoutinfo.height   = Convert.ToInt32(layout.Tables[0].Rows[i]["Height"].ToString());
                        layoutinfo.type     = layout.Tables[0].Rows[i]["ModelType"].ToString();
                        bY = layoutinfo.y;
                    }
                    else
                    {
                        int bHeight      = Convert.ToInt32(layout.Tables[0].Rows[i - 1]["height"]);
                        int bTopDistance = Convert.ToInt32(layout.Tables[0].Rows[i - 1]["TopDistance"]);
                        layoutinfo          = new layoutList();
                        layoutinfo.layoutid = layout.Tables[0].Rows[i]["GroupValue"].ToString();
                        layoutinfo.x        = 0;
                        layoutinfo.y        = bY + bHeight + bTopDistance;
                        layoutinfo.width    = 320;
                        layoutinfo.height   = Convert.ToInt32(layout.Tables[0].Rows[i]["height"].ToString());
                        layoutinfo.type     = layout.Tables[0].Rows[i]["modeltype"].ToString();
                        bY = layoutinfo.y;
                    }
                    ArrlayoutList.Add(layoutinfo);
                }
            }
            #endregion

            #region 2.获取homedata模块
            var ArrhomedataList = new List <homedataList> {
            };                                               //用于填充homedata数据集合

            var homeBll = new MobileHomeBLL(this.CurrentUserInfo);
            //根据客户ID获取homeList集合
            var homeList = homeBll.QueryByEntity(new MobileHomeEntity {
                CustomerId = this.CurrentUserInfo.ClientID
            }, null);
            if (homeList != null)
            {
                var homeEntity        = homeList.FirstOrDefault();
                var dsGroup           = adBll.GetCategoryGroupId(homeEntity.HomeId.ToString());
                var ArriteminfoList   = new List <itemsList> {
                };
                homedataList homeinfo = new homedataList();
                itemsList    tempAd   = new itemsList();

                #region  获取广告部分
                var tempAdArealist = adBll.GetByCustomerID().OrderBy(t => t.DisplayIndex);//获取客户下图片广告集合
                if (tempAdArealist != null)
                {
                    homeinfo.layoutid = "001";
                    homeinfo.title    = "Title";
                    foreach (var item in tempAdArealist)
                    {
                        tempAd           = new itemsList();
                        tempAd.imgUrl    = item.ImageUrl;
                        tempAd.tagartUrl = GettagartUrl("MHAdArea", Convert.ToInt32(item.ObjectTypeId), CurrentUserInfo.ClientID.ToString(), item.ObjectId, item.Url, "");
                        tempAd.biztype   = "";
                        tempAd.trackid   = "";
                        ArriteminfoList.Add(tempAd); //广告
                    }
                    homeinfo.items = ArriteminfoList.ToArray();
                    ArrhomedataList.Add(homeinfo);
                }
                #endregion

                #region 获取分类部分
                if (dsGroup != null && dsGroup.Tables.Count > 0 && dsGroup.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsGroup.Tables[0].Rows)
                    {
                        ArriteminfoList   = new List <itemsList> {
                        };
                        homeinfo          = new homedataList();
                        homeinfo.layoutid = dr["GroupId"].ToString();
                        homeinfo.title    = "Title";
                        var dsItem = adBll.GetItemList(homeinfo.layoutid, homeEntity.HomeId.ToString());
                        if (dsItem != null && dsItem.Tables.Count > 0 && dsItem.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow itemrow in dsItem.Tables[0].Rows)
                            {
                                tempAd           = new itemsList();
                                tempAd.imgUrl    = itemrow["imageUrl"].ToString();
                                tempAd.tagartUrl = GettagartUrl("MHCategoryArea", Convert.ToInt32(itemrow["typeId"]), CurrentUserInfo.ClientID.ToString(), itemrow["objectId"].ToString(), itemrow["imageUrl"].ToString(), itemrow["categoryAreaId"].ToString());
                                tempAd.biztype   = "";
                                tempAd.trackid   = "1314";
                                ArriteminfoList.Add(tempAd);
                            }
                            homeinfo.items = ArriteminfoList.ToArray(); //分类部分
                            ArrhomedataList.Add(homeinfo);
                        }
                    }
                }
                #endregion
            }
            #endregion

            RD.timespan = "";
            RD.version  = "";
            RD.layout   = ArrlayoutList.ToArray();
            RD.homedata = ArrhomedataList.ToArray();
            return(RD);
        }