private static void OnNoteTooltip(ReportManager.ReportEntry entry, ReportManager.ReportGroup reportGroup, Dictionary <string, string> data, List <string> headers, Func <ReportManager.ReportEntry.Note, bool> is_note_applicable_cb) { //Debug.Log("OnNoteTooltip"); List <ReportManager.ReportEntry.Note> notes = new List <ReportManager.ReportEntry.Note>(); entry.IterateNotes(delegate(ReportManager.ReportEntry.Note note) { if (is_note_applicable_cb(note)) { notes.Add(note); } }); foreach (ReportManager.ReportEntry.Note item in Sort(notes, reportGroup.posNoteOrder)) { ReportManager.ReportEntry.Note current = item; string colName = CleanHeader(current.note); if (current.value > 0f) { AddValue(colName + " (+)", current.value, data, headers); } else { AddValue(colName + " (-)", current.value, data, headers); } } }
private static void CreateOrUpdateLine(ReportManager.ReportEntry entry, ReportManager.ReportGroup reportGroup, int day, ReportData data) { addedValue = float.NegativeInfinity; removedValue = float.NegativeInfinity; netValue = float.NegativeInfinity; SetLine(entry, reportGroup, day, data); }
public static void SetLine(ReportManager.ReportEntry entry, ReportManager.ReportGroup reportGroup, int day, ReportData data) { //Debug.Log("cycle: "+day); string columnName = (entry.context == null ? reportGroup.stringKey : entry.context); if (addedValue != entry.Positive) { addedValue = entry.Positive; } if (removedValue != entry.Negative) { removedValue = entry.Negative; } if (netValue != entry.Net) { netValue = entry.Net; } //pos_notes.Clear(); //neg_notes.Clear(); string cleanedColName = CleanHeader(columnName); AddValue(cleanedColName + " (+)", addedValue, data.dataGeneral.GetValueSafe(day), data.headersGeneral); AddValue(cleanedColName + " (-)", removedValue, data.dataGeneral.GetValueSafe(day), data.headersGeneral); AddValue(cleanedColName + " (=)", netValue, data.dataGeneral.GetValueSafe(day), data.headersGeneral); if (cleanedColName.Contains("Power Usage")) { //Debug.Log(cleanedColName + " TOOLTIP POSITIVE:"); OnNoteTooltip(entry, reportGroup, data.dataPower.GetValueSafe(day), data.headersPower, (ReportManager.ReportEntry.Note note) => IsPositiveNote(note)); //Debug.Log(cleanedColName + " TOOLTIP NEGATIVE:"); OnNoteTooltip(entry, reportGroup, data.dataPower.GetValueSafe(day), data.headersPower, (ReportManager.ReportEntry.Note note) => IsNegativeNote(note)); } /* * List<ReportManager.ReportEntry.Note> pos_notes = new List<ReportManager.ReportEntry.Note>(); * entry.IterateNotes(delegate (ReportManager.ReportEntry.Note note) * { * if (note.value > 0f) * { * pos_notes.Add(note); * //Debug.Log("pos "+note.note+" = "+note.value); * } * }); * * List<ReportManager.ReportEntry.Note> neg_notes = new List<ReportManager.ReportEntry.Note>(); * entry.IterateNotes(delegate (ReportManager.ReportEntry.Note note) * { * if (note.value < 0f) * { * neg_notes.Add(note); * //Debug.Log("neg " + note.note + " = " + note.value); * } * }); */ }
private static void OnExportDailyReports() { bool error = false; if (ReportManager.Instance == null) { return; } List <DailyReport> dailyReports = ReportManager.Instance.reports; if (dailyReports == null) { return; } ReportData data = new ReportData(); foreach (var report in dailyReports) { try { //Debug.Log(report.day); AddValueCycle("Cycle", report.day, data.dataGeneral, data.headersGeneral); AddValueCycle("Cycle", report.day, data.dataPower, data.headersPower); foreach (KeyValuePair <ReportManager.ReportType, ReportManager.ReportGroup> reportGroup in ReportManager.Instance.ReportGroups) { ReportManager.ReportEntry entry = report.GetEntry(reportGroup.Key); bool showLine = true; if (entry.accumulate == 0f) { showLine = reportGroup.Value.reportIfZero; } if (reportGroup.Value.isHeader) { //CreateHeader(reportGroup.Value); } else if (showLine) { CreateOrUpdateLine(entry, reportGroup.Value, report.day, data); } else { string columnName = (entry.context == null ? reportGroup.Value.stringKey : entry.context); //Debug.Log("Hidden data: "+ columnName); } } } catch (Exception e) { error = true; Debug.LogError(e); InfoDialogScreen infoDialogScreen = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject); infoDialogScreen.SetHeader("Export Daily Reports").AddPlainText("Error exporting daily reports:\n" + e.ToString()); infoDialogScreen.Show(); break; } } if (!error) { data.headersPower.Sort((f1, f2) => { if (f1.Equals("Cycle")) { return(-1); // Cycle is the first column } return(f1.CompareTo(f2)); } ); WriteData(dailyReports.Count, data); } data.dataGeneral.Clear(); data.dataPower.Clear(); data.headersGeneral.Clear(); data.headersPower.Clear(); }