public ActionResult PostRole()
        {
            int    id   = DoRequest.GetFormInt("roleid");
            string name = DoRequest.GetFormString("rolename").Trim();
            string desc = DoRequest.GetFormString("roledesc").Trim();
            int    type = DoRequest.GetFormInt("roletype", 2);

            RoleInfo role = new RoleInfo();

            role.role_id   = id;
            role.role_name = name;
            role.role_desc = desc;
            role.role_type = type;

            var returnValue = -1;
            var res         = OpRole.Do(role);

            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.RemoveCacheStartsWith("user");
                return(Json(new { error = false, message = "操作成功!" }));
            }

            return(Json(new { error = true, message = "操作失败" }));
        }
        public ActionResult ResetMobile()
        {
            int    id        = DoRequest.GetFormInt("userid");
            string newmobile = DoRequest.GetFormString("newmobile");

            int returnValue = -1;
            var res         = ModifyUserMoblie.Do(id, newmobile);

            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.RemoveCacheStartsWith("user");
                return(Json(new { error = false, mobile = newmobile, message = "操作成功!" }));
            }
            if (returnValue == 135251)
            {
                return(Json(new { error = true, message = "该手机号,已经使用,请更换手机号!" }));
            }

            return(Json(new { error = true, message = "操作失败!" }));
        }
        public ActionResult ResetUserState()
        {
            string idString = DoRequest.GetFormString("visitid").Trim();
            int    status   = DoRequest.GetFormInt("status");

            if (string.IsNullOrEmpty(idString))
            {
                return(Json(new { error = true, message = "没有选择任何项" }));
            }

            int returnValue = -1;
            var res         = ModifyUserState.Do(idString, status);

            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.RemoveCacheStartsWith("user");
                return(Json(new { error = false, message = "操作成功!" }));
            }

            return(Json(new { error = true, message = "操作失败" }));
        }
Exemple #4
0
 /// <summary>
 /// 读取规则目录下的文件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="fileName">文件名</param>
 /// <returns></returns>
 private static T ParseSettings <T>(string fileName)
 {
     try
     {
         string path = SettingsPath + fileName;
         //T obj = (T)js.ReadObject(stream);
         string  cacheKey = "Settings$" + path;
         DoCache _cache   = new DoCache();
         if (_cache.GetCache(cacheKey) != null)
         {
             return((T)_cache.GetCache(cacheKey));
         }
         string json = Utils.LoadFile(path, "utf-8");
         byte[] bt   = Encoding.UTF8.GetBytes(json.Trim());
         DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(T));
         MemoryStream stream           = new MemoryStream(bt);
         T            obj = (T)js.ReadObject(stream);
         _cache.SetCache(cacheKey, obj, 3600);
         return(obj);
     }
     catch (Exception e)
     {
         Logger.Error(e.ToString());
         //Console.WriteLine(SettingsPath);
         //throw(e);
     }
     return(default(T));
 }
Exemple #5
0
        public ActionResult ClearCache()
        {
            //121.41.42.209
            //120.55.186.140
            Session.Clear();
            DoCache cache = new DoCache();

            cache.RemoveCacheAll();
            Robots _rob  = new Robots();
            var    html  = _rob.GetHtml("http://121.41.42.209/EbaoLifeServer/runstate?cmdMode=clearCache");
            var    html2 = _rob.GetHtml("http://120.55.186.140/EbaoLifeServer/runstate?cmdMode=clearCache");

            return(Json(new { text1 = "http://121.41.42.209/EbaoLifeServer/runstate?cmdMode=clearCache", text2 = "http://120.55.186.140/EbaoLifeServer/runstate?cmdMode=clearCache" }, JsonRequestBehavior.AllowGet));
            //var html = _rob.GetHtml("http://115.28.79.0/EbaoLifeServer/runstate?cmdMode=clearCache");
            //var html2 = _rob.GetHtml("http://42.96.154.177/EbaoLifeServer/runstate?cmdMode=clearCache");
            //return Json(new { text1 = "http://115.28.79.0/EbaoLifeServer/runstate?cmdMode=clearCache", text2 = "http://42.96.154.177/EbaoLifeServer/runstate?cmdMode=clearCache" }, JsonRequestBehavior.AllowGet);
            //    Response.Write(html);
            //   Response.Write("<hr/>");
            // Response.Write(html2);
        }
        public ActionResult DeleteRoleInfo()
        {
            int id = DoRequest.GetFormInt("id");

            int returnValue = -1;
            var res         = DeleteRole.Do(id);

            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.RemoveCacheStartsWith("user");
                return(Json(new { error = false, message = "操作成功!" }));
            }

            return(Json(new { error = true, message = "操作失败" }));
        }
        public ActionResult ResetShopState()
        {
            int id    = DoRequest.GetFormInt("id");
            int state = DoRequest.GetFormInt("state");

            int returnValue = -1;
            var res         = ModifyShopState.Do(id, state);

            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 = "操作失败" }));
        }
