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); }
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); } } }
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(); }
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); } } }
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; } } }