コード例 #1
0
        //public static IServiceCollection TfsObjectModelWorkerServices(this IServiceCollection collection, EngineConfiguration config)
        //{
        //    if (collection == null) throw new ArgumentNullException(nameof(collection));
        //    if (config == null) throw new ArgumentNullException(nameof(config));

        //   // return collection.AddTransient<IWorkItemSink, AzureDevOpsWorkItemSink>();
        //}

        //public static void SaveWorkItem(this IProcessor context, WorkItem workItem)
        //{
        //    if (workItem == null) throw new ArgumentNullException(nameof(workItem));
        //    workItem.Fields["System.ChangedBy"].Value = "Migration";
        //    workItem.Save();
        //}

        public static void SaveToAzureDevOps(this WorkItemData context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var workItem = (WorkItem)context.internalObject;
            var fails    = workItem.Validate();

            if (fails.Count > 0)
            {
                Log.Warning("Work Item is not ready to save as it has some invalid fields. This may not result in an error. Enable LogLevel as 'Debug' in the ocnfig to see more.");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                foreach (Field f in fails)
                {
                    Log.Debug("   Invalid Field: [Id:{CurrentRevisionWorkItemId}/{CurrentRevisionWorkItemRev}][Type:{CurrentRevisionWorkItemTypeName}][IsDirty:{IsDirty}][ReferenceName:{FieldReferenceName}][Value: {FieldValue}]",
                              new Dictionary <string, object>()
                    {
                        { "CurrentRevisionWorkItemId", workItem.Id },
                        { "CurrentRevisionWorkItemRev", workItem.Rev },
                        { "CurrentRevisionWorkItemTypeName", workItem.Type },
                        { "IsDirty", f.IsDirty },
                        { "FieldReferenceName", f.ReferenceName },
                        { "FieldValue", f.Value }
                    });
                    Log.Verbose("{   Field Object: {field}", f);
                }
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
            }
            workItem.Fields["System.ChangedBy"].Value = "Migration";
            workItem.Save();
            context.RefreshWorkItem();
        }
コード例 #2
0
        //public static IServiceCollection TfsObjectModelWorkerServices(this IServiceCollection collection, EngineConfiguration config)
        //{
        //    if (collection == null) throw new ArgumentNullException(nameof(collection));
        //    if (config == null) throw new ArgumentNullException(nameof(config));

        //   // return collection.AddTransient<IWorkItemSink, AzureDevOpsWorkItemSink>();
        //}

        //public static void SaveWorkItem(this IProcessor context, WorkItem workItem)
        //{
        //    if (workItem == null) throw new ArgumentNullException(nameof(workItem));
        //    workItem.Fields["System.ChangedBy"].Value = "Migration";
        //    workItem.Save();
        //}

        public static void SaveToAzureDevOps(this WorkItemData context)
        {
            Log.Debug("TfsExtensions::SaveToAzureDevOps");

            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var workItem = (WorkItem)context.internalObject;

            Log.Debug("TfsExtensions::SaveToAzureDevOps: ChangedBy: {ChangedBy}, AuthorisedBy: {AuthorizedIdentity}", workItem.ChangedBy, workItem.Store.TeamProjectCollection.AuthorizedIdentity.DisplayName);
            var fails = workItem.Validate();

            if (fails.Count > 0)
            {
                Log.Warning("Work Item is not ready to save as it has some invalid fields. This may not result in an error. Enable LogLevel as 'Debug' in the config to see more.");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                foreach (Field f in fails)
                {
                    Log.Debug("Invalid Field Object:\r\n{Field}", f.ToJson());
                }
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
            }
            Log.Verbose("TfsExtensions::SaveToAzureDevOps::Save()");
            workItem.Save();
            context.RefreshWorkItem();
        }
