Esempio n. 1
0
        static async Task <Issue> GetIssueAsync(IssueRequest request)
        {
            Issue issue = null;
            //var byteArray = Encoding.ASCII.GetBytes("username:password");
            //client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
            string path = GetGitHubIssueApiUrl(request.Owner, request.RepoName, request.IssueId);
            HttpResponseMessage response = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                issue = await response.Content.ReadAsAsync <Issue>();
            }
            else
            {
                Console.WriteLine(response);
            }

            return(issue);
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            try
            {
                string errors        = "";
                string dataAnomalies = "";
                client.DefaultRequestHeaders.Add("User-Agent", "request");
                client.DefaultRequestHeaders.Add("Authorization", "<<from postman>>");
                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;

                using (var package = new ExcelPackage(new FileInfo(@"C:\data\AllData1110.xlsx")))
                {
                    var firstSheet   = package.Workbook.Worksheets["Sheet1"];
                    int colCount     = firstSheet.Dimension.End.Column; //get Column Count
                    int rowCount     = firstSheet.Dimension.End.Row;    //get row count
                    int totalIssues  = rowCount - 4;
                    int mistakeCount = 0;
                    if (colCount != stateCol)
                    {
                        firstSheet.InsertColumn(stateCol, 1);
                        firstSheet.Cells[3, stateCol].Value = "Issue state";
                    }
                    // firstSheet.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    // firstSheet.Cells[3, colCount + 1].Style.Fill.BackgroundColor.SetColor(Color.Green);
                    Issue            issue   = null;
                    IssueRequest     request = null;
                    HashSet <string> myhash1 = new HashSet <string>();

                    for (int row = 4; row <= rowCount; row++)
                    {
                        if (row % 100 == 0)
                        {
                            Console.WriteLine("At Row " + row);
                        }
                        request = GetIssueRequest(firstSheet.Cells[row, repoUrlCol].Value?.ToString().Trim());
                        issue   = await GetIssueAsync(request);

                        if (issue == null)
                        {
                            firstSheet.Cells[row, stateCol].Value = "ERROR";
                            Console.WriteLine("Error  at row  " + row);
                            errors += "\n" + request.Owner + "    " + request.RepoName + "  NA  " + firstSheet.Cells[row, repoUrlCol].Value?.ToString().Trim();
                            Console.WriteLine(firstSheet.Cells[row, repoUrlCol].Value?.ToString().Trim());
                            continue;
                        }
                        else
                        {
                            firstSheet.Cells[row, stateCol].Value = issue.State;
                        }
                        if (!issue.State.Equals("open"))
                        {
                            dataAnomalies += "\n" + request.Owner + "    " + request.RepoName + "    " + issue.Id + "     " + firstSheet.Cells[row, repoUrlCol].Value?.ToString().Trim();
                            Console.WriteLine(firstSheet.Cells[row, repoUrlCol].Value?.ToString().Trim());
                            mistakeCount++;
                        }
                    }
                    package.Save();
                    using (StreamWriter writer = new StreamWriter(@"C:\data\errors.txt", false))
                    {
                        writer.Write(errors);
                    }
                    using (StreamWriter writer = new StreamWriter(@"C:\data\Data_Anomalies.txt", false))
                    {
                        writer.Write(dataAnomalies);
                    }
                    Console.WriteLine(" Total " + totalIssues + " Mistakes " + mistakeCount + "Percentage" + (mistakeCount / totalIssues) * 100 + "%");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }