private iTool IdentifyTool() { iTool toolToExecute = new NOP(); switch (this.operation.ToLower()) { case "export security": toolToExecute = new ExportSecurity(); break; case "export alerts": toolToExecute = new ExportAlerts(); break; case "comparison report": toolToExecute = new ComparisonReport(); break; case "site structure": toolToExecute = new SiteStructure(); break; case "list report": toolToExecute = new ListReport(); break; } return(toolToExecute); }
internal static void ExpectMembersInReport(ListReport messagesReport, string path, IReadOnlyCollection <string> expectedMembers) { Assert.NotNull(messagesReport); var pathParts = path == string.Empty ? Enumerable.Empty <string>() : path.Split('.'); var reportLines = messagesReport.Where(item => (path == string.Empty) || (item.StartsWith(path) && item.Contains(':'))).ToArray(); reportLines = reportLines .Where(item => item.Contains(':')) .Select(item => item.Substring(0, item.IndexOf(':'))) .ToArray(); var groups = reportLines.Select(item => item.Split('.')).ToArray(); groups = groups.Where(g => g.Count() >= (pathParts.Count() + 1)).ToArray(); var members = groups.Select(g => g.ElementAt(pathParts.Count())).Distinct().ToArray(); Assert.Equal(expectedMembers.Count(), members.Length); for (var i = 0; i < expectedMembers.Count(); ++i) { Assert.Equal(expectedMembers.ElementAt(i), members.ElementAt(i)); } }
// ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local private static void BuildListReport(ListReport listReport, string path, IErrorsCollection errorsCollection, Translator translator, int depth, IExecutionOptions executionOptions) { if (depth > executionOptions.MaxDepth) { throw new MaxDepthExceededException(executionOptions.MaxDepth); } if (errorsCollection.IsEmpty) { return; } if (errorsCollection.Errors.Any()) { listReport.AddRange(errorsCollection.Errors .Select(m => string.IsNullOrWhiteSpace(path) ? translator(m) : $"{path}: {translator(m)}") .Distinct() .ToList() ); } foreach (var memberPair in errorsCollection.Members) { var currentPath = string.IsNullOrEmpty(path) ? string.Empty : $"{path}."; BuildListReport(listReport, $"{currentPath}{memberPair.Key}", memberPair.Value, translator, depth + 1, executionOptions); } }
public void ToString_Should_ReturnSingleMessage_When_SingleErrorMessage() { var listReport = new ListReport { "Test1" }; var expected = $"Test1{Environment.NewLine}"; Assert.Equal(expected, listReport.ToString()); }
public void ToString_Should_CombineAllMessages_When_ErrorMessages() { var listReport = new ListReport { "Test1", "Test2", "Test3" }; var expected = $"Test1{Environment.NewLine}Test2{Environment.NewLine}Test3{Environment.NewLine}"; Assert.Equal(expected, listReport.ToString()); }
/// <summary> /// Creates List Report. Report is a list of error messages. ToString() returns them in a single string. /// </summary> /// <param name="this"></param> /// <param name="translationName"> /// Name of the translation to be used in the report. If null, using the default one set in /// the validation context. /// </param> /// <typeparam name="T">Type of the validated model.</typeparam> public static ListReport ToListReport <T>(this IValidationResult <T> @this, string translationName = null) where T : class { var listReport = new ListReport(); var translator = translationName == null ? @this.TranslationProxy.DefaultTranslator : @this.TranslationProxy.TranslatorsRepository.Get(translationName); BuildListReport(listReport, string.Empty, @this.ErrorsCollection, translator, 0, @this.ExecutionOptions); return(listReport); }
protected void Page_Init(object sender, EventArgs e) { if (!int.TryParse(base.Request.QueryString["reportid"].ToString(), out this._reportId)) { } if (base.Request.QueryString[TokenVariableSetting].ToString().Length != 0) { this.validateToken(Request.QueryString[TokenVariableSetting]); } /*if (!System.Net.Dns.GetHostEntry(base.Request.UserHostAddress).HostName.Contains(RDNSCallerValueSetting)) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, System.Net.Dns.GetHostEntry(base.Request.UserHostAddress).HostName + " is not allowed to call this page."); }*/ this.rpt = new ListReport(this._reportId); }
private void tsbReport_Click(object sender, EventArgs e) { //FrmReportBrowser frm = new FrmReportBrowser(); //frm.ShowDialog(); this._currentUserCtr = null; SetEditButtonsStatus(false); ListReport lr = new ListReport(); this.tlpMainPanel.Controls.Clear(); //lr.MdiParentForm = this; lr.Dock = DockStyle.Fill; //.OnSelectedItemChanged += new EventHandler(_currentUserCtr_OnSelectedItemChanged); this.lblTitle.Text = "List of reports"; this.tlpMainPanel.Controls.Add(lr); }
/// <summary> /// Load a list of person placemark objects from the given report ID. The /// list is constrained to the start and count parameters. /// </summary> /// <param name="reportid">The Arena Report to generate a list of people from.</param> /// <param name="start">The member index to start loading from.</param> /// <param name="count">The maximum number of people to load, pass Int32.MaxValue for complete load.</param> /// <returns>A list of PersonPlacemark objects.</returns> public List <PersonPlacemark> PersonPlacemarksInReport(int reportid, int start, int count) { List <PersonPlacemark> people = new List <PersonPlacemark>(); SqlDataReader rdr; ListReport report; if (PersonFieldOperationAllowed(PersonFields.Profile_Name, OperationType.View) == false) { return(people); } report = new ListReport(reportid); rdr = new Arena.DataLayer.Organization.OrganizationData().ExecuteReader(report.Query); people = PersonPlacemarksFromReader(rdr, start, count); rdr.Close(); return(people); }
internal static void ExpectMessagesInReport(ListReport messagesReport, string path, IReadOnlyCollection <string> expectedMessages) { Assert.NotNull(messagesReport); var messages = string.IsNullOrEmpty(path) ? messagesReport .Where(item => !item.Contains(':')) .ToArray() : messagesReport .Where(item => item.StartsWith($"{path}:")) .Select(item => item.Split(": ", StringSplitOptions.RemoveEmptyEntries).ElementAtOrDefault(1)) .ToArray(); Assert.Equal(expectedMessages.Count(), messages.Count()); for (var i = 0; i < expectedMessages.Count(); ++i) { Assert.Equal(expectedMessages.ElementAt(i), messages.ElementAt(i)); } }
private void LoadBuildings(int userid) { this.Cursor = Cursors.WaitCursor; reportList.Clear(); Buildings bManager = (userid == 0 ? new Buildings(false) : new Buildings(userid)); buildings = bManager.buildings.OrderBy(c => c.Name).ToList(); foreach (Building b in buildings) { if (b.Web_Building) { String buildingCode = GetBuildingID(b.Abbr); ListReport lr = new ListReport { Name = b.Name, Code = b.Abbr, Debtor = bManager.getDebtorName(b.ID), Letters_updated = GetDate(1, buildingCode), Letters_ageanalysis = GetDate(2, buildingCode), Letters_printed = GetDate(3, buildingCode), Letters_filed = GetDate(4, buildingCode), Statements_updated = GetDate(5, buildingCode), Statements_interest = GetDate(6, buildingCode), Statements_printed = GetDate(7, buildingCode), Statements_filed = GetDate(8, buildingCode), Month_end_updated = GetDate(9, buildingCode), Month_end_invest_account = GetDate(10, buildingCode), Month_end_9990 = GetDate(11, buildingCode), Month_end_4000 = GetDate(12, buildingCode), Month_end_petty_cash = GetDate(13, buildingCode), Daily_trust = GetDate(14, buildingCode), Daily_own = GetDate(15, buildingCode), Daily_file = GetDate(16, buildingCode) }; reportList.Add(lr); } } this.Cursor = Cursors.Default; }
public void ToString_Should_ReturnEmptyString_When_NoErrorMessages() { var listReport = new ListReport(); Assert.Equal(string.Empty, listReport.ToString()); }