Ejemplo n.º 1
0
        public void CreateStealing(string projectName, string username, string title, float time, string activity, bool leaveActive)
        {
            var stealingsUS = TFS.GetWorkItemWithRelations(StealingId);

            Dictionary <string, object> fields = new Dictionary <string, object>();

            fields.Add("Title", title);
            fields.Add("Activity", activity);
            fields.Add("Priority", 1);
            fields.Add("System.AssignedTo", username);
            fields.Add("System.AreaPath", stealingsUS.Fields["System.AreaPath"]);
            fields.Add("System.IterationPath", stealingsUS.Fields["System.IterationPath"]);
            fields.Add("Microsoft.VSTS.Scheduling.CompletedWork", time);

            var item = TFS.CreateWorkItem(projectName, "Eco Task", fields);

            TFS.AddParentLink(item.Id.Value, StealingId);

            fields.Clear();
            fields.Add("State", "Active");
            var r = TFS.UpdateWorkItem(item.Id.Value, fields);

            Console.WriteLine(r.Url);
            if (leaveActive == false)
            {
                fields.Clear();
                fields.Add("State", "Closed");
                var r2 = TFS.UpdateWorkItem(item.Id.Value, fields);
                Console.WriteLine(r2.Url);
            }
        }
Ejemplo n.º 2
0
        public void CreateTask(string projectName, int parentUsId, string title, string activity, bool silent, int?plannedWork = null)
        {
            var parentUs = TFS2.GetWorkItemWithRelations(parentUsId);

            if (parentUs.Relations != null)
            {
                foreach (var link in parentUs.Relations)
                {
                    int usid = int.Parse(link.Url.Split('/').Last());
                    var task = TFS2.GetWorkItemWithRelations(usid);
                    if (task.Fields["System.Title"].ToString() == title && task.Fields["Microsoft.VSTS.Common.Activity"].ToString() == activity)
                    {
                        if (silent)
                        {
                            return;
                        }
                        throw new Exception($"Task with this name {title} and activity {activity} already exists");
                    }
                }
            }

            Dictionary <string, object> fields = new Dictionary <string, object>();

            fields.Add("Title", title);
            fields.Add("Activity", activity);
            fields.Add("Priority", 1);
            // fields.Add("System.AssignedTo", username);
            fields.Add("System.AreaPath", parentUs.Fields["System.AreaPath"]);
            fields.Add("System.IterationPath", parentUs.Fields["System.IterationPath"]);
            if (plannedWork != null)
            {
                fields.Add("Microsoft.VSTS.Scheduling.OriginalEstimate", plannedWork.Value);
            }
            //fields.Add("Microsoft.VSTS.Scheduling.CompletedWork", time);

            var item = TFS2.CreateWorkItem(projectName, "Eco Task", fields);

            TFS2.AddParentLink(item.Id.Value, parentUsId);

            fields.Clear();
            Console.WriteLine(item.Url);
        }