public void given_no_data_when_creating_report_entry_for_a_week_then_all_entries_have_zero_hours() { var entry = new ReportEntry(_engineer, _description, new DateTime(2020, 3, 2), 7, new Dictionary <DateTime, float>()); Assert.AreEqual(7, entry.NrOfHoursPerDay.Count, "entries for nr of days"); Assert.True(entry.NrOfHoursPerDay.Select(x => x.Value).All(nrOfHours => Math.Abs(nrOfHours) < 0.01f), "nr of hours value"); }
private static bool RunTest(Test test) { var temp = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.White; WriteLine("{0}, {1}, {2}", test.GetType().Name, test.TestName, DateTime.Now.ToString("G", CultureInfo.CurrentCulture)); DateTime startTime = DateTime.Now; DateTime stopTime; try { if (test.Enabled) { test.Run(); } stopTime = DateTime.Now; var entry = new ReportEntry { TestName = test.TestName, Result = true, TestStartTime = startTime, TestStopTime = stopTime }; _reportEntries.Add(entry); Console.ForegroundColor = ConsoleColor.Green; WriteLine("\t\t{0}", TestPassedMessage); return(true); } catch (Exception ex) { stopTime = DateTime.Now; Console.ForegroundColor = ConsoleColor.Red; WriteLine("\tMessage: {0}", ex.Message); WriteLine("\tStackTrace: {0}", ex.StackTrace); var entry = new ReportEntry { TestName = test.TestName, Result = false, ErrorMessage = ex.Message, TestStartTime = startTime, TestStopTime = stopTime }; _reportEntries.Add(entry); return(false); } finally { Console.ForegroundColor = temp; } }
protected void Page_Load(object sender, EventArgs e) { var list = ReportDataSource.Select(); if (!IsPostBack) { this.DropDownList1.DataSource = list; this.DropDownList1.DataTextField = "DisplayName"; this.DropDownList1.DataValueField = "Name"; this.DropDownList1.DataBind(); this.From.SelectedDate = DateTime.Now.Date; this.To.SelectedDate = DateTime.Now.Date.AddDays(+1); } //this.ReportViewer1.Reset(); ReportEntry re = list[DropDownList1.SelectedIndex]; this.ReportViewer1.LocalReport.ReportEmbeddedResource = "Ogdi.InteractiveSdk.Mvc.Reports.data." + re.Name; this.ObjectDataSource1.SelectMethod = re.Method; this.ObjectDataSource1.TypeName = re.Type; this.ObjectDataSource1.DataBind(); //this.ReportViewer1.LocalReport.DataSources.Add( // new Microsoft.Reporting.WebForms.ReportDataSource("Data", "ObjectDataSource1")); this.ReportViewer1.LocalReport.Refresh(); }
private ReportEntry ConstructReportEntry(JSONNode reportData) { string studentId = reportData["userId"]; string name = reportData["real_name"]; double accuracy; if (reportData["overall_accuracy"] == "NaN") { accuracy = 0.0; } else { accuracy = (double)reportData["overall_accuracy"]; } ReportEntry reportEntry = new ReportEntry { studentId = studentId, name = name, accuracy = accuracy }; Debug.Log("report entry successfully constructed"); return(reportEntry); }
IEnumerator GetReportEntry(string studentId) { string reportUrl = baseUrl + "player/getReport/" + studentId; // requesting player data UnityWebRequest reportRequest = UnityWebRequest.Get(reportUrl); yield return(reportRequest.SendWebRequest()); if (reportRequest.isNetworkError || reportRequest.isHttpError) { Debug.Log(reportRequest.error); yield break; } else { Debug.Log("Get player data successfully"); } JSONNode reportData = JSON.Parse(reportRequest.downloadHandler.text); Debug.Log(reportData); ReportEntry report = ConstructReportEntry(reportData); reports.Add(report); if (reports.Count == noPlayers) { Display(choice); } }
// output list of ReportEntry to a text file private static void WriteReportEntriesToFile(string fileName, IEnumerable <ReportEntry> reportEntries) { var filePath = Path.Combine(GetReportPath(), fileName); File.WriteAllLines(filePath, ReportEntry.GetMarkdownTable(reportEntries)); Console.WriteLine($"Wrote markdown table report to {filePath}"); }
public void AddReport(string title, string description) { ReportEntry entry = new ReportEntry { title = title, description = description, dateLogged = string.Format("logged on: {0}", DateTime.Now.ToString(new CultureInfo("en-GB"))) }; reportDB.list.Add(entry); }
public void AddNewEntry() { ReportEntry newentry = new ReportEntry(report.Count); report.Add(newentry); newentry.UpdateLocation(); // newentry.removeButton.Click += new EventHandler(AddRemoveButton_Click); this.Controls.Add(newentry.fileTBox); this.Controls.Add(newentry.blockTBox); this.Controls.Add(newentry.previewButton); this.Controls.Add(newentry.removeButton); }
public void given_a_report_entry_with_incorrect_number_of_columns_when_saved_then_argument_exception_is_thrown() { var nrOfHoursForAllDaysPerDay = new Dictionary <DateTime, float> { { _testDefaultReportStartDate, 2f }, { _testDefaultReportStartDate.AddDays(1), 3f }, }; var wrongNumberOfReportDays = TestNrOfReportDays + 1; var reportEntry = new ReportEntry("TestEngineer", "Description", _testDefaultReportStartDate, wrongNumberOfReportDays, nrOfHoursForAllDaysPerDay); Assert.Throws <ArgumentException>(() => _repository.SaveReportEntry(reportEntry)); }
private void UpdateReport_Load(object sender, EventArgs e) { ReportEntry re = new ReportEntry(); rc = new ReportController(); re = rc.GetReportByID(ID); textBox1.Text = re.ID.ToString(); comboBox1.Text = re.BT; textBox2.Text = re.TP.ToString(); textBox3.Text = re.TDesc; textBox5.Text = re.Age.ToString(); dateTimePicker1.Value = re.TDate; dateTimePicker2.Value = re.RDate; }
private void TestRunWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (_formClosing) { return; } var testRunHelper = e.Result as TestRunHelper; var item = testRunHelper.ListViewItem; var test = item.Tag as Test; var testPassed = (testRunHelper.Exception == null); if (testPassed) { item.Text = @"Pass"; item.ImageIndex = 0; item.SubItems[2].Text = string.Empty; } else { var ex = testRunHelper.Exception; item.Text = @"Fail"; item.ImageIndex = 1; item.SubItems[2].Text = string.Format(CultureInfo.CurrentUICulture, "{0} - {1}", ex.Source, ex.Message); } if (!test.Enabled) { item.Text = @"Disabled"; item.ImageIndex = 2; item.SubItems[2].Text = string.Empty; } var entry = new ReportEntry { TestName = test.TestName, Result = testPassed, TestStartTime = testRunHelper.StartTime, TestStopTime = testRunHelper.StopTime, ErrorMessage = testPassed ? string.Empty : testRunHelper.Exception.Message }; _reportEntries.Add(entry); if (tspProgress.Value == tspProgress.Maximum) { ShowIdleStatus(); ResetProgressCounter(); EnableOrDisableTestMenus(true); } }
public async Task RunAsync() { Log.Info($"Running Migration Tool ..... "); foreach (var file in _filesLister.GetSqlFilesWithContents()) { var entry = new ReportEntry { File = file.FullPath, StartRunTime = DateTime.Now, Status = "Success" }; try { //check if file has been modified before executing it. if (!_scriptCacheStrategy.HasScriptChanged(file)) { entry.Status = "Skipped"; continue; } await ExecuteAsync(file); // maintain history if executed successfully. _scriptCacheStrategy.CacheScript(file); } catch (Exception ex) { entry.Exception = ex.Message; entry.ReportEntryType = ReportEntryType.Error; entry.Status = "Fail"; } finally { entry.EndRunTime = DateTime.Now; ExecutionReport.AddEntry(entry); } } try { Log.Info("Writing reports....."); var createLogViewerWork = CreateLogViewerFileAsync(); await ExecutionReport.WriteReportAsync(ReportFileName); await createLogViewerWork; Log.Info("Finished running migration tool."); } catch (Exception ex) { throw ex; } }
public ReportEntry GetEntry(ReportType reportType) { for (int i = 0; i < reportEntries.Count; i++) { ReportEntry reportEntry = reportEntries[i]; if (reportEntry.reportType == reportType) { return(reportEntry); } } ReportEntry reportEntry2 = new ReportEntry(reportType, noteStorage.GetNewNoteId(), null, false); reportEntries.Add(reportEntry2); return(reportEntry2); }
public void given_a_report_entry_when_saved_then_it_is_persisted_in_the_file() { var nrOfHoursForAllDaysPerDay = new Dictionary <DateTime, float> { { _testDefaultReportStartDate, 2f }, { _testDefaultReportStartDate.AddDays(1), 3f }, { _testDefaultReportStartDate.AddDays(2), 2.5f } }; var reportEntry = new ReportEntry("TestEngineer", "Description", _testDefaultReportStartDate, TestNrOfReportDays, nrOfHoursForAllDaysPerDay); _repository.SaveReportEntry(reportEntry); var linesInFile = File.ReadAllLines(_absoluteFilePath); Assert.AreEqual(2, linesInFile.Length, "Nr of lines in file"); }
private Boolean TryShowHistogram(ReportEntry reportEntry) { if (Object.ReferenceEquals(reportEntry, null)) { throw new ArgumentNullException(nameof(reportEntry)); } if (!reportEntry.HasHistogram) { return(false); } if (!reportEntry.HasNonDegenerateHistogram) { return(false); } this.ShowHistogram(reportEntry.Histogram, reportEntry.Caption); return(true); }
public void given_partial_data_when_creating_report_entry_for_a_week_then_the_hour_data_for_the_days_equal_the_provided_hour_data_and_the_unknown_days_have_zero_hours() { var monday = new DateTime(2020, 3, 2); var tuesday = monday.AddDays(1); var wednesday = monday.AddDays(2); var thursday = monday.AddDays(3); var hoursOnTuesday = 2f; var hoursOnThursday = 3f; var nrOfHoursPerDayInputData = new Dictionary <DateTime, float> { { tuesday, hoursOnTuesday }, { thursday, hoursOnThursday } }; var entry = new ReportEntry(_engineer, _description, monday, 7, nrOfHoursPerDayInputData); Assert.AreEqual(7, entry.NrOfHoursPerDay.Count, "entries for nr of days"); Assert.True(Math.Abs(entry.NrOfHoursPerDay[monday]) < 0.01f, "nr of hours value on monday"); Assert.True(Math.Abs(entry.NrOfHoursPerDay[tuesday] - nrOfHoursPerDayInputData[tuesday]) < 0.01f, "nr of hours value on tuesday"); Assert.True(Math.Abs(entry.NrOfHoursPerDay[wednesday]) < 0.01f, "nr of hours value on wednesday"); Assert.True(Math.Abs(entry.NrOfHoursPerDay[thursday] - nrOfHoursPerDayInputData[thursday]) < 0.01f, "nr of hours value on thursday"); }
public void AddData(NoteStorage note_storage, float value, string note = null, string dataContext = null) { AddActualData(note_storage, value, note); if (dataContext != null) { ReportEntry reportEntry = null; for (int i = 0; i < contextEntries.Count; i++) { if (contextEntries[i].context == dataContext) { reportEntry = contextEntries[i]; break; } } if (reportEntry == null) { reportEntry = new ReportEntry(reportType, note_storage.GetNewNoteId(), dataContext, true); contextEntries.Add(reportEntry); } reportEntry.AddActualData(note_storage, value, note); } }
protected override void InternalBeginProcessing() { TaskLogger.LogEnter(); try { ReportEntry reportEntry = new ReportEntry(MrsStrings.ReportRequestCreated(this.ExecutingUserIdentity)); reportEntry.Connectivity = new ConnectivityRec(ServerKind.Cmdlet, VersionInformation.MRS); this.GeneralReportEntries.Insert(0, reportEntry); RequestTaskHelper.ValidateItemLimits(this.BadItemLimit, this.LargeItemLimit, this.AcceptLargeDataLoss, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), this.ExecutingUserIdentity); if (this.SuspendComment != null && !this.Suspend) { base.WriteError(new SuspendCommentWithoutSuspendPermanentException(), ErrorCategory.InvalidArgument, this.SuspendComment); } if (!string.IsNullOrEmpty(this.SuspendComment) && this.SuspendComment.Length > 4096) { base.WriteError(new ParameterLengthExceededPermanentException("SuspendComment", 4096), ErrorCategory.InvalidArgument, this.SuspendComment); } if (!string.IsNullOrEmpty(this.Name) && this.Name.Length > 255) { base.WriteError(new ParameterLengthExceededPermanentException("Name", 255), ErrorCategory.InvalidArgument, this.Name); } if (!string.IsNullOrEmpty(this.BatchName) && this.BatchName.Length > 255) { base.WriteError(new ParameterLengthExceededPermanentException("BatchName", 255), ErrorCategory.InvalidArgument, this.BatchName); } if (!string.IsNullOrEmpty(this.ContentFilter)) { this.NormalizedContentFilter = this.NormalizeContentFilter(); } this.ValidateFolderFilter(); base.InternalBeginProcessing(); } finally { TaskLogger.LogExit(); } }
public void SaveReportEntry(ReportEntry reportEntry) { var reportEntryString = $"\"{reportEntry.GroupedBy}\"{CsvSeparator}\"{reportEntry.ThenGroupedBy}\"{CsvSeparator}\"{Enumerable.Sum<KeyValuePair<DateTime, float>>(reportEntry.NrOfHoursPerDay, x => x.Value)}\"{CsvSeparator}{string.Join(CsvSeparator.ToString(), Enumerable.Select<KeyValuePair<DateTime, float>, string>(reportEntry.NrOfHoursPerDay, hoursForDay => $"\"{GetHoursForDayString(hoursForDay)}\""))}"; SavedReportEntries.Add(reportEntryString); }
private List <ReportEntry> Sort(List <ReportEntry> reportEntryList, int criteria) { if (criteria == 0) { for (int i = 0; i < reportEntryList.Count; i++) { for (int j = i + 1; j < reportEntryList.Count; j++) { if (int.Parse(reportEntryList[j].studentId) < int.Parse(reportEntryList[i].studentId)) { ReportEntry temp = reportEntryList[i]; reportEntryList[i] = reportEntryList[j]; reportEntryList[j] = temp; } } } } else if (criteria == 1) { for (int i = 0; i < reportEntryList.Count; i++) { for (int j = i + 1; j < reportEntryList.Count; j++) { if (reportEntryList[j].accuracy < reportEntryList[i].accuracy) { ReportEntry temp = reportEntryList[i]; reportEntryList[i] = reportEntryList[j]; reportEntryList[j] = temp; } } } } else if (criteria == 2) { for (int i = 0; i < reportEntryList.Count; i++) { for (int j = i + 1; j < reportEntryList.Count; j++) { if (reportEntryList[j].accuracy > reportEntryList[i].accuracy) { ReportEntry temp = reportEntryList[i]; reportEntryList[i] = reportEntryList[j]; reportEntryList[j] = temp; } } } } else if (criteria == 3) { for (int i = 0; i < reportEntryList.Count; i++) { for (int j = i + 1; j < reportEntryList.Count; j++) { if (string.Compare(reportEntryList[j].name, reportEntryList[i].name) < 0) { ReportEntry temp = reportEntryList[i]; reportEntryList[i] = reportEntryList[j]; reportEntryList[j] = temp; } } } } return(reportEntryList); }
/// <summary> /// Сформировать отчет /// </summary> /// <param name="startReportDate">Дата с</param> /// <param name="endReportDate">Дата по</param> /// <returns>Отчет</returns> public ObservableCollection <ReportEntry> GenerateReport(DateTime startReportDate, DateTime endReportDate) { Report = new ObservableCollection <ReportEntry>(); var manningTable = ManningTableEntryRepository.AllManningTable; // Сортируем записи по дате и группируем по подразделению var groupedByDivisionManningTable = manningTable.OrderBy(x => x.Rate.ValidDate).GroupBy(x => x.Division.Id); foreach (var subManningTable in groupedByDivisionManningTable.ToList()) { bool isFirstSuitable = true; // Это первый подходящий элемент // Здесь будет храниться ФОТ для каждой должности в отдельности, чтобы потом просуммировать их var payRollForDivision = new Dictionary <JobPosition, int>(); for (int i = 0; i < subManningTable.Count(); i++) { // Дата действия для текущейзаписи в штатном расписании var validDate = subManningTable.ElementAt(i).Rate.ValidDate; // Если дата не попадает в интервал, переходим к следующей итерации if ((startReportDate > validDate) || (validDate >= endReportDate)) { continue; } ReportEntry entry = new ReportEntry(); // Запись в отчете ManningTableEntry manningTableEntry; // Запись в штатном расписании // Если элемент не первый из подходящих под интервал, или выполняются остальные условия, // то записываем в отчет текущий элемент if (!isFirstSuitable || i == 0 || validDate == startReportDate) { manningTableEntry = subManningTable.ElementAt(i); entry.Division = manningTableEntry.Division; entry.StartDate = validDate; //entry.PayRoll = manningTableEntry.HeadCount * manningTableEntry.Rate.RateValue; isFirstSuitable = false; } // Если же элемент первый подходящий, но не первый в коллекции // и его дата действия больше даты начала интервала, // то записываем в отчет данные с предыдущего элемента else { manningTableEntry = subManningTable.ElementAt(i - 1); entry.Division = manningTableEntry.Division; entry.StartDate = startReportDate; //entry.PayRoll = manningTableEntry.HeadCount * manningTableEntry.Rate.RateValue; isFirstSuitable = false; } // Аналогично проверяем, какую дату записать в качестве конечной if (i + 1 < subManningTable.Count() && subManningTable.ElementAt(i + 1).Rate.ValidDate < endReportDate) { entry.EndDate = subManningTable.ElementAt(i + 1).Rate.ValidDate; } else { entry.EndDate = endReportDate; } // Если в один отдел записано две ставки с одной датой, // то этот интервал можно объединить, // а ФОТ отдела за этот период будет просуммирована if (Report.Count > 0) { var preReportEntry = Report[Report.Count - 1]; if (preReportEntry.StartDate == entry.StartDate) { Report.Remove(preReportEntry); } } // Высчитываем ФОТ отдела из ФОТ на каждую ставку внутри отдела, // действующую за данный период var pos = manningTableEntry.Rate.Position; if (payRollForDivision.ContainsKey(pos)) { payRollForDivision.Remove(pos); } payRollForDivision.Add(pos, manningTableEntry.HeadCount * manningTableEntry.Rate.RateValue); foreach (var value in payRollForDivision.Values) { entry.PayRoll += value; } Report.Add(entry); // Добавляем запись в коллекцию } } return(Report); }
public async Task <RuntimeResult> ReportAsync(IGuildUser user, [Optional][Remainder] string reason) { var reportChannel = Context.Guild.GetTextChannel(Global.Channels["reports"]);; var reporter = Context.Message.Author; var entry = new ReportEntry { ReportedUser = user.Username + '#' + user.Discriminator, ReportedUserId = user.Id, ReportedBy = reporter.Username + '#' + reporter.Discriminator, ReportedById = reporter.Id, Reason = reason, ChannelID = Context.Channel.Id, Date = Context.Message.Timestamp.Date, }; using (var db = new Database()) { db.Reports.Add(entry); db.SaveChanges(); } var builder = new EmbedBuilder(); builder.Title = "...a new report has emerged from outer space!"; builder.Color = new Color(0x3E518); builder.Timestamp = Context.Message.Timestamp; builder.WithFooter(footer => { footer .WithText("Case #" + entry.ID) .WithIconUrl("https://a.kyot.me/0WPy.png"); }); builder.ThumbnailUrl = user.GetAvatarUrl(); builder.WithAuthor(author => { author .WithName("Woah...") .WithIconUrl("https://a.kyot.me/cno0.png"); }); const string discordUrl = "https://discordapp.com/channels/{0}/{1}/{2}"; builder.AddField("Reported User", user.Mention) .AddField("Reported by", reporter.Mention) .AddField( "Location of the incident", $"[#{Context.Message.Channel.Name}]({string.Format(discordUrl, Context.Guild.Id, Context.Channel.Id, Context.Message.Id)})") .AddField("Reason", reason ?? "No reason was provided."); var embed = builder.Build(); await reportChannel.SendMessageAsync(null, embed : embed).ConfigureAwait(false); return(CustomResult.FromSuccess()); }
public void AddReportEntry(ReportEntry model) { var repository = new ReportRepository(); repository.AddReportEntry(model); }
public EditorReportEntry(IContext context, IValidator validator, ReportEntry entry) : base(entry) { Context = context; Validator = validator; }
public void AddReportEntry(ReportEntry model) { }
public void AddData(ReportType reportType, float value, string note = null, string context = null) { ReportEntry entry = GetEntry(reportType); entry.AddData(noteStorage, value, note, context); }
protected ReportEntry(ReportEntry entry) { Code = entry.Code; Message = entry.Message; ErrorLevel = entry.ErrorLevel; }
public ReportEntryBuilder() { _reportEntry = new ReportEntry(); }