private void LoadEvents() { tvEvents.Nodes.Clear(); WorkAsync(new WorkAsyncInfo { Message = "Loading Sdk message filters...", Work = (bw, e) => { _events = new List <ISynchronousEvent>(); List <Entity> filters = Service.RetrieveMultiple(new QueryExpression("sdkmessagefilter") { ColumnSet = new ColumnSet("sdkmessageid", "primaryobjecttypecode") }).Entities.ToList(); bw.ReportProgress(0, "Loading SDK messages..."); List <Entity> messages = Service.RetrieveMultiple(new QueryExpression("sdkmessage") { ColumnSet = new ColumnSet("name") }).Entities.ToList(); bw.ReportProgress(25, "Loading Plugin steps..."); _events.AddRange(PluginStep.RetrievePluginSteps(Service, filters, messages)); bw.ReportProgress(50, "Loading Synchronous workflows..."); _events.AddRange(SynchronousWorkflow.RetrieveWorkflowSteps(Service)); }, PostWorkCallBack = e => { if (e.Error != null) { MessageBox.Show(ParentForm, "An error occured: " + e.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { TreeViewHelper tvh = new TreeViewHelper(tvEvents); foreach (ISynchronousEvent sEvent in _events) { tvh.AddSynchronousEvent(sEvent); } } }, ProgressChanged = e => { // it will display "I have found the user id" in this example SetWorkingMessage(e.UserState.ToString()); } }); }
private void LoadEvents() { tvEvents.Nodes.Clear(); WorkAsync(new WorkAsyncInfo { Message = "Loading Sdk message filters...", Work = (bw, e) => { events = new List <ISynchronousEvent>(); var filters = Service.RetrieveMultiple(new QueryExpression("sdkmessagefilter") { ColumnSet = new ColumnSet("sdkmessageid", "primaryobjecttypecode") }).Entities.ToList(); bw.ReportProgress(0, "Loading SDK messages..."); var messages = Service.RetrieveMultiple(new QueryExpression("sdkmessage") { ColumnSet = new ColumnSet("name") }).Entities.ToList(); bw.ReportProgress(0, "Loading Plugin steps..."); events.AddRange(PluginStep.RetrievePluginSteps(Service, filters, messages)); bw.ReportProgress(0, "Loading Synchronous workflows..."); events.AddRange(SynchronousWorkflow.RetrieveTriggeredWorkflows(Service)); bw.ReportProgress(0, "Loading Business Rules..."); events.AddRange(BusinessRules.RetrieveBusinessRules(Service)); }, PostWorkCallBack = e => { if (e.Error != null) { MessageBox.Show(ParentForm, "An error occured: " + e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var tvh = new TreeViewHelper(tvEvents); foreach (var sEvent in events) { tvh.AddSynchronousEvent(sEvent); } } }, ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); } }); }