/// <summary> /// Gets the dashboard data. /// </summary> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public DashboardDataModel GetDashboardData() { DashboardDataModel dashboardDataModel = new DashboardDataModel(); try { DataSet dsDashboard = DBHelper.GetDataTable(StoredProcedure.DashboardData, null, DBHelper.ParseString(_settings.Value.AppDbContext)); if (dsDashboard != null && dsDashboard.Tables.Count > 0) { DataTable dtCountTable = dsDashboard.Tables[0]; if (dtCountTable != null && dtCountTable.Rows.Count > 0) { dashboardDataModel.TotalCustomer = DBHelper.ParseInt64(dtCountTable.Rows[0]["TotalCustomer"]); dashboardDataModel.TotalProduct = DBHelper.ParseInt64(dtCountTable.Rows[0]["TotalProduct"]); } } } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + Constants.ExceptionSeprator + ex.StackTrace); throw ex; } return(dashboardDataModel); }
public DashboardDataModel GetDashboardData() { try { var model = new DashboardDataModel(); string approvedStat = Enums.StatusOfRecall.POTRJEN.ToString(); string rejectedStat = Enums.StatusOfRecall.ZAVRNJEN.ToString(); string needApprovalStat = Enums.StatusOfRecall.V_ODOBRITEV.ToString(); string clientTypeTransport = Enums.TypeOfClient.PREVOZNIK.ToString(); string clientTypeWarehouse = Enums.TypeOfClient.SKLADISCE.ToString(); string overtake = Enums.StatusOfRecall.PREVZET.ToString(); string partialOvertake = Enums.StatusOfRecall.DELNO_PREVZET.ToString(); model.AllRecalls = context.Odpoklic.Count(); model.ApprovedRecalls = context.Odpoklic.Where(o => o.StatusOdpoklica.Koda == approvedStat).Count(); model.RejectedRecalls = context.Odpoklic.Where(o => o.StatusOdpoklica.Koda == rejectedStat).Count(); model.NeedsApproval = context.Odpoklic.Where(o => o.StatusOdpoklica.Koda == needApprovalStat).Count(); model.Routes = context.Relacija.Count(); model.Transporters = context.Stranka_OTP.Where(sotp => sotp.TipStranka.Koda == clientTypeTransport).Count(); model.OwnWarehouse = context.Stranka_OTP.Where(sotp => sotp.TipStranka.Koda == clientTypeWarehouse).Count(); //število odpoklicev v tekočem letu var query = from recalls in context.Odpoklic where recalls.ts.Value.Year == DateTime.Now.Year group recalls by new { month = recalls.ts.Value.Month } into groupRecall select new RecallsInYear { Month = groupRecall.Key.month, Count = groupRecall.Count() }; model.CurrentYearRecall = new List <object>(); model.CurrentYearRecall.Add(new object[] { "MonthName", "Št. odpoklicev" }); foreach (var item in query.ToList()) { item.MonthName = DataTypesHelper.GetDateTimeMonthByNumber(item.Month); model.CurrentYearRecall.Add(new object[] { item.MonthName, item.Count }); } //število odpoklicev na zaposlenega var query2 = from recalls in context.Odpoklic where recalls.ts.Value.Year == DateTime.Now.Year group recalls by recalls.Osebe_OTP into groupRecall select new RecallsInYear { EmployeeName = groupRecall.Key.Ime + " " + groupRecall.Key.Priimek, Count = groupRecall.Count() }; model.EmployeesRecallCount = new List <object>(); model.EmployeesRecallCount.Add(new object[] { "EmployeeName", "Št. odpoklicev " }); foreach (var item in query2.ToList()) { model.EmployeesRecallCount.Add(new object[] { item.EmployeeName, item.Count }); } //gledamo odpoklice za 30 dni nazaj ali odpoklice 1 leta nazaj. In vsi odpoklici morajo biti odobreni, prevzeti ali delno prevzeti. bool checkForPastYear = Convert.ToBoolean(ConfigurationManager.AppSettings["RouteRecallsPastYear"].ToString()); DateTime dateStart = !checkForPastYear?DateTime.Now.AddDays(-30).Date : DateTime.Now.AddYears(-1).Date; DateTime dateEnd = DateTime.Now.Date; //število odpoklicev na posameznega prevoznika var query3 = from recalls in context.Odpoklic where recalls.ts.Value >= dateStart && recalls.ts.Value <= dateEnd && (recalls.StatusOdpoklica.Koda == approvedStat || recalls.StatusOdpoklica.Koda == overtake || recalls.StatusOdpoklica.Koda == partialOvertake) group recalls by recalls.Stranka_OTP1 into groupRecall select new RecallsInYear { Transporter = groupRecall.Key.NazivPrvi, Count = !checkForPastYear?groupRecall.Count() * 12 : groupRecall.Count() }; model.TransporterRecallCount = new List <object>(); model.TransporterRecallCount.Add(new object[] { "Transporter", "Št. odpoklicov" }); foreach (var item in query3.ToList()) { if (item.Count > 0) { model.TransporterRecallCount.Add(new object[] { item.Transporter, item.Count }); } } var query4 = from recalls in context.Odpoklic where recalls.ts.Value >= dateStart && recalls.ts.Value <= dateEnd && (recalls.StatusOdpoklica.Koda == approvedStat || recalls.StatusOdpoklica.Koda == overtake || recalls.StatusOdpoklica.Koda == partialOvertake) group recalls by recalls.Relacija into groupRecalls select new RecallsInYear { Route = groupRecalls.Key.Naziv, Count = !checkForPastYear?groupRecalls.Count() * 12 : groupRecalls.Count() }; model.RouteRecallCount = new List <object>(); model.RouteRecallCount.Add(new object[] { "Relacija", "Št. odpoklicov" }); foreach (var item in query4.OrderByDescending(o => o.Count).Take(10).ToList()) { if (item.Count > 0) { model.RouteRecallCount.Add(new object[] { item.Route, item.Count }); } } var query5 = from recalls in context.Odpoklic where recalls.ts.Value.Year == DateTime.Now.Year && (recalls.StatusOdpoklica.Koda == approvedStat || recalls.StatusOdpoklica.Koda == overtake || recalls.StatusOdpoklica.Koda == partialOvertake) group recalls by recalls.DobaviteljNaziv into groupRecalls select new RecallsInYear { Supplier = groupRecalls.Key, Count = groupRecalls.Count() }; model.SupplierRecallCount = new List <object>(); model.SupplierRecallCount.Add(new object[] { "Dobavitelj", "Št. odpoklicov" }); foreach (var item in query5.OrderByDescending(o => o.Count).Take(10).ToList()) { if (item.Count > 0) { model.SupplierRecallCount.Add(new object[] { item.Supplier, item.Count }); } } return(model); } catch (Exception ex) { throw new Exception(ValidationExceptionError.res_27, ex); } }
public DashboardModel PrepareDashboardModel(DashboardModel model) { long totalCount = 0; //coolComs DashboardDataModel coolComItem = new DashboardDataModel(); var coolComData = _coolComService.SearchCoolCom(out totalCount, 0, _erpManagerSettings.DashboardDataItemCount, "", "", true); coolComItem.Count = Convert.ToInt32(totalCount); coolComItem.ManageButton = "/CoolCom/Index"; coolComItem.Name = _languageService.GetLocaleString("CoolCom Main"); coolComItem.ZetoItemText = _languageService.GetLocaleString("CoolCom0"); coolComItem.UseAvatar = false; coolComItem.ShowCount = _erpManagerSettings.DashboardDataItemCount; coolComItem.CssClass = "btn-danger"; coolComItem.FaClass = "fa fa-building-o"; foreach (var coolCom in coolComData) { DashboardDataItemModel subItem = new DashboardDataItemModel(); subItem.Images = _erpManagerSettings.CompanyImagePath + coolCom.CoolCompanyId; subItem.FirstDataIds = _languageService.GetLocaleString("CompanyId") + ": " + coolCom.Id; subItem.SecondDataIds = _languageService.GetLocaleString("CoolCompanyId") + ": " + coolCom.CoolCompanyId; coolComItem.Items.Add(subItem); } model.Items.Add(coolComItem); DashboardDataModel coolUserItem = new DashboardDataModel(); var coolUserData = _coolUserService.SearchCoolUser(out totalCount, 0, _erpManagerSettings.DashboardDataItemCount, "", "", true); coolUserItem.Count = Convert.ToInt32(totalCount); coolUserItem.ManageButton = "/CoolUser/Index"; coolUserItem.Name = _languageService.GetLocaleString("CoolUser Main"); coolUserItem.ZetoItemText = _languageService.GetLocaleString("CoolUser0"); coolUserItem.UseAvatar = true; coolUserItem.ShowCount = _erpManagerSettings.DashboardDataItemCount; coolUserItem.CssClass = "btn-info"; coolUserItem.FaClass = "fa fa-user-o"; foreach (var coolUser in coolUserData) { DashboardDataItemModel subItem = new DashboardDataItemModel(); subItem.Images = _erpManagerSettings.UserProfilePath + coolUser.CoolUserId; subItem.FirstDataIds = _languageService.GetLocaleString("CompanyId") + ": " + coolUser.CoolComId; subItem.SecondDataIds = _languageService.GetLocaleString("CoolUserId") + ": " + coolUser.CoolUserId; coolUserItem.Items.Add(subItem); } model.Items.Add(coolUserItem); DashboardDataModel coolQueryItem = new DashboardDataModel(); var coolQueryData = _coolQueryService.SearchCoolQuery(out totalCount, 0, _erpManagerSettings.DashboardDataItemCount, "", "", true); coolQueryItem.Count = Convert.ToInt32(totalCount); coolQueryItem.ManageButton = "/CoolQuery/Index"; coolQueryItem.Name = _languageService.GetLocaleString("CoolQuery Main"); coolQueryItem.ZetoItemText = _languageService.GetLocaleString("CoolQuery0"); coolQueryItem.ShowCount = _erpManagerSettings.DashboardDataItemCount; coolQueryItem.CssClass = "btn-purple"; coolQueryItem.FaClass = "fa fa-database"; foreach (var coolQuery in coolQueryData) { DashboardDataItemModel subItem = new DashboardDataItemModel(); subItem.Images = "/assets/images/messages/soldan-bakan.png"; subItem.FirstDataIds = _languageService.GetLocaleString("CompanyId") + ": " + coolQuery.CoolComId; subItem.SecondDataIds = _languageService.GetLocaleString("QueryCode") + ": " + coolQuery.QueryCode; coolQueryItem.Items.Add(subItem); } model.Items.Add(coolQueryItem); DashboardDataModel coolAppItem = new DashboardDataModel(); var coolAppData = _coolAppService.SearchCoolApp(out totalCount, 0, _erpManagerSettings.DashboardDataItemCount, "", "", true); coolAppItem.Count = Convert.ToInt32(totalCount); coolAppItem.ManageButton = "/CoolApp/Index"; coolAppItem.Name = _languageService.GetLocaleString("CoolApp Main"); coolAppItem.ZetoItemText = _languageService.GetLocaleString("coolApp0"); coolAppItem.ShowCount = _erpManagerSettings.DashboardDataItemCount; coolAppItem.CssClass = "btn-warning"; coolAppItem.FaClass = "fa fa-window-maximize"; foreach (var coolApp in coolAppData) { DashboardDataItemModel subItem = new DashboardDataItemModel(); subItem.Images = "/assets/images/messages/mutlu.png"; subItem.FirstDataIds = _languageService.GetLocaleString("CompanyId") + ": " + coolApp.CoolComId; subItem.SecondDataIds = _languageService.GetLocaleString("CoolCompanyId") + ": " + coolApp.CoolCompanyId; coolAppItem.Items.Add(subItem); } model.Items.Add(coolAppItem); return(model); }
public static async Task <DashboardDataModel> GetPatientsForDashboard() { DashboardDataModel dashboardDataModel = new DashboardDataModel(); using (SqlConnection dbConn = new SqlConnection(connectionString)) { var queryNoOfPatients = "SELECT Count(Id) from Patient"; var queryNoOfPatientsAdmitted = "SELECT Count(Id) from In_Patient"; var queryNoOfPatientsDischarged = "SELECT Count(Id) from In_Patient WHERE DischargeDate IS NOT NULL"; var queryNoOfPatientsInHouse = "SELECT Count(Id) from In_Patient WHERE DischargeDate IS NULL"; SqlDataReader reader1; SqlDataReader reader2; SqlDataReader reader3; SqlDataReader reader4; try { dbConn.Open(); SqlCommand cmd1 = new SqlCommand(queryNoOfPatients, dbConn); reader1 = await cmd1.ExecuteReaderAsync(); if (reader1.HasRows) { while (reader1.Read()) { dashboardDataModel.NoOfPatients = reader1.GetInt32(0); } } dbConn.Close(); dbConn.Open(); SqlCommand cmd2 = new SqlCommand(queryNoOfPatientsAdmitted, dbConn); reader2 = await cmd2.ExecuteReaderAsync(); if (reader2.HasRows) { while (reader2.Read()) { dashboardDataModel.NoOfPatientsAdmitted = reader2.GetInt32(0); } } dbConn.Close(); dbConn.Open(); SqlCommand cmd3 = new SqlCommand(queryNoOfPatientsDischarged, dbConn); reader3 = await cmd3.ExecuteReaderAsync(); if (reader3.HasRows) { while (reader3.Read()) { dashboardDataModel.NoOfPatientsDischarged = reader3.GetInt32(0); } } dbConn.Close(); dbConn.Open(); SqlCommand cmd4 = new SqlCommand(queryNoOfPatientsInHouse, dbConn); reader4 = await cmd4.ExecuteReaderAsync(); if (reader4.HasRows) { while (reader4.Read()) { dashboardDataModel.NoOfPatientsInHouse = reader4.GetInt32(0); } } dbConn.Close(); } catch (Exception ex) { reader1 = null; reader2 = null; reader3 = null; reader4 = null; Console.WriteLine(ex); } finally { dbConn.Close(); } return(dashboardDataModel); } }
public async Task <IActionResult> Index() { var folder = await _foldersProvider.GetActiveFolder(); SystemUser user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = await _usersProvider.GetUser(HttpContext.User.GetUserId()); folder = user.SelectedFolder; } var platforms = new string[] { "osx", "win7", "win", "linux" }; var runs = folder.Runs; var model = new DashboardDataModel { FailedTests = new List <FailedTestPerPlatform>(), Users = await _usersProvider.GetAllUsers() }; foreach (var platform in platforms) { model.LatestStats.Add(await _runsProvider.GetLatestRunForEnvironment(platform, folder.Id)); } foreach (var run in runs.GroupBy(p => p.Environment).OrderBy(p => p.Key)) { var runner = run.OrderByDescending(p => p.ReportTime).FirstOrDefault(); model.LatestResults.Add(runner); var allTestsInfo = await _runsProvider.GetAllTestsInfo(); foreach (var test in runner.FailedTests) { var testInfo = allTestsInfo.FirstOrDefault(p => p.TestName == test + ".py"); var failedTest = new FailedTestPerPlatform { LinuxRunId = runs.Where(p => p.Environment == "linux").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, OsxRunId = runs.Where(p => p.Environment == "osx").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, Win10RunId = runs.Where(p => p.Environment == "win").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, Win7RunId = runs.Where(p => p.Environment == "win7").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, TestId = runs.OrderByDescending(p => p.ReportTime).Where(p => p.Tests != null).SelectMany(z => z.Tests).FirstOrDefault(q => q.Name == test)?.Id, Test = test, Author = testInfo?.AuthorLogin, Suit = testInfo?.SuiteName, CurrentUser = user, Linux = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "linux")?.FailedTests.ToList().Exists(p => p == test), Windows7 = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "win7")?.FailedTests.ToList().Exists(p => p == test), Osx = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "osx")?.FailedTests.ToList().Exists(p => p == test), Windows10 = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "win")?.FailedTests.ToList().Exists(p => p == test) }; model.FailedTests.Add(failedTest); } } model.FailedTests = model.FailedTests.Distinct().ToList(); //Historic data var groupedEnvironment = runs.GroupBy(p => p.Environment); model.HistoricData = new List <HistoricData>(); foreach (var grouping in groupedEnvironment) { var newHistoricData = new HistoricData { Platform = grouping.Key }; var groupedDate = grouping.GroupBy(p => p.ReportTime.Date).OrderBy(p => p.Key); newHistoricData.HistoricDataItems = new List <HistoricDataItems>(); foreach (var dt in groupedDate) { var item = dt.OrderByDescending(p => p.Total).FirstOrDefault(); if (item != null) { newHistoricData.HistoricDataItems.Add(new HistoricDataItems { DateLabel = dt.Key.ToShortDateString(), Blocked = item.Blocked, Failed = item.Failed, Passed = item.Passed, Skipped = item.Skipped, Total = item.Total }); } } model.HistoricData.Add(newHistoricData); } return(View(model)); }