/// <summary>
        /// 更新缓存
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateCache()
        {
            var result = new MJsonResult()
            {
                Status = true
            };

            try
            {
                // 更新缓存
                using (var client = new ConfigClient())
                {
                    var reVauel = client.RefreshCityAgingCacheAsync();
                    if (!reVauel.Success)
                    {
                        result.Status = false;
                        result.Msg    = "更新缓存失败!";
                    }
                }
            }
            catch (Exception e)
            {
                result.Status = false;
                result.Msg    = "异常:" + e.Message;
            }
            return(Json(result));
        }
        public ActionResult DeleteActivity(Guid?activityId)
        {
            MJsonResult json = new MJsonResult();

            if (activityId == null)
            {
                json.Status = false;
                json.Msg    = "活动ID不合法";
                return(Json(json));
            }
            int id = cityActivityConfig.GetActivityPKIDByActivityId(activityId.Value);

            if (!cityActivityConfig.DeleteActivity(activityId.Value))
            {
                json.Status = false;
                json.Msg    = "删除失败";
            }
            else
            {
                LoggerManager.InsertOplog(new ConfigHistory()
                {
                    AfterValue = null, Author = User.Identity.Name, Operation = activityId.Value.ToString() + "删除活动", ObjectType = "CVPage", ObjectID = id.ToString()
                });
                json.Status = true;
                json.Msg    = "ok";
            }
            return(Json(json));
        }
        /// <summary>
        /// 批量操作
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        public JsonResult SaveCityAgingBulk(List <CityAgingModel> models)
        {
            var result = new MJsonResult()
            {
                Status = true
            };

            try
            {
                if (models == null)
                {
                    result.Status = false;
                    result.Msg    = "数据不能为空!";
                    return(Json(result));
                }
                var returnValue       = 0;
                var operatorsUserName = ThreadIdentity.Operator.Name;
                //批量查询修改前的历史数据
                var tableDatas = CityAgingManage.SelectCityAgingInfoByIds(models.Select(t => t.PKid).ToList());
                foreach (CityAgingModel model in models)
                {
                    if (model.PKid == -1) //还没有修改过时效性
                    {
                        returnValue = CityAgingManage.CreateSelectCityAging(model.CityId, model.CityName, model.IsShow,
                                                                            model.Title, model.Content, operatorsUserName);
                    }
                    else
                    {
                        model.UpdateUser = operatorsUserName;
                        returnValue      = CityAgingManage.UpdateSelectCityAging(model.PKid, model.IsShow, model.Title,
                                                                                 model.Content, operatorsUserName);
                    }
                    var beforvalue = new CityAgingModel();
                    if (tableDatas != null && tableDatas.Any())
                    {
                        beforvalue = tableDatas.Where(t => t.PKid == model.PKid).FirstOrDefault();
                    }
                    else
                    {
                        beforvalue = null;
                    }

                    if (returnValue > 0)
                    {
                        SaveLog(beforvalue, model);
                    }
                }
            }
            catch (Exception e)
            {
                result.Status = false;
                result.Msg    = "异常:" + e.Message;
            }
            return(Json(result));
        }
        public ActionResult CreateActivity(RegionVehicleIdActivityConfig model)
        {
            MJsonResult json = new MJsonResult();

            if (string.IsNullOrEmpty(model.ActivityName))
            {
                json.Status = false;
                json.Msg    = "活动名不能为空";
            }
            else if (string.IsNullOrEmpty(model.ActivityType))
            {
                json.Status = false;
                json.Msg    = "活动类型不合法";
            }
            else if (model.StartTime == null)
            {
                json.Status = false;
                json.Msg    = "开始时间不能为空";
            }
            else if (model.EndTime == null)
            {
                json.Status = false;
                json.Msg    = "结束时间不能为空";
            }
            else
            {
                model.ActivityName = model.ActivityName.Trim();
                string userno = User.Identity.Name;
                if (string.IsNullOrEmpty(userno))
                {
                    json.Status = false;
                    json.Msg    = "获取用户名异常";
                }
                else
                {
                    var activityId = Guid.NewGuid();
                    model.ActivityId = activityId;
                    model.CreateUser = model.UpdateUser = userno;
                    var result = cityActivityConfig.CreateActivity(model);
                    if (result)
                    {
                        int id         = cityActivityConfig.GetActivityPKIDByActivityId(activityId);
                        var AfterValue = $"活动名:{model.ActivityName},活动类型:{model.ActivityType},开始时间:{model.StartTime.ToString()},结束时间:{model.EndTime.ToString()},是否启用:{model.IsEnabled}";
                        LoggerManager.InsertOplog(new ConfigHistory()
                        {
                            AfterValue = AfterValue, Author = User.Identity.Name, Operation = $"{activityId.ToString()}创建活动", ObjectType = "CVPage", ObjectID = id.ToString()
                        });
                    }

                    return(Json(new { Status = result, Msg = result ? "OK" : "创建失败", Data = activityId }));
                }
            }
            return(Json(json));
        }
