/// <summary> /// 添加年检代办配置 /// </summary> /// <param name="model"></param> /// <param name="user"></param> /// <returns></returns> public bool AddVehicleAnnualInspectionAgent(VehicleAnnualInspectionAgentModel model, string user) { var result = false; try { var oldValue = GetVehicleAnnualInspectionAgent(model.ServicePid, model.TelNum, model.CarNoPrefix); if (oldValue == null) { var pkid = dbScopeManagerConfiguration.Execute (conn => DalVehicleAnnualInspectionAgent.AddVehicleAnnualInspectionAgent(conn, model)); result = pkid > 0; model.PKID = pkid; } else if (oldValue.IsDeleted) { model.PKID = oldValue.PKID; result = dbScopeManagerConfiguration.Execute (conn => DalVehicleAnnualInspectionAgent.UpdateVehicleAnnualInspectionAgent(conn, model)); } model.CreateDateTime = DateTime.Now; model.LastUpdateDateTime = DateTime.Now; var log = new AnnualInspectionOprLogModel { LogType = "VehicleAnnualInspectionAgent", IdentityId = $"{model.CarNoPrefix}_{model.ServicePid}_{model.TelNum}", OperationType = "Add", OldValue = null, NewValue = JsonConvert.SerializeObject(model), Remarks = $"添加{model.CarNoPrefix},供应商:{model.VenderShortName}," + $"服务Pid:{model.ServicePid},联系人:{model.Contact},联系电话:{model.TelNum}," + $"的{model.ServiceName}服务", Operator = user, }; LoggerManager.InsertLog("AnnualInspectOprLog", log); } catch (Exception ex) { result = false; Logger.Error("AddVehicleAnnualInspectionAgent", ex); } return(result); }
/// <summary> /// 更新年检代办配置 /// </summary> /// <param name="model"></param> /// <param name="user"></param> /// <returns></returns> public bool UpdateVehicleAnnualInspectionAgent (VehicleAnnualInspectionAgentModel model, string user) { var result = false; try { var oldValue = GetVehicleAnnualInspectionAgent(model.ServicePid, model.TelNum, model.CarNoPrefix); if (oldValue != null) { result = dbScopeManagerConfiguration.Execute(conn => DalVehicleAnnualInspectionAgent.UpdateVehicleAnnualInspectionAgent(conn, model)); if (!result) { throw new Exception($"UpdateVehicleAnnualInspectionAgent失败,待更新数据{JsonConvert.SerializeObject(model)}"); } model.CreateDateTime = oldValue.CreateDateTime; model.LastUpdateDateTime = DateTime.Now; var log = new AnnualInspectionOprLogModel { LogType = "VehicleAnnualInspectionAgent", IdentityId = $"{model.CarNoPrefix}_{model.ServicePid}_{model.TelNum}", OperationType = "Update", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(model), Remarks = $"更新{model.CarNoPrefix},供应商:{model.VenderShortName},服务Pid:{model.ServicePid}," + $"联系人:{model.Contact},联系电话{model.TelNum}的{model.ServiceName}服务", Operator = user, }; LoggerManager.InsertLog("AnnualInspectOprLog", log); } } catch (Exception ex) { result = false; Logger.Error("UpdateVehicleAnnualInspectionAgent", ex); } return(result); }