Esempio n. 1
0
        private void RetryProcess()
        {
            bool newVersion = base.GetBoolProperty(Constants.SOProperties.ErrorLog.TryNewVersion);
            int  procInstId = base.GetIntProperty(Constants.SOProperties.ErrorLog.ProcessInstanceId, true);

            base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            WorkflowManagementServer mngServer = new WorkflowManagementServer();

            using (mngServer.CreateConnection())
            {
                mngServer.Open(BaseAPIConnectionString);

                ErrorProfile           all         = mngServer.GetErrorProfiles()[0];
                ErrorLogCriteriaFilter errorfilter = new ErrorLogCriteriaFilter();
                errorfilter.AddRegularFilter(ErrorLogFields.ProcInstID, Comparison.Equals, procInstId);
                ErrorLogs errors = mngServer.GetErrorLogs(all.ID, errorfilter);

                if (errors.Count != 1)
                {
                    throw new ApplicationException(string.Format("Could not retrieve process (with id: {0}). Got {1} results.", procInstId, errors.Count));
                }

                int errorId = errors[0].ID;

                if (newVersion)
                {
                    int newVersionNumber = 0;
                    ProcessInstanceCriteriaFilter procFilter = new ProcessInstanceCriteriaFilter();
                    procFilter.AddRegularFilter(ProcessInstanceFields.ProcInstID, Comparison.Equals, procInstId);
                    ProcessInstances procs          = mngServer.GetProcessInstancesAll(procFilter);
                    Processes        procesVersions = mngServer.GetProcessVersions(procs[0].ProcSetID);
                    foreach (Process proc in procesVersions)
                    {
                        if (proc.VersionNumber > newVersionNumber)
                        {
                            newVersionNumber = proc.VersionNumber;
                        }
                    }
                    mngServer.SetProcessInstanceVersion(procInstId, newVersionNumber);
                }
                mngServer.RetryError(procInstId, errorId, string.Format("Process Retry using {0}", base.ServiceBroker.Service.ServiceObjects[0].Name));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 设置流程实例最新版本,重试流程错误
        /// </summary>
        /// <param name="procInstID"></param>
        public static void SetProcessInstanceVersionRetry(int procInstID)
        {
            WorkflowManagementServer wms = new WorkflowManagementServer();

            wms.Open(GetK2ManagementServerConnectionString());

            SqlHelper sqlHelper = new SqlHelper(K2ConnectionString);
            var       dt        = sqlHelper.ExecuteDataTable(string.Format("EXEC Utility.GetProcInstNewVersionByProcInstID {0}", procInstID));
            int       Ver       = Convert.ToInt32(dt.Rows[0]["Ver"]);
            int       ErrorID   = Convert.ToInt32(dt.Rows[0]["ErrorID"]);

            if (ErrorID != 0)
            {
                wms.SetProcessInstanceVersion(procInstID, Ver);

                wms.RetryError(procInstID, ErrorID, MngUserID);
            }
        }
        //sample that shows how to repair error on a K2 server
        //in this sample, we want to attempt the "Retry" statement on all workflows currently in Error state
        //be careful doing this on a server with many errored process instances, since executing more than about 20 Retry statements in a very short interval can cause
        //the K2 server to slow down significantly
        public void RepairErrors()
        {
            //establish the connection
            WorkflowManagementServer K2Mgmt = new WorkflowManagementServer();

            K2Mgmt.CreateConnection();
            K2Mgmt.Connection.Open("connectionstring");

            //first get the error profile ID., In this case, we will use the default "All" profile
            int errorProfileId = K2Mgmt.GetErrorProfile("All").ID;

            ErrorLogs K2Errors = K2Mgmt.GetErrorLogs(errorProfileId); //you can also construct a criteria filter to filter the error profile further.

            foreach (ErrorLog K2Error in K2Errors)
            {
                //Do something with the error log entry
                K2Mgmt.RetryError(K2Error.ProcInstID, K2Error.ID, @"domain\username");
            }

            //close the connection
            K2Mgmt.Connection.Close();
        }
Esempio n. 4
0
        private void RetryProcess()
        {
            bool newVersion = base.GetBoolProperty(Constants.SOProperties.ErrorLog.TryNewVersion);
            int procInstId = base.GetIntProperty(Constants.SOProperties.ErrorLog.ProcessInstanceId, true);

            base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            WorkflowManagementServer mngServer = new WorkflowManagementServer();
            using (mngServer.CreateConnection())
            {
                mngServer.Open(BaseAPIConnectionString);

                ErrorProfile all = mngServer.GetErrorProfiles()[0];
                ErrorLogCriteriaFilter errorfilter = new ErrorLogCriteriaFilter();
                errorfilter.AddRegularFilter(ErrorLogFields.ProcInstID, Comparison.Equals, procInstId);
                ErrorLogs errors = mngServer.GetErrorLogs(all.ID, errorfilter);

                if (errors.Count != 1)
                {
                    throw new ApplicationException(string.Format("Could not retrieve process (with id: {0}). Got {1} results.", procInstId, errors.Count));
                }

                int errorId = errors[0].ID;

                if (newVersion)
                {
                    int newVersionNumber = 0;
                    ProcessInstanceCriteriaFilter procFilter = new ProcessInstanceCriteriaFilter();
                    procFilter.AddRegularFilter(ProcessInstanceFields.ProcInstID, Comparison.Equals, procInstId);
                    ProcessInstances procs = mngServer.GetProcessInstancesAll(procFilter);
                    Processes procesVersions = mngServer.GetProcessVersions(procs[0].ProcSetID);
                    foreach (Process proc in procesVersions)
                    {
                        if (proc.VersionNumber > newVersionNumber)
                            newVersionNumber = proc.VersionNumber;
                    }
                    mngServer.SetProcessInstanceVersion(procInstId, newVersionNumber);
                }
                mngServer.RetryError(procInstId, errorId, string.Format("Process Retry using {0}", base.ServiceBroker.Service.ServiceObjects[0].Name));
            }
        }