コード例 #3
0
        //public static IServiceCollection TfsObjectModelWorkerServices(this IServiceCollection collection, EngineConfiguration config)
        //{
        //    if (collection == null) throw new ArgumentNullException(nameof(collection));
        //    if (config == null) throw new ArgumentNullException(nameof(config));

        //   // return collection.AddTransient<IWorkItemSink, AzureDevOpsWorkItemSink>();
        //}

        //public static void SaveWorkItem(this IProcessor context, WorkItem workItem)
        //{
        //    if (workItem == null) throw new ArgumentNullException(nameof(workItem));
        //    workItem.Fields["System.ChangedBy"].Value = "Migration";
        //    workItem.Save();
        //}

        public static void SaveToAzureDevOps(this WorkItemData context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var workItem = (WorkItem)context.internalObject;
            var fails    = workItem.Validate();

            if (fails.Count > 0)
            {
                Log.Warning("Work Item is not ready to save as it has some invalid fields. This may not result in an error. Enable LogLevel as 'Debug' in the config to see more.");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                foreach (Field f in fails)
                {
                    Log.Debug("Invalid Field Object:\r\n{Field}", f.ToJson());
                }
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
                Log.Debug("--------------------------------------------------------------------------------------------------------------------");
            }
            workItem.Fields["System.ChangedBy"].Value = "Migration";
            workItem.Save();
            context.RefreshWorkItem();
        }
コード例 #4
0
        public static WorkItemData AsWorkItemData(this WorkItem context, FieldCollection fieldsOfRevision = null)
        {
            var internalWorkItem = new WorkItemData
            {
                internalObject = context
            };

            internalWorkItem.RefreshWorkItem(fieldsOfRevision);
            return(internalWorkItem);
        }
コード例 #5
0
        public static WorkItemData AsWorkItemData(this WorkItem context)
        {
            var internalWorkItem = new WorkItemData
            {
                internalObject = context
            };

            internalWorkItem.RefreshWorkItem();
            return(internalWorkItem);
        }
コード例 #6
0
        public static WorkItemData GetRevision(this WorkItemData context, int rev)
        {
            var wid = new WorkItemData
            {
                internalObject = context.internalObject
            };

            wid.RefreshWorkItem((FieldCollection)context.Revisions[rev].Fields);

            return(wid);
        }
コード例 #7
0
        public static WorkItemData AsWorkItemData(this WorkItem context, Dictionary <string, object> fieldsOfRevision = null, int retryLimit = 10)
        {
            var internalWorkItem = new WorkItemData
            {
                internalObject = context
            };

            CallWithRetry(() => internalWorkItem.RefreshWorkItem(fieldsOfRevision), retryLimit);

            return(internalWorkItem);
        }
コード例 #8
0
        public static WorkItemData AsWorkItemData(this WorkItem context)
        {
            Log.Debug("TfsExtensions::AsWorkItemData");
            var internalWorkItem = new WorkItemData
            {
                internalObject = context
            };

            internalWorkItem.RefreshWorkItem();
            return(internalWorkItem);
        }
コード例 #9
0
        //public static IServiceCollection TfsObjectModelWorkerServices(this IServiceCollection collection, EngineConfiguration config)
        //{
        //    if (collection == null) throw new ArgumentNullException(nameof(collection));
        //    if (config == null) throw new ArgumentNullException(nameof(config));

        //   // return collection.AddTransient<IWorkItemSink, AzureDevOpsWorkItemSink>();
        //}

        //public static void SaveWorkItem(this IProcessor context, WorkItem workItem)
        //{
        //    if (workItem == null) throw new ArgumentNullException(nameof(workItem));
        //    workItem.Fields["System.ChangedBy"].Value = "Migration";
        //    workItem.Save();
        //}

        public static void SaveToAzureDevOps(this WorkItemData context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var wi = (WorkItem)context.internalObject;

            wi.Fields["System.ChangedBy"].Value = "Migration";
            wi.Save();
            context.RefreshWorkItem();
        }
コード例 #10
0
        public static WorkItemData GetRevisionAsync(this WorkItemData context, int rev, int retryLimit = 10)
        {
            var originalWi = (WorkItem)context.internalObject;
            var wid        = new WorkItemData
            {
                // internalObject = context.internalObject
                // TODO: Had to revert to calling revision load again untill WorkItemMigrationContext.PopulateWorkItem can be updated to pull from WorkItemData
                internalObject = originalWi.Store.GetWorkItem(originalWi.Id, rev)
            };

            CallWithRetry(() => wid.RefreshWorkItem(context.Revisions[rev].Fields), retryLimit);

            return(wid);
        }
コード例 #11
0
        public static WorkItemData AsWorkItemData(this WorkItem context)
        {
            if (context.AreaPath == "migrationTarget1")
            {
                //stop here
                Log.Information(context.AreaPath);
            }
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var internalWorkItem = new WorkItemData();

            internalWorkItem.internalObject = context;
            internalWorkItem.RefreshWorkItem();
            return(internalWorkItem);
        }