Exemple #1
0
        public virtual bool Edit(ref ValidationErrors errors, Flow_SealModel model)
        {
            try
            {
                Flow_Seal entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id         = model.Id;
                entity.Path       = model.Path;
                entity.CreateTime = model.CreateTime;
                entity.SysUserId  = model.SysUserId;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Exemple #2
0
        public virtual bool Create(ref ValidationErrors errors, Flow_SealModel model)
        {
            try
            {
                Flow_Seal entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity            = new Flow_Seal();
                entity.Id         = model.Id;
                entity.Path       = model.Path;
                entity.CreateTime = model.CreateTime;
                entity.SysUserId  = model.SysUserId;


                if (m_Rep.Create(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
        public ActionResult Edit(string id)
        {
            ViewBag.Perm = GetPermission();
            Flow_SealModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
Exemple #4
0
        public bool Edit(ref ValidationErrors errors, Flow_SealModel model)
        {
            try
            {
                Flow_Seal entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Suggestion.Disable);
                    return(false);
                }
                entity.CreateTime = model.CreateTime;
                entity.Id         = model.Id;
                entity.Path       = model.Path;
                entity.Using      = model.Using;

                if (m_Rep.Edit(entity) == 1)
                {
                    return(true);
                }
                else
                {
                    errors.Add(Suggestion.EditFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Exemple #5
0
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Flow_SealModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

            if (!targetFile.Exists)
            {
                errors.Add("导入的数据文件不存在");
                return(false);
            }

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Flow_SealModel>(x => x.Path, "Path");
            excelFile.AddMapping <Flow_SealModel>(x => x.CreateTime, "CreateTime");
            excelFile.AddMapping <Flow_SealModel>(x => x.SysUserId, "SysUserId");

            //SheetName
            var excelContent = excelFile.Worksheet <Flow_SealModel>(0);
            int rowIndex     = 1;

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Flow_SealModel();
                entity.Id         = row.Id;
                entity.Path       = row.Path;
                entity.CreateTime = row.CreateTime;
                entity.SysUserId  = row.SysUserId;

                //=============================================================================
                if (errorMessage.Length > 0)
                {
                    errors.Add(string.Format(
                                   "第 {0} 列发现错误:{1}{2}",
                                   rowIndex,
                                   errorMessage,
                                   "<br/>"));
                }
                list.Add(entity);
                rowIndex += 1;
            }
            if (errors.Count > 0)
            {
                return(false);
            }
            return(true);
        }
Exemple #6
0
 public Flow_SealModel GetById(string id)
 {
     if (IsExist(id))
     {
         Flow_Seal      entity = m_Rep.GetById(id);
         Flow_SealModel model  = new Flow_SealModel();
         model.CreateTime = entity.CreateTime;
         model.Id         = entity.Id;
         model.Path       = entity.Path;
         model.Using      = entity.Using;
         return(model);
     }
     else
     {
         return(null);
     }
 }
Exemple #7
0
        public virtual Flow_SealModel GetById(object id)
        {
            if (IsExists(id))
            {
                Flow_Seal      entity = m_Rep.GetById(id);
                Flow_SealModel model  = new Flow_SealModel();
                model.Id         = entity.Id;
                model.Path       = entity.Path;
                model.CreateTime = entity.CreateTime;
                model.SysUserId  = entity.SysUserId;

                return(model);
            }
            else
            {
                return(null);
            }
        }
 public JsonResult Edit(Flow_SealModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Edit(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Path" + model.Path, "成功", "修改", "Flow_Seal");
             return(Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Path" + model.Path + "," + ErrorCol, "失败", "修改", "Flow_Seal");
             return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Suggestion.EditFail)));
     }
 }
 public JsonResult Create(Flow_SealModel model)
 {
     model.Id         = ResultHelper.NewId;
     model.CreateTime = ResultHelper.NowTime;
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Create(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Path" + model.Path, "成功", "创建", "Flow_Seal");
             return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Path" + model.Path + "," + ErrorCol, "失败", "创建", "Flow_Seal");
             return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail)));
     }
 }
Exemple #10
0
        public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(Flow_SealModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                Flow_Seal entity = await m_Rep.GetByIdAsync(model.Id);

                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity            = new Flow_Seal();
                entity.Id         = model.Id;
                entity.Path       = model.Path;
                entity.CreateTime = model.CreateTime;
                entity.SysUserId  = model.SysUserId;


                if (await m_Rep.CreateAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }