Пример #1
0
        public ErrorLogs GetWorkflowErrors()
        {
            ErrorLogCriteriaFilter filter = new ErrorLogCriteriaFilter();

            filter.AddRegularFilter(ErrorLogFields.Date, Comparison.GreaterOrEquals, DateTime.Now.Date);
            ErrorLogs errorLogs = _server.GetErrorLogs(_server.GetErrorProfile("All").ID, filter);

            return(errorLogs);
        }
Пример #2
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));
            }
        }
Пример #3
0
        private void GetErrors()
        {
            string profile = base.GetStringProperty(Constants.SOProperties.ErrorLog.Profile);

            if (string.IsNullOrEmpty(profile))
            {
                profile = "All";
            }

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

            WorkflowManagementServer mngServer = this.ServiceBroker.K2Connection.GetConnection <WorkflowManagementServer>();

            using (mngServer.Connection)
            {
                ErrorProfile prof = mngServer.GetErrorProfile(profile);
                if (prof == null)
                {
                    throw new Exception(string.Format(Resources.ProfileNotFound, profile));
                }

                ErrorLogs errors = mngServer.GetErrorLogs(prof.ID);

                foreach (ErrorLog e in errors)
                {
                    DataRow r = results.NewRow();
                    r[Constants.SOProperties.ErrorLog.ProcessInstanceId] = e.ProcInstID;
                    r[Constants.SOProperties.ErrorLog.ProcessName]       = e.ProcessName;
                    r[Constants.SOProperties.ErrorLog.Folio]             = e.Folio;
                    r[Constants.SOProperties.ErrorLog.ErrorDescription]  = e.Description;
                    r[Constants.SOProperties.ErrorLog.ErrorItem]         = e.ErrorItemName;
                    r[Constants.SOProperties.ErrorLog.ErrorDate]         = e.ErrorDate;
                    r[Constants.SOProperties.ErrorLog.ErrorId]           = e.ID;
                    r[Constants.SOProperties.ErrorLog.TypeDescription]   = e.TypeDescription;
                    r[Constants.SOProperties.ErrorLog.ExecutingProcId]   = e.ExecutingProcID;
                    r[Constants.SOProperties.ErrorLog.StackTrace]        = e.StackTrace;
                    results.Rows.Add(r);
                }
            }
        }
Пример #4
0
        private void GetErrors()
        {
            string profile = base.GetStringProperty(Constants.SOProperties.ErrorLog.Profile);

            if (string.IsNullOrEmpty(profile))
            {
                profile = "All";
            }

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

            WorkflowManagementServer mngServer = new WorkflowManagementServer();

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

                //TODO: catch exception on this?
                ErrorProfile prof   = mngServer.GetErrorProfile(profile);
                ErrorLogs    errors = mngServer.GetErrorLogs(prof.ID);

                foreach (ErrorLog e in errors)
                {
                    DataRow r = results.NewRow();
                    r[Constants.SOProperties.ErrorLog.ProcessInstanceId] = e.ProcInstID;
                    r[Constants.SOProperties.ErrorLog.ProcessName]       = e.ProcessName;
                    r[Constants.SOProperties.ErrorLog.Folio]             = e.Folio;
                    r[Constants.SOProperties.ErrorLog.ErrorDescription]  = e.Description;
                    r[Constants.SOProperties.ErrorLog.ErrorItem]         = e.ErrorItemName;
                    r[Constants.SOProperties.ErrorLog.ErrorDate]         = e.ErrorDate;
                    r[Constants.SOProperties.ErrorLog.ErrorId]           = e.ID;
                    r[Constants.SOProperties.ErrorLog.TypeDescription]   = e.TypeDescription;
                    r[Constants.SOProperties.ErrorLog.ExecutingProcId]   = e.ExecutingProcID;
                    r[Constants.SOProperties.ErrorLog.StackTrace]        = e.StackTrace;
                    results.Rows.Add(r);
                }
            }
        }
        //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();
        }
        //sample that shows how to list workflows in error state
        //in this sample, we just want to output all workflows that are in error state
        public void ListErrors()
        {
            //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
                Console.WriteLine(K2Error.Description);
            }

            //close the connection
            K2Mgmt.Connection.Close();
        }
Пример #7
0
        private void GetErrors()
        {
            string profile = base.GetStringProperty(Constants.SOProperties.ErrorLog.Profile);
            if (string.IsNullOrEmpty(profile))
            {
                profile = "All";
            }

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

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

                //TODO: catch exception on this?
                ErrorProfile prof = mngServer.GetErrorProfile(profile);
                ErrorLogs errors = mngServer.GetErrorLogs(prof.ID);

                foreach (ErrorLog e in errors)
                {
                    DataRow r = results.NewRow();
                    r[Constants.SOProperties.ErrorLog.ProcessInstanceId] = e.ProcInstID;
                    r[Constants.SOProperties.ErrorLog.ProcessName] = e.ProcessName;
                    r[Constants.SOProperties.ErrorLog.Folio] = e.Folio;
                    r[Constants.SOProperties.ErrorLog.ErrorDescription] = e.Description;
                    r[Constants.SOProperties.ErrorLog.ErrorItem] = e.ErrorItemName;
                    r[Constants.SOProperties.ErrorLog.ErrorDate] = e.ErrorDate;
                    r[Constants.SOProperties.ErrorLog.ErrorId] = e.ID;
                    results.Rows.Add(r);
                }
            }
        }
Пример #8
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));
            }
        }
 private SourceCode.Workflow.Management.ErrorLog GetLastError() //////int ErrorCountBeforeTests, out int LastErrorNumBeforeTests )
 {
     WorkflowManagementServer ManagementServer = null;
     try
     {
         ManagementServer = new WorkflowManagementServer();
         ManagementServer.Open(ConfigHelper.GetConnectionString("ManagementServerCS"));
         ErrorProfile profile = ManagementServer.GetErrorProfile("All");
         ErrorLogCriteriaFilter elcf = new ErrorLogCriteriaFilter();
         elcf.ORDER_BY(ErrorLogFields.ErrorLogID, CriteriaSortOrder.Ascending);
         ErrorLogs logs = ManagementServer.GetErrorLogs(profile.ID);
         if (logs.Count > 0)
         {
             return logs[logs.Count - 1];
         }
         else
         {
             return null;
         }
     }
     finally
     {
         if (ManagementServer != null && ManagementServer.Connection != null)
         {
             ManagementServer.Connection.Dispose();
             ManagementServer = null;
         }
     }
 }