public async Task <IActionResult> CreateAttachmentToWorkitem(CreateWorkItem wit)
        {
            BuildManager buildManager = new BuildManager(_builderPool);
            var          buildReport  = await buildManager.GetBuildFinalReport(wit.projectname, wit.buildId);

            var result = await _workItemManager.CreateAttachmentToWorkitem(wit.WitId, wit.crmsolutioname,
                                                                           wit.projectid, wit.crmorgurl, buildReport.Html);

            return(Ok(result));
        }
Beispiel #2
0
        public async Task <WorkItemModel> CreateWorkitem(CreateWorkItem workItem)
        {
            WorkItemModel workItemModel = new WorkItemModel();

            try
            {
                workItemModel = await workItemManager.CreateWorkitem(workItem);
            }
            catch (Exception)
            {
            }
            return(workItemModel);
        }
Beispiel #3
0
            void IWorkItem.Execute()
            {
                Stream stream = null;

                try {
                    Exception exc = null;
                    if (!Provider.TryGetStream(Name, Data, Optional, out stream, out exc))
                    {
                        Future.SetResult2(
                            default(T), (exc != null)
                                ? ExceptionDispatchInfo.Capture(exc)
                                : null
                            );
                        lock (Provider.PendingLoadLock)
                            Provider._PendingLoads--;
                        return;
                    }

                    // Console.WriteLine($"PreloadInstance('{Name}') on thread {Thread.CurrentThread.Name}");
                    var now            = Provider.Now;
                    var waitDuration   = now - StartedWhen;
                    var preloadedData  = Provider.PreloadInstance(Name, stream, Data);
                    var preloadElapsed = Provider.Now - now;
                    var item           = new CreateWorkItem {
                        Future          = Future,
                        Provider        = Provider,
                        Name            = Name,
                        Data            = Data,
                        Optional        = Optional,
                        Stream          = stream,
                        PreloadedData   = preloadedData,
                        Async           = Async,
                        WaitDuration    = waitDuration,
                        PreloadDuration = preloadElapsed
                    };
                    Provider.CreateQueue.Enqueue(ref item);
                } catch (Exception exc) {
                    if (stream != null)
                    {
                        stream.Dispose();
                    }
                    Future.SetResult2(default(T), ExceptionDispatchInfo.Capture(exc));
                }
            }
        public async Task <IActionResult> CreateLinkedWorkitem(CreateWorkItem workItem)
        {
            var result = await _workItemManager.CreateLinkedWorkitem(workItem);

            return(Ok(result));
        }
