private void SubmitChangesWithUpdateDoc(
            MigrationAction[] changeGroup,
            ConversionResult changeResult)
        {
            // NOTE / TODO:
            //   Currently, work item revisions are submitted separately. To minimize server round-trips for
            //   performance improvement, we may want to submit changes in batch.
            foreach (MigrationAction action in changeGroup)
            {
                try
                {
                    XmlDocument updateDocument = CreateUpdateOperationDoc(action);

                    if (updateDocument == null)
                    {
                        throw new InvalidOperationException("updateDocument is null");
                    }

                    var updates = new XmlDocument[1] {
                        updateDocument
                    };
                    UpdateResult[] results = TfsBatchUpdateHelper.Submit(Core, WorkItemServer, updates);

                    if (results.Length != updates.Length)
                    {
                        string msg = string.Format(
                            TfsWITAdapterResources.Culture,
                            TfsWITAdapterResources.ErrorWrongNumberOfUpdateResults,
                            Core.ServerName,
                            StoreName,
                            updates.Length,
                            results.Length);
                        throw new Exception(msg);
                    }

                    for (int i = 0; i < results.Length; ++i)
                    {
                        UpdateResult rslt = results[i];

                        if (rslt.Exception != null)
                        {
                            throw rslt.Exception;
                        }
                        else
                        {
                            //TODO: Update watermark on pending update statements
                            UpdateConversionHistory(action, rslt.Watermark, changeResult);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new MigrationException(changeResult, ex);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Submits updates into the work item store.
        /// </summary>
        /// <param name="core">Target TFS</param>
        /// <param name="svc">Work item tracking service</param>
        /// <param name="updates">Updates to submit</param>
        /// <returns>Results</returns>
        public static UpdateResult[] Submit(
            TfsCore core,
            ITfsWorkItemServer svc,
            XmlDocument[] updates)
        {
            TraceManager.EnterMethod(core, svc, updates);

            TfsBatchUpdateHelper helper = new TfsBatchUpdateHelper(core, svc, updates);

            helper.Submit(0, updates.Length - 1);
            return(helper.m_results);
        }