/// <summary> /// 保存模板信息 /// </summary> /// <param name="keyValue">主键</param> /// <param name="wfSchemeInfoEntity">模板基础信息</param> /// <param name="wfSchemeEntity">模板信息</param> public void SaveEntity(string keyValue, WfSchemeInfoEntity wfSchemeInfoEntity, WfSchemeEntity wfSchemeEntity, List <WfSchemeAuthorizeEntity> wfSchemeAuthorizeList) { try { if (!string.IsNullOrEmpty(keyValue)) { WfSchemeEntity wfSchemeEntityOld = GetWfSchemeEntity(wfSchemeInfoEntity.F_SchemeId); if (wfSchemeEntityOld.F_Scheme == wfSchemeEntity.F_Scheme && wfSchemeEntityOld.F_Type == wfSchemeEntity.F_Type) { wfSchemeEntity = null; } cache.Remove(cacheKey + wfSchemeInfoEntity.F_Code, CacheId.workflow); cache.Remove(cacheKey + wfSchemeInfoEntity.F_SchemeId, CacheId.workflow); } wfSchemeService.SaveEntity(keyValue, wfSchemeInfoEntity, wfSchemeEntity, wfSchemeAuthorizeList); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 获取模板的实体通过流程编号 /// </summary> /// <param name="code">流程编号</param> /// <returns></returns> public WfSchemeEntity GetWfSchemeEntityByCode(string code) { try { WfSchemeInfoEntity wfSchemeInfoEntity = GetWfSchemeInfoEntityByCode(code); WfSchemeEntity wfSchemeEntity = cache.Read <WfSchemeEntity>(cacheKey + wfSchemeInfoEntity.F_SchemeId, CacheId.workflow); if (wfSchemeEntity == null) { wfSchemeEntity = wfSchemeService.GetWfSchemeEntity(wfSchemeInfoEntity.F_SchemeId); cache.Write <WfSchemeEntity>(cacheKey + wfSchemeInfoEntity.F_SchemeId, wfSchemeEntity, CacheId.workflow); } return(wfSchemeEntity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 保存模板基础信息 /// </summary> /// <param name="keyValue">主键</param> /// <param name="schemeInfoEntity">模板基础信息</param> public void SaveSchemeInfoEntity(string keyValue, WfSchemeInfoEntity schemeInfoEntity) { try { if (!string.IsNullOrEmpty(keyValue)) { schemeInfoEntity.Modify(keyValue); this.BaseRepository().Update(schemeInfoEntity); } else { schemeInfoEntity.Create(); this.BaseRepository().Insert(schemeInfoEntity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 更新流程模板 /// </summary> /// <param name="schemeInfoId">模板信息主键</param> /// <param name="schemeId">模板主键</param> public void UpdateScheme(string schemeInfoId, string schemeId) { try { WfSchemeEntity wfSchemeEntity = GetWfSchemeEntity(schemeId); WfSchemeInfoEntity entity = new WfSchemeInfoEntity { F_Id = schemeInfoId, F_SchemeId = schemeId }; if (wfSchemeEntity.F_Type != 1) { entity.F_EnabledMark = 0; } this.BaseRepository().Update(entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 保存模板信息 /// </summary> /// <param name="keyValue">主键</param> /// <param name="wfSchemeInfoEntity">模板基础信息</param> /// <param name="wfSchemeEntity">模板信息</param> public void SaveEntity(string keyValue, WfSchemeInfoEntity wfSchemeInfoEntity, WfSchemeEntity wfSchemeEntity, List <WfSchemeAuthorizeEntity> wfSchemeAuthorizeList) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); try { if (string.IsNullOrEmpty(keyValue)) { wfSchemeInfoEntity.Create(); } else { wfSchemeInfoEntity.Modify(keyValue); } #region 模板信息 if (wfSchemeEntity != null) { wfSchemeEntity.F_SchemeInfoId = wfSchemeInfoEntity.F_Id; wfSchemeEntity.Create(); db.Insert(wfSchemeEntity); wfSchemeInfoEntity.F_SchemeId = wfSchemeEntity.F_Id; } #endregion #region 模板基础信息 if (!string.IsNullOrEmpty(keyValue)) { db.Update(wfSchemeInfoEntity); } else { db.Insert(wfSchemeInfoEntity); } #endregion #region 流程模板权限信息 string schemeInfoId = wfSchemeInfoEntity.F_Id; db.Delete <WfSchemeAuthorizeEntity>(t => t.F_SchemeInfoId == schemeInfoId); foreach (var wfSchemeAuthorize in wfSchemeAuthorizeList) { wfSchemeAuthorize.F_SchemeInfoId = schemeInfoId; db.Insert(wfSchemeAuthorize); } #endregion db.Commit(); } catch (Exception ex) { db.Rollback(); if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 保存模板基础信息 /// </summary> /// <param name="keyValue">主键</param> /// <param name="schemeInfoEntity">模板基础信息</param> public void SaveSchemeInfoEntity(string keyValue, WfSchemeInfoEntity schemeInfoEntity) { try { wfSchemeService.SaveSchemeInfoEntity(keyValue, schemeInfoEntity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 更新流程模板 /// </summary> /// <param name="schemeInfoId">模板信息主键</param> /// <param name="schemeId">模板主键</param> public void UpdateScheme(string schemeInfoId, string schemeId) { try { WfSchemeInfoEntity wfSchemeInfoEntity = wfSchemeService.GetWfSchemeInfoEntity(schemeInfoId); cache.Remove(cacheKey + wfSchemeInfoEntity.F_Code, CacheId.workflow); cache.Remove(cacheKey + wfSchemeInfoEntity.F_SchemeId, CacheId.workflow); wfSchemeService.UpdateScheme(schemeInfoId, schemeId); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 虚拟删除模板信息 /// </summary> /// <param name="keyValue">主键</param> public void VirtualDelete(string keyValue) { try { WfSchemeInfoEntity wfSchemeInfoEntity = wfSchemeService.GetWfSchemeInfoEntity(keyValue); cache.Remove(cacheKey + wfSchemeInfoEntity.F_Code, CacheId.workflow); cache.Remove(cacheKey + wfSchemeInfoEntity.F_SchemeId, CacheId.workflow); wfSchemeService.VirtualDelete(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 更新自定义表单模板状态 /// </summary> /// <param name="schemeInfoId">模板信息主键</param> /// <param name="state">状态1启用0禁用</param> public void UpdateState(string schemeInfoId, int state) { try { WfSchemeInfoEntity entity = new WfSchemeInfoEntity { F_Id = schemeInfoId, F_EnabledMark = state }; this.BaseRepository().Update(entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 虚拟删除模板信息 /// </summary> /// <param name="keyValue">主键</param> public void VirtualDelete(string keyValue) { try { WfSchemeInfoEntity entity = new WfSchemeInfoEntity() { F_Id = keyValue, F_DeleteMark = 1 }; this.BaseRepository().Update(entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }