private async System.Threading.Tasks.Task ShareCommit(Repository repository, Commit commit) { using (MultipartFormDataContent formData = new MultipartFormDataContent()) { CweEntry selectedEntry = cweComboBox.SelectedItem as CweEntry; formData.Add(new StringContent(selectedEntry.Id.ToString()), "CweId"); formData.Add(new StringContent(commit.Message), "CommitMessage"); formData.Add(new StringContent(commentTextBox.Text), "Comment"); formData.Add(new StringContent((fixesButton.IsChecked == true).ToString()), "FixedWithCommit"); await TaskScheduler.Default; int fileCount = 0; Commit parentCommit = commit.Parents.First(); Patch patch = repository.Diff.Compare <Patch>(parentCommit.Tree, commit.Tree); int totalChanges = patch.Count(); foreach (PatchEntryChanges change in patch) { fileCount++; string fileName = Path.GetFileName(change.Path); await WriteToOutput($"Retrieving change {fileCount}/{totalChanges} ({fileName})"); TreeEntry treeEntry = commit.Tree[change.Path]; if (treeEntry != null && treeEntry.TargetType == TreeEntryTargetType.Blob) { Blob blob = treeEntry.Target as Blob; formData.Add(new StringContent(((int)change.Status).ToString()), $"File{fileCount}ChangeKind"); formData.Add(new StreamContent(blob.GetContentStream()), $"CurrentFile{fileCount}", treeEntry.Path); TreeEntry previousVersion = GetPreviousVersionOfFile(repository, treeEntry, commit); if (previousVersion != null) { Blob previousBlob = previousVersion.Target as Blob; formData.Add(new StreamContent(previousBlob.GetContentStream()), $"PreviousFile{fileCount}", previousVersion.Path); } } await UpdateProgress(fileCount / (totalChanges + 1.0)); } string apiUrl = "https://micscan.azurewebsites.net/api/Share"; using (HttpClient httpClient = new HttpClient()) { await WriteToOutput($"Uploading commit."); HttpResponseMessage response = await httpClient.PostAsync(apiUrl, formData); await UpdateProgress(1.0); } } }