Exemple #1
0
        /// <summary>
        /// Analizza l'email allegata al WI
        /// </summary>
        /// <param name="att">
        /// il path del file temporaneo
        /// </param>
        /// <param name="wiid">
        /// l'id del Work Item per la tracciatura degli errori
        /// </param>
        /// <returns>
        /// I dati della mail allegata al work item
        /// </returns>
        private MailReplyData GetMailData(string att, string wiid)
        {
            try
            {
                var strs   = string.Empty;
                var result = new MailReplyData();
                using (var rdr = new StreamReader(att))
                {
                    strs = rdr.ReadToEnd();
                    var rows = strs.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
                    rows = this.RemoveCodedRows(rows);

                    result.From    = this.GetFromAddress(rows, wiid);
                    result.Subject = this.GetMailSubject(rows, wiid);
                }

                using (var f = File.OpenRead(att))
                {
                    result.Attachment = new byte[f.Length];
                    f.Read(result.Attachment, 0, result.Attachment.Length);
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // faccio pulizia
                TempFileManager.ClearFile(att);
            }
        }
Exemple #2
0
        public int AddNewWIFromMailBug(MessageRequest data)
        {
            var manager = new TFSConnectionManager();

            //var WIToAdd = GetNewWorkItem(Connection, ProjectName, "BUG", AreaPath, IterationPath, data.Subject, data.Body);

            using (var conn = manager.GetConnection())
            {
                WorkItemStore workItemStore = conn.GetService <WorkItemStore>();
                Project       prj           = workItemStore.Projects[ProjectName];
                WorkItemType  workItemType  = prj.WorkItemTypes["BUG"];


                var WIToAdd = new WorkItem(workItemType)
                {
                    Title         = data.Subject,
                    Description   = data.Body,
                    IterationPath = IterationPath,
                    AreaPath      = AreaPath,
                };

                WIToAdd.Fields[this.StepsToReproduceName].Value = data.Body;
                if (!string.IsNullOrWhiteSpace(this.AssignedToValue))
                {
                    WIToAdd.Fields[this.AssignedToName].Value = this.AssignedToValue;
                }

                var filePath = TempFileManager.SaveFileAndGetName(data.FileFormat);
                try
                {
                    WIToAdd.Attachments.Add(new Microsoft.TeamFoundation.WorkItemTracking.Client.Attachment(filePath));
                    WIToAdd.Save();
                    return(WIToAdd.Id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    TempFileManager.ClearFile(filePath);
                }
            }
        }