Beispiel #5
0
        public async Task <WorkItemModel> CreateLinkedWorkitem(CreateWorkItem workItem)
        {
            WorkItemModel        workItemModel = new WorkItemModel();
            DevOpsConnectionPool poolObj       = _builderPool.Get();

            try
            {
                List <Params> ListParams = new List <Params>();
                //VssCredentials creds = new VssBasicCredential(string.Empty, personalaccesstoken);
                //VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);
                //ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>();

                var workItemTrackingClient = poolObj.VssConnection.GetClient <WorkItemTrackingHttpClient>();

                JsonPatchDocument patchDocument = new JsonPatchDocument();
                Fields            field         = null;
                string            title         = $"Error deploying solution {workItem.crmsolutioname} in {workItem.crmorgurl}.";
                string            bugtest       = $"Error deploying solution {workItem.crmsolutioname} in {workItem.crmorgurl}. \n See attachment file for full error log.";
                string            description   = $"Error deploying solution {workItem.crmsolutioname} in {workItem.crmorgurl}. \n See attachment file for full error log.";

                switch (workItem.type.ToLower())
                {
                case "bug":
                    field = new Fields()
                    {
                        AssignedTo = workItem.assignedTo,
                        BugText    = bugtest,
                        Priority   = "2",
                        Title      = title,
                        Severity   = "2 - High"
                    };
                    ListParams.AddRange(GetBugFields(field));
                    break;

                default:    //Issue,Feature,Task
                    field = new Fields()
                    {
                        AssignedTo  = workItem.assignedTo,
                        Description = description,
                        Priority    = "2",
                        Title       = title,
                        Severity    = "2 - High"
                    };
                    ListParams.AddRange(GetTaskIssueFeatureFields(field));
                    break;
                }

                foreach (var item in ListParams)//there will be one type of witalways
                {
                    patchDocument.Add(
                        new JsonPatchOperation()
                    {
                        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
                        Path      = item.Path,
                        Value     = item.Value,
                    }
                        );
                }

                if (workItem.parentWit > 0)
                {
                    /* patchDocument.Add(new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()
                     * {
                     *   Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
                     *   Path = "/fields/System.Title",
                     *   Value = "childWIT"
                     * });*/
                    patchDocument.Add(new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()
                    {
                        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
                        Path      = "/relations/-",
                        Value     = new
                        {
                            rel = "System.LinkTypes.Hierarchy-Reverse",
                            url = poolObj.VssConnection.Uri.AbsoluteUri + "/" + workItem.projectname + "/_apis/wit/workItems/" + workItem.parentWit
                        }
                    });
                }

                var workitem = await workItemTrackingClient.CreateWorkItemAsync(patchDocument, workItem.projectid, workItem.type);

                if (workitem != null)
                {
                    workItemModel.Id  = workitem.Id.Value;
                    workItemModel.url = workitem.Url;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                _builderPool.Return(poolObj);
            }
            return(workItemModel);
        }
Beispiel #6
0
        public async Task <WorkItemModel> CreateWorkitem(CreateWorkItem workItem)
        {
            WorkItemModel        workItemModel = new WorkItemModel();
            DevOpsConnectionPool poolObj       = _builderPool.Get();

            try
            {
                List <Params> ListParams = new List <Params>();
                //VssCredentials creds = new VssBasicCredential(string.Empty, personalaccesstoken);
                //VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);
                //ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>();

                var workItemTrackingClient = poolObj.VssConnection.GetClient <WorkItemTrackingHttpClient>();

                JsonPatchDocument patchDocument = new JsonPatchDocument();
                Fields            field         = null;

                string title       = $"error deploying solution {workItem.crmsolutioname} in {workItem.crmorgurl}";
                string bugtest     = $"error deploying solution {workItem.crmsolutioname} in {workItem.crmorgurl}. \n see attachment file for full error log.";
                string description = $"error deploying solution {workItem.crmsolutioname} in {workItem.crmorgurl}. \n see attachment file for full error log.";

                switch (workItem.type.ToLower())
                {
                case "bug":
                    field = new Fields()
                    {
                        AssignedTo = workItem.assignedTo,
                        BugText    = bugtest, //workItem.bugtest,
                        Priority   = "2",
                        Title      = title,   //workItem.title,
                        Severity   = "2 - High"
                    };
                    ListParams.AddRange(GetBugFields(field));
                    break;

                default:    //Issue,Feature,Task
                    field = new Fields()
                    {
                        AssignedTo  = workItem.assignedTo,
                        Description = description,    //workItem.description,
                        Priority    = "2",
                        Title       = title,
                        Severity    = "2 - High"
                    };
                    ListParams.AddRange(GetTaskIssueFeatureFields(field));
                    break;
                }

                foreach (var item in ListParams)
                {
                    patchDocument.Add(
                        new JsonPatchOperation()
                    {
                        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
                        Path      = item.Path,
                        Value     = item.Value,
                    }
                        );
                }

                var workitem = await workItemTrackingClient.CreateWorkItemAsync(patchDocument, workItem.projectid, workItem.type);

                if (workitem != null)
                {
                    workItemModel.Id  = workitem.Id.Value;
                    workItemModel.url = workitem.Url;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                _builderPool.Return(poolObj);
            }
            return(workItemModel);
        }