/// <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; } } }