private bool tryPost(ref Model.Instanceforbid model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Creater     = this.auth.UserId;
            model.CreatedDate = DateTime.Now;
            if (InstanceManager.ForbidInstance(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
        private bool tryValidate(Model.Instanceforbid model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.Trace == 0 ||
                model.Instance == 0 ||
                model.Car == 0 ||
                model.Status == null || model.Status.Length == 0 || model.Status.Length > 20 ||
                model.StartInfo.Length > 200 ||
                model.Creater == 0)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            if (re && model.Creater != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
Beispiel #3
0
 /// <summary>
 /// 禁用申请单
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool ForbidInstance(ref Model.Instanceforbid model, out string errMsg)
 {
     return(InstanceService.ForbidInstance(ref model, out errMsg));
 }
Beispiel #4
0
        /// <summary>
        /// 禁用申请单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool ForbidInstance(ref Model.Instanceforbid model, out string errMsg)
        {
            errMsg = "";
            try
            {
                model.Status    = model.Status.Trim();
                model.StartInfo = model.StartInfo.Trim();
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@Trace", model.Trace),
                    new SqlParameter("@Instance", model.Instance),
                    new SqlParameter("@Car", model.Car),
                    new SqlParameter("@Status", model.Status),
                    new SqlParameter("@StartInfo", model.StartInfo),
                    new SqlParameter("@Creater", model.Creater),
                    new SqlParameter("@CreatedDate", model.CreatedDate),
                    new SqlParameter("@OutState", SqlDbType.Int),
                    new SqlParameter("@return", SqlDbType.Int)
                };
                para[7].Direction = ParameterDirection.Output;
                para[8].Direction = ParameterDirection.ReturnValue;
                DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_InstanceForbid", para);
                int outState    = int.Parse(para[7].Value.ToString());
                int returnValue = int.Parse(para[8].Value.ToString());
                if (returnValue > 0)
                {
                    EventLog e = new EventLog();
                    e.TargetIds = returnValue.ToString();
                    e.CodeTag   = "ForbidInstance";
                    e.LogName   = "禁用申请单";
                    EventLogService.AddEventLog <Model.Instanceforbid>(e, model);
                    return(true);
                }
                else
                {
                    switch (outState)
                    {
                    case -100:
                        errMsg = "该申请单已被归档,不能禁用";
                        break;

                    case -200:
                        errMsg = "该申请单处于待审核状态,不能禁用";
                        break;

                    case -300:
                        errMsg = "该申请单处于未发布状态,不能禁用";
                        break;

                    case -400:
                        errMsg = "该申请单已被禁用,不能重复禁用";
                        break;

                    case -500:
                        errMsg = "该申请单最后一个履历处于未完成状态,不能禁用";
                        break;

                    case -1:
                        errMsg = "添加申请单履历失败";
                        break;

                    case -2:
                        errMsg = "更新申请单禁用状态失败";
                        break;

                    case -3:
                        errMsg = "更新车辆信息失败";
                        break;

                    default:
                        errMsg = "异常错误";
                        break;
                    }
                    ErrorLog e = new ErrorLog();
                    e.TargetIds = model.Car.ToString();
                    e.CodeTag   = "ForbidInstance";
                    e.LogName   = "禁用申请单";
                    e.ErrorMsg  = errMsg;
                    ErrorLogService.AddErrorLog <Model.Instanceforbid>(e, model);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                ErrorLog e = new ErrorLog();
                e.TargetIds = "0";
                e.CodeTag   = "ForbidInstance";
                e.LogName   = "禁用申请单";
                e.ErrorMsg  = ex.Message.ToString();
                ErrorLogService.AddErrorLog <Model.Instanceforbid>(e, model);
                return(false);
            }
        }