示例#1
0
        private void UpdateWorkItem(IIncomingEmailMessage message, int workItemId)
        {
            Logger.InfoFormat("Modifying work item {0} subject: {1}", workItemId, message.Subject);

            var resolver        = new SpecialValueResolver(message, _workItemManager.GetNameResolver());
            var workItemUpdates = new Dictionary <string, string>();

            if (_config.WorkItemSettings.OverrideChangedBy)
            {
                workItemUpdates["Changed By"] = resolver.Sender;
            }

            if (_config.WorkItemSettings.ApplyOverridesDuringUpdate)
            {
                var extractor = new OverridesExtractor(_config);
                var overrides = extractor.GetOverrides(message.GetLastMessageText());

                Logger.DebugFormat("Found {0} overrides for update message", overrides.Count);

                overrides.ToList().ForEach(x => workItemUpdates[x.Key] = x.Value);
            }

            // Construct the text to be appended
            _workItemManager.ModifyWorkItem(workItemId, message.GetLastMessageText(), workItemUpdates);

            ProcessAttachments(message, workItemId);

            if (_config.WorkItemSettings.AttachUpdateMessages)
            {
                AttachMessageToWorkItem(message, workItemId, "ReplyMessage");
            }
        }
示例#2
0
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary <string, string> workItemUpdates)
        {
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

            workItemUpdates["Title"] = resolver.Subject;
            var rawConversationIndex = message.ConversationId;

            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] =
                rawConversationIndex.Substring(0, Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));

            foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
            {
                workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value);
            }

            string emailBodyFieldName = _config.WorkItemSettings.EmailBodyFieldName;

            if (!String.IsNullOrEmpty(emailBodyFieldName))
            {
                if (workItemUpdates.Keys.Contains(emailBodyFieldName))
                {
                    Logger.Warn($"Field {emailBodyFieldName} is defined for mapping in {nameof(_config.WorkItemSettings.EmailBodyFieldName)} for mapping. The DefaultValueDefinition entry will be ignored.");
                }
                workItemUpdates[emailBodyFieldName] = MailHeaderExtractor.GetHtmlBody(_config, message, resolver.HtmlMessageBody);
            }
        }
示例#3
0
        private void AppendToWorkItem(IIncomingEmailMessage message, int workItemId)
        {
            Logger.InfoFormat("Modifying work item {0} subject: {1}", workItemId, message.Subject);

            var resolver        = new SpecialValueResolver(message, _workItemManager.GetNameResolver());
            var workItemUpdates = new Dictionary <string, string> {
                { "Changed By", resolver.Sender }
            };

            // Construct the text to be appended
            _workItemManager.ModifyWorkItem(workItemId, message.GetLastMessageText(), workItemUpdates);

            ProcessAttachments(message, workItemId);
        }
示例#4
0
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary <string, string> workItemUpdates)
        {
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

            workItemUpdates["Title"] = resolver.Subject;
            var rawConversationIndex = message.ConversationId;

            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] =
                rawConversationIndex.Substring(0, Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));

            foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
            {
                workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value);
            }
        }
示例#5
0
        private void UpdateWorkItem(IIncomingEmailMessage message, int workItemId)
        {
            Logger.InfoFormat("Modifying work item {0} subject: {1}", workItemId, message.Subject);

            var resolver        = new SpecialValueResolver(message, _workItemManager.GetNameResolver());
            var workItemUpdates = new Dictionary <string, string>();

            if (_config.WorkItemSettings.OverrideChangedBy)
            {
                workItemUpdates["Changed By"] = resolver.Sender;
            }

            bool isHtmlEnabled = _config.WorkItemSettings.EnableExperimentalHtmlFeatures;
            bool commentIsHtml = message.IsHtmlBody && isHtmlEnabled;

            string lastMessageText = message.GetLastMessageText(isHtmlEnabled);

            if (_config.WorkItemSettings.ApplyOverridesDuringUpdate)
            {
                // OverrideExtractor can't currently handle HTML input, so we need to make sure we pass it the plain text version
                string lastMessagePlainText = commentIsHtml
                    ? message.GetLastMessageText(enableExperimentalHtmlFeatures: false)
                    : lastMessageText;

                var extractor = new OverridesExtractor(_config);
                var overrides = extractor.GetOverrides(lastMessagePlainText);

                Logger.DebugFormat("Found {0} overrides for update message", overrides.Count);

                overrides.ToList().ForEach(x => workItemUpdates[x.Key] = x.Value);
            }

            using (var attachments = SaveAttachments(message))
            {
                _workItemManager.ModifyWorkItem(workItemId, lastMessageText, commentIsHtml, workItemUpdates, attachments);
            }

            if (_config.WorkItemSettings.AttachUpdateMessages)
            {
                AttachMessageToWorkItem(message, workItemId, "ReplyMessage");
            }
        }
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary <string, string> workItemUpdates)
        {
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

            //workItemUpdates["Title"] = resolver.Subject;
            workItemUpdates[FieldNames.Incident.CreatedBy]   = resolver.SenderAlias;
            workItemUpdates[FieldNames.Incident.Title]       = resolver.Subject;
            workItemUpdates[FieldNames.Incident.Description] = resolver.MessageBody;
            workItemUpdates[FieldNames.Incident.CreateDate]  = message.SentOn.ToUniversalTime().ToString();

            var rawConversationIndex = message.ConversationIndex;

            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] = rawConversationIndex.Substring(
                0,
                Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));


            foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
            {
                workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value);
            }
        }
