/// <summary> /// Uploads the screenshot at the given path to the work item with the given issue id /// </summary> /// <param name="path">path of screenshot to upload</param> /// <returns>Task with URL of the screenshot attachment reference, null if not connected</returns> internal async Task <string> AttachScreenshotToIssue(string path, int issueId) { if (!ConnectedToAzureDevOps) { return(null); } WorkItemTrackingHttpClient wit = _baseServerConnection.GetClient <WorkItemTrackingHttpClient>(); AttachmentReference attachment = await wit.CreateAttachmentAsync(new FileStream(path, FileMode.Open), Invariant($"{issueId}-pic.png")).ConfigureAwait(false); JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachment.Url, attributes = new { comment = "Screenshot of element" } } } ); // Return attachment URL once this work item is updated #pragma warning disable CA2007 // Do not directly await a Task #pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler return(await wit.UpdateWorkItemAsync(patchDoc, issueId).ContinueWith(t => attachment.Url)); #pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler #pragma warning restore CA2007 // Do not directly await a Task }
public string AddAttachmentToBug() { var _id = _configuration.WorkItemId; var _filePath = _configuration.FilePath; using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials)) { // upload attachment to attachment store and // get a reference to that file AttachmentReference attachmentReference = workItemTrackingHttpClient.CreateAttachmentAsync(_filePath).Result; JsonPatchDocument patchDocument = new JsonPatchDocument(); patchDocument.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachmentReference.Url, attributes = new { comment = "adding link to bug" } } }); WorkItem result = workItemTrackingHttpClient.UpdateWorkItemAsync(patchDocument, _id).Result; } return("success"); }
private void CreateDefaultSwapchainRenderPass(Device SelectedLogicalGraphicsDevice) { var anAttachmentDescription = new AttachmentDescription { Format = VulkanRenderer.Surface.SelectedSurfaceFormat.Format, Samples = SampleCountFlags.Count1, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.Store, StencilLoadOp = AttachmentLoadOp.DontCare, StencilStoreOp = AttachmentStoreOp.DontCare, InitialLayout = ImageLayout.Undefined, FinalLayout = ImageLayout.PresentSrcKHR }; var anAttachmentReference = new AttachmentReference { Layout = ImageLayout.ColorAttachmentOptimal }; var aSubpassDescription = new SubpassDescription { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachments = new AttachmentReference[] { anAttachmentReference } }; var aRenderPassCreateInfo = new RenderPassCreateInfo { Attachments = new AttachmentDescription[] { anAttachmentDescription }, Subpasses = new SubpassDescription[] { aSubpassDescription } }; myBaseRenderPass = SelectedLogicalGraphicsDevice.CreateRenderPass(aRenderPassCreateInfo); }
/// <summary> /// Adds an attachment to a work item by using the <paramref name="attachmentReference"/> and optionally setting the attachment's <paramref name="comment"/>. /// </summary> /// <param name="attachmentReference">The attachment reference.</param> /// <param name="comment">The (optional) attachment comment.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">attachmentReference</exception> public virtual WorkItemPatchDocumentBuilder AddAttachment(AttachmentReference attachmentReference, string comment = "") { if (attachmentReference == null) { throw new ArgumentNullException(nameof(attachmentReference)); } PatchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = $"{Constants.WorkItems.RelationsBasePath}/-", Value = new { rel = Constants.WorkItems.RelationReferenceNameForAttachedFiles, url = attachmentReference.Url, attributes = new { comment = !string.IsNullOrWhiteSpace(comment) ? comment : string.Empty } } }); return(this); }
public AttachmentLink(string filename, AttachmentReference aRef, long resourceSize, string comment = null) { this.FileName = filename; this.AttachmentReference = aRef; this.ResourceSize = resourceSize; this.Comment = comment; }
public FrameObjectModel(FrameObjectModel other) : base(other) { blendInfoIndex = other.blendInfoIndex; skeletonIndex = other.skeletonIndex; skeletonHierachyIndex = other.skeletonHierachyIndex; skeleton = other.skeleton; blendInfo = other.blendInfo; restPose = new TransformMatrix[skeleton.NumBones[0]]; for (int i = 0; i != restPose.Length; i++) { restPose[i] = new TransformMatrix(other.restPose[i]); } unkTrasform = other.unkTrasform; attachmentReferences = new AttachmentReference[other.attachmentReferences.Length]; for (int i = 0; i != attachmentReferences.Length; i++) { attachmentReferences[i] = new AttachmentReference(other.attachmentReferences[i]); } unkFlags = other.unkFlags; physSplitSize = other.physSplitSize; hitBoxSize = other.hitBoxSize; nPhysSplits = other.nPhysSplits; blendMeshSplits = new WeightedByMeshSplit[nPhysSplits]; for (int i = 0; i != blendMeshSplits.Length; i++) { blendMeshSplits[i] = new WeightedByMeshSplit(other.blendMeshSplits[i]); } hitBoxInfo = new HitBoxInfo[other.hitBoxInfo.Length]; for (int i = 0; i != hitBoxInfo.Length; i++) { hitBoxInfo[i] = new HitBoxInfo(hitBoxInfo[i]); } }
private RenderPass CreateRenderPass(SurfaceFormatKhr surfaceFormat) { var attDesc = new AttachmentDescription { Format = surfaceFormat.Format, Samples = SampleCountFlags.Count1, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.Store, StencilLoadOp = AttachmentLoadOp.DontCare, StencilStoreOp = AttachmentStoreOp.DontCare, InitialLayout = ImageLayout.ColorAttachmentOptimal, FinalLayout = ImageLayout.ColorAttachmentOptimal }; var attRef = new AttachmentReference { Layout = ImageLayout.ColorAttachmentOptimal }; var subpassDesc = new SubpassDescription { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachments = new [] { attRef } }; var renderPassCreateInfo = new RenderPassCreateInfo { Attachments = new [] { attDesc }, Subpasses = new [] { subpassDesc } }; return(_device.CreateRenderPass(renderPassCreateInfo)); }
public AttachmentReference UploadAttachmentBinaryFile(string filePath) { VssConnection connection = new VssConnection(_uri, _credentials); WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); AttachmentReference attachmentReference = workItemTrackingHttpClient.CreateAttachmentAsync(@filePath).Result; return(attachmentReference); }
public async Task <IEnumerable <JsonPatchOperation> > Process(IMigrationContext migrationContext, IBatchMigrationContext batchContext, WorkItem sourceWorkItem, WorkItem targetWorkItem) { IList <JsonPatchOperation> jsonPatchOperations = new List <JsonPatchOperation>(); AttachmentReference aRef = await UploadAttachmentsToTarget(migrationContext, sourceWorkItem); JsonPatchOperation revisionHistoryAttachmentAddOperation = MigrationHelpers.GetRevisionHistoryAttachmentAddOperation(aRef, sourceWorkItem.Id.Value); jsonPatchOperations.Add(revisionHistoryAttachmentAddOperation); return(jsonPatchOperations); // We could just return one item, but we make an IList to be consistent }
public void ReadFromFilePart2(MemoryStream stream, bool isBigEndian) { //do rest matrices. restTransform = new Matrix[skeleton.NumBones[0]]; for (int i = 0; i != restTransform.Length; i++) { restTransform[i] = MatrixExtensions.ReadFromFile(stream, isBigEndian); } //unknown transform. unkTransform = MatrixExtensions.ReadFromFile(stream, isBigEndian); //attachments. int length1 = stream.ReadInt32(isBigEndian); attachmentReferences = new AttachmentReference[length1]; for (int i = 0; i != length1; i++) { attachmentReferences[i] = new AttachmentReference(stream, isBigEndian); } //unknwon. unkFlags = stream.ReadUInt32(isBigEndian); physSplitSize = stream.ReadInt32(isBigEndian); hitBoxSize = stream.ReadInt32(isBigEndian); if (physSplitSize > 0) { nPhysSplits = stream.ReadInt16(isBigEndian); } else { nPhysSplits = 0; } int totalSplits = 0; blendMeshSplits = new WeightedByMeshSplit[nPhysSplits]; for (int i = 0; i != nPhysSplits; i++) { blendMeshSplits[i] = new WeightedByMeshSplit(stream, isBigEndian); int index = blendInfo.BoneIndexInfos[0].IDs[blendMeshSplits[i].BlendIndex]; blendMeshSplits[i].JointName = skeleton.BoneNames[index].ToString(); totalSplits += blendMeshSplits[i].Data.Length; } hitBoxInfo = new HitBoxInfo[totalSplits]; for (int i = 0; i != hitBoxInfo.Length; i++) { hitBoxInfo[i] = new HitBoxInfo(stream, isBigEndian); } }
public void ReadFromFilePart2(BinaryReader reader, FrameSkeleton skeleton, FrameBlendInfo blendInfo) { this.skeleton = skeleton; this.blendInfo = blendInfo; //do rest matrices. restPose = new TransformMatrix[skeleton.NumBones[0]]; for (int i = 0; i != restPose.Length; i++) { restPose[i] = new TransformMatrix(reader); } //unknown transform. unkTrasform = new TransformMatrix(reader); //attachments. int length1 = reader.ReadInt32(); attachmentReferences = new AttachmentReference[length1]; for (int i = 0; i != length1; i++) { attachmentReferences[i] = new AttachmentReference(reader); } //unknwon. unkFlags = reader.ReadUInt32(); physSplitSize = reader.ReadInt32(); hitBoxSize = reader.ReadInt32(); if (physSplitSize > 0) { nPhysSplits = reader.ReadInt16(); } else { nPhysSplits = 0; } int totalSplits = 0; blendMeshSplits = new WeightedByMeshSplit[nPhysSplits]; for (int i = 0; i != nPhysSplits; i++) { blendMeshSplits[i] = new WeightedByMeshSplit(reader); totalSplits += blendMeshSplits[i].Data.Length; } hitBoxInfo = new HitBoxInfo[totalSplits]; for (int i = 0; i != hitBoxInfo.Length; i++) { hitBoxInfo[i] = new HitBoxInfo(reader); } }
public void AddAttachment() { // Create a file to attach with sample text var filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); using (FileStream fstream = File.Create(filePath)) { using (StreamWriter swriter = new StreamWriter(fstream)) { swriter.Write("Sample attachment text"); } } // Upload attachment AttachmentReference attachment = WitClient.CreateAttachmentAsync(filePath).Result; Console.WriteLine("Attachment created"); Console.WriteLine($"ID: {attachment.Id}"); Console.WriteLine($"URL: '{attachment.Url}'"); Console.WriteLine(); // Get an existing work item and add the attachment to it WorkItem wi = WitClient.GetWorkItemAsync(this.WorkItemsAdded.First()).Result; JsonPatchDocument attachmentPatchDocument = new JsonPatchDocument { new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachment.Url, attributes = new { comment = "Attached a file" } } } }; var attachments = wi.Relations?.Where(r => r.Rel == "AttachedFile") ?? new List <WorkItemRelation>(); var previousAttachmentsCount = attachments.Count(); var result = WitClient.UpdateWorkItemAsync(attachmentPatchDocument, wi.Id.Value).Result; var newAttachments = result.Relations?.Where(r => r.Rel == "AttachedFile"); var newAttachmentsCount = newAttachments.Count(); Console.WriteLine($"Updated Existing Work Item: '{wi.Id}'. Had {previousAttachmentsCount} attachments, now has {newAttachmentsCount}"); Console.WriteLine(); }
/// <summary> /// Create document for work item with attachment info /// </summary> /// <param name="reference">attachment reference</param> /// <returns></returns> private static JsonPatchOperation CreateAttachmentJsonPatchOperation(AttachmentReference reference) { return(new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = reference.Url } }); }
private void CreateRenderPass() { var colorAttachment = new AttachmentDescription() { Format = vkSwapChainImageFormat, Samples = SampleCountFlags.Count1, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.Store, StencilLoadOp = AttachmentLoadOp.DontCare, StencilStoreOp = AttachmentStoreOp.DontCare, InitialLayout = ImageLayout.Undefined, FinalLayout = ImageLayout.PresentSrcKhr, }; var colorAttachmentRef = new AttachmentReference() { Attachment = 0, Layout = Vulkan.ImageLayout.ColorAttachmentOptimal, }; var subpass = new SubpassDescription() { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachmentCount = 1, ColorAttachments = new AttachmentReference[] { colorAttachmentRef }, }; var dependency = new SubpassDependency() { SrcSubpass = VK_SUBPASS_EXTERNAL, SrcStageMask = PipelineStageFlags.ColorAttachmentOutput, SrcAccessMask = 0, DstSubpass = 0, DstStageMask = PipelineStageFlags.ColorAttachmentOutput, DstAccessMask = AccessFlags.ColorAttachmentRead | AccessFlags.ColorAttachmentWrite, }; var renderPassInfo = new RenderPassCreateInfo() { AttachmentCount = 1, Attachments = new AttachmentDescription[] { colorAttachment }, SubpassCount = 1, Subpasses = new SubpassDescription[] { subpass }, DependencyCount = 1, Dependencies = new SubpassDependency[] { dependency }, }; vkRenderPass = vkDevice.CreateRenderPass(renderPassInfo); }
void CreateRenderPass() { var attachment_descriptions = new AttachmentDescription { flags = (AttachmentDescriptionFlagBits)0, // VkAttachmentDescriptionFlagBits flags format = GetSwapChain.Format, // VkFormat format samples = SampleCountFlagBits._1Bit, // VkSampleCountFlagBits samples loadOperation = AttachmentLoadOperation.Clear, // VkAttachmentLoadOp loadOp storeOperation = AttachmentStoreOperation.Store, // VkAttachmentStoreOp storeOp stencilLoadOperation = AttachmentLoadOperation.DontCare, // VkAttachmentLoadOp stencilLoadOp stencilStoreOperation = AttachmentStoreOperation.DontCare, // VkAttachmentStoreOp stencilStoreOp initialLayout = ImageLayout.Undefined, // VkImageLayout initialLayout; finalLayout = ImageLayout.PresentSourceKhr // VkImageLayout finalLayout }; var color_attachment_references = new AttachmentReference { attachment = 0, // uint32_t attachment layout = ImageLayout.ColorAttachmentOptimal // VkImageLayout layout }; var subpass_descriptions = new SubpassDescription { flags = 0, // VkSubpassDescriptionFlagBits flags pipelineBindPoint = PipelineBindPoint.Graphics, // VkPipelineBindPoint pipelineBindPoint inputAttachmentCount = 0, // uint32_t inputAttachmentCount pInputAttachments = (AttachmentReference *)0, // const VkAttachmentReference *pInputAttachments colorAttachmentCount = 1, // uint32_t colorAttachmentCount pColorAttachments = &color_attachment_references, // const VkAttachmentReference *pColorAttachments pResolveAttachments = (AttachmentReference *)0, // const VkAttachmentReference *pResolveAttachments pDepthStencilAttachment = (AttachmentReference *)0, // const VkAttachmentReference *pDepthStencilAttachment preserveAttachmentCount = 0, // uint32_t preserveAttachmentCount pPreserveAttachments = (uint *)0 // const uint32_t* pPreserveAttachments }; var render_pass_create_info = new RenderPassCreateInfo { sType = StructureType.RenderPassCreateInfo, // VkStructureType sType pNext = IntPtr.Zero, // const void *pNext flags = 0, // VkRenderPassCreateFlagBits flags attachmentCount = 1, // uint32_t attachmentCount pAttachments = &attachment_descriptions, // const VkAttachmentDescription *pAttachments subpassCount = 1, // uint32_t subpassCount pSubpasses = &subpass_descriptions, // const VkSubpassDescription *pSubpasses dependencyCount = 0, // uint32_t dependencyCount pDependencies = (SubpassDependency *)0 // const VkSubpassDependency *pDependencies }; vk.CreateRenderPass(GetDevice, ref render_pass_create_info, (AllocationCallbacks *)0, out Vulkan.RenderPass).CheckError(); }
public WorkItem AddAttachment() { int id = Convert.ToInt32(Context.GetValue <WorkItem>("$newWorkItem3").Id); string filePath = ClientSampleHelpers.GetSampleTextFile(); VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>(); // upload attachment to store and get a reference to that file AttachmentReference attachmentReference = workItemTrackingClient.CreateAttachmentAsync(filePath).Result; JsonPatchDocument patchDocument = new JsonPatchDocument(); patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Test, Path = "/rev", Value = "1" } ); patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/System.History", Value = "Adding the necessary spec" } ); patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachmentReference.Url, attributes = new { comment = "VanDelay Industries - Spec" } } } ); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; return(result); }
protected void CreateRenderPass() { var colorAttachment = new AttachmentDescription { Format = format.Format, Samples = SampleCountFlags.Count1, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.Store, StencilLoadOp = AttachmentLoadOp.DontCare, StencilStoreOp = AttachmentStoreOp.DontCare, InitialLayout = ImageLayout.Undefined, FinalLayout = ImageLayout.PresentSrcKhr }; var colorAttachmentRef = new AttachmentReference { Attachment = 0, Layout = ImageLayout.ColorAttachmentOptimal }; var subpass = new SubpassDescription { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachmentCount = 1, ColorAttachments = new AttachmentReference[] { colorAttachmentRef }, }; var dependency = new SubpassDependency { SrcSubpass = VK_SUBPASS_INTERNAL, DstSubpass = 0, SrcStageMask = PipelineStageFlags.ColorAttachmentOutput, SrcAccessMask = 0, DstStageMask = PipelineStageFlags.ColorAttachmentOutput, DstAccessMask = AccessFlags.ColorAttachmentRead | AccessFlags.ColorAttachmentWrite }; var renderPassInfo = new RenderPassCreateInfo { AttachmentCount = 1, Attachments = new AttachmentDescription[] { colorAttachment }, SubpassCount = 1, Subpasses = new SubpassDescription[] { subpass }, DependencyCount = 1, Dependencies = new SubpassDependency[] { dependency } }; renderPass = device.CreateRenderPass(renderPassInfo); }
// This method will upload attachment and return url for file and Id private static AttachmentReference UploadAttachment(Uri uri, VssBasicCredential credentials) { try { VssConnection _tpc = new VssConnection(uri, credentials); WorkItemTrackingHttpClient workItemTrackingHttpClient = _tpc.GetClient <WorkItemTrackingHttpClient>(); AttachmentReference attachment = workItemTrackingHttpClient.CreateAttachmentAsync(PathOfAttachment).Result; // Save the attachment ID for the "download" sample call later return(attachment); } catch (Exception ex) { Log.Logger.Error("Error occurred while Attaching Attachment in bug" + ex); return(null); } }
public WorkItem UpdateWorkItemAddAttachment(int id, string filePath) { VssConnection connection = new VssConnection(_uri, _credentials); WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); // upload attachment to attachment store and // get a reference to that file AttachmentReference attachmentReference = workItemTrackingHttpClient.CreateAttachmentAsync(filePath).Result; JsonPatchDocument patchDocument = new JsonPatchDocument(); patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Test, Path = "/rev", Value = "1" } ); patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/System.History", Value = "Adding the necessary spec" } ); patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachmentReference.Url, attributes = new { comment = "VanDelay Industries - Spec" } } } ); WorkItem result = workItemTrackingHttpClient.UpdateWorkItemAsync(patchDocument, id).Result; return(result); }
public static WorkItem CreateBugInVSO(IWebDriver driver, Fields fields) { try { PathOfAttachment = ScreenShotCapture.CaptureScreenShotOfCurrentBrowser(driver, fields.PathOfFile); ListParams.AddRange(GetAllField(fields)); Uri uri = new Uri(_uri); string personalAccessToken = _personalAccessToken; string project = _project; VssBasicCredential credentials = new VssBasicCredential("", _personalAccessToken); AttachmentReference attachment = UploadAttachment(uri, credentials); ListParams.Add(new Params() { Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachment.Url, attributes = new { comment = fields.Comments } } }); JsonPatchDocument patchDocument = new JsonPatchDocument(); //add fields and their values to your patch document foreach (var item in ListParams) { patchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = item.Path, Value = item.Value, } ); } VssConnection connection = new VssConnection(uri, credentials); WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>(); WorkItem result = workItemTrackingHttpClient.CreateWorkItemAsync(patchDocument, project, "Bug").Result; return(result); } catch (AggregateException ex) { Log.Logger.Error("Error occurred while Creating bug in VSO" + ex); return(null); } }
private void CreateRenderPass() { var colorAttachmentReference = new AttachmentReference { Attachment = 0, Layout = ImageLayout.ColorAttachmentOptimal }; var depthStencilAttachmentReference = new AttachmentReference { Attachment = 1, Layout = ImageLayout.DepthStencilAttachmentOptimal }; var subpass = new SubpassDescription { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachmentCount = 1, ColorAttachments = new IntPtr(&colorAttachmentReference), }; var attachments = new[] { new AttachmentDescription { Format = backBufferFormat, Samples = SampleCountFlags.Sample1, LoadOperation = AttachmentLoadOperation.Load, StoreOperation = AttachmentStoreOperation.Store, StencilLoadOperation = AttachmentLoadOperation.DontCare, StencilStoreOperation = AttachmentStoreOperation.DontCare, InitialLayout = ImageLayout.ColorAttachmentOptimal, FinalLayout = ImageLayout.ColorAttachmentOptimal }, }; fixed(AttachmentDescription *attachmentsPointer = &attachments[0]) { var createInfo = new RenderPassCreateInfo { StructureType = StructureType.RenderPassCreateInfo, AttachmentCount = (uint)attachments.Length, Attachments = new IntPtr(attachmentsPointer), SubpassCount = 1, Subpasses = new IntPtr(&subpass) }; renderPass = device.CreateRenderPass(ref createInfo); } }
/// <summary> /// Upload attachment of file at the given path to the issue with given issue id /// from "AzureDevOps-dotnet-samples" repo /// Also adds comment about snapshot to work item /// </summary> /// <param name="path">path to file that should be attached</param> /// <param name="issueId">issue id to attach file to</param> /// <returns>Task with completed issue ID or null if user is not connected to AzureDevOps</returns> internal async Task <int?> AttachTestResultToIssue(string path, int issueId) { if (!ConnectedToAzureDevOps) { return(null); } WorkItemTrackingHttpClient wit = _baseServerConnection.GetClient <WorkItemTrackingHttpClient>(); AttachmentReference attachment = await wit.CreateAttachmentAsync(new FileStream(path, FileMode.Open), Invariant($"{issueId}.a11ytest")).ConfigureAwait(false); JsonPatchDocument patchDoc = new JsonPatchDocument(); patchDoc.Add(new JsonPatchOperation() { Operation = Operation.Test, Path = "/rev", Value = "1" } ); patchDoc.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/System.History", Value = "Attached an Accessibility Insights for Windows test file and screenshot." } ); patchDoc.Add(new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachment.Url, attributes = new { comment = "Accessibility Insights for Windows test file" } } } ); #pragma warning disable CA2007 // Do not directly await a Task #pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler return(await wit.UpdateWorkItemAsync(patchDoc, issueId).ContinueWith(t => t.Result.Id)); #pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler #pragma warning restore CA2007 // Do not directly await a Task }
public static JsonPatchOperation GetRevisionHistoryAttachmentAddOperation(AttachmentReference attachmentReference, int workItemId) { JsonPatchOperation jsonPatchOperation = new JsonPatchOperation(); jsonPatchOperation.Operation = Operation.Add; jsonPatchOperation.Path = $"/{Constants.Relations}/-"; jsonPatchOperation.Value = new { rel = Constants.AttachedFile, url = attachmentReference.Url, attributes = new { name = $"{Constants.WorkItemHistory}{workItemId}.json" } }; return(jsonPatchOperation); }
public AttachmentReference UploadBinaryFile() { // Full path to the binary file to upload as an attachment string filePath = ClientSampleHelpers.GetSampleBinaryFile(); VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>(); Console.WriteLine("Attempting upload of: {0}", filePath); AttachmentReference attachment = workItemTrackingClient.CreateAttachmentAsync(@filePath).Result; Console.WriteLine("Attachment created"); Console.WriteLine(" ID : {0}", attachment.Id); Console.WriteLine(" URL : {0}", attachment.Url); return(attachment); }
public void CL_WorkItemTracking_Attachements_UploadAttachmentBinaryFile_Success() { // arrange Attachments request = new Attachments(_configuration); string filePath = @"D:\temp\test.jpg"; if (!System.IO.File.Exists(filePath)) { Assert.Inconclusive("file not found"); } // act AttachmentReference attachmentReference = request.UploadAttachmentBinaryFile(filePath); // assert Assert.IsNotNull(attachmentReference); request = null; }
private AttachmentReference SaveThumbnailAttachment(AttachmentReference photoReference) { var thumbnailFileName = "thumb_" + photoReference.FileName; var photo = RavenSession.Load <Attachment>(photoReference.Id); var photoStream = Query(new ReadAttachment(photo) { UploadPath = UploadPath }); photoStream.Position = 0; //Find a more elegant way to do it //TODO: generate thumbnail var thumbnailStream = photoStream; return(ExecuteCommand(new SaveAttachment(RelatedEntity, thumbnailFileName, thumbnailStream) { UploadPath = UploadPath })); }
public void CL_WorkItemTracking_Attachements_DownloadAttachmentTextFile_Success() { // arrange Attachments request = new Attachments(_configuration); string filePath = @"D:\temp\test.txt"; if (!System.IO.File.Exists(filePath)) { Assert.Inconclusive("file not found"); } // act AttachmentReference attachmentReference = request.UploadAttachmentTextFile(filePath); request.DownloadAttachment(attachmentReference.Id, @"D:\temp\attachment.txt"); // assert Assert.IsTrue(System.IO.File.Exists(@"D:\temp\attachment.txt")); request = null; }
public static JsonPatchDocument ToPatchDocument(this AttachmentReference attachment) { var patchDocument = new JsonPatchDocument() { new JsonPatchOperation { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachment.Url, attributes = new { comment = $"Ported by tfs-to-devops @ {DateTime.Now:dd-MMM-yyyy HH:mm:ss}" } } } }; return(patchDocument); }
public AttachmentReference UploadTextFile() { // Full path to the text file to upload as an attachment string filePath = ClientSampleHelpers.GetSampleTextFile(); // Get a client VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>(); Console.WriteLine("Attempting upload of: {0}", filePath); // Upload the attachment AttachmentReference attachment = workItemTrackingClient.CreateAttachmentAsync(@filePath).Result; Console.WriteLine("Attachment created"); Console.WriteLine(" ID : {0}", attachment.Id); Console.WriteLine(" URL : {0}", attachment.Url); // Save the attachment ID for the "download" sample call later Context.SetValue <Guid>("$attachmentId", attachment.Id); Context.SetValue <string>("$attachmentFileName", Path.GetFileName(filePath)); return(attachment); }
private unsafe void CreateRenderPass(PipelineStateDescription pipelineStateDescription) { bool hasDepthStencilAttachment = pipelineStateDescription.Output.DepthStencilFormat != PixelFormat.None; var renderTargetCount = pipelineStateDescription.Output.RenderTargetCount; var attachmentCount = renderTargetCount; if (hasDepthStencilAttachment) attachmentCount++; var attachments = new AttachmentDescription[attachmentCount]; var colorAttachmentReferences = new AttachmentReference[renderTargetCount]; fixed (PixelFormat* renderTargetFormat = &pipelineStateDescription.Output.RenderTargetFormat0) fixed (BlendStateRenderTargetDescription* blendDescription = &pipelineStateDescription.BlendState.RenderTarget0) { for (int i = 0; i < renderTargetCount; i++) { var currentBlendDesc = pipelineStateDescription.BlendState.IndependentBlendEnable ? (blendDescription + i) : blendDescription; attachments[i] = new AttachmentDescription { Format = VulkanConvertExtensions.ConvertPixelFormat(*(renderTargetFormat + i)), Samples = SampleCountFlags.Sample1, LoadOperation = currentBlendDesc->BlendEnable ? AttachmentLoadOperation.Load : AttachmentLoadOperation.DontCare, // TODO VULKAN: Only if any destination blend? StoreOperation = AttachmentStoreOperation.Store, StencilLoadOperation = AttachmentLoadOperation.DontCare, StencilStoreOperation = AttachmentStoreOperation.DontCare, InitialLayout = ImageLayout.ColorAttachmentOptimal, FinalLayout = ImageLayout.ColorAttachmentOptimal, }; colorAttachmentReferences[i] = new AttachmentReference { Attachment = (uint)i, Layout = ImageLayout.ColorAttachmentOptimal, }; } } if (hasDepthStencilAttachment) { attachments[attachmentCount - 1] = new AttachmentDescription { Format = Texture.GetFallbackDepthStencilFormat(GraphicsDevice, VulkanConvertExtensions.ConvertPixelFormat(pipelineStateDescription.Output.DepthStencilFormat)), Samples = SampleCountFlags.Sample1, LoadOperation = AttachmentLoadOperation.Load, // TODO VULKAN: Only if depth read enabled? StoreOperation = AttachmentStoreOperation.Store, // TODO VULKAN: Only if depth write enabled? StencilLoadOperation = AttachmentLoadOperation.DontCare, // TODO VULKAN: Handle stencil StencilStoreOperation = AttachmentStoreOperation.DontCare, InitialLayout = ImageLayout.DepthStencilAttachmentOptimal, FinalLayout = ImageLayout.DepthStencilAttachmentOptimal, }; } var depthAttachmentReference = new AttachmentReference { Attachment = (uint)attachments.Length - 1, Layout = ImageLayout.DepthStencilAttachmentOptimal, }; var subpass = new SubpassDescription { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachmentCount = (uint)renderTargetCount, ColorAttachments = colorAttachmentReferences.Length > 0 ? new IntPtr(Interop.Fixed(colorAttachmentReferences)) : IntPtr.Zero, DepthStencilAttachment = hasDepthStencilAttachment ? new IntPtr(&depthAttachmentReference) : IntPtr.Zero, }; var renderPassCreateInfo = new RenderPassCreateInfo { StructureType = StructureType.RenderPassCreateInfo, AttachmentCount = (uint)attachmentCount, Attachments = attachments.Length > 0 ? new IntPtr(Interop.Fixed(attachments)) : IntPtr.Zero, SubpassCount = 1, Subpasses = new IntPtr(&subpass) }; NativeRenderPass = GraphicsDevice.NativeDevice.CreateRenderPass(ref renderPassCreateInfo); }
private void CreateRenderPass() { var colorAttachmentReference = new AttachmentReference { Attachment = 0, Layout = ImageLayout.ColorAttachmentOptimal }; var depthStencilAttachmentReference = new AttachmentReference { Attachment = 1, Layout = ImageLayout.DepthStencilAttachmentOptimal }; var subpass = new SubpassDescription { PipelineBindPoint = PipelineBindPoint.Graphics, ColorAttachmentCount = 1, ColorAttachments = new IntPtr(&colorAttachmentReference), }; var attachments = new[] { new AttachmentDescription { Format = backBufferFormat, Samples = SampleCountFlags.Sample1, LoadOperation = AttachmentLoadOperation.Load, StoreOperation = AttachmentStoreOperation.Store, StencilLoadOperation = AttachmentLoadOperation.DontCare, StencilStoreOperation = AttachmentStoreOperation.DontCare, InitialLayout = ImageLayout.ColorAttachmentOptimal, FinalLayout = ImageLayout.ColorAttachmentOptimal }, }; fixed (AttachmentDescription* attachmentsPointer = &attachments[0]) { var createInfo = new RenderPassCreateInfo { StructureType = StructureType.RenderPassCreateInfo, AttachmentCount = (uint)attachments.Length, Attachments = new IntPtr(attachmentsPointer), SubpassCount = 1, Subpasses = new IntPtr(&subpass) }; renderPass = device.CreateRenderPass(ref createInfo); } }
public override async Task <IEnumerable <WorkItemModel> > FileWorkItems(IEnumerable <WorkItemModel> workItemModels) { foreach (WorkItemModel workItemModel in workItemModels) { //TODO: Provide helper that generates useful attachment name from filed bug. // This helper should be common to both ADO and GH filers. The implementation // should work like this: the filer should prefix the proposed file name with // the account and project and number of the filed work item. So an attachment // name of Scan.sarif would be converted tO // // MyAcct_MyProject_WorkItem1000_Scan.sarif // // The GH filer may prefer to use 'issue' instead: // // myowner_my-repo_Issue1000_Scan.sarif // // The common helper should preserve casing choices in the account/owner and // project/repo information that's provided. // // Obviously, this proposal requires a change below to first file the bug, // then compute the file name and add the attachment. // // https://github.com/microsoft/sarif-sdk/issues/1753 AttachmentReference attachmentReference = null; string attachmentText = workItemModel.Attachment?.Text; if (!string.IsNullOrEmpty(attachmentText)) { using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream)) { writer.Write(attachmentText); writer.Flush(); stream.Position = 0; try { attachmentReference = await _witClient.CreateAttachmentAsync(stream, fileName : workItemModel.Attachment.Name); } catch { // TBD error handling throw; } } } var patchDocument = new JsonPatchDocument { new JsonPatchOperation { Operation = Operation.Add, Path = $"/fields/{AzureDevOpsFieldNames.Title}", Value = workItemModel.Title }, new JsonPatchOperation { Operation = Operation.Add, Path = $"/fields/{AzureDevOpsFieldNames.Area}", Value = workItemModel.Area ?? workItemModel.RepositoryOrProject }, new JsonPatchOperation { Operation = Operation.Add, Path = $"/fields/{AzureDevOpsFieldNames.Tags}", Value = string.Join(",", workItemModel.LabelsOrTags) } }; if (workItemModel.CustomFields != null) { foreach (KeyValuePair <string, string> customField in workItemModel.CustomFields) { patchDocument.Add(new JsonPatchOperation { Operation = Operation.Add, Path = $"/fields/{customField.Key}", Value = customField.Value }); } } if (attachmentReference != null) { patchDocument.Add( new JsonPatchOperation { Operation = Operation.Add, Path = $"/relations/-", Value = new { rel = "AttachedFile", attachmentReference.Url } }); } WorkItem workItem = null; try { // TODO: Make work item kind configurable for Azure DevOps filer // // https://github.com/microsoft/sarif-sdk/issues/1770 string workItemKind = "Bug"; Console.Write($"Creating work item: {workItemModel.Title}"); workItem = await _witClient.CreateWorkItemAsync(patchDocument, project : this.ProjectOrRepository, workItemKind); Console.WriteLine($": {workItem.Id}: DONE"); } catch (Exception e) { Console.Error.WriteLine(e); if (patchDocument != null) { string patchJson = JsonConvert.SerializeObject(patchDocument, Formatting.Indented); Console.Error.WriteLine(patchJson); } continue; } const string HTML = "html"; workItemModel.HtmlUri = new Uri(((ReferenceLink)workItem.Links.Links[HTML]).Href, UriKind.Absolute); // TODO: ADO work item filer should populate the raw URI (in addition to HtmlUri) // // https://github.com/microsoft/sarif-sdk/issues/1773 } return(workItemModels); }