前面两章讲解了工作流的整体设计和数据库设计,从这章开始就讲类的设计。整体来说我们分为4个部分:数据库访问部分,Activity活动部分,业务接口部分,引擎核心部分和生成待办部分。
一. 数据库访问部分设计. 也就是工作流的底层访问部分。这部分主要是用来操作工作流数据库的,功能点上主要包括:工作流模板信息,工作流活动信息,工作流活动角色信息,工作流活动条件信息,工作流实例信息,工作流实例节点信息,工作流实例节点角色信息,工作流实例条件信息和审批日志。下面是具体接口的代码:
1. 工作流模板.
public interface IWorkflowTemplateService
{
/// <summary>
/// Get the entity of WorkflowTemplate by entity id
/// </summary>
/// <param name="workflow">entity id which is from XML and ready it by Foundation service</param>
/// <returns>return the WorkflowTemplate result which only one</returns>
WorkflowTemplateResult ReadByWorkflow(string workflow);
/// <summary>
/// Get the entity of WorkflowTemplate by template id
/// </summary>
/// <param name="workflow">the primary key which belongs to WorkflowTemplate</param>
/// <returns>return the WorkflowTemplate result which only one</returns>
WorkflowTemplateResult ReadByTemplateID(Guid templateID);
/// <summary>
/// Save the entity of WorkflowTemplate
/// </summary>
/// <param name="data">the entity of WorkflowTemplate</param>
/// <returns>operation result which true or false</returns>
[OperationContract]
bool Save(WorkflowTemplateParameter data);
/// <summary>
/// Delete the entity of WorkflowTemplate
/// </summary>
/// <param name="templateID">The entity of primary key</param>
/// <returns>return operation result which true or false</returns>
bool Delete(Guid templateID);
/// <summary>
/// Update the entity of WorkflowTemplate
/// </summary>
/// <param name="data">the newer entity of WorkTemplate</param>
/// <returns>return operation result which true or false</returns>
bool Update(WorkflowTemplateParameter data);
}
2. Activity活动
public interface IWorkflowTemplateFlowService
{
/// <summary>
/// Get the entity of WorkflowTemplateFlow by Flow id
/// </summary>
/// <param name="FlowID">the primary key of WorkflowTemplateFlow</param>
/// <returns>return the WorkflowTemplateFlow result which only one</returns>
WorkflowTemplateFlowResult ReadByFlowID(Guid FlowID);
/// <summary>
/// Get the entity of WorkflowTemplateFlow by workflow template id
/// </summary>
/// <param name="templateID">workflow template id which belongs to WorkflowTemplateFlowResult</param>
/// <returns>return the WorkflowTemplateFlow array</returns>
List<WorkflowTemplateFlowResult> ReadByTemplateID(Guid templateID);
/// <summary>
/// Get the first entity of WorkflowTemplateFlow by entity id
/// </summary>
/// <param name="templateID">workflow template id which belongs to WorkflowTemplate</param>
/// <returns>return the first WorkflowTemplateFlow which only one</returns>
[OperationContract]
WorkflowTemplateFlowResult ReadFirstByTemplateID(Guid templateID);
/// <summary>
/// Get the closed entity of WorkflowTemplateFlow by Flow id
/// </summary>
/// <param name="FlowID">workflow template id which belongs to WorkflowTemplate</param>
/// <returns>return the WorkflowTemplateFlow array</returns>
List<WorkflowTemplateFlowResult> ReadNextByFlowID(Guid flowID);
/// <summary>
/// Get the entity of WorkflowTemplateFlowResult which is container by entity id
/// </summary>
/// <param name="templateID">the parent Flow id</param>
/// <returns>return the WorkflowTemplateFlowResult result which only one</returns>
WorkflowTemplateFlowResult ReadNoContainerNextByFlowID(Guid flowID);
/// <summary>
/// Get the entity of WorkflowTemplateFlowResult by entity id
/// </summary>
/// <param name="templateID">entity id which is from XML and ready it by Foundation service</param>
/// <returns>return the WorkflowTemplateFlow array which contains the Flow's child</returns>
List<WorkflowTemplateFlowResult> ReadContainerNextByFlowID(Guid flowID);
/// <summary>
/// Save the entity of WorkflowTemplateFlow
/// </summary>
/// <param name="data">the entity of WorkflowTemplateFlow</param>
/// <returns>operation result which true or false</returns>
Guid Save(WorkflowTemplateFlowParameter data);
/// <summary>
/// Delete the entity of WorkflowTemplateFlow
/// </summary>
/// <param name="templateID">The entity of primary key</param>
/// <returns>return operation result which true or false</returns>
bool Delete(Guid flowID);
/// <summary>
/// Delete the list of WorkflowTemplateFlow
/// </summary>
/// <param name="flowIDs">the list of keys</param>
/// <returns>return opeation result which true or false</returns>
bool DeleteList(List<Guid> flowIDs);
/// <summary>
/// Update the entity of WorkflowTemplateFlow
/// </summary>
/// <param name="data">the newer entity of WorkflowTemplateFlow</param>
/// <returns>return operation result which true or false</returns>
bool Update(WorkflowTemplateFlowParameter data);
/// <summary>
/// Delete the entity of WorkflowTemplateFlow
/// </summary>
/// <param name="templateID">The entity of primary key</param>
/// <returns>return operation result which true or false</returns>
bool SaveAndUpdateChild(WorkflowTemplateFlowParameter nowData, Guid childFlowID);
}
public interface IWorkflowRunLogService
{
/// <summary>
/// Save the workflow run log
/// </summary>
/// <param name="data">the entity of WorkflowRunLog</param>
/// <returns>return the operation record's primary key</returns>
Guid Save(WorkflowRunLogParameter data);
/// <summary>
/// Get the list of WorkflowRunLogResult by workflow instance id
/// </summary>
/// <param name="instanceFlowID">the workflow instance id</param>
/// <returns>return the WorkflowRunLogResult array</returns>
List<WorkflowRunLogResult> ReadByFlowID(Guid flowID);
/// <summary>
/// Get the list of WorkflowRunLogResult by workflow instance id
/// </summary>
/// <param name="instanceFlowID">the workflow instance id</param>
/// <returns>return the WorkflowRunLogResult array</returns>
List<WorkflowRunLogResult> ReadByInstanceID(Guid instanceID);
/// <summary>
/// Get the entity of WorkflowRunLogResult by primary key
/// </summary>
/// <param name="logID">the primary key of WorkflowRunLogResult</param>
/// <returns>return the one WorkflowRunLogResult</returns>
WorkflowRunLogResult Read(Guid logID);
/// <summary>
/// Update the logs's status by flowID
/// </summary>
/// <param name="flowID">the key of WorkflowInstantceFlow</param>
/// <param name="status">the target status</param>
/// <returns>return true or false</returns>
bool UpdateStatus(Guid flowID, RunStatus status);
/// <summary>
/// Update the logs's status by flowID
/// </summary>
/// <param name="flowID">the keys of WorkflowInstantceFlow</param>
/// <param name="status">the target status</param>
/// <returns>return true or false</returns>
bool UpdateListStatus(List<Guid> flowIDs, RunStatus status);
}