WorkflowManager.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Web;
- using System.Collections;
- using System.Web.Services;
- using System.Web.Services.Protocols;
- /// <summary>
- /// Summary description for WorkflowManager
- /// </summary>
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- public class WorkflowManager : System.Web.Services.WebService
- {
- public WorkflowManager()
- {
- //Uncomment the following line if using designed components
- //InitializeComponent();
- }
- [WebMethod]
- public long AddPackage(string WorkflowPackage)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.AddPackage(WorkflowPackage);
- }
- [WebMethod]
- public long RegisterWorkflow(
- string UserAlias,
- string Password,
- byte[] Workflow,
- byte[] AssemblyContent,
- byte[] DocumentContent)
- {
- // 检验输入的用户名密码是否正确
- if (!OThinker.H3.Portal.UserValidatorFactory.ValidateUser(OThinker.H3.Server.Engine.Organization, UserAlias, Password))
- {
- return OThinker.H3.ErrorCode.NOT_ENOUGH_PERMISSION;
- }
- // 检验用户是否具备权限
- OThinker.H3.Portal.UserValidator user = OThinker.H3.Portal.UserValidatorFactory.GetValidator(UserAlias);
- if (user == null || !user.ValidatePublishWorkflow())
- {
- return OThinker.H3.ErrorCode.NOT_ENOUGH_PERMISSION;
- }
- OThinker.H3.WorkflowTemplate.WorkflowTemplate template = (OThinker.H3.WorkflowTemplate.WorkflowTemplate)OThinker.Data.Convertor.ByteArrayToObject(Workflow, false);
- template.Designer = user.UserID;
- long result = OThinker.H3.Server.Engine.WorkflowManager.RegisterWorkflow(
- UserAlias,
- Password,
- template,
- AssemblyContent,
- DocumentContent);
- if (result == OThinker.H3.ErrorCode.SUCCESS)
- {
- OThinker.H3.Acl.WorkflowAcl acl = new OThinker.H3.Acl.WorkflowAcl();
- acl.Administrator = false;
- acl.CreateBy = UserAlias;
- acl.CreateInstance = true;
- acl.CreateTime = System.DateTime.Now;
- acl.LastModifyTime = acl.CreateTime;
- acl.ModifyBy = UserAlias;
- acl.UserID = OThinker.H3.Server.Engine.Organization.Company.CompanyID;
- acl.WorkflowName = template.WorkflowName;
- acl.WorkflowPackage = template.WorkflowPackageName;
- OThinker.H3.Server.Engine.WorkflowAclManager.Add(acl);
- }
- return result;
- }
- [WebMethod]
- public OThinker.H3.WorkflowTemplate.WorkflowTemplate GetDefaultVersionWorkflow(
- string WorkflowPackage,
- string WorkflowName)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
- WorkflowPackage,
- WorkflowName);
- }
- [WebMethod]
- public OThinker.H3.WorkflowTemplate.WorkflowTemplate GetWorkflow(
- string WorkflowPackage,
- string WorkflowName,
- int WorkflowVersion)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
- WorkflowPackage,
- WorkflowName,
- WorkflowVersion);
- }
- // 列出当前的所有流程类型
- [WebMethod]
- public string[] GetWorkflowPackages()
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
- }
- // 获得某个流行的所有流程名
- [WebMethod]
- public string[] GetWorkflowNames(string WorkflowPackage, OThinker.H3.WorkflowTemplate.WorkflowState State)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(WorkflowPackage, State);
- }
- // 获得某个流程ID的所有版本
- [WebMethod]
- public int[] GetWorkflowVersions(
- string WorkflowPackage,
- string WorkflowName)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(
- WorkflowPackage,
- WorkflowName);
- }
- // 获得某个流程的当前默认版本号
- [WebMethod]
- public int GetWorkflowDefaultVersion(
- string WorkflowPackage,
- string WorkflowName)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowDefaultVersion(
- WorkflowPackage,
- WorkflowName);
- }
- // 设置某个流程的默认版本号
- [WebMethod]
- public long SetWorkflowDefaultVersion(
- string WorkflowPackage,
- string WorkflowName,
- int DefaultVersion)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.SetWorkflowDefaultVersion(
- WorkflowPackage,
- WorkflowName,
- DefaultVersion);
- }
- [WebMethod]
- public OThinker.H3.WorkflowTemplate.WorkflowPerformance GetWorkflowPerformance(
- string[] Originators,
- string Department,
- string WorkflowPackage,
- string WorkflowName,
- int WorkflowVersion,
- System.DateTime CreatedTime_From,
- System.DateTime CreatedTime_To)
- {
- return OThinker.H3.Server.Engine.InstanceManager.GetWorkflowPerformance(
- Originators,
- Department,
- WorkflowPackage,
- WorkflowName,
- WorkflowVersion,
- CreatedTime_From,
- CreatedTime_To);
- }
- /// <summary>
- /// 获得某个任务的性能
- /// </summary>
- /// <param name="Instances"></param>
- /// <param name="ActivityName"></param>
- /// <returns></returns>
- [WebMethod]
- public OThinker.H3.WorkflowTemplate.ActivityPerformance GetActivityPerformance(
- string[] Instances,
- string ActivityName)
- {
- return OThinker.H3.Server.Engine.TokenPool.GetActivityPerformance(
- Instances,
- ActivityName);
- }
- /// <summary>
- /// 获得某个流程的新版本号,这个版本号并不一定能够作为新版本,
- /// 因为可能获得这个版本的时候其他地方又重新发布了一个新版本。
- /// </summary>
- /// <param name="WorkflowPackage"></param>
- /// <param name="WorkflowName"></param>
- /// <returns></returns>
- [WebMethod]
- public int GetWorkflowNewVersion(string WorkflowPackage, string WorkflowName)
- {
- return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNewVersion(
- WorkflowPackage,
- WorkflowName);
- }
- }