/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(string keyValue, TSSchemeInfoEntity entity) { try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { entity.Create(); this.BaseRepository().Insert(entity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 删除实体数据 /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void DeleteEntity(string keyValue) { TSProcessEntity entity = this.BaseRepository().FindEntity <TSProcessEntity>(t => t.F_SchemeInfoId == keyValue && (t.F_State == 1 || t.F_State == 2)); var db = this.BaseRepository().BeginTrans(); try { if (entity != null) { entity.F_State = 10; db.Update(entity); } TSSchemeInfoEntity tSSchemeInfoEntity = new TSSchemeInfoEntity() { F_Id = keyValue, F_DeleteMark = 1 }; db.Update(tSSchemeInfoEntity); db.Commit(); } catch (Exception ex) { db.Rollback(); if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(string keyValue, TSSchemeInfoEntity entity) { try { schemeService.SaveEntity(keyValue, entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(string keyValue, TSSchemeInfoEntity schemeInfoEntity, TSSchemeEntity schemeEntity) { try { TSProcessEntity tSProcessEntity = schemeService.SaveEntity(keyValue, schemeInfoEntity, schemeEntity); if (tSProcessEntity != null) { QuartzHelper.DeleteJob(keyValue); QuartzHelper.AddJob(schemeInfoEntity.F_Id, tSProcessEntity.F_Id, schemeEntity.F_Scheme.ToObject <TSSchemeModel>()); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public TSProcessEntity SaveEntity(string keyValue, TSSchemeInfoEntity schemeInfoEntity, TSSchemeEntity schemeEntity) { TSSchemeModel tSSchemeModel = schemeEntity.F_Scheme.ToObject <TSSchemeModel>(); TSProcessEntity tSProcessEntity = null; TSSchemeEntity schemeEntity2 = null; if (!string.IsNullOrEmpty(keyValue)) { schemeEntity2 = this.BaseRepository().FindEntity <TSSchemeEntity>(t => t.F_IsActive == 1 && t.F_SchemeInfoId == keyValue); } var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { schemeInfoEntity.Modify(keyValue); db.Update(schemeInfoEntity); if (schemeEntity2 == null || schemeEntity2.F_Scheme != schemeEntity.F_Scheme) { schemeEntity.Create(); schemeEntity.F_SchemeInfoId = schemeInfoEntity.F_Id; schemeEntity.F_IsActive = 1; db.Insert(schemeEntity); if (schemeEntity2 != null) { schemeEntity2.F_IsActive = 2; db.Update(schemeEntity2); } // 关闭老的任务进程 TSProcessEntity tSProcessOldEntity = this.BaseRepository().FindEntity <TSProcessEntity>(t => t.F_SchemeInfoId == keyValue && t.F_State != 10); if (tSProcessOldEntity.F_State != 3) { if (tSProcessOldEntity.F_State == 1 || tSProcessOldEntity.F_State == 2) { tSProcessOldEntity.F_State = 10; db.Update(tSProcessOldEntity); } // 新增一个任务进程 tSProcessEntity = new TSProcessEntity() { F_State = 1, F_SchemeId = schemeEntity.F_Id, F_SchemeInfoId = schemeInfoEntity.F_Id, F_EndType = tSSchemeModel.endType, F_EndTime = tSSchemeModel.endTime }; tSProcessEntity.Create(); if (tSSchemeModel.startType == 1) { tSProcessEntity.F_BeginTime = DateTime.Now; } else { tSProcessEntity.F_BeginTime = tSSchemeModel.startTime; } if (tSSchemeModel.endType == 1) { tSProcessEntity.F_EndTime = DateTime.MaxValue; } db.Insert(tSProcessEntity); } } } else { schemeInfoEntity.Create(); db.Insert(schemeInfoEntity); schemeEntity.Create(); schemeEntity.F_SchemeInfoId = schemeInfoEntity.F_Id; schemeEntity.F_IsActive = 1; db.Insert(schemeEntity); // 新增一个任务进程 tSProcessEntity = new TSProcessEntity() { F_State = 1, F_SchemeId = schemeEntity.F_Id, F_SchemeInfoId = schemeInfoEntity.F_Id, F_EndType = tSSchemeModel.endType, F_EndTime = tSSchemeModel.endTime }; tSProcessEntity.Create(); if (tSSchemeModel.startType == 1) { tSProcessEntity.F_BeginTime = DateTime.Now; } else { tSProcessEntity.F_BeginTime = tSSchemeModel.startTime; } if (tSSchemeModel.endType == 1) { tSProcessEntity.F_EndTime = DateTime.MaxValue; } db.Insert(tSProcessEntity); } db.Commit(); return(tSProcessEntity); } catch (Exception ex) { db.Rollback(); if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }