public static bool CancelEmployeeIdByEmployeeId(string employeeId) { if (employeeId.IsEmpty()) { throw new ArgumentNullException("employeeId"); } IBaseCard factory = BaseCardFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.CancelEmployeeIdByEmployeeId(employeeId, dbOperator); if (!result) { throw new MyException("取消卡绑定用户信息失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public bool DeleteBySellerID(string sellerId) { List <ParkDerate> models = QueryBySellerID(sellerId); if (models.Count == 0) { return(true); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = CommonDelete("ParkDerate", "SellerID", sellerId, dbOperator); if (!result) { throw new MyException("删除优免信息失败"); } foreach (var item in models) { CommonDelete("ParkDerateIntervar", "DerateID", item.DerateID, dbOperator); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
/// <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 Add(List <SysScopeAuthorize> models) { if (models == null || models.Count == 0) { throw new ArgumentNullException("models"); } ISysScopeAuthorize factory = SysScopeAuthorizeFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.DeleteByScopeId(models.First().ASID, dbOperator); result = factory.Add(models, dbOperator); if (!result) { throw new MyException("保存失败"); } dbOperator.CommitTransaction(); return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
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 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 Recharge(string cardId, decimal balance) { if (cardId.IsEmpty()) { throw new ArgumentNullException("cardId"); } if (balance <= 0) { throw new ArgumentNullException("balance"); } IBaseCard factory = BaseCardFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.Recharge(cardId, balance, dbOperator); if (!result) { throw new MyException("卡片充值失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool Add(List <ParkCarDerate> models) { if (models == null || models.Count == 0) { throw new ArgumentNullException("models"); } IParkCarDerate factory = ParkCarDerateFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); foreach (var item in models) { bool result = factory.Add(item, dbOperator); if (!result) { throw new MyException("保存失败"); } } dbOperator.CommitTransaction(); return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
public bool Add(ParkFeeRule model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = AddFeeRule(model, dbOperator); if (!result) { throw new MyException("添加收费规则失败"); } result = AddFeeRuleDetails(model.ParkFeeRuleDetails, dbOperator); if (!result) { throw new MyException("添加收费规则明细失败"); } dbOperator.CommitTransaction(); return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool Delete(string cardId) { if (cardId.IsEmpty()) { throw new ArgumentNullException("cardId"); } IBaseCard factory = BaseCardFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.Delete(cardId, dbOperator); if (!result) { throw new MyException("删除卡失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool Add(BaseCard model) { if (model == null) { throw new ArgumentNullException("model"); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); IBaseCard factory = BaseCardFactory.GetFactory(); model.CardID = GuidGenerator.GetGuidString(); bool result = factory.Add(model, dbOperator); if (!result) { throw new MyException("添加卡信息失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public bool Delete(string feeRuleId) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = CommonDelete("ParkFeeRule", "FeeRuleID", feeRuleId, dbOperator); if (!result) { throw new MyException("删除收费规则失败"); } result = CommonDelete("ParkFeeRuleDetail", "RuleID", feeRuleId, dbOperator); if (!result) { throw new MyException("删除收费规则明细失败"); } dbOperator.CommitTransaction(); return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static WX_Info AddOrGetWXInfo(WX_Info model) { IWXAccount factory = WXAccountFactory.GetFactory(); WX_Info oldModel = factory.QueryWXInfoByMobilePhone(model.MobilePhone, model.CompanyID); if (oldModel == null) { using (DbOperator dbOperator = ConnectionManager.CreateReadConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.AddWXAccount(model, dbOperator); if (!result) { throw new MyException("添加微信账号信息失败"); } result = factory.AddWXInfo(model, dbOperator); if (!result) { throw new MyException("添加微信信息失败"); } dbOperator.CommitTransaction(); } catch { dbOperator.RollbackTransaction(); throw; } } } return(factory.QueryWXInfoByMobilePhone(model.MobilePhone, model.CompanyID)); }
public static bool Delete(string employeeId) { if (string.IsNullOrWhiteSpace(employeeId)) { throw new ArgumentNullException("employeeId"); } IBaseEmployee factory = BaseEmployeeFactory.GetFactory(); IEmployeePlate platefactory = EmployeePlateFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); //删除车牌 bool result = platefactory.DeleteByEmployeeId(employeeId, dbOperator); if (!result) { throw new MyException("删除车牌失败"); } //删授权表 result = factory.Delete(employeeId, dbOperator); if (!result) { throw new MyException("删除人员信息失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool Create(List <WX_Article> models) { if (models == null || models.Count == 0) { throw new ArgumentNullException("models"); } IWXArticle factory = WXArticleFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); factory.DeleteByGroupID(models.First().GroupID, dbOperator); foreach (var item in models) { bool result = factory.Create(item, dbOperator); if (!result) { throw new MyException("添加图文失败"); } OperateLogServices.AddOperateLog <WX_Article>(item, OperateType.Add); } dbOperator.CommitTransaction(); return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
public bool Add(VisitorInfo model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); dbOperator.ClearParameters(); bool result = AddVisitorInfo(model, dbOperator); if (!result) { throw new MyException("保存访客信息失败"); } if (model.ParkVisitors != null && model.ParkVisitors.Count > 0) { foreach (var item in model.ParkVisitors) { dbOperator.ClearParameters(); result = AddVisitorCar(item, dbOperator); if (!result) { throw new MyException("保存访客车辆信息失败"); } } } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public bool Update(ParkDerate model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = Update(model, dbOperator); if (!result) { throw new MyException("修改优免信息失败"); } CommonDelete("ParkDerateIntervar", "DerateID", model.DerateID, dbOperator); result = AddDerateIntervar(model.DerateIntervar, dbOperator); if (!result) { throw new MyException("添加优免时段信息失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public bool Add(ParkDerate model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = Add(model, dbOperator); if (!result) { throw new MyException("保存优免信息失败"); } result = AddDerateIntervar(model.DerateIntervar, dbOperator); if (!result) { throw new MyException("保存优免时段信息失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
private static bool SyncSellerRecharge(OnlineOrder order, OrderPayWay payWay) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { IParkSeller factory = ParkSellerFactory.GetFactory(); ParkSeller model = factory.QueryBySellerId(order.InOutID); if (model == null) { throw new MyException("商家不存在"); } dbOperator.BeginTransaction(); try { ParkOrder pkOrder = ParkOrderServices.MarkSellerChargeOrder(model, order.Amount, model.SellerID, OrderSource.WeiXin, payWay, dbOperator); if (order == null) { throw new MyException("创建充值订单失败"); } bool result = factory.SellerRecharge(model.SellerID, order.Amount, dbOperator); if (!result) { throw new MyException("商家充值失败"); } dbOperator.CommitTransaction(); return(result); } catch (Exception ex) { dbOperator.RollbackTransaction(); ExceptionsServices.AddExceptions(ex, "商家微信充值通知失败,订单编号:" + order.OrderID); return(false); } } }
public static bool Update(BaseCard model) { if (model == null) { throw new ArgumentNullException("model"); } IBaseCard factory = BaseCardFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.Update(model, dbOperator); if (!result) { throw new MyException("修改卡信息失败"); } dbOperator.CommitTransaction(); return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
/// <summary> /// 月租车恢复使用 /// </summary> /// <param name="cardGrantId"></param> /// <returns></returns> public static bool CarRestoreUse(string grantId) { IParkGrant factory = ParkGrantFactory.GetFactory(); ParkGrant grant = factory.QueryByGrantId(grantId); if (grant == null) { throw new MyException("获取授权信息失败"); } if (grant.State == ParkGrantState.Normal) { return(true); } ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(grant.CarTypeID); if (carType == null) { throw new MyException("获取车型类型失败"); } IParkCardSuspendPlan planFactory = ParkCardSuspendPlanFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); ParkCardSuspendPlan plan = planFactory.QueryByGrantId(grantId); DateTime newEndDate = ComputeParkGrantNewEndDate(grant, plan); grant.BeginDate = grant.BeginDate == null ? DateTime.Now.Date : grant.BeginDate; bool result = factory.RestoreUse(grantId, grant.BeginDate, newEndDate, dbOperator); if (!result) { throw new MyException("恢复暂停失败"); } result = planFactory.Delete(grantId, dbOperator); if (!result) { throw new MyException("取消暂停计划失败"); } dbOperator.CommitTransaction(); ParkGrant dbGrant = factory.QueryByGrantId(grantId); if (dbGrant != null) { OperateLogServices.AddOperateLog <ParkGrant>(dbGrant, OperateType.Update); } OperateLogServices.AddOperateLog(OperateType.Update, string.Format("CarRestore.GrantID:{0}", grantId)); return(result); } catch (Exception ex) { dbOperator.RollbackTransaction(); throw ex; } } }
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 int Save(Guid companyId, IEnumerable <Customer> customers) { if (!customers.Any()) { return(0); } using (var dbOperator = new DbOperator(Provider, ConnectionString)) { dbOperator.BeginTransaction(); try { foreach (var item in customers) { string sql = "IF NOT EXISTS(SELECT NULL FROM dbo.T_Customer WHERE Company=@Company AND Name=@Name AND CredentialsType=@CredentialsType) " + "INSERT INTO dbo.T_Customer (Id,Name,Sex,PassengerType,CredentialsType,Credentials,Mobile,Remark,Company,[Time]) " + "VALUES(@Id,@Name,@Sex,@PassengerType,@CredentialsType,@Credentials,@Mobile,@Remark,@Company,@Time)"; dbOperator.ClearParameters(); dbOperator.AddParameter("Company", companyId); dbOperator.AddParameter("Id", item.Id); dbOperator.AddParameter("Name", item.Name); if (item.Sex.HasValue) { dbOperator.AddParameter("Sex", (byte)item.Sex); } else { dbOperator.AddParameter("Sex", DBNull.Value); } dbOperator.AddParameter("CredentialsType", (byte)item.CredentialsType); dbOperator.AddParameter("Credentials", item.Credentials); if (string.IsNullOrWhiteSpace(item.Mobile)) { dbOperator.AddParameter("Mobile", DBNull.Value); } else { dbOperator.AddParameter("Mobile", item.Mobile); } if (string.IsNullOrWhiteSpace(item.Remark)) { dbOperator.AddParameter("Remark", DBNull.Value); } else { dbOperator.AddParameter("Remark", item.Remark); } dbOperator.AddParameter("PassengerType", (byte)item.PassengerType); dbOperator.AddParameter("Time", DateTime.Now); dbOperator.ExecuteNonQuery(sql); } dbOperator.CommitTransaction(); return(customers.Count()); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool SellerCharge(string sellerId, decimal balance, string operatorId) { if (sellerId.IsEmpty()) { throw new ArgumentNullException("sellerId"); } if (operatorId.IsEmpty()) { throw new ArgumentNullException("operatorId"); } if (balance <= 0) { throw new ArgumentNullException("balance"); } IParkSeller factory = ParkSellerFactory.GetFactory(); ParkSeller model = factory.QueryBySellerId(sellerId); if (model == null) { throw new MyException("商家不存在"); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); ParkOrder order = ParkOrderServices.MarkSellerChargeOrder(model, balance, operatorId, OrderSource.ManageOffice, OrderPayWay.Cash, dbOperator); if (order == null) { throw new MyException("创建充值订单失败"); } bool result = factory.SellerRecharge(sellerId, balance, dbOperator); if (!result) { throw new MyException("取消暂停计划失败"); } dbOperator.CommitTransaction(); ParkSeller newSeller = factory.QueryBySellerId(sellerId); if (newSeller != null) { OperateLogServices.AddOperateLog(OperateType.Update, string.Format("sellerId:{0},充值:{1},余额为:{2}", sellerId, balance, newSeller.Balance)); } return(result); } catch (Exception ex) { dbOperator.RollbackTransaction(); throw ex; } } }
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; } } }
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 DAAdd(List <DAAddMonth> listmonth) { if (listmonth.Count == 0) { throw new ArgumentNullException("employee"); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { dbOperator.BeginTransaction(); try { foreach (var obj in listmonth) { bool result = BaseEmployeeServices.AddOrUpdateBaseEmployee(obj.employye, dbOperator); if (!result) { throw new MyException("保存人员信息失败"); } result = BaseCardServices.AddOrUpdateCard(obj.card, dbOperator); if (!result) { throw new MyException("保存卡信息失败"); } result = EmployeePlateServices.AddOrUpdateEmployeePlate(obj.plate, dbOperator); if (!result) { throw new MyException("保存车牌信息失败"); } obj.grant.PlateID = obj.plate.PlateID; obj.grant.CardID = obj.card.CardID; result = AddOrderUpdateParkGrant(obj.grant, dbOperator); if (!result) { throw new MyException("保存授权失败"); } dbOperator.CommitTransaction(); } return(true); } catch { dbOperator.RollbackTransaction(); throw; } } }
/// <summary> /// 再次同步支付结果 /// </summary> /// <param name="orderId"></param> /// <param name="payTime"></param> /// <returns></returns> public static void AgainSyncPayResult(decimal orderId, DateTime payTime) { lock (order_lock) { IOnlineOrder factory = OnlineOrderFactory.GetFactory(); OnlineOrder order = factory.QueryByOrderId(orderId); if (order.Status == OnlineOrderStatus.SyncPayResultFail) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.SyncPayResultSuccess(orderId, dbOperator); if (!result) { throw new MyException("更改同步成功状态失败"); } string payDetailId = string.Empty; bool noticePayResult = SyncNoticePayResult(orderId, payTime, order, out payDetailId); if (!noticePayResult) { throw new MyException("同步支付结果失败"); } dbOperator.CommitTransaction(); UpdateSyncResultTimes(order.OrderID, payDetailId); SendSyncResultMessage(order); } catch (MyException ex) { dbOperator.RollbackTransaction(); factory.SyncPayResultFail(order.OrderID, ex.Message); } catch (Exception ex) { dbOperator.RollbackTransaction(); factory.SyncPayResultFail(orderId, "同步支付结果异常"); string message = string.Format("【{0}】再次同步支付结果,订单编号:{1},描述:{2}", order.PaymentChannel.GetDescription(), order.OrderTime, ex.Message); ExceptionsServices.AddExceptionToDbAndTxt("OnlineOrderServices", message, ex, LogFrom.WeiXin); } } } } }
public static bool CancelParkGrant(string grantId) { if (grantId.IsEmpty()) { throw new ArgumentNullException("grantId"); } IParkGrant factory = ParkGrantFactory.GetFactory(); IBaseCard cardFactory = BaseCardFactory.GetFactory(); IEmployeePlate plateFactory = EmployeePlateFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { ParkGrant grant = factory.QueryByGrantId(grantId); dbOperator.BeginTransaction(); bool result = plateFactory.Delete(grant.PlateID, dbOperator); if (!result) { throw new MyException("删除车牌失败"); } result = cardFactory.Delete(grant.CardID, dbOperator); if (!result) { throw new MyException("删除卡失败"); } result = factory.Delete(grantId, dbOperator); if (!result) { throw new MyException("删除授权失败"); } dbOperator.CommitTransaction(); if (result) { OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("grantId:{0}", grantId)); } return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
private static bool NoticePaymentResult(OnlineOrder order) { if (order.Status != OnlineOrderStatus.PaySuccess) { TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【通知支付结果】订单不是已支付状态,订单编号:{0},支付账号:{1}", order.OrderID, order.PayAccount); return(false); } bool noticePayResult = false; IOnlineOrder factory = OnlineOrderFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); bool result = factory.SyncPayResultSuccess(order.OrderID, dbOperator); if (!result) { throw new MyException("更改同步成功状态失败"); } string payDetailId = string.Empty; noticePayResult = SyncNoticePayResult(order.OrderID, order.RealPayTime, order, out payDetailId); if (!noticePayResult) { throw new MyException("同步支付结果失败"); } dbOperator.CommitTransaction(); factory.UpdateSyncResultTimes(order.OrderID, payDetailId); SendSyncResultMessage(order); return(true); } catch (MyException ex) { dbOperator.RollbackTransaction(); factory.SyncPayResultFail(order.OrderID, ex.Message); return(false); } catch (Exception ex) { dbOperator.RollbackTransaction(); factory.SyncPayResultFail(order.OrderID, "同步支付结果异常"); TxtLogServices.WriteTxtLogEx("OnlineOrderServices", "【{0}】支付账号{3},订单编号:{1},描述:{2}", order.PaymentChannel.GetDescription(), order.OrderID, ex.Message, order.PayAccount); return(false); } } }