コード例 #1
0
        private void NewWorkItem(IIncomingEmailMessage message)
        {
            var workItemUpdates = new Dictionary <string, string>();

            InitWorkItemFields(message, workItemUpdates);

            var workItemId = _workItemManager.CreateWorkItem(workItemUpdates);

            Logger.InfoFormat("Added new work item {0} for message with subject: {1} (conversation index:{2})",
                              workItemId, message.Subject, message.ConversationId);

            try
            {
                // Since the work item *has* been created, failures in this stage are not treated as critical
                var overrides = new OverridesExtractor(_config).GetOverrides(message);
                TryApplyFieldOverrides(overrides, workItemId);
                ProcessAttachments(message, workItemId);

                if (_config.WorkItemSettings.AttachOriginalMessage)
                {
                    AttachMessageToWorkItem(message, workItemId, "OriginalMessage");
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Exception caught while applying settings to work item {0}\n{1}", workItemId, ex);
            }

            var workItem = _workItemManager.GetWorkItemFields(workItemId);

            _ackEmailHandler.SendAckEmail(message, workItem);
        }