コード例 #1
0
ファイル: Program.cs プロジェクト: wullemsb/TFS-Monitor
        private static bool CreateNewWorkItem(TFSData proxy, string teamProject, string workItemType, string title)
        {
            var success = true;
            var workItem = WorkItem.CreateWorkItem(0, 0, DateTime.Now, DateTime.Now);
            workItem.Project = teamProject;
            workItem.Type = workItemType;
            workItem.Title = title;
            workItem.AreaPath = teamProject;
            workItem.IterationPath = teamProject;
            workItem.Reason = "New";
            workItem.StackRank = "3.5";
            workItem.Priority = "2";
            workItem.Severity = "1 - Critical";
            workItem.Description = "Sample description for a new Work Item created through the OData service for TFS";
            workItem.ReproSteps = "Sample repro steps for a new Work Item created through the OData service for TFS";

            proxy.AddToWorkItems(workItem);
            var result = proxy.SaveChanges();

            Console.WriteLine("Batch status code: {0}", result.BatchStatusCode);

            foreach (var opeartionResponse in result)
            {
                Console.WriteLine("Operation status code: {0}", opeartionResponse.StatusCode);
                if (opeartionResponse.Error != null)
                {
                    Console.WriteLine("Operation error: {0}", opeartionResponse.Error.Message);
                    success = false;
                }
            }

            return success;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wullemsb/TFS-Monitor
        private static bool UpdateWorkItem(TFSData proxy, WorkItem workItem)
        {
            var success = true;
            workItem.Title = "Updated Title from the OData service for TFS";
            workItem.StackRank = "1.5";
            workItem.Priority = "2";
            workItem.Severity = "1 - Critical";
            workItem.Description = "Updated description from the OData service for TFS";
            workItem.ReproSteps = "Updated repro steps from the OData service for TFS";

            proxy.UpdateObject(workItem);
            var result = proxy.SaveChanges(System.Data.Services.Client.SaveChangesOptions.ReplaceOnUpdate);

            Console.WriteLine("Batch status code: {0}", result.BatchStatusCode);

            foreach (var opeartionResponse in result)
            {
                Console.WriteLine("Operation status code: {0}", opeartionResponse.StatusCode);
                if (opeartionResponse.Error != null)
                {
                    Console.WriteLine("Operation error: {0}", opeartionResponse.Error.Message);
                    success = false;
                }
            }

            return success;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: wullemsb/TFS-Monitor
        private static bool CreateNewAttachment(TFSData proxy, int workItemId, string comment, string path)
        {
            var success = true;
            var attachment = Attachment.CreateAttachment(string.Empty, workItemId, 0, DateTime.Now, DateTime.Now, DateTime.Now, 0);

            attachment.Comment = comment;
            attachment.Name = Path.GetFileNameWithoutExtension(path);
            attachment.Extension = Path.GetExtension(path);

            DataServiceResponse response;
            using (var fileStream = new FileStream(path, FileMode.Open))
            {
                proxy.AddToAttachments(attachment);
                proxy.SetSaveStream(attachment, fileStream, false, RegistryHelper.GetMimeType(Path.GetExtension(path)), string.Empty);
                response = proxy.SaveChanges();
            }

            Console.WriteLine("Batch status code: {0}", response.BatchStatusCode);
            foreach (var opeartionResponse in response)
            {
                Console.WriteLine("Operation status code: {0}", opeartionResponse.StatusCode);
                if (opeartionResponse.Error != null)
                {
                    Console.WriteLine("Operation error: {0}", opeartionResponse.Error.Message);
                    success = false;
                }
            }

            return success;
        }