Exemple #1
0
        private HistoryBuilder CreateHistoryBuilder()
        {
            HistoryBuilder history = new HistoryBuilder();

            while (m_historyFieldValue.Contains("<div><img src='"))
            {
                history.Append <string>(m_historyFieldValue.Substring(0, m_historyFieldValue.IndexOf("<div><img src='", StringComparison.Ordinal) + 15));

                m_historyFieldValue = m_historyFieldValue.Substring(m_historyFieldValue.IndexOf("<div><img src='", StringComparison.Ordinal) + 15);

                string     attachmentPath = m_historyFieldValue.Substring(0, m_historyFieldValue.IndexOf("' /></div>", StringComparison.Ordinal));
                Attachment attachment     = new Attachment(attachmentPath);
                m_workItem.Attachments.Add(attachment);
                history.Append <Attachment>(attachment);

                m_historyFieldValue = m_historyFieldValue.Substring(m_historyFieldValue.IndexOf("' /></div>", StringComparison.Ordinal));
            }
            history.Append <string>(m_historyFieldValue);
            return(history);
        }
Exemple #2
0
 public virtual void Save()
 {
     try
     {
         if (!string.IsNullOrEmpty(m_historyFieldValue))
         {
             if (m_historyFieldValue.Contains("<div><img src='"))
             {
                 HistoryBuilder history = CreateHistoryBuilder();
                 m_workItem.Save();
                 m_workItem.Fields["History"].Value = history.Text;
                 m_workItem.Save();
             }
             else
             {
                 m_workItem.Fields["History"].Value = m_historyFieldValue;
                 m_workItem.Save();
             }
         }
         else
         {
             m_workItem.Save();
         }
     }
     catch (TeamFoundationServerException)
     {
         string error = string.Empty;
         foreach (Field field in m_workItem.Fields)
         {
             if (field.Status != FieldStatus.Valid)
             {
                 error += "TFS Field: " + field.Name + "-->" + field.Status + "\n";
             }
         }
         throw new WorkItemMigratorException(error, null, null);
     }
 }