예제 #1
0
 /// <summary>
 /// 添加设备类型
 /// </summary>
 /// <param name="newEquipmentType">需要添加的设备类型</param>
 public EquipmentTypeEditModel Add(EquipmentTypeEditModel newEquipmentType)
 {
     try
     {
         if (CheckCodeExists(newEquipmentType.EditEquipmentType.EquipmentTypeCode))
         {
             throw new FaultException<AisinoMesFault>(new AisinoMesFault("添加失败"), "该编号已存在,不能重复添加");
         }
         if (CheckNameExists(newEquipmentType.EditEquipmentType.Name))
         {
             throw new FaultException<AisinoMesFault>(new AisinoMesFault("添加失败"), "该名称已存在,不能重复添加");
         }
         _unitOfWork.AddAction(newEquipmentType.EditEquipmentType, DataActions.Add);
         _unitOfWork.Save();
         return newEquipmentType;
     }
     catch (RepositoryException rex)
     {
         string msg = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
 }
예제 #2
0
 /// <summary>
 /// 更新设备类型
 /// </summary>
 /// <param name="newEquipmentType">需要修改的设备类型</param>
 public EquipmentTypeEditModel Update(EquipmentTypeEditModel newEquipmentType)
 {
     try
     {
         Repository<EquipmentType> equipmentTypeDal = _unitOfWork.GetRepository<EquipmentType>();
         EquipmentType equipmentType = equipmentTypeDal.GetObjectByKey(newEquipmentType.EditEquipmentType.EquipmentTypeCode).Entity;
         EquipmentTypeEditModel equipmentTypeEditModel = new EquipmentTypeEditModel();
         if (equipmentType != null)
         {
             equipmentType.EquipmentTypeCode = newEquipmentType.EditEquipmentType.EquipmentTypeCode;
             equipmentType.Name = newEquipmentType.EditEquipmentType.Name;
             equipmentType.Remark = newEquipmentType.EditEquipmentType.Remark;
             equipmentType.IsWeight = newEquipmentType.EditEquipmentType.IsWeight;
             equipmentType.Stopped = newEquipmentType.EditEquipmentType.Stopped;
         }
         _unitOfWork.AddAction(equipmentType, DataActions.Update);
         _unitOfWork.Save();
         return newEquipmentType;
     }
     catch (RepositoryException rex)
     {
         string msg = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
 }
예제 #3
0
 /// <summary>
 /// 根据设备类型编号获取设备类型编辑对象
 /// </summary>
 /// <param name="code">设备类型编号</param>
 public EquipmentTypeEditModel GetEquipmentTypeByCode(string code)
 {
     try
     {
         Repository<EquipmentType> equipmentTypeDal = _unitOfWork.GetRepository<EquipmentType>();
         EquipmentType equipmentType = equipmentTypeDal.GetObjectByKey(code).Entity;
         EquipmentTypeEditModel equipmentTypeEditModel = new EquipmentTypeEditModel();
         if (equipmentType != null)
         {
             equipmentTypeEditModel.EditEquipmentType = equipmentType;
         }
         return equipmentTypeEditModel;
     }
     catch (RepositoryException rex)
     {
         string msg = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
 }
예제 #4
0
 /// <summary>
 /// 删除设备类型
 /// </summary>
 /// <param name="deleteEquipmentType">需要删除的设备类型信息</param>
 public bool Delete(EquipmentTypeEditModel deleteEquipmentType)
 {
     bool res = true;
     try
     {
         Repository<EquipmentType> equipmentTypeDal = _unitOfWork.GetRepository<EquipmentType>();
         EquipmentType equipmentType = equipmentTypeDal.GetObjectByKey(deleteEquipmentType.EditEquipmentType.EquipmentTypeCode).Entity;
         if (equipmentType != null)
         {
             this.DeleteByCode(deleteEquipmentType.EditEquipmentType.EquipmentTypeCode);
         }
         else
         {
             res = false;
             throw new FaultException<AisinoMesFault>(new AisinoMesFault("删除失败"), "该编号不存在,不能删除");
         }
         return res;
     }
     catch (RepositoryException rex)
     {
         string msg = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
 }
예제 #5
0
 /// <summary>
 /// 根据设备类型编号删除设备类型
 /// </summary>
 /// <param name="deleteEquipmentTypeCode">需要删除的设备类型编号</param>
 public bool DeleteByCode(string deleteEquipmentTypeCode)
 {
     bool res = true;
     try
     {
         Repository<EquipmentType> equipmentTypeDal = _unitOfWork.GetRepository<EquipmentType>();
         EquipmentType equipmentType = equipmentTypeDal.GetObjectByKey(deleteEquipmentTypeCode).Entity;
         EquipmentTypeEditModel equipmentTypeEditModel = new EquipmentTypeEditModel();
         if (equipmentType != null)
         {
             equipmentTypeEditModel.EditEquipmentType = equipmentType;
             if (equipmentTypeEditModel.HasSubEquipments())
             {
                 res = false;
                 throw new FaultException<AisinoMesFault>(new AisinoMesFault("删除失败"), "该设备存在子设备,不能删除");
             }
             _unitOfWork.AddAction(equipmentTypeEditModel.EditEquipmentType, DataActions.Delete);
             _unitOfWork.Save();
         }
         else
         {
             res = false;
             throw new FaultException<AisinoMesFault>(new AisinoMesFault("删除失败"), "该编号不存在,不能删除");
         }
         return res;
     }
     catch (RepositoryException rex)
     {
         string msg = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException<AisinoMesFault>
         (new AisinoMesFault(msg), reason);
     }
 }