Пример #1
0
        public void Run()
        {
            string tempFolder = Path.Combine(Path.GetTempPath(), "Mail2WorkItem");

            Directory.CreateDirectory(tempFolder);

            try
            {
                var picker = new MailPicker(
                    this.logger,
                    configuration.Pop3.Hostname, configuration.Pop3.Port, configuration.Pop3.UseSsl,
                    configuration.Pop3.Username, configuration.Pop3.Password,
                    tempFolder);
                var messages = picker.ReadAll();

                if (messages.Count > 0)
                {
                    var tfs = new TfsFacade(
                        this.logger,
                        new Uri(configuration.TFS.CollectionUrl), configuration.TFS.ProjectName,
                        configuration.TFS.WorkItemType);
                    foreach (var mail in messages)
                    {
                        int workItemId = tfs.AddWorkItem(mail);
                        var model      = PrepareConfirmationModel(tfs, mail, workItemId);
                        SendConfirmation(mail.From, model);
                    } //for
                }     //if
            }
            catch (Exception e)
            {
                logger.UnexpectedError(e);
            }
            finally
            {
                logger.RemovingTemporaryFolder(tempFolder);
                Directory.Delete(tempFolder, true);
            }//try
        }