Exemple #8
0
        /// <summary>
        /// 根据关键词,更新使用频率
        /// </summary>
        /// <param name="words">关键词列表</param>
        /// <param name="userKey">ip + 设备号</param>
        public static void ModifyWordUseFreq(List <string> words, string userKey)
        {
            if (words.Count < 1)
            {
                return;//没有关键词
            }
            string            _cacheKey = "ModifyWordUseFreq$" + userKey + "$";
            List <ModifyWord> list      = new List <ModifyWord>();

            foreach (string s in words)
            {
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }
                list.Add(new ModifyWord(s));
                _cacheKey += s;
            }
            DoCache _cache = new DoCache();
            var     data   = _cache.GetCache(_cacheKey);

            if (data != null)
            {
                return;//缓存存在的情况,不更新
            }
            RequestModifyWordBody body = new RequestModifyWordBody()
            {
                word_list = list
            };
            var response = DBHelper <ResponseWord> .GetResponse("ModifyWordUseFreq", JsonHelper.ObjectToJson(body), "", false);

            if (DBHelper <ResponseWord> .IsOK(response))
            {
                _cache.SetCache(_cacheKey, 1, 600);//缓存10分钟
            }
        }
        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 = "操作失败" }));
        }
        public ActionResult UserList()
        {
            UserResBody currResBody = new UserResBody();

            foreach (UserResBody item in base._userResBody)
            {
                if (item.res_path.Equals("0,1,107,118,121,"))
                {
                    currResBody = item;
                    break;
                }
            }

            HasPermission(currResBody.res_id);

            ViewData["currResBody"] = currResBody;//当前菜单
            string position = "";

            ViewData["pageTitle"] = base.FormatPageTile(currResBody, ref position);
            ViewData["position"]  = position;//页面位置

            int                  pagesize  = DoRequest.GetQueryInt("size", 60);
            int                  pageindex = DoRequest.GetQueryInt("page", 1);
            string               q         = DoRequest.GetQueryString("q");
            int                  state     = DoRequest.GetQueryInt("state", -1);
            int                  usertype  = DoRequest.GetQueryInt("usertype", -1);
            DateTime             date      = DateTime.Now.AddYears(-3);
            DateTime             sDate     = DoRequest.GetQueryDate("sDate", date);
            DateTime             eDate     = DoRequest.GetQueryDate("eDate", DateTime.Now);
            int                  dataCount = 0;
            int                  pageCount = 0;
            List <ShortUserInfo> infoList  = new List <ShortUserInfo>();
            DoCache              cache     = new DoCache();
            string               cachekey  = "user-QueryUserListindex=" + pageindex + "state=" + state + "type=" + usertype + "sdate=" + sDate.ToString("yyyy-MM-dd") + "edate=" + eDate.ToString("yyyy-MM-dd") + "q=" + q;

            if (cache.GetCache(cachekey) == null)
            {
                var resp = QueryUserList.Do(pagesize, pageindex, state, usertype, sDate.ToString("yyyy-MM-dd 00:00:00"), eDate.ToString("yyyy-MM-dd 23:59:59"), q, ref dataCount, ref pageCount);
                if (resp != null && resp.Body != null && resp.Body.user_list != null)
                {
                    infoList = resp.Body.user_list;
                    cache.SetCache(cachekey, infoList, 300);
                    cache.SetCache("userdatacount", dataCount, 300);
                    if (infoList.Count == 0)
                    {
                        cache.RemoveCache(cachekey);
                    }
                }
            }
            else
            {
                infoList  = (List <ShortUserInfo>)cache.GetCache(cachekey);
                dataCount = (int)cache.GetCache("userdatacount");
            }

            ViewData["infoList"] = infoList;                                         //数据列表

            System.Text.StringBuilder currPageUrl = new System.Text.StringBuilder(); //拼接当前页面URL
            currPageUrl.Append("/musers/userlist?");
            currPageUrl.Append("&size=" + pagesize);
            currPageUrl.Append("&page=" + pageindex);
            currPageUrl.Append("&q=" + DoRequest.UrlEncode(q));
            currPageUrl.Append("&state=" + state);
            currPageUrl.Append("&usertype=" + usertype);
            currPageUrl.Append("&sdate=" + sDate.ToString("yyyy-MM-dd"));
            currPageUrl.Append("&edate=" + eDate.ToString("yyyy-MM-dd"));
            ViewData["currPageUrl"] = currPageUrl;//当前页面的URL
            ViewData["pagesize"]    = pagesize;
            ViewData["pageindex"]   = pageindex;
            ViewData["dataCount"]   = dataCount;

            ViewData["pageIndexLink"]  = this.FormatPageIndex(dataCount, pagesize, pageindex, currPageUrl.ToString());
            ViewData["pageIndexLink2"] = this.FormatPageIndex(dataCount, pagesize, pageindex, currPageUrl.ToString());

            return(View());
        }