Ejemplo n.º 1
0
        [OutputCache(Duration = 86400, VaryByParam = "*")] //缓存24个小时
        public void AreaDataToJson()
        {
            List <AreaInfo> list = GetArea.Do(0).Body.area_list;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("var areas=[");
            int i = 0;

            foreach (AreaInfo s in list)
            {
                if (i > 0)
                {
                    sb.Append(",");
                }
                i++;
                sb.Append("{");
                sb.Append("'ID':" + s.area_id);
                sb.Append(",'ParentID':" + s.parent_id);
                sb.Append(",'AreaID':" + s.area_id);
                sb.Append(",'Code':'" + s.area_path + "'");
                sb.Append(",'Name':'" + s.area_name + "'");
                sb.Append("}");
            }
            sb.Append("];");
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
            System.Web.HttpContext.Current.Response.End();
            //return Json(sList, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
        public ActionResult PostShopData()
        {
            int      shopid = DoRequest.GetFormInt("shopid");
            ShopInfo shop   = GetShopDetail.Do(shopid).Body;

            shop.shop_name    = DoRequest.GetFormString("shopName");
            shop.company_name = DoRequest.GetFormString("Company");
            shop.shop_key     = DoRequest.GetFormString("keyword");
            shop.shop_pswd    = DoRequest.GetFormString("psword");

            int province = DoRequest.GetFormInt("province");
            int city     = DoRequest.GetFormInt("city");

            shop.area_id   = province;
            shop.shop_addr = GetArea.Do(province).Body.area_list[0].area_name;
            string cityName = GetArea.Do(city).Body.area_list[0].area_name;

            if (!cityName.StartsWith("市辖") && !cityName.StartsWith("直辖"))
            {
                shop.shop_addr += cityName;
            }
            shop.link_way    = DoRequest.GetFormString("linkway");
            shop.shop_remark = DoRequest.GetFormString("remarks");

            #region Checking
            if (shop.shop_name.Length < 1)
            {
                return(Json(new { error = true, message = "[名称] 不能为空" }));
            }
            if (shop.shop_name.Length > 50)
            {
                return(Json(new { error = true, message = "[名称] 不能大于50个字符" }));
            }
            if (shop.company_name.Length < 0 && shop.company_name.Length > 100)
            {
                return(Json(new { error = true, message = "[公司] 不能为空或大于100个字符" }));
            }
            if (shop.area_id < 0)
            {
                return(Json(new { error = true, message = "[发货地址] 不能为空" }));
            }
            #endregion

            int returnValue = -1;

            returnValue = int.Parse(OpShopInfo.Do(shop).Header.Result.Code);

            if (returnValue == 0)
            {
                return(Json(new { error = false, message = "操作成功" }));
            }
            return(Json(new { error = true, message = "操作失败" }));
        }
Ejemplo n.º 3
0
        public ActionResult PostShopData()
        {
            int      shopid = DoRequest.GetFormInt("shopid");
            ShopInfo shop   = GetShopDetail.Do(shopid).Body;

            if (shop == null)
            {
                shop         = new ShopInfo();
                shop.shop_id = 0;
            }
            shop.shop_name    = DoRequest.GetFormString("shopName");
            shop.company_name = DoRequest.GetFormString("Company");
            shop.shop_key     = DoRequest.GetFormString("skeyword");

            string pswd = DoRequest.GetFormString("spsword");

            if ((pswd.Equals("") || pswd == null) && shop.shop_id == 0)
            {
                return(Json(new { error = true, message = "[密码] 不能为空" }));
            }
            if (!pswd.Equals("") && pswd != null)
            {
                shop.shop_pswd = AES.Decode2(pswd, "5f9bf958d112f8668ac53389df8bceba");
            }
            int province = DoRequest.GetFormInt("province");
            int city     = DoRequest.GetFormInt("city");

            shop.area_id   = province;
            shop.shop_addr = GetArea.Do(province).Body.area_list[0].area_name;
            string cityName = GetArea.Do(city).Body.area_list[0].area_name;

            if (!cityName.StartsWith("市辖") && !cityName.StartsWith("直辖"))
            {
                shop.shop_addr += cityName;
            }
            shop.link_way        = DoRequest.GetFormString("linkway");
            shop.support_express = DoRequest.GetFormString("supportexpress");
            shop.delivery_intro  = DoRequest.GetFormString("deliveryintro");
            shop.service_intro   = DoRequest.GetFormString("serviceintro", false);

            string   sdate     = DoRequest.GetFormString("sdate").Trim();
            int      shours    = DoRequest.GetFormInt("shours");
            int      sminutes  = DoRequest.GetFormInt("sminutes");
            DateTime startDate = Utils.IsDateString(sdate) ? DateTime.Parse(sdate + " " + shours + ":" + sminutes + ":00") : DateTime.Now;

            string   edate    = DoRequest.GetFormString("edate").Trim();
            int      ehours   = DoRequest.GetFormInt("ehours");
            int      eminutes = DoRequest.GetFormInt("eminutes");
            DateTime endDate  = Utils.IsDateString(edate) ? DateTime.Parse(edate + " " + ehours + ":" + eminutes + ":59") : DateTime.Now.AddDays(7);

            shop.notice_btime = startDate.ToString("yyyy-MM-dd HH:mm:ss");
            shop.notice_etime = endDate.ToString("yyyy-MM-dd HH:mm:ss");
            shop.shop_notice  = DoRequest.GetFormString("shopnotice", false);
            shop.shop_remark  = DoRequest.GetFormString("remarks");
            shop.shop_type    = DoRequest.GetFormInt("shoptype");
            #region Checking
            if (shop.shop_name.Length < 1)
            {
                return(Json(new { error = true, message = "[店铺名称] 不能为空" }));
            }
            if (shop.shop_name.Length > 50)
            {
                return(Json(new { error = true, message = "[店铺名称] 不能大于50个字符" }));
            }
            if (shop.company_name.Length < 0 && shop.company_name.Length > 100)
            {
                return(Json(new { error = true, message = "[公司名称] 不能为空或大于100个字符" }));
            }
            if (shop.shop_key.Length < 1)
            {
                return(Json(new { error = true, message = "[账号] 不能为空" }));
            }
            if (shop.shop_pswd.Length < 1)
            {
                return(Json(new { error = true, message = "[密码] 不能为空" }));
            }
            if (shop.area_id < 0)
            {
                return(Json(new { error = true, message = "[发货地址] 不能为空" }));
            }
            if (shop.shop_addr.Length < 1)
            {
                return(Json(new { error = true, message = "[联系方式] 不能为空" }));
            }
            if (shop.support_express.Length < 1)
            {
                return(Json(new { error = true, message = "[快递公司] 不能为空" }));
            }
            #endregion

            int returnValue = -1;
            var res         = OpShopInfo.Do(shop);
            if (res != null && res.Header != null && res.Header.Result != null && res.Header.Result.Code != null)
            {
                returnValue = Utils.StrToInt(res.Header.Result.Code, -1);
            }

            if (returnValue == 0)
            {
                DoCache cache = new DoCache();
                cache.RemoveCache("shoplist");
                return(Json(new { error = false, message = "操作成功" }));
            }
            return(Json(new { error = true, message = "操作失败" }));
        }