WorkflowManager.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Web;
  3. using System.Collections;
  4. using System.Web.Services;
  5. using System.Web.Services.Protocols;
  6. /// <summary>
  7. /// Summary description for WorkflowManager
  8. /// </summary>
  9. [WebService(Namespace = "http://tempuri.org/")]
  10. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  11. public class WorkflowManager : System.Web.Services.WebService
  12. {
  13.     public WorkflowManager()
  14.     {
  15.         //Uncomment the following line if using designed components 
  16.         //InitializeComponent(); 
  17.     }
  18.     [WebMethod]
  19.     public long AddPackage(string WorkflowPackage)
  20.     {
  21.         return OThinker.H3.Server.Engine.WorkflowManager.AddPackage(WorkflowPackage);
  22.     }
  23.     [WebMethod]
  24.     public long RegisterWorkflow(
  25.         string UserAlias,
  26.         string Password,
  27.         byte[] Workflow,
  28.         byte[] AssemblyContent,
  29.         byte[] DocumentContent)
  30.     {
  31.         // 检验输入的用户名密码是否正确
  32.         if (!OThinker.H3.Portal.UserValidatorFactory.ValidateUser(OThinker.H3.Server.Engine.Organization, UserAlias, Password))
  33.         {
  34.             return OThinker.H3.ErrorCode.NOT_ENOUGH_PERMISSION;
  35.         }
  36.         // 检验用户是否具备权限
  37.         OThinker.H3.Portal.UserValidator user = OThinker.H3.Portal.UserValidatorFactory.GetValidator(UserAlias);
  38.         if (user == null || !user.ValidatePublishWorkflow())
  39.         {
  40.             return OThinker.H3.ErrorCode.NOT_ENOUGH_PERMISSION;
  41.         }
  42.         OThinker.H3.WorkflowTemplate.WorkflowTemplate template = (OThinker.H3.WorkflowTemplate.WorkflowTemplate)OThinker.Data.Convertor.ByteArrayToObject(Workflow, false);
  43.         template.Designer = user.UserID;
  44.         long result = OThinker.H3.Server.Engine.WorkflowManager.RegisterWorkflow(
  45.             UserAlias,
  46.             Password,
  47.             template,
  48.             AssemblyContent,
  49.             DocumentContent);
  50.         if (result == OThinker.H3.ErrorCode.SUCCESS)
  51.         {
  52.             OThinker.H3.Acl.WorkflowAcl acl = new OThinker.H3.Acl.WorkflowAcl();
  53.             acl.Administrator = false;
  54.             acl.CreateBy = UserAlias;
  55.             acl.CreateInstance = true;
  56.             acl.CreateTime = System.DateTime.Now;
  57.             acl.LastModifyTime = acl.CreateTime;
  58.             acl.ModifyBy = UserAlias;
  59.             acl.UserID = OThinker.H3.Server.Engine.Organization.Company.CompanyID;
  60.             acl.WorkflowName = template.WorkflowName;
  61.             acl.WorkflowPackage = template.WorkflowPackageName;
  62.             OThinker.H3.Server.Engine.WorkflowAclManager.Add(acl);
  63.         }
  64.         return result;
  65.     }
  66.     [WebMethod]
  67.     public OThinker.H3.WorkflowTemplate.WorkflowTemplate GetDefaultVersionWorkflow(
  68.         string WorkflowPackage,
  69.         string WorkflowName)
  70.     {
  71.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
  72.             WorkflowPackage,
  73.             WorkflowName);
  74.     }
  75.     [WebMethod]
  76.     public OThinker.H3.WorkflowTemplate.WorkflowTemplate GetWorkflow(
  77.         string WorkflowPackage,
  78.         string WorkflowName,
  79.         int WorkflowVersion)
  80.     {
  81.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
  82.             WorkflowPackage,
  83.             WorkflowName,
  84.             WorkflowVersion);
  85.     }
  86.     // 列出当前的所有流程类型
  87.     [WebMethod]
  88.     public string[] GetWorkflowPackages()
  89.     {
  90.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
  91.     }
  92.     // 获得某个流行的所有流程名
  93.     [WebMethod]
  94.     public string[] GetWorkflowNames(string WorkflowPackage, OThinker.H3.WorkflowTemplate.WorkflowState State)
  95.     {
  96.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(WorkflowPackage, State);
  97.     }
  98.     // 获得某个流程ID的所有版本
  99.     [WebMethod]
  100.     public int[] GetWorkflowVersions(
  101.         string WorkflowPackage,
  102.         string WorkflowName)
  103.     {
  104.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(
  105.             WorkflowPackage,
  106.             WorkflowName);
  107.     }
  108.     // 获得某个流程的当前默认版本号
  109.     [WebMethod]
  110.     public int GetWorkflowDefaultVersion(
  111.         string WorkflowPackage,
  112.         string WorkflowName)
  113.     {
  114.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowDefaultVersion(
  115.             WorkflowPackage,
  116.             WorkflowName);
  117.     }
  118.     // 设置某个流程的默认版本号
  119.     [WebMethod]
  120.     public long SetWorkflowDefaultVersion(
  121.         string WorkflowPackage,
  122.         string WorkflowName,
  123.         int DefaultVersion)
  124.     {
  125.         return OThinker.H3.Server.Engine.WorkflowManager.SetWorkflowDefaultVersion(
  126.             WorkflowPackage,
  127.             WorkflowName,
  128.             DefaultVersion);
  129.     }
  130.     [WebMethod]
  131.     public OThinker.H3.WorkflowTemplate.WorkflowPerformance GetWorkflowPerformance(
  132.         string[] Originators,
  133.         string Department,
  134.         string WorkflowPackage,
  135.         string WorkflowName,
  136.         int WorkflowVersion,
  137.         System.DateTime CreatedTime_From,
  138.         System.DateTime CreatedTime_To)
  139.     {
  140.         return OThinker.H3.Server.Engine.InstanceManager.GetWorkflowPerformance(
  141.             Originators,
  142.             Department,
  143.             WorkflowPackage,
  144.             WorkflowName,
  145.             WorkflowVersion,
  146.             CreatedTime_From,
  147.             CreatedTime_To);
  148.     }
  149.     /// <summary>
  150.     /// 获得某个任务的性能
  151.     /// </summary>
  152.     /// <param name="Instances"></param>
  153.     /// <param name="ActivityName"></param>
  154.     /// <returns></returns>
  155.     [WebMethod]
  156.     public OThinker.H3.WorkflowTemplate.ActivityPerformance GetActivityPerformance(
  157.         string[] Instances,
  158.         string ActivityName)
  159.     {
  160.         return OThinker.H3.Server.Engine.TokenPool.GetActivityPerformance(
  161.             Instances,
  162.             ActivityName);
  163.     }
  164.     /// <summary>
  165.     /// 获得某个流程的新版本号,这个版本号并不一定能够作为新版本,
  166.     /// 因为可能获得这个版本的时候其他地方又重新发布了一个新版本。
  167.     /// </summary>
  168.     /// <param name="WorkflowPackage"></param>
  169.     /// <param name="WorkflowName"></param>
  170.     /// <returns></returns>
  171.     [WebMethod]
  172.     public int GetWorkflowNewVersion(string WorkflowPackage, string WorkflowName)
  173.     {
  174.         return OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNewVersion(
  175.             WorkflowPackage,
  176.             WorkflowName);
  177.     }
  178. }