Ejemplo n.º 1
0
        private bool tryPost(ref Model.Optimizer model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Creater     = this.auth.UserId;
            model.CreatedDate = DateTime.Now;
            if (InstanceManager.OneTouchOptimize(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
Ejemplo n.º 2
0
        private bool tryValidate(Model.Optimizer model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.Creater == 0)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            if (re && model.Creater != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 一键优化
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool OneTouchOptimize(ref Model.Optimizer model, out string errMsg)
 {
     return(InstanceService.OneTouchOptimize(ref model, out errMsg));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 一键优化
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool OneTouchOptimize(ref Model.Optimizer model, out string errMsg)
        {
            errMsg = "";
            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@Creater", model.Creater),
                    new SqlParameter("@CreatedDate", model.CreatedDate),
                    new SqlParameter("@OutAllCarsCount", SqlDbType.Int),
                    new SqlParameter("@OutArchivedCarsCount", SqlDbType.Int),
                    new SqlParameter("@OutArchivedInstancesCount", SqlDbType.Int),
                    new SqlParameter("@OutState", SqlDbType.Int),
                    new SqlParameter("@return", SqlDbType.Int)
                };
                para[2].Direction = ParameterDirection.Output;
                para[3].Direction = ParameterDirection.Output;
                para[4].Direction = ParameterDirection.Output;
                para[5].Direction = ParameterDirection.Output;
                para[6].Direction = ParameterDirection.ReturnValue;
                DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_OneTouchOptimize", para);
                int outAllCarsCount           = int.Parse(para[2].Value.ToString());
                int outArchivedCarsCount      = int.Parse(para[3].Value.ToString());
                int outArchivedInstancesCount = int.Parse(para[4].Value.ToString());
                int outState    = int.Parse(para[5].Value.ToString());
                int returnValue = int.Parse(para[6].Value.ToString());
                if (returnValue > 0)
                {
                    model.AllCarsCount           = outAllCarsCount;
                    model.ArchivedCarsCount      = outArchivedCarsCount;
                    model.ArchivedInstancesCount = outArchivedInstancesCount;
                    EventLog e = new EventLog();
                    e.TargetIds = returnValue.ToString();
                    e.CodeTag   = "OneTouchOptimize";
                    e.LogName   = "一键优化";
                    EventLogService.AddEventLog <Model.Optimizer>(e, model);
                    return(true);
                }
                else
                {
                    switch (outState)
                    {
                    case -1:
                        errMsg = "更新申请单履历归档状态失败";
                        break;

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

                    case -3:
                        errMsg = "更新申请单关联车辆信息失败";
                        break;

                    case -11:
                        errMsg = "归档车辆失败";
                        break;

                    default:
                        errMsg = "异常错误";
                        break;
                    }
                    ErrorLog e = new ErrorLog();
                    e.TargetIds = "0";
                    e.CodeTag   = "OneTouchOptimize";
                    e.LogName   = "一键优化";
                    e.ErrorMsg  = errMsg;
                    ErrorLogService.AddErrorLog <Model.Optimizer>(e, model);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                ErrorLog e = new ErrorLog();
                e.TargetIds = "0";
                e.CodeTag   = "OneTouchOptimize";
                e.LogName   = "一键优化";
                e.ErrorMsg  = ex.Message.ToString();
                ErrorLogService.AddErrorLog <Model.Optimizer>(e, model);
                return(false);
            }
        }