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

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 InstanceManager
  8. /// </summary>
  9. [WebService(Namespace = "http://tempuri.org/")]
  10. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  11. public class InstanceManager : System.Web.Services.WebService
  12. {
  13.     public InstanceManager()
  14.     {
  15.         //Uncomment the following line if using designed components 
  16.         //InitializeComponent(); 
  17.     }
  18.     // 创建一个流程实例,InstanceId为新创建的实例的ID,WorkflowDefinitionID为他的定义的模板的ID
  19.     [WebMethod]
  20.     public string CreateInstance(
  21.         string WorkflowPackage,
  22.         string WorkflowName,
  23.         int WorkflowVersion,
  24.         string InstanceName,
  25.         string Originator,
  26.         string OriginateRole, 
  27.         string Department,
  28.         bool IsChildInstance,
  29.         string ParentInstanceID,
  30.         string ParentActivityName,
  31.         long ParentActivityTokenID)
  32.     {
  33.         return OThinker.H3.Server.Engine.InstanceManager.CreateInstance(
  34.             WorkflowPackage,
  35.             WorkflowName,
  36.             WorkflowVersion,
  37.             InstanceName,
  38.             Originator,
  39.             OriginateRole, 
  40.             Department,
  41.             IsChildInstance,
  42.             ParentInstanceID,
  43.             ParentActivityName, 
  44.             ParentActivityTokenID);
  45.     }
  46.     [WebMethod]
  47.     public void RemoveInstance(string InstanceId)
  48.     {
  49.         OThinker.H3.Server.Engine.InstanceManager.RemoveInstance(InstanceId);
  50.     }
  51.     [WebMethod]
  52.     public void SendMessage(byte[] BinMessage)
  53.     {
  54.         OThinker.H3.Messages.Message message
  55.             = (OThinker.H3.Messages.Message)OThinker.Data.Convertor.ByteArrayToObject(BinMessage, false);
  56.         if (message != null)
  57.         {
  58.             OThinker.H3.Server.Engine.InstanceManager.SendMessage(message);
  59.         }
  60.     }
  61.     // 获得一个实例的状态
  62.     [WebMethod]
  63.     public byte[] GetInstanceContext(string InstanceId)
  64.     {
  65.         OThinker.H3.Instance.InstanceContext context = OThinker.H3.Server.Engine.InstanceManager.GetInstanceContext(InstanceId);
  66.         return OThinker.Data.Convertor.ObjectToByteArray(context, true);
  67.     }
  68.     [WebMethod]
  69.     public string GetInstanceName(string InstanceId)
  70.     {
  71.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceName(InstanceId);
  72.     }
  73.     [WebMethod]
  74.     public void SetInstanceName(string InstanceId, string InstanceName)
  75.     {
  76.         OThinker.H3.Server.Engine.InstanceManager.SetInstanceName(InstanceId, InstanceName);
  77.     }
  78.     [WebMethod]
  79.     public OThinker.H3.Instance.PriorityType GetInstancePriority(string InstanceId)
  80.     {
  81.         return OThinker.H3.Server.Engine.InstanceManager.GetInstancePriority(InstanceId);
  82.     }
  83.     [WebMethod]
  84.     public void SetInstancePriority(string InstanceId, OThinker.H3.Instance.PriorityType Priority)
  85.     {
  86.         OThinker.H3.Server.Engine.InstanceManager.SetInstancePriority(InstanceId, Priority);
  87.     }
  88.     [WebMethod]
  89.     public string GetInstanceOriginator(string InstanceId)
  90.     {
  91.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceOriginator(InstanceId);
  92.     }
  93.     [WebMethod]
  94.     public string GetInstanceOriginateGroup(string InstanceId)
  95.     {
  96.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceOriginateGroup(InstanceId);
  97.     }
  98.     [WebMethod]
  99.     public System.DateTime GetInstanceCreateTime(string InstanceId)
  100.     {
  101.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceCreateTime(InstanceId);
  102.     }
  103.     [WebMethod]
  104.     public string GetInstanceWorkflowPackage(string InstanceId)
  105.     {
  106.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowPackage(InstanceId);
  107.     }
  108.     [WebMethod]
  109.     public string GetInstanceWorkflowName(string InstanceId)
  110.     {
  111.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowName(InstanceId);
  112.     }
  113.     [WebMethod]
  114.     public int GetInstanceWorkflowVersion(string InstanceId)
  115.     {
  116.         return OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowVersion(InstanceId);
  117.     }
  118.     /// <summary>
  119.     /// 查找符合条件的实例
  120.     /// </summary>
  121.     /// <param name="ParentInstanceID">父实例ID,如果为OThinker.H3.Instance.InstanceContext.UnspecifiedID,则忽略</param>
  122.     /// <param name="InstanceState">实例状态,如果为OThinker.H3.Instance.InstanceState.Unspecified,则忽略</param>
  123.     /// <param name="WorkflowPackage">流程类型,如果为null,则忽略</param>
  124.     /// <param name="WorkflowName">流程名,如果为null,则忽略</param>
  125.     /// <param name="WorkflowVersion">流程版本号,如果为OThinker.H3.Workflow.Workflow.AllWorkflowVersion,则忽略</param>
  126.     /// <param name="CreateTime_From">最小创建时间,如果为System.DateTime.MinValue,则忽略</param>
  127.     /// <param name="CreateTime_To">最大创建时间,如果为System.DateTime.MaxValue,则忽略</param>
  128.     /// <returns>实例ID</returns>
  129.     [WebMethod]
  130.     public string[] Query(
  131.         string[] Originators,
  132.         string Department,
  133.         string ParentInstanceID,
  134.         OThinker.H3.Instance.InstanceState InstanceState,
  135.         string WorkflowPackage,
  136.         string WorkflowName,
  137.         int WorkflowVersion,
  138.         System.DateTime CreatedTime_From,
  139.         System.DateTime CreatedTime_To,
  140.             string Name)
  141.     {
  142.         return OThinker.H3.Server.Engine.InstanceManager.Query(
  143.             Originators,
  144.             Department,
  145.             ParentInstanceID,
  146.             InstanceState,
  147.             WorkflowPackage,
  148.             WorkflowName,
  149.             WorkflowVersion,
  150.             CreatedTime_From,
  151.             CreatedTime_To, 
  152.             Name);
  153.     }
  154.     [WebMethod]
  155.     public System.Data.DataTable QueryDataTable(
  156.             string[] Instances,
  157.             string[] Originators,
  158.             string Department,
  159.             string ParentInstanceID,
  160.             OThinker.H3.Instance.InstanceState InstanceState,
  161.             string WorkflowPackage,
  162.             string WorkflowName,
  163.             int WorkflowVersion,
  164.             System.DateTime CreatedTime_From,
  165.             System.DateTime CreatedTime_To,
  166.             string Name,
  167.             OThinker.H3.Instance.PriorityType Priority)
  168.     {
  169.         return OThinker.H3.Portal.Query.QueryInstance(
  170.             Instances,
  171.             Originators,
  172.             Department,
  173.             ParentInstanceID,
  174.             InstanceState,
  175.             WorkflowPackage,
  176.             WorkflowName,
  177.             WorkflowVersion,
  178.             CreatedTime_From,
  179.             CreatedTime_To,
  180.             Name,
  181.             Priority, 
  182.             OThinker.Data.BoolMatchValue.Unspecified, 
  183.             OThinker.Data.BoolMatchValue.Unspecified);
  184.     }
  185.     /// <summary>
  186.     /// 获得流程的性能
  187.     /// </summary>
  188.     /// <param name="WorkflowPackage"></param>
  189.     /// <param name="WorkflowName"></param>
  190.     /// <param name="WorkflowVersion"></param>
  191.     /// <param name="CreatedTime_From"></param>
  192.     /// <param name="CreatedTime_To"></param>
  193.     /// <returns></returns>
  194.     [WebMethod]
  195.     public OThinker.H3.WorkflowTemplate.WorkflowPerformance GetWorkflowPerformance(
  196.         string[] Originators,
  197.         string Department,
  198.         string WorkflowPackage,
  199.         string WorkflowName,
  200.         int WorkflowVersion,
  201.         System.DateTime CreatedTime_From,
  202.         System.DateTime CreatedTime_To)
  203.     {
  204.         return OThinker.H3.Server.Engine.InstanceManager.GetWorkflowPerformance(
  205.             Originators,
  206.             Department,
  207.             WorkflowPackage,
  208.             WorkflowName,
  209.             WorkflowVersion,
  210.             CreatedTime_From,
  211.             CreatedTime_To);
  212.     }
  213.     /// <summary>
  214.     /// 绘制流程图
  215.     /// </summary>
  216.     /// <param name="InstanceId"></param>
  217.     /// <param name="FinishedElements"></param>
  218.     /// <param name="RunningElements"></param>
  219.     /// <returns></returns>
  220.     [WebMethod]
  221.     public byte[] ChartInstanceState(
  222.         string InstanceId,
  223.          string[] FinishedActivities,
  224.             string[] RunningActivities,
  225.             string[] ExceptionalActivities)
  226.     {
  227.         return OThinker.H3.Server.Engine.InstanceManager.ChartInstanceState(InstanceId, FinishedActivities, RunningActivities, ExceptionalActivities);
  228.     }
  229.     /// <summary>
  230.     /// 获得父流程的工作流信息
  231.     /// </summary>
  232.     /// <param name="InstanceId"></param>
  233.     /// <returns></returns>
  234.     [WebMethod]
  235.     public OThinker.H3.Instance.ParentInstanceInfo GetParentInstanceInfo(string InstanceId)
  236.     {
  237.         return OThinker.H3.Server.Engine.InstanceManager.GetParentInstanceInfo(InstanceId);
  238.     }
  239. }