public override List<ServiceObject> DescribeServiceObjects()
        {
            ServiceObject so = Helper.CreateServiceObject("ProcessInstanceClient", "Exposes functionality to start the workflow.");

            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessFolio, SoType.Text, "The folio to use for the process."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessName, SoType.Text, "The full name of the process."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.StartSync, SoType.YesNo, "Start the process synchronously or not."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId, SoType.Number, "The process instance ID."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessVersion, SoType.Number, "The version number to start. Leave empty for default."));

            Method startProcessInstance = Helper.CreateMethod(Constants.Methods.ProcessInstanceClient.StartProcessInstance, "Start a new process instance", MethodType.Create);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessName);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessVersion);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.StartSync);
            startProcessInstance.Validation.RequiredProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessName);
            startProcessInstance.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId);
            startProcessInstance.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
            so.Methods.Add(startProcessInstance);

            //Adding a separate StartWF method for each workflow, exposing DataFields as Parameters
            WorkflowManagementServer mngServer = new WorkflowManagementServer();
            using (mngServer.CreateConnection())
            {
                mngServer.Open(BaseAPIConnectionString);

                ProcessSets pSets = mngServer.GetProcSets();
                foreach (ProcessSet pSet in pSets)
                {
                    string displayName = Constants.Methods.ProcessInstanceClient.StartProcess + "_" + pSet.FullName;
                    string description = "Starts " + pSet.FullName;
                    Method m = new Method
                    {
                        Name = pSet.FullName,
                        Type = MethodType.Create,
                        MetaData = new MetaData(displayName, description)
                    };
                    m.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
                    m.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.StartSync);
                    m.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessVersion);
                    m.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId);
                    m.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);

                    foreach (ProcessDataField pDataField in mngServer.GetProcessDataFields(pSet.ProcID))
                    {
                        m.MethodParameters.Add(Helper.CreateParameter(pDataField.Name, GetDataFieldType(pDataField.Type), false, pDataField.Name));
                    }
                    so.Methods.Add(m);
                }
            }
            return new List<ServiceObject>() { so };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取流程的全称
        /// </summary>
        /// <returns></returns>
        public static string GetWorkflowName(string WorkflowTypeName)
        {
            WorkflowManagementServer wms = new WorkflowManagementServer();

            wms.Open(GetK2ManagementServerConnectionString());
            ProcessSets processSets = wms.GetProcSets();

            foreach (ProcessSet procSet in processSets)
            {
                if (procSet.StringTable == StringTableType && procSet.Name == WorkflowTypeName)
                {
                    return(procSet.FullName);
                }
            }
            return("");
        }
Ejemplo n.º 3
0
        public static string GetK2ProcessFolder()
        {
            WorkflowManagementServer wms = new WorkflowManagementServer();

            wms.Open(GetK2ManagementServerConnectionString());
            ProcessSets processSets = wms.GetProcSets();

            foreach (ProcessSet procSet in processSets)
            {
                if (procSet.StringTable == StringTableType)
                {
                    return(procSet.Folder);
                }
            }
            return("");
        }
Ejemplo n.º 4
0
        public override List <ServiceObject> DescribeServiceObjects()
        {
            ServiceObject so = Helper.CreateServiceObject("ProcessInstanceClient", "Exposes functionality to start the workflow.");

            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessFolio, SoType.Text, "The folio to use for the process."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessName, SoType.Text, "The full name of the process."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.StartSync, SoType.YesNo, "Start the process synchronously or not."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId, SoType.Number, "The process instance ID."));
            so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.ProcessInstanceClient.ProcessVersion, SoType.Number, "The version number to start. Leave empty for default."));

            Method startProcessInstance = Helper.CreateMethod(Constants.Methods.ProcessInstanceClient.StartProcessInstance, "Start a new process instance", MethodType.Create);

            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessName);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessVersion);
            startProcessInstance.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.StartSync);
            startProcessInstance.Validation.RequiredProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessName);
            startProcessInstance.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId);
            startProcessInstance.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
            so.Methods.Add(startProcessInstance);

            Method setFolio = Helper.CreateMethod(Constants.Methods.ProcessInstanceClient.SetFolio, "Set the folio of a process instance", MethodType.Update);

            setFolio.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId);
            setFolio.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
            setFolio.Validation.RequiredProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId);
            so.Methods.Add(setFolio);

            //Adding a separate StartWF method for each workflow, exposing DataFields as Parameters
            try
            {
                WorkflowManagementServer mngServer = this.ServiceBroker.K2Connection.GetConnection <WorkflowManagementServer>();
                using (mngServer.Connection)
                {
                    ProcessSets pSets = mngServer.GetProcSets();
                    foreach (ProcessSet pSet in pSets)
                    {
                        string displayName = Constants.Methods.ProcessInstanceClient.StartProcess + "_" + pSet.FullName;
                        string description = "Starts " + pSet.FullName;
                        Method m           = new Method
                        {
                            Name     = pSet.FullName,
                            Type     = MethodType.Create,
                            MetaData = new MetaData(displayName, description)
                        };
                        m.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);
                        m.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.StartSync);
                        m.InputProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessVersion);
                        m.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessInstanceId);
                        m.ReturnProperties.Add(Constants.SOProperties.ProcessInstanceClient.ProcessFolio);

                        foreach (ProcessDataField pDataField in mngServer.GetProcessDataFields(pSet.ProcID))
                        {
                            m.MethodParameters.Create(Helper.CreateParameter(pDataField.Name, GetDataFieldType(pDataField.Type), false, pDataField.Name));
                        }
                        so.Methods.Add(m);
                    }
                }
            }
            catch (Exception ex)
            {
                base.ServiceBroker.HostServiceLogger.LogError(Resources.FailedToRetrieveProcesses);
                base.ServiceBroker.HostServiceLogger.LogException(ex);
            }
            return(new List <ServiceObject>()
            {
                so
            });
        }