public async Task <IEnumerable <ProgramSummary> > GetProgramSummary(List <Program> programs) { List <ProgramSummary> returnData = new List <ProgramSummary>(); foreach (Program program in programs) { ProgramSummary summary; try { List <Event> events = await this.Events.FindAsync(x => x.ProgramId == program.Id).ConfigureAwait(false); List <EventTelemetrySummary> eventSummaries = events.SelectMany(x => x.TelemetrySummaries).ToList(); summary = new ProgramSummary { ProgramName = program.Name , DeveloperName = program.DeveloperTeam?.Name ?? "N/A" , TelemetryKey = program.TelemetryKey , RegisteredDate = program.RegisteredDate , UsersCount = eventSummaries.DistinctBy(x => x.ClientAppUserId).Count() }; ProgramUpdatePackageInfo latestPkg = await this.UpdatePackages.GetLatestPackage(program.Id).ConfigureAwait(false); if (latestPkg != null) { summary.LastUpdateDate = latestPkg.UploadedDate; summary.LatestVersion = latestPkg.SupportedToolkitVersion ?? "?"; summary.ToolkitVersion = latestPkg.SupportedToolkitVersion ?? "?"; } else { ProgramPackageInfo programPkg = await this.ProgramPackages.GetLatestProgramPackageInfo(program.Id).ConfigureAwait(false); if (programPkg != null) { summary.LastUpdateDate = programPkg.UploadedDate; summary.LatestVersion = programPkg.Version; summary.ToolkitVersion = programPkg.SupportedToolkitVersion; } else { summary.LatestVersion = "N/A"; summary.ToolkitVersion = "N/A"; } } summary.NumberOfUpdatePackages = await this.UpdatePackages.CountPackages(program.Id).ConfigureAwait(false); } catch (Exception) { summary = new ProgramSummary(); summary.ProgramName = program?.Name ?? "Error while loading summary"; summary.DeveloperName = "Error while loading summary"; } returnData.Add(summary); } return(returnData); }
public ViewResult AddProgramToRobot(ProgramSummary programSummary) { foreach (var robotId in programSummary.RobotIds) { var robot = _robotManager.GetRobotById(robotId); var program = _programManager.GetProgramById(programSummary.ProgramId); _programManager.CreateProgramRobot(robot, program); _commandManager.CreateRobotCommand(robot, program, RobotCommandTypes.Install); } return(View()); }
public async Task <IEnumerable <ProgramSummary> > GetProgramSummary(List <Program> programs) { List <ProgramSummary> returnData = new List <ProgramSummary>(); foreach (Program program in programs) { ProgramSummary summary; try { List <View> views = await this.Views.FindAsync(x => x.ProgramId == program.Id).ConfigureAwait(false); List <ViewTelemetrySummary> viewSummaries = views.SelectMany(x => x.TelemetrySummaries).ToList(); List <Event> events = await this.Events.FindAsync(x => x.ProgramId == program.Id).ConfigureAwait(false); List <EventTelemetrySummary> eventSummaries = events.SelectMany(x => x.TelemetrySummaries).ToList(); List <TelemetrySummary> allSummaries = viewSummaries.Cast <TelemetrySummary>().Concat(eventSummaries).ToList(); ProgramUpdatePackageInfo latestPkg = await this.UpdatePackages.GetLatestPackage(program.Id).ConfigureAwait(false); summary = new ProgramSummary { ProgramName = program.Name , DeveloperName = program.DeveloperTeam?.Name ?? "N/A" , TelemetryKey = program.TelemetryKey , RegisteredDate = program.RegisteredDate , UsersCount = allSummaries.DistinctBy(x => x.ClientAppUserId).Count() , LastUpdateDate = latestPkg?.UploadedDate , LatestVersion = latestPkg?.SupportedToolkitVersion ?? "?" , ToolkitVersion = latestPkg?.SupportedToolkitVersion ?? "?" }; } catch (Exception) { summary = new ProgramSummary(); summary.ProgramName = program?.Name ?? "Error while loading summary"; summary.DeveloperName = "Error while loading summary"; } returnData.Add(summary); } return(returnData); }
public ProgramSummary Summary(DateTime start, DateTime end) { var context = new CallAnalyzerContext(); ProgramSummary s = new ProgramSummary(); var results = context.TblCallsFull .Where(c => c.DateTimeDisconnect > start) .Where(c => c.DateTimeDisconnect < end); foreach (var c in results) { if (c.CallingPartyNumber == "" || c.CallingPartyNumber.Length > 4) { s.FromOutside.Calls++; s.FromOutside.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromOutside.Unanswered++; } else { s.FromOutside.Answered++; } } else { switch (c.CallingPartyNumber.Substring(0, 1)) { case "8": s.FromLSNJ.Calls++; s.FromLSNJ.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromLSNJ.Unanswered++; } else { s.FromLSNJ.Answered++; } break; case "6": s.FromSJLS.Calls++; s.FromSJLS.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromSJLS.Unanswered++; } else { s.FromSJLS.Answered++; } break; case "5": s.FromLSNWJ.Calls++; s.FromLSNWJ.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromLSNWJ.Unanswered++; } else { s.FromLSNWJ.Answered++; } break; case "4": s.FromENLS.Calls++; s.FromENLS.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromENLS.Unanswered++; } else { s.FromENLS.Answered++; } break; case "3": s.FromNNJLS.Calls++; s.FromNNJLS.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromNNJLS.Unanswered++; } else { s.FromNNJLS.Answered++; } break; case "2": s.FromCJLS.Calls++; s.FromCJLS.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromCJLS.Unanswered++; } else { s.FromCJLS.Answered++; } break; default: s.FromOutside.Calls++; s.FromOutside.Minutes += Convert.ToDecimal(c.Duration); if (c.FinalCalledPartyNumber == "8888") { s.FromOutside.Unanswered++; } else { s.FromOutside.Answered++; } break; } } } return(s); }