public bool Start() { if (Settings.GetValue(MailHelper.MAILPROCESSOR_SETTINGS, MailHelper.SETTINGS_MODE, null, MailProcessingMode.ExchangePull) != MailProcessingMode.ExchangePush) { return(false); } // renew subscriptions // 1: go through doclibs with email addresses var doclibs = ContentQuery.Query("+TypeIs:DocumentLibrary +ListEmail:* -ListEmail:\"\""); if (doclibs.Count > 0) { Logger.WriteInformation(Logger.EventId.NotDefined, String.Concat("Exchange subscription service enabled, running subscriptions (", doclibs.Count.ToString(), " found)"), ExchangeHelper.ExchangeLogCategory); foreach (var doclib in doclibs.Nodes) { try { ExchangeHelper.Subscribe(doclib); } catch (Exception ex) { Logger.WriteException(ex, ExchangeHelper.ExchangeLogCategory); } } } else { Logger.WriteInformation(Logger.EventId.NotDefined, "Exchange subscription service enabled, no subscriptions found.", ExchangeHelper.ExchangeLogCategory); } return(true); }
private void StartSubscription() { var subscribe = Settings.GetValue <MailProcessingMode>( MailHelper.MAILPROCESSOR_SETTINGS, MailHelper.SETTINGS_MODE, this.Path) == MailProcessingMode.ExchangePush; if (subscribe) { // subscribe to email after saving content. this is done separately from saving the content, // since subscriptionid must be persisted on the content and we use cyclic retrials for that ExchangeHelper.Subscribe(this); } var parent = GetMailProcessorWorkflowContainer(this); if (parent == null) { return; } // get the workflow to start var incomingEmailWorkflow = this.GetReference <Node>("IncomingEmailWorkflow"); if (incomingEmailWorkflow == null) { return; } // set this list as the related content var workflowC = Content.CreateNew(incomingEmailWorkflow.Name, parent, incomingEmailWorkflow.Name); workflowC["RelatedContent"] = this; try { workflowC.Save(); } catch (Exception ex) { SnLog.WriteException(ex, categories: ExchangeHelper.ExchangeLogCategory); } // reflection: because we do not have access to the workflow engine here var t = TypeResolver.GetType("SenseNet.Workflow.InstanceManager", false); if (t == null) { return; } var m = t.GetMethod("Start", BindingFlags.Static | BindingFlags.Public); m.Invoke(null, new object[] { workflowC.ContentHandler }); }
private void StartSubscription() { if (Exchange.Configuration.SubscribeToPushNotifications) { // subscribe to email after saving content. this is done separately from saving the content, // since subscriptionid must be persisted on the content and we use cyclic retrials for that ExchangeHelper.Subscribe(this.ContextNode); } var contextNode = this.ContextNode; var parent = GetParent(contextNode); if (parent == null) { return; } // start workflow var incomingEmailWorkflow = contextNode.GetReference <Node>("IncomingEmailWorkflow"); if (incomingEmailWorkflow == null) { return; } var workflowC = Content.CreateNew(incomingEmailWorkflow.Name, parent, incomingEmailWorkflow.Name); workflowC["RelatedContent"] = contextNode; using (new SystemAccount()) { try { workflowC.Save(); } catch (Exception ex) { Logger.WriteException(ex, ExchangeHelper.ExchangeLogCategory); } } var t = TypeHandler.GetType("SenseNet.Workflow.InstanceManager"); if (t != null) { var m = t.GetMethod("Start", BindingFlags.Static | BindingFlags.Public); m.Invoke(null, new object[] { workflowC.ContentHandler }); } }
private static void StartSubscription(ContentList list) { var subscribe = Settings.GetValue <MailProcessingMode>( MailHelper.MAILPROCESSOR_SETTINGS, MailHelper.SETTINGS_MODE, list.Path) == MailProcessingMode.ExchangePush; if (subscribe) { // subscribe to email after saving content. this is done separately from saving the content, // since subscriptionid must be persisted on the content and we use cyclic retrials for that ExchangeHelper.Subscribe(list); } var parent = GetMailProcessorWorkflowContainer(list); if (parent == null) { return; } // get the workflow to start var incomingEmailWorkflow = list.GetReference <Node>("IncomingEmailWorkflow"); if (incomingEmailWorkflow == null) { return; } // set the list as the related content var workflowC = Content.CreateNew(incomingEmailWorkflow.Name, parent, incomingEmailWorkflow.Name); workflowC["RelatedContent"] = list; try { workflowC.Save(); InstanceManager.Start(workflowC.ContentHandler as WorkflowHandlerBase); } catch (Exception ex) { SnLog.WriteException(ex, categories: ExchangeHelper.ExchangeLogCategory); } }