示例#7
0
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary <string, string> workItemUpdates)
        {
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

            workItemUpdates["Title"] = resolver.Subject;
            var rawConversationIndex = message.ConversationId;

            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] =
                rawConversationIndex.Substring(0, Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));

            workItemUpdates[_config.WorkItemSettings.ReceivedOnFieldName] = CalcDateTimeForTFS(message.ReceivedOn).ToString();
            workItemUpdates[_config.WorkItemSettings.SentOnFieldName]     = CalcDateTimeForTFS(message.SentOn).ToString();

            foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
            {
                workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value);
            }

            if (workItemUpdates.ContainsKey("Description"))
            {
                workItemUpdates["Description"] = AddInfoBeforeDescription(message, workItemUpdates["Description"]);
            }
        }
示例#8
0
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary <string, string> workItemUpdates, MessageAttachmentCollection attachments)
        {
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

            workItemUpdates["Title"] = resolver.Subject;
            var rawConversationIndex = message.ConversationId;

            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] =
                rawConversationIndex.Substring(0, Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));

            bool enableImgUpdating = _config.WorkItemSettings.EnableExperimentalHtmlFeatures;

            foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
            {
                var result = resolver.Resolve(defaultFieldValue.Value);
                if (enableImgUpdating && message.IsHtmlBody && defaultFieldValue.Value == SpecialValueResolver.RawMessageBodyKeyword)
                {
                    result = EmailBodyProcessingUtils.UpdateEmbeddedImageLinks(result, attachments.Attachments);
                }

                workItemUpdates[defaultFieldValue.Field] = result;
            }
        }
示例#9
0
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary<string, string> workItemUpdates)
    	{
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

    		workItemUpdates["Title"] = resolver.Subject;
            var rawConversationIndex = message.ConversationIndex;
            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] = 
                rawConversationIndex.Substring(0, Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));

    		foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
    		{
    		    workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value);
    		}
    	}
示例#10
0
        private void UpdateWorkItem(IIncomingEmailMessage message, int workItemId)
        {
            Logger.InfoFormat("Modifying work item {0} subject: {1}", workItemId, message.Subject);

            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());
            var workItemUpdates = new Dictionary<string, string>();

            if (_config.WorkItemSettings.OverrideChangedBy)
            {
                workItemUpdates["Changed By"] = resolver.Sender;
            }

            if (_config.WorkItemSettings.ApplyOverridesDuringUpdate)
            {
                var extractor = new OverridesExtractor(_config);
                var overrides = extractor.GetOverrides(message.GetLastMessageText());

                Logger.DebugFormat("Found {0} overrides for update message", overrides.Count);

                overrides.ToList().ForEach(x => workItemUpdates[x.Key] = x.Value);
            }

            // Construct the text to be appended
            _workItemManager.ModifyWorkItem(workItemId, message.GetLastMessageText(), workItemUpdates);

            ProcessAttachments(message, workItemId);

            if (_config.WorkItemSettings.AttachUpdateMessages)
            {
                AttachMessageToWorkItem(message, workItemId, "ReplyMessage");
            }
        }
示例#11
0
        private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary<string, string> workItemUpdates)
        {
            var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver());

            //workItemUpdates["Title"] = resolver.Subject;
            workItemUpdates[FieldNames.Incident.CreatedBy] = resolver.SenderAlias;
            workItemUpdates[FieldNames.Incident.Title] = resolver.Subject;
            workItemUpdates[FieldNames.Incident.Description] = resolver.MessageBody;
            workItemUpdates[FieldNames.Incident.CreateDate] = message.SentOn.ToUniversalTime().ToString();

            var rawConversationIndex = message.ConversationIndex;
            workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] = rawConversationIndex.Substring(
                0,
                Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength));

            foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues)
            {
                workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value);
            }
        }