Exemple #1
0
        public ActionResult GetCustomItemValues(string datacode)
        {
            AjaxResult ar = new Globals.AjaxResult();

            if (datacode == string.Empty)
            {
                ar.state   = ResultType.error.ToString();
                ar.message = "提交的数据为空,获取自定义项失败";

                return(Json(ar, JsonRequestBehavior.AllowGet));
            }

            try
            {
                // 获取当前登录的用户
                var currentUser = LoginManager.GetCurrentUser();

                List <CustomItemValue> itemvalueList = new List <CustomItemValue>();

                // 根据datacode获取到相应的数据
                var infor = _informationBLL.GetInformation(datacode);

                // 获取自定义值列表
                var state = _customItemValueBLL.GetCustomItemValueByMember(currentUser.Account, infor.Id, ref itemvalueList);

                if (state == OperatorState.empty)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "无法获取到当前用户信息,获取数据失败";
                }
                else if (state == OperatorState.error)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "获取数据失败";
                }
                else if (state == OperatorState.success)
                {
                    List <CustomItemModel> cmList = ModelChangeManager.ChangeTOCustomItemModel(itemvalueList);

                    ar.state = ResultType.success.ToString();
                    ar.data  = cmList.ToJson();
                }
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);

                ar.state   = ResultType.error.ToString();
                ar.message = "系统错误,获取数据失败";
            }

            return(Json(ar, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult AddCustomItems(string customItemName)
        {
            AjaxResult ar = new Globals.AjaxResult();

            if (customItemName == string.Empty)
            {
                ar.state   = ResultType.error.ToString();
                ar.message = "提交的数据为空,添加自定义项失败";
                return(Json(ar, JsonRequestBehavior.AllowGet));
            }

            try
            {
                var        currentUser = LoginManager.GetCurrentUser();
                CustomItem ci          = new CustomItem();
                var        state       = _customItemBLL.AddCustomItems(currentUser.Account, customItemName, ref ci);

                if (state == OperatorState.repeat)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "所提交自定义项已存在,添加自定义项失败";
                }
                else if (state == OperatorState.error)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "添加自定义项失败";
                }
                else if (state == OperatorState.success)
                {
                    ar.state   = ResultType.success.ToString();
                    ar.data    = ModelChangeManager.ChangeTOCustomItemModel(ci).ToJson();
                    ar.message = "添加自定义项成功";
                }
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);

                ar.state   = ResultType.error.ToString();
                ar.message = "系统错误,添加自定义项失败";
            }
            return(Json(ar, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public ActionResult GetCustomItems()
        {
            AjaxResult ar = new AjaxResult();

            try
            {
                // 獲取當前登陸用戶
                var currentUser = LoginManager.GetCurrentUser();

                List <CustomItem>      CustomItemList      = new List <CustomItem>();
                List <CustomItemModel> CustomItemModelList = new List <CustomItemModel>();

                var state = _customItemBLL.GetCustomItems(currentUser.Account, ref CustomItemList);
                if (state == OperatorState.empty)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "不能获取当前用户所定义的自定义项";
                }
                else if (state == OperatorState.error)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "获取自定义项失败";
                }
                else if (state == OperatorState.success)
                {
                    ar.state = ResultType.success.ToString();
                    ar.data  = ModelChangeManager.ChangeTOCustomItemModel(CustomItemList).ToJson();
                }
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);

                ar.state   = ResultType.error;
                ar.message = "系统错误,获取自定义项失败";
            }
            return(Json(ar, JsonRequestBehavior.AllowGet));
        }