public UIAutomationAggregate(int TeamId) { var dbU = new ApplicationDbContext(); CurrentUser = dbU.Users.FirstOrDefault(u => u.Email == HttpContext.Current.User.Identity.Name); var db = new AutomationDashboardEntities(); var productTeam = db.ProductTeams.First(team => team.TeamId == TeamId); TotalTFSTests = productTeam.TotalTFSTests ?? 0; TotalAutomatedTests = productTeam.TotalAutomatedTests ?? 0; dailySmokes = db.DailySmokes.Where(e => e.TeamId == TeamId).OrderByDescending(column => column.Date).ToList(); foreach (var smokeItem in dailySmokes) { smokeItem.detail_results = null; } FullPass = db.FullPasses.Where(e => e.TeamId == TeamId).OrderByDescending(column => column.Date).ToList(); foreach (var fullPassReport in FullPass) { fullPassReport.detail_results = null; } testSuites = db.spGetTestSuitesForTeam(TeamId).OrderBy(col => col.SuiteName).ToList(); CoreModSmokes = db.CoreModSmokes.Where(e => e.TeamId == TeamId).OrderByDescending(column => column.Date).ToList(); foreach (var coreModSmokesReport in CoreModSmokes) { coreModSmokesReport.detail_results = null; } productTeams = db.ProductTeams.Where(t => t.TeamId > 0).ToList(); CurrentTeam = db.ProductTeams.First(t => t.TeamId == TeamId); }
public TeamAutomationWeeklyProgress(int TeamId) { this.TeamId = TeamId; var db = new AutomationDashboardEntities(); WeeklyStatus = db.spGetPreviousAndCurrentWeekAutomationAggregateData(TeamId).ToList(); var ProductAreas = db.AutomateDatas.Where(e => e.TeamId == TeamId).Select(col => col.ProductArea).Distinct().ToList(); if (DateTime.Now.DayOfWeek == DayOfWeek.Friday) { Date1 = DateTime.Now.Date; } else { Date1 = Helpers.GetPreviousFriday(DateTime.Now); } Date2 = Helpers.GetPreviousFriday(Date1); Date3 = Helpers.GetPreviousFriday(Date2); Date4 = Helpers.GetPreviousFriday(Date3); var data3 = GetProgress(TeamId, Date4, Date3, ProductAreas); var data2 = GetProgress(TeamId, Date3, Date2, ProductAreas); var data1 = GetProgress(TeamId, Date2, Date1, ProductAreas); Week1.TFSTestCasesThisWeek = data1.Select(r => r.TFSTestCasesThisWeek).Sum(); Week1.AutomatedThisWeek = data1.Select(r => r.AutomatedThisWeek).Sum(); Week1.NoOfTestCasesDebugged = data1.Select(r => r.NoOfTestCasesDebugged).Sum(); Week2.TFSTestCasesThisWeek = data2.Select(r => r.TFSTestCasesThisWeek).Sum(); Week2.AutomatedThisWeek = data2.Select(r => r.AutomatedThisWeek).Sum(); Week2.NoOfTestCasesDebugged = data2.Select(r => r.NoOfTestCasesDebugged).Sum(); Week3.TFSTestCasesThisWeek = data3.Select(r => r.TFSTestCasesThisWeek).Sum(); Week3.AutomatedThisWeek = data3.Select(r => r.AutomatedThisWeek).Sum(); Week3.NoOfTestCasesDebugged = data3.Select(r => r.NoOfTestCasesDebugged).Sum(); try { TFSTotal = WeeklyStatus[1].TotalTFS; AutomatedTotal = WeeklyStatus[1].TotalAutomated; } catch { TFSTotal = 0; AutomatedTotal = 0; } TeamName = db.ProductTeams.Where(r => r.TeamId == TeamId).First().TeamName; }
static void UpdateTriaging(int TeamId, List <spGetCurrentStatusOfAutomationForATeam_Result> automationStatus) { var CurrentFriday = GetPreviousFriday(DateTime.Now).AddDays(7); using (var db = new AutomationDashboardEntities()) { foreach (var productArea in automationStatus) { var entry = db.WeeklyTriagings.FirstOrDefault(row => row.TeamId == TeamId && row.ProductArea == productArea.ProductArea && row.Date == CurrentFriday); if (entry == null) { productArea.NoOfTestCasesDebugged = 0; } else { productArea.NoOfTestCasesDebugged = entry.NoOfTestCasesDebugged; } } } }
public static void WriteAutomationStatusToExcel(string ExcelFilePath, int TeamId) { var db = new AutomationDashboardEntities(); var automationStatus = db.spGetCurrentStatusOfAutomationForATeam(TeamId).ToList(); UpdateTriaging(TeamId, automationStatus); //clear the excel file ClearExcelFile(ExcelFilePath, automationStatus.Count); try { new FileInfo(ExcelFilePath) { IsReadOnly = false }; ExcelPackage Browser = new ExcelPackage(new FileInfo(ExcelFilePath)); var BrowserWorkBook = Browser.Workbook; var BrowserWorkSheet = BrowserWorkBook.Worksheets[1]; for (int i = 2; i <= automationStatus.Count + 1; i++) { BrowserWorkSheet.Cells[i, 1].Value = automationStatus[i - 2].ProductArea; BrowserWorkSheet.Cells[i, 2].Value = automationStatus[i - 2].NoOfTFSTestcase; BrowserWorkSheet.Cells[i, 3].Value = automationStatus[i - 2].NoOfAutomatedTestcases; BrowserWorkSheet.Cells[i, 4].Value = automationStatus[i - 2].NoOfTestCasesDebugged; if (TeamId == 1) { BrowserWorkSheet.Cells[i, 5].Value = automationStatus[i - 2].ExpectedTestCases; } Browser.Save(); } BrowserWorkSheet.Dispose(); } catch (Exception e) { Debug.WriteLine("Error occured in ClearExcelFile \n" + e.ToString()); } }
static List <spGetWeeklyProgressForProductAreaBetweenDates_Result> GetProgress(int TeamId, DateTime From, DateTime To, List <string> ProductAreas) { var db = new AutomationDashboardEntities(); var FirstData = db.spGetStatusOfAutomationForATeamWithSpecifiedDate(TeamId, To).ToDictionary(s => s.ProductArea); var SecondData = db.spGetStatusOfAutomationForATeamWithSpecifiedDate(TeamId, From).ToDictionary(s => s.ProductArea); List <spGetWeeklyProgressForProductAreaBetweenDates_Result> list = new List <spGetWeeklyProgressForProductAreaBetweenDates_Result>(); foreach (string productArea in ProductAreas) { var progressData = new spGetWeeklyProgressForProductAreaBetweenDates_Result(); progressData.ProductArea = productArea; progressData.TeamId = TeamId; if (FirstData.ContainsKey(productArea) && SecondData.ContainsKey(productArea)) { progressData.TFSTestCasesThisWeek = FirstData[productArea].NoOfTFSTestcase - SecondData[productArea].NoOfTFSTestcase; progressData.AutomatedThisWeek = FirstData[productArea].NoOfAutomatedTestcases - SecondData[productArea].NoOfAutomatedTestcases; } else if (!FirstData.ContainsKey(productArea) && !SecondData.ContainsKey(productArea)) { progressData.TFSTestCasesThisWeek = 0; progressData.AutomatedThisWeek = 0; } else if (FirstData.ContainsKey(productArea)) { progressData.TFSTestCasesThisWeek = FirstData[productArea].NoOfTFSTestcase; progressData.AutomatedThisWeek = FirstData[productArea].NoOfAutomatedTestcases; } var temp = db.WeeklyTriagings.Where(row => row.TeamId == TeamId && row.Date <= To && row.Date > From && row.ProductArea == productArea).FirstOrDefault(); progressData.NoOfTestCasesDebugged = temp == null ? 0 : temp.NoOfTestCasesDebugged; list.Add(progressData); } return(list); }
public AutomationTeamModel(int TeamId) { var db = new AutomationDashboardEntities(); automateData = db.AutomateDatas.Where(e => e.TeamId == TeamId).First(); }