public static bool AddOrUpdateIOTime(List <ParkGateIOTime> list) { if (list == null || list.Count == 0) { throw new ArgumentNullException("list"); } IParkGate factory = ParkGateFactory.GetFactory(); List <ParkGateIOTime> models = factory.QueryGateIOTime(list.First().GateID); List <ParkGateIOTime> updateModels = new List <ParkGateIOTime>(); List <ParkGateIOTime> addModels = new List <ParkGateIOTime>(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); foreach (var item in list) { ParkGateIOTime model = models.FirstOrDefault(p => p.RuleType == 0 && p.WeekIndex == item.WeekIndex); if (model != null) { model.StartTime = item.StartTime; model.EndTime = item.EndTime; model.InOutState = item.InOutState; bool result = factory.UpdateIOTime(model, dbOperator); if (!result) { throw new MyException("修改星期规则失败"); } updateModels.Add(model); } else { item.RecordID = GuidGenerator.GetGuid().ToString(); bool result = factory.AddIOTime(item, dbOperator); if (!result) { throw new MyException("添加星期规则失败"); } addModels.Add(item); } } dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } if (updateModels.Count > 0) { OperateLogServices.AddOperateLog <List <ParkGateIOTime> >(updateModels, OperateType.Update); } if (addModels.Count > 0) { OperateLogServices.AddOperateLog <List <ParkGateIOTime> >(addModels, OperateType.Add); } return(true); }
public static bool Update(BaseVillage model) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrWhiteSpace(model.VNo)) { throw new ArgumentNullException("小区编号不能为空"); } IVillage factory = VillageFactory.GetFactory(); BaseVillage dbModel = factory.QueryVillageByVillageNo(model.VNo, model.CPID); if (dbModel != null && dbModel.VID != model.VID) { throw new MyException("小区编号已经存在"); } dbModel = factory.QueryVillageByProxyNo(model.ProxyNo); if (dbModel != null && dbModel.VID != model.VID) { throw new MyException("代理编号已存在"); } bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <BaseVillage>(model, OperateType.Update); } return(result); }
/// <summary> /// 修改通道规则 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UpdateIOTime(List <ParkGateIOTime> list) { if (list == null || list.Count == 0) { throw new ArgumentNullException("list"); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); foreach (var model in list) { IParkGate factory = ParkGateFactory.GetFactory(); bool result = factory.UpdateIOTime(model, dbOperator); if (!result) { throw new MyException("修改通道规则失败"); } } dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } OperateLogServices.AddOperateLog <List <ParkGateIOTime> >(list, OperateType.Update); return(true); }
public static bool Update(ParkCarModel model) { if (model == null) { throw new ArgumentNullException("model"); } model.CarModelName = model.CarModelName.Trim(); IParkCarModel factory = ParkCarModelFactory.GetFactory(); ParkCarModel carModel = factory.QueryByRecordId(model.CarModelID); //if (carModel.IsDefault == YesOrNo.Yes && model.IsDefault == YesOrNo.No) // throw new MyException("必须设置一个默认类型"); List <ParkCarModel> carModels = factory.QueryByParkingId(model.PKID); if (carModels.Count(p => p.CarModelName == model.CarModelName && p.CarModelID != model.CarModelID) != 0) { throw new MyException("车型名称已存在,请更改名称"); } bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <ParkCarModel>(model, OperateType.Update); } return(result); }
public static bool Add(List <SysRoleAuthorize> models) { if (models == null || models.Count == 0) { throw new ArgumentNullException("models"); } ISysRoleAuthorize factory = SysRoleAuthorizeFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.DeleteByRoleId(models.First().RoleID, dbOperator); result = factory.Add(models, dbOperator); if (!result) { throw new MyException("保存失败"); } dbOperator.CommitTransaction(); OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("RoleId:{0}", models.First().RoleID)); OperateLogServices.AddOperateLog(OperateType.Add, string.Format("RecordIds:{0}", string.Join(",", models.Select(p => p.RecordID)))); return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool Update(ParkCarType model) { if (model == null) { throw new ArgumentNullException("model"); } model.CarTypeName = model.CarTypeName.Trim(); IParkCarType factory = ParkCarTypeFactory.GetFactory(); ParkCarType carType = factory.QueryCarTypesByCarTypeName(model.PKID, model.CarTypeName); if (carType != null && model.CarTypeID != carType.CarTypeID) { throw new MyException("车类名称不能重复"); } if (model.BaseTypeID == BaseCarType.TempCar) { List <ParkCarType> carTypes = ParkCarTypeServices.QueryParkCarTypeByParkingId(model.PKID); if (carTypes.FirstOrDefault(p => p.BaseTypeID == BaseCarType.TempCar && p.CarTypeID != model.CarTypeID) != null) { throw new MyException("基础类型为临时车的已经存在,不能重复添加"); } } bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <ParkCarType>(model, OperateType.Update); } return(result); }
public static bool Update(BaseParkinfo model, bool addlog = true) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrWhiteSpace(model.PKNo)) { throw new MyException("车场编号不能为空"); } IParking factory = ParkingFactory.GetFactory(); BaseParkinfo park = factory.QueryParkingByParkingNo(model.PKNo); if (park != null && park.PKID != model.PKID) { throw new MyException("车场编号不能重复"); } bool result = factory.Update(model); if (result && addlog) { OperateLogServices.AddOperateLog <BaseParkinfo>(model, OperateType.Update); } return(result); }
public static bool Add(BaseParkinfo model) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrWhiteSpace(model.PKNo)) { throw new MyException("车场编号不能为空"); } IParking factory = ParkingFactory.GetFactory(); BaseParkinfo park = factory.QueryParkingByParkingNo(model.PKNo); if (park != null) { throw new MyException("车场编号不能重复"); } model.PKID = GuidGenerator.GetGuidString(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.Add(model, dbOperator); if (!result) { throw new MyException("添加车场信息失败"); } result = ParkCarModelServices.AddDefault(model.PKID, dbOperator); if (!result) { throw new MyException("添加车型失败"); } result = ParkCarTypeServices.AddDefault(model.PKID, dbOperator); if (!result) { throw new MyException("添加车类型失败"); } dbOperator.CommitTransaction(); if (result) { OperateLogServices.AddOperateLog <BaseParkinfo>(model, OperateType.Add); } return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static int UpdateCarBit(string PKID) { IParking factory = ParkingFactory.GetFactory(); int result = factory.UpdateCarBit(PKID); if (result > 0) { OperateLogServices.AddOperateLog(OperateType.Update, string.Format("PKID:{0}", PKID)); } return(result); }
/// <summary> /// 修改车场结算配置 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UpdateParkSettleConfig(BaseParkinfo model) { IParking factory = ParkingFactory.GetFactory(); bool result = factory.UpdateParkSettleConfig(model); if (result) { OperateLogServices.AddOperateLog <BaseParkinfo>(model, OperateType.Update); } return(result); }
public static bool Delete(string recordId) { if (string.IsNullOrWhiteSpace(recordId)) { throw new ArgumentNullException("recordId"); } ISysUser factory = SysUserFactory.GetFactory(); SysUser model = factory.QuerySysUserByRecordId(recordId); if (model == null) { throw new MyException("待删除的用户不存在"); } if (model.IsDefaultUser == YesOrNo.Yes) { throw new MyException("该用户为系统默认用户不能删除"); } ISysUserRolesMapping roleFactory = SysUserRolesMappingFactory.GetFactory(); ISysUserScopeMapping scopeFactory = SysUserScopeMappingFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.Delete(recordId, dbOperator); if (!result) { throw new MyException("添加用户信息失败"); } roleFactory.DeleteByUserId(recordId, dbOperator); scopeFactory.DeleteByUserID(recordId, dbOperator); dbOperator.CommitTransaction(); if (result) { OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("RecordId:{0}", recordId)); } return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
/// <summary> /// 创建默认小区 /// </summary> /// <param name="model"></param> /// <param name="dbOperator"></param> /// <returns></returns> public static bool AddVillageDefaultUser(BaseVillage model, DbOperator dbOperator) { model.DataStatus = DataStatus.Normal; model.LastUpdateTime = DateTime.Now; model.HaveUpdate = SystemDefaultConfig.DataUpdateFlag; IVillage factory = VillageFactory.GetFactory(); bool result = factory.Add(model, dbOperator); if (result) { OperateLogServices.AddOperateLog <BaseVillage>(model, OperateType.Add); } return(result); }
public static bool Update(ParkDevice model) { if (model == null) { throw new ArgumentNullException("model"); } IParkDevice factory = ParkDeviceFactory.GetFactory(); IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory(); bool result = false; using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); result = factory.Update(model, dbOperator); if (!result) { throw new MyException("修改设备失败"); } if (model.DeviceType == DeviceType.NZ_CONTROL) { ParkDeviceParam deviceParam = factory.QueryParkDeviceParamByDID(model.DeviceID); if (deviceParam == null) { AddDefaultParkDeviceParam(model.GateID, model.DeviceID, model.DeviceNo, dbOperator); } else { factory.UpdateParam(model.DeviceID, model.DeviceNo, dbOperator); } } dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } if (result) { OperateLogServices.AddOperateLog <ParkDevice>(model, OperateType.Update); } return(result); }
public static bool AddDefualt(ParkArea model) { if (model == null) { throw new ArgumentNullException("model"); } IParkArea factory = ParkAreaFactory.GetFactory(); bool result = factory.Add(model); if (result) { OperateLogServices.AddOperateLog <ParkArea>(model, OperateType.Add); } return(result); }
public static bool Update(Message model) { if (model == null) { throw new ArgumentNullException("model"); } IMessage factory = MessageFactory.GetFactory(); bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <Message>(model, OperateType.Update); } return(result); }
public static bool Delete(string recordId) { if (recordId.IsEmpty()) { throw new ArgumentNullException("recordId"); } IMessage factory = MessageFactory.GetFactory(); bool result = factory.Delete(recordId); if (result) { OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId)); } return(result); }
public static bool Update(SysUser model) { if (model == null) { throw new ArgumentNullException("model"); } ISysUser factory = SysUserFactory.GetFactory(); bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <SysUser>(model, OperateType.Update); } return(result); }
public static bool Update(ParkBox model) { if (model == null) { throw new ArgumentNullException("model"); } IParkBox factory = ParkBoxFactory.GetFactory(); bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <ParkBox>(model, OperateType.Update); } return(result); }
public static bool Delete(string recordId) { if (string.IsNullOrWhiteSpace(recordId)) { throw new ArgumentNullException("recordId"); } IParkCarModel factory = ParkCarModelFactory.GetFactory(); bool result = factory.Delete(recordId); if (result) { OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId)); } return(result); }
public static bool UpdateCarbitNum(string recordId, int carNum) { if (string.IsNullOrWhiteSpace(recordId)) { throw new ArgumentNullException("recordId"); } IParkArea factory = ParkAreaFactory.GetFactory(); bool result = factory.UpdateCarbitNum(recordId, carNum); if (result) { OperateLogServices.AddOperateLog(OperateType.Update, string.Format("recordId:{0},CarbitNum:{1}", recordId, carNum)); } return(result); }
public static bool Add(Message model) { if (model == null) { throw new ArgumentNullException("model"); } model.RecordID = GuidGenerator.GetGuid().ToString(); IMessage factory = MessageFactory.GetFactory(); bool result = factory.Add(model); if (result) { OperateLogServices.AddOperateLog <Message>(model, OperateType.Add); } return(result); }
public static bool Add(ParkDevice model) { if (model == null) { throw new ArgumentNullException("model"); } IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory(); model.DeviceID = GuidGenerator.GetGuid().ToString(); IParkDevice factory = ParkDeviceFactory.GetFactory(); bool result = false; using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); result = factory.Add(model, dbOperator); if (!result) { throw new MyException("添加设备失败"); } if (model.DeviceType == DeviceType.NZ_CONTROL) { int devId = 0; if (!int.TryParse(model.DeviceNo, out devId)) { throw new MyException("设备编号只能输入纯数字"); } AddDefaultParkDeviceParam(model.GateID, model.DeviceID, model.DeviceNo, dbOperator); } dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } if (result) { OperateLogServices.AddOperateLog <ParkDevice>(model, OperateType.Add); } return(result); }
public static bool AddSysRole(SysRoles model) { if (model == null) { throw new ArgumentNullException("model"); } model.RecordID = GuidGenerator.GetGuid().ToString(); ISysRoles factory = SysRolesFactory.GetFactory(); bool result = factory.AddSysRole(model); if (result) { OperateLogServices.AddOperateLog <SysRoles>(model, OperateType.Add); } return(result); }
public static bool Add(BasePassRemark model) { if (model == null) { throw new ArgumentNullException("model"); } model.RecordID = GuidGenerator.GetGuidString(); IPassRemark factory = PassRemarkFactory.GetFactory(); bool result = factory.Add(model); if (result) { OperateLogServices.AddOperateLog <BasePassRemark>(model, OperateType.Add); } return(result); }
public static bool Add(ParkArea model) { if (model == null) { throw new ArgumentNullException("model"); } model.AreaID = GuidGenerator.GetGuid().ToString(); IParkArea factory = ParkAreaFactory.GetFactory(); bool result = factory.Add(model); if (result) { OperateLogServices.AddOperateLog <ParkArea>(model, OperateType.Add); } return(result); }
public static bool AddParam(ParkDeviceParam model) { if (model == null) { throw new ArgumentNullException("model"); } model.RecordID = GuidGenerator.GetGuid().ToString(); IParkDevice factory = ParkDeviceFactory.GetFactory(); ParkDeviceParam deviceParam = factory.QueryParkDeviceParamByDevID(model.DevID); if (deviceParam != null) { throw new MyException("设备编号不能重复"); } bool result = false; using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); result = factory.AddParam(model, dbOperator); if (!result) { throw new MyException("添加设备参数失败"); } dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } if (result) { OperateLogServices.AddOperateLog <ParkDeviceParam>(model, OperateType.Add); } return(result); }
public static bool Add(BaseCompany model) { if (model == null) { throw new ArgumentNullException("model"); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); model.CPID = GuidGenerator.GetGuid().ToString(); ICompany factory = CompanyFactory.GetFactory(); BaseCompany dbModel = factory.QueryCompanyByCompanyName(model.CPName); if (dbModel != null) { throw new MyException("系统已存在相同单位名称的单位"); } bool result = factory.Add(model, dbOperator); result = SysUserServices.AddCompanyDefaultUser(model, dbOperator); if (!result) { throw new MyException("添加默认用户失败"); } dbOperator.CommitTransaction(); if (result) { OperateLogServices.AddOperateLog <BaseCompany>(model, OperateType.Add); } return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool ResetPassword(string userAccount, string newPassword) { if (string.IsNullOrWhiteSpace(userAccount)) { throw new ArgumentNullException("userAccount"); } if (string.IsNullOrWhiteSpace(newPassword)) { throw new ArgumentNullException("newPassword"); } ISysUser factory = SysUserFactory.GetFactory(); bool result = factory.ResetPassword(userAccount, newPassword); if (result) { OperateLogServices.AddOperateLog(OperateType.Update, string.Format("userAccount:{0},修改密码为:{1}", userAccount, newPassword)); } return(result); }
public static bool UpdateRole(SysRoles model) { if (model == null) { throw new ArgumentNullException("model"); } ISysRoles factory = SysRolesFactory.GetFactory(); bool result = factory.UpdateRole(model); if (result) { model = factory.QuerySysRolesByRecordId(model.RecordID); if (model != null) { OperateLogServices.AddOperateLog <SysRoles>(model, OperateType.Update); } } return(result); }
public static bool Delete(string recordId) { if (string.IsNullOrWhiteSpace(recordId)) { throw new ArgumentNullException("recordId"); } IParkDevice factory = ParkDeviceFactory.GetFactory(); IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory(); bool result = false; using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); result = factory.Delete(recordId, dbOperator); if (!result) { throw new MyException("删除设备失败"); } factoryDetection.Delete(recordId, dbOperator); factory.DeleParam(recordId, dbOperator); dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } if (result) { OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId)); } return(result); }