Beispiel #1
0
        public static string ModelMenuPageList(int modelid, int pageindex, int pagesize)
        {
            int totalcount = 0;

            try
            {
                B2bModelData modedata = new B2bModelData();
                var          list     = modedata.ModelMenuPageList(modelid, pageindex, pagesize, out totalcount);
                if (list == null)
                {
                    return(JsonConvert.SerializeObject(new { type = 1, msg = "没有查询到模板", totalCount = 0 }));
                }

                IEnumerable result = "";
                if (list != null)
                {
                    result = from pro in list
                             select new
                    {
                        Id             = pro.Id,
                        Name           = pro.Name,
                        Imgurl_address = FileSerivce.GetImgUrl(pro.Imgurl),
                        Imgurl         = pro.Imgurl,
                        Linkurl        = pro.Linkurl,
                        Modelid        = pro.Modelid,
                        Sortid         = pro.Sortid,
                        Fonticon       = pro.Fonticon
                    };
                }

                return(JsonConvert.SerializeObject(new { type = 100, msg = result, totalCount = totalcount }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message }));

                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        ///  选定模板
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public static string SelectModel(int modelid, int comid)
        {
            using (var helper = new SqlHelper())
            {
                int totalcount  = 0;
                int totalcount1 = 0;
                try
                {
                    B2bModelData modeldata    = new B2bModelData();
                    var          b2bmodel     = modeldata.GetModelById(modelid);
                    var          b2bmodelmenu = modeldata.ModelMenuPageList(modelid, 1, 100, out totalcount);

                    if (b2bmodel != null)
                    {
                        var delemodel = modeldata.DeleteSelectModel(comid);//删除已选择模板

                        H5_html model = new H5_html();
                        model.Comid     = comid;
                        model.Modelid   = modelid;
                        model.Style_str = b2bmodel.Style_str;
                        model.Html_str  = b2bmodel.Html_str;

                        //插入模板
                        int orderid = modeldata.SelectModel(model);

                        //原有图片都下线
                        var saledata   = new B2bCompanyImageData();
                        var bannerlist = saledata.UpAllDownState(comid);


                        //插入默认banner(也用于背景图片),重新选择模板后可能重复插入
                        B2bCompanyImageData modedata = new B2bCompanyImageData();
                        var imglist = modedata.GettypemodelidimageLibraryList(1, modelid, 1, 3, out totalcount1);
                        if (imglist != null)
                        {
                            for (int i = 0; i < imglist.Count; i++)
                            {
                                B2b_company_image imagemodel = new B2b_company_image()
                                {
                                    Id               = 0,
                                    Com_id           = comid,
                                    Typeid           = 0,
                                    Imgurl           = imglist[i].Imgurl,
                                    Linkurl          = "#",
                                    Title            = "#",
                                    Channelcompanyid = 0,
                                };
                                var crmid = saledata.InsertOrUpdate(imagemodel);
                            }
                        }


                        if (b2bmodelmenu != null)//首先判断模板里是否有默认栏目
                        {
                            var insertmenu = 0;
                            var imagedata  = new B2bCompanyMenuData();
                            var list       = imagedata.GetMenuList(comid, 1, 10, out totalcount);//如果已经有菜单的模板将不删除菜单,以后可增加判断是否删除菜单,有利于方便切换模板导航不需要重复修改,但容易出现因栏目图片不符新模板而影响使用。可先删除已有模板再进行切换

                            if (totalcount == 0)
                            {
                                insertmenu = modeldata.InsertSelectModelMenu(modelid, comid);//插入已选择模板菜单
                            }

                            //var deletemenu= modeldata.DeleteSelectModelMenu(comid);//删除已选择模板菜单
                            return(JsonConvert.SerializeObject(new { type = 100, msg = insertmenu }));
                        }
                    }

                    return(JsonConvert.SerializeObject(new { type = 1, msg = "选择模板错误,请重新尝试" }));
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message }));
                }
            }
        }