Example #1
0
        public JsonResult SaveBasSpecialScheduleIndex(CBasSpecialScheduleIndex BasSpecialScheduleIndex)
        {
            string str = string.Empty;

            if (!ModelState.IsValid)
            {
                List <string> errorList = ModelStateExtension.GetModelError(ViewData);
                str = string.Join(",", errorList.ToArray());
                return(Json(new { Success = false, Msg = str }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                CBasSpecialScheduleIndex tmpBasSpecialScheduleIndex = null;
                str = "<=SaveSuccess>";
                if (!string.IsNullOrEmpty(BasSpecialScheduleIndex.BasSpecialScheduleIndexId))
                {
                    tmpBasSpecialScheduleIndex = _BasSpecialScheduleIndexDBAccess.Get(BasSpecialScheduleIndex.BasSpecialScheduleIndexId);
                    TryUpdateModel <CBasSpecialScheduleIndex>(tmpBasSpecialScheduleIndex);
                }
                else
                {
                    tmpBasSpecialScheduleIndex = BasSpecialScheduleIndex;
                }
                string errMsg;
                bool   Success;
                Success = _BasSpecialScheduleIndexDBAccess.Save(tmpBasSpecialScheduleIndex, out errMsg);
                return(Json(new { Success = Success, Msg = Success ? str : errMsg, BasSpecialScheduleIndex = tmpBasSpecialScheduleIndex }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public JsonResult SaveBasPdcSequence(CBasPdcSequence BasPdcSequence)
        {
            string str = string.Empty;

            if (!ModelState.IsValid)
            {
                List <string> errorList = ModelStateExtension.GetModelError(ViewData);
                str = string.Join(",", errorList.ToArray());
                return(Json(new { Success = false, Msg = str }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                CBasPdcSequence tmpBasPdcSequence = null;
                str = "<=SaveSuccess>";
                if (!string.IsNullOrEmpty(BasPdcSequence.BasPdcSequenceId))
                {
                    tmpBasPdcSequence = _BasPdcSequenceDBAccess.Get(BasPdcSequence.BasPdcSequenceId);
                    TryUpdateModel <CBasPdcSequence>(tmpBasPdcSequence);
                }
                else
                {
                    tmpBasPdcSequence = BasPdcSequence;
                }
                string errMsg;
                bool   Success;
                Success = _BasPdcSequenceDBAccess.Save(tmpBasPdcSequence, out errMsg);
                return(Json(new { Success = Success, Msg = Success ? str : errMsg, BasPdcSequence = tmpBasPdcSequence }, JsonRequestBehavior.AllowGet));
            }
        }
Example #3
0
        public JsonResult ChangePasswordPost(FormCollection collection)
        {
            var     service = new SysUserService();
            SysUser user    = service.Login(collection["UserCode"], collection["OldPwd"]);

            if (user == null || string.Compare(user.Pwd, collection["OldPwd"], false) != 0)
            {
                return(Json(new { success = false, msg = "<=OldPwdNotMatched>" }));
            }
            else
            {
                if (string.Compare(collection["NewPwd"], collection["ConfirmPwd"], false) != 0)
                {
                    return(Json(new { success = false, msg = "<=NewPwdNotMatched>" }));
                }

                if (string.Compare(collection["NewPwd"], user.Pwd, false) == 0)
                {
                    return(Json(new { success = false, msg = "<=ForbidMatchOldPwd>" }));
                }

                string errorMsg = string.Empty;
                user.PasswordDate = DateTime.Now.Date;

                user.Pwd = collection["NewPwd"];
                TryUpdateModel <SysUser>(user);

                //判断新密码规则,Operator不受密码规则控制
                var _sysUserRoleService = new SysUserRoleService();
                var _sysRoleService     = new SysRoleService();
                var sysUserRole         = _sysUserRoleService.GetList().Where(o => o.SysUserId == user.SysUserId).Select(o => o.SysRoleId).Distinct().ToList();
                var sysRole             = _sysRoleService.GetList().Where(o => sysUserRole.Contains(o.SysRoleId) || o.SysRoleId == user.RoleId).ToList();
                if (sysRole.Count() > 0 && (sysRole.Count() != 1 || sysRole.Where(o => o.RoleCode.Contains("Operator")).Count() <= 0))
                {
                    if (!this.PassWordIsValid(user.Pwd))
                    {
                        return(Json(new { success = false, msg = "<=PasswordError>" }, JsonRequestBehavior.AllowGet));
                    }
                }
                if (!ModelState.IsValid)
                {
                    List <string> errorList = ModelStateExtension.GetModelError(ViewData);
                    string        str       = string.Join(",", errorList.ToArray());
                    return(Json(new { success = false, msg = str }, JsonRequestBehavior.AllowGet));
                }
                bool success = service.Save(user, out errorMsg);
                if (!success)
                {
                    return(Json(new { success = false, msg = errorMsg }));
                }

                FormsService.SignIn(collection["UserCode"], false);
                return(Json(new { success = true, msg = "<=ModifySuccess>" }));
            }
        }
Example #4
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            var state = context.ModelState;

            context.HttpContext.Features.Set <ModelStateFeature>(new ModelStateFeature(state));
            if (!state.IsValid)
            {
                throw new ApiException("Your Request is not valid", 500, ModelStateExtension.AllErrors(state));
            }
            await next();
        }
        public List <string> GetExcResult()
        {
            throw new ApiException("Your Message", 401, ModelStateExtension.AllErrors(ModelState));
            var result = new List <string>();

            result.Add("date 1");
            result.Add("date 2");
            result.Add("date 3");
            result.Add("date 4");
            result.Add("date 5");
            result.Add("date 6");
            result.Add("date 7");
            return(result);
        }
Example #6
0
 public ActionResult <string> Get(int id)
 {
     throw new ApiException("Your Message", 401, ModelStateExtension.AllErrors(ModelState));
     //return "value";
 }