Esempio n. 5
0
        public ActionResult IsSupperUser()
        {
            MJsonResult jsonObj = new MJsonResult {
                Status = false, Msg = ""
            };

            if (System.Configuration.ConfigurationManager.AppSettings["SupperUsers"].Contains(User.Identity.Name + "|"))
            {
                jsonObj.Status = true;
            }
            return(Json(jsonObj));
        }
        public ActionResult UpdateActivity(RegionVehicleIdActivityConfig model)
        {
            MJsonResult json = new MJsonResult();

            if (model.ActivityId == Guid.Empty)
            {
                json.Status = false;
                json.Msg    = "活动ID不合法";
            }
            else if (string.IsNullOrEmpty(model.ActivityName))
            {
                json.Status = false;
                json.Msg    = "活动名不能为空";
            }
            else if (model.StartTime == null || model.EndTime == null)
            {
                json.Status = false;
                json.Msg    = "活动开始时间或结束时间不合法";
            }
            else if (model.IsEnabled != 0 && model.IsEnabled != 1)
            {
                json.Status = false;
                json.Msg    = "是否启用字段不合法";
            }
            string userno = User.Identity.Name;

            if (string.IsNullOrEmpty(userno))
            {
                json.Status = false;
                json.Msg    = "用户登录信息获取失败";
            }
            else
            {
                model.UpdateUser = userno;
                json.Status      = cityActivityConfig.UpdateActivity(model);
                if (json.Status)
                {
                    int id         = cityActivityConfig.GetActivityPKIDByActivityId(model.ActivityId);
                    var AfterValue = $"活动名:{ model.ActivityName },开始时间:{model.StartTime.ToString()},结束时间:{model.EndTime.ToString()},是否启用:{model.IsEnabled}";
                    LoggerManager.InsertOplog(new ConfigHistory()
                    {
                        AfterValue = AfterValue, Author = userno, Operation = $"{model.ActivityId.ToString()}更新活动", ObjectType = "CVPage", ObjectID = id.ToString()
                    });
                }
                json.Msg = json.Status ? "OK" : "更新失败";
            }
            return(Json(json));
        }
        /// <summary>
        /// 该活动下是否配置了默认活动页
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="activityChannel"></param>
        /// <returns></returns>
        public ActionResult GetIsExistDefaultUrl(Guid?activityId)
        {
            MJsonResult json = new MJsonResult();

            if (activityId == null)
            {
                json.Status = false;
                json.Msg    = "活动ID不合法";
            }
            else
            {
                var res = cityActivityConfig.IsExistDefaultUrl(activityId.Value);
                return(Json(new { Status = true, Msg = "OK", Data = res }, JsonRequestBehavior.AllowGet));
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 根据活动页链接获取活动页名称
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public ActionResult GetActivityTitleByUrl(string url)
        {
            MJsonResult json = new MJsonResult();

            if (string.IsNullOrEmpty(url))
            {
                json.Status = false;
                json.Msg    = "活动页Url不能为空";
            }
            else
            {
                var result = cityActivityConfig.GetActivityTitleByUrl(url);
                json.Status = true;
                json.Msg    = result;
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
        public override void OnException(ExceptionContext context)
        {
            MJsonResult <object> result = null;

            if (context.Exception != null)
            {
                result = this.GeneratExceptionResult(context.Exception);
            }
            else
            {
                result = this.GeneratExceptionResult(new Exception("服务器繁忙,请重试"));
            }

            context.ExceptionHandled = true;
            context.Result           = new JsonResult(result);

            // todo log
        }
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     if (!(context.Result is FileResult) && !(context.Result is ContentResult))
     {
         if (context.Result is EmptyResult)
         {
             var result = new MJsonResult <object>(null);
             context.Result = new JsonResult(result);
         }
         else
         {
             var tempResult = context.Result as dynamic;
             var result     = new MJsonResult <object>(tempResult?.Value);
             context.Result = new JsonResult(result);
         }
     }
     else
     {
         context.Result = context.Result;
     }
 }
Esempio n. 11
0
        /// <summary>
        /// 图片上传
        /// </summary>
        /// <returns></returns>
        public JsonResult UploadPicture()
        {
            var returnValue = new MJsonResult()
            {
                Status = true
            };

            try
            {
                if (Request.Files.Count == 1)
                {
                    var file      = Request.Files[0];
                    var index     = file.FileName.LastIndexOf('.') + 1;
                    var extension = file.FileName.Substring(index,
                                                            file.FileName.Length - index);
                    var domainPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DoMain_image"];
                    var result     = UpLoadManage.UpLoadFile("/GiftManage/Pictures/", file, extension);
                    if (!result.Success)
                    {
                        returnValue.Status = false;
                        returnValue.Msg    = "图片上传失败!";
                    }
                    else
                    {
                        returnValue.Msg = domainPath + result.Result;
                    }
                }
            }
            catch (Exception ex)
            {
                returnValue.Status = false;
                returnValue.Msg    = "异常:" + ex.Message;
            }
            return
                (Json(
                     new
            {
                Data = returnValue,
            }, "text/html"));
        }
        /// <summary>
        /// 获取该活动页配置的车型
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="targetUrl"></param>
        /// <param name="wxappUrl"></param>
        /// <returns></returns>
        public ActionResult GetVehicleInfoByActivityIdUrl(Guid?activityId, string targetUrl, string wxappUrl)
        {
            var json = new MJsonResult();

            targetUrl = targetUrl?.Trim();
            wxappUrl  = wxappUrl?.Trim();
            if (activityId == null)
            {
                json.Status = false;
                json.Msg    = "活动ID不合法";
            }
            else if (string.IsNullOrWhiteSpace(targetUrl) && string.IsNullOrWhiteSpace(wxappUrl))
            {
                json.Status = false;
                json.Msg    = "活动地址不能全为空";
            }
            else
            {
                var regionList = cityActivityConfig.GetVehicleIdByActivityIdUrl(activityId.Value, targetUrl, wxappUrl);
                return(Json(new { Status = true, Msg = "OK", Data = regionList }, JsonRequestBehavior.AllowGet));
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
        public ActionResult GetBtnPower(string Info, string BtnKey, string Key = "")
        {
            MJsonResult jsonObj = new MJsonResult {
                Status = false, Msg = ""
            };
            //if (Session["CaPowerList"] == null)
            //{
            //    byte isSupper = 0;
            //    if (System.Configuration.ConfigurationManager.AppSettings["SupperUsers"].Contains(User.Identity.Name + "|"))
            //        isSupper = 1;
            //    Session["CaPowerList"] = new BusPowerManage().GetBusPower(User.Identity.Name, isSupper);
            //}
            byte isSupper           = (byte)(System.Configuration.ConfigurationManager.AppSettings["SupperUsers"].Contains(User.Identity.Name) ? 1 : 0);
            List <ActionPower> list = new BusPowerManage().GetBusPower(User.Identity.Name, isSupper);//(List<ActionPower>)Session["CaPowerList"];

            if (list == null || list.Count == 0)
            {
                jsonObj.Status = true;
                jsonObj.Msg    = "[]";
                return(Json(jsonObj));
            }
            var infos   = Info.Split('_');
            var tmpList = list.Where(ap => ap.Controller.ToLower() == infos[0].ToLower() && ap.Action.ToLower() == infos[1].ToLower()).ToList();

            if (tmpList == null || tmpList.Count == 0)
            {
                jsonObj.Status = true;
                jsonObj.Msg    = "[]";
                return(Json(jsonObj));
            }
            int id = 0;

            foreach (ActionPower ap in tmpList)
            {
                if (string.IsNullOrEmpty(Key))
                {
                    id = tmpList[0].PKID;
                    break;
                }
                else
                {
                    if (EnOrDe.GetMd5("Info=" + ap.PKID.ToString() + EnOrDe.GetMd5(keyStr, Encoding.UTF8), Encoding.UTF8).Equals(Key))
                    {
                        id = ap.PKID;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if (string.IsNullOrEmpty(BtnKey))
            {
                list = list.Where(ap => ap.ParentID == id && !string.IsNullOrEmpty(ap.BtnKey)).ToList();
            }
            else
            {
                list = list.Where(ap => ap.ParentID == id && ap.BtnKey == BtnKey).ToList();
            }
            if (list == null || list.Count == 0)
            {
                jsonObj.Status = true;
                jsonObj.Msg    = "[]";
                return(Json(jsonObj));
            }
            jsonObj.Status = true;
            string tmp = "";

            foreach (ActionPower ap in list)
            {
                tmp += "{BtnKey:\"" + ap.BtnKey + "\",BtnType:\"" + ap.BtnType + "\"},";
            }
            tmp         = "[" + tmp.TrimEnd(',') + "]";
            jsonObj.Msg = tmp;
            return(Json(jsonObj));
        }
        /// <summary>
        /// 保存时效信息
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveCityAging(CityAgingModel model)
        {
            var result = new MJsonResult()
            {
                Status = true
            };

            try
            {
                var returnValue = 0;
                if (model == null)
                {
                    result.Status = false;
                    result.Msg    = "model 不能为空!";
                    return(Json(result));
                }

                var operatorsUserName = ThreadIdentity.Operator.Name;

                var beforvalue = new CityAgingModel();
                if (model.PKid != -1)
                {
                    var tableData = CityAgingManage.SelectCityAgingInfoByIds(new List <int>()
                    {
                        model.PKid
                    });
                    if (tableData != null && tableData.Any())
                    {
                        beforvalue = tableData.FirstOrDefault();
                    }
                    else
                    {
                        beforvalue = null;
                    }
                }
                else
                {
                    beforvalue = null;
                }

                if (model.PKid == -1)
                {
                    returnValue = CityAgingManage.CreateSelectCityAging(model.CityId, model.CityName, model.IsShow,
                                                                        model.Title, model.Content, operatorsUserName);
                }
                else
                {
                    model.UpdateUser = operatorsUserName;
                    returnValue      = CityAgingManage.UpdateSelectCityAging(model.PKid, model.IsShow, model.Title,
                                                                             model.Content, operatorsUserName);
                }

                if (returnValue > 0)
                {
                    SaveLog(beforvalue, model);
                    result.Status = true;
                    result.Msg    = "保存成功!";
                }
                else
                {
                    result.Status = false;
                    result.Msg    = "保存失败!";
                }
            }
            catch (Exception e)
            {
                result.Status = false;
                result.Msg    = "异常:" + e.Message;
            }

            return(Json(result));
        }