////////////////////////////////////// // Function runs in worker thread and emulates long process. ////////////////////////////////////// public void Run() { String s; object missing = System.Reflection.Missing.Value; int ii; // Create an instance of Outlook Application and Outlook Contacts folder. //try { //Monitor.Enter(this); s = "Opening Folder \"" + m_folderName + "\""; m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AppendToLog, new Object[] { s }); OutLook1.MAPIFolder fldContacts = null; OutLook1._Application outlookObj = new OutLook1.Application(); //m_ContactList = new List<MyContact>(); if (m_folderName == "Default") { fldContacts = (OutLook1.MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook1.OlDefaultFolders.olFolderContacts); } else { OutLook1.MAPIFolder contactsFolder = (OutLook1.MAPIFolder) outlookObj.Session.GetDefaultFolder(OutLook1.OlDefaultFolders.olFolderContacts); // Verify the custom folder in Outlook. foreach (OutLook1.MAPIFolder subFolder in contactsFolder.Folders) { if (subFolder.Name == m_folderName) { fldContacts = subFolder; break; } } } ///////////////////////////////// // CountFields ///////////////////////////////// //MyContact contact = new MyContact(); MyFields flds = new MyFields(m_form); flds.ClearFieldCount(); ///////////////////////////////// // Load Contacts ///////////////////////////////// s = "Load contacts from Folder \"" + m_folderName + "\""; m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AppendToLog, new Object[] { s }); // Loop through contact in specified folder. ii = 0; foreach (Microsoft.Office.Interop.Outlook._ContactItem OutlookContact in fldContacts.Items) { ii++; if (ii > m_MaxContactsToRead) { break; } // Count used fields flds.AccumulateFields(OutlookContact); // Add contact to list MyContact contact = new MyContact(); contact.Clear(); contact.StoreContact(contact, ii, OutlookContact); // Make synchronous call to main form. // MainForm.AppendToLog function runs in main thread. // (To make asynchronous call use BeginInvoke) // Add line to log //s = m_folderName + "[" + m_MaxContactsToRead + "] " + ii.ToString() + " read"; //m_form.Invoke(m_form.m_DelegateLoadContactsThreadAppendToLog, new Object[] {s}); // Update counter on main form m_form.Invoke(m_form.m_Delegate_LoadContactsThread_UpdateCounter, new Object[] { ii }); // Build Contact List m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AddOneContact, new Object[] { contact }); // Check if thread is cancelled if (m_EventStop.WaitOne(0, true)) { // Clean-up operations may be placed here // ... // Inform main thread that this thread stopped m_EventStopped.Set(); return; } } // Build Field Occurance List flds.PrintFieldCount(); s = "Done"; m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AppendToLog, new Object[] { s }); // Inform the user of the status //m_NumberOfContactsRead = m_ContactList.Count; //m_ContactsInOutlook = m_ContactList.Count; //txtContactsInOutlook.Text = m_ContactList.Count.ToString(); // Make synchronous call to main form // to inform it that thread finished m_form.Invoke(m_form.m_Delegate_LoadContactsThread_Finished, null); //Monitor.Exit(this); } //catch (System.Exception ex) //{ // throw new ApplicationException(ex.Message); //} }
/// <summary> /// Not working. We cannot find out a correct way how to send recepients to the standard workflow for it to work /// </summary> private static void StartStandardWorkflow() { var op = "http://*****:*****@keenmate.com", AccountType = "User" } } } }; data.Add("myFields", allData); IDictionary <string, object> data1 = new Dictionary <string, object>(); //data1.Add("Reviewers", allData.DataFields.SharePointListItem_RW); data1.Add("Assignee", "km\\ondrej.valenta"); var wfResult = interOpService.StartWorkflow("Collect feedback", Guid.NewGuid(), op.LastList.Id, itemId, data1); op.Execute(); var instancesForListItem = instanceService.EnumerateInstancesForListItem(op.LastList.Id, 2); //var wa = op.Context.Web.Lists.GetByTitle("xxx").WorkflowAssociations[0]; //wa. // var wfServicesManager = new WorkflowServicesManager(op.Context, op.LastWeb); //InteropService interopService = wfServicesManager.GetWorkflowInteropService(); //ClientResult<Guid> resultGuid = interopService.StartWorkflow(association.Name, new Guid(), list.Id, itemId, initData); //ctx.ExecuteQuery(); //new WorkflowServicesManager().GetWorkflowInstanceService(). }