Ejemplo n.º 1
0
        static string GenerateTableHeaderRow(ReportBuilder reportBuilder, ReportTable table)
        {
            ReportColumns[]      columns    = table.ReportDataColumns;
            ReportTextBoxControl ColumnCell = new ReportTextBoxControl();
            ReportDimensions     padding    = new ReportDimensions();

            if (columns == null)
            {
                return("");
            }

            string strTableRow = "";

            strTableRow = @"<TablixRow> 
                <Height>0.6cm</Height> 
                <TablixCells>";
            for (int i = 0; i < columns.Length; i++)
            {
                ColumnCell   = columns[i].ColumnCell;
                padding      = columns[i].HeaderColumnPadding;
                strTableRow += @"<TablixCell> 
                  <CellContents> 
                   " + GenerateTextBox("txtHeader_" + table.ReportName + "_", ColumnCell.Name, columns[i].HeaderText == null || columns[i].HeaderText.Trim() == "" ? ColumnCell.Name : columns[i].HeaderText, false, padding) + @" 
                  </CellContents> 
                </TablixCell>";
            }
            strTableRow += @"</TablixCells></TablixRow>";
            return(strTableRow);
        }
Ejemplo n.º 2
0
        static string GetTableColumns(ReportBuilder reportBuilder, ReportTable table)
        {
            ReportColumns[]      columns    = table.ReportDataColumns;
            ReportTextBoxControl ColumnCell = new ReportTextBoxControl();

            if (columns == null)
            {
                return("");
            }

            string strColumnHeirarchy = "";

            strColumnHeirarchy = @" 
            <TablixColumns>";
            for (int i = 0; i < columns.Length; i++)
            {
                ColumnCell = columns[i].ColumnCell;

                strColumnHeirarchy += @" <TablixColumn> 
                                          <Width>" + ColumnCell.Size.Width.ToString() + @"cm</Width>  
                                        </TablixColumn>";
            }
            strColumnHeirarchy += @"</TablixColumns>";
            return(strColumnHeirarchy);
        }
Ejemplo n.º 3
0
        public Report MakeReport(ReportBuilder reportBuilder)
        {
            reportBuilder.CreateNewReport();
            reportBuilder.SetReportType();

            return(reportBuilder.GetReport());
        }
Ejemplo n.º 4
0
        static string GenerateTableRow(ReportBuilder reportBuilder, ReportTable table)
        {
            ReportColumns[]      columns    = table.ReportDataColumns;
            ReportTextBoxControl ColumnCell = new ReportTextBoxControl();
            ReportScale          colHeight  = ColumnCell.Size;
            ReportDimensions     padding    = new ReportDimensions();

            if (columns == null)
            {
                return("");
            }

            string strTableRow = "";

            strTableRow = @"<TablixRow> 
                <Height>0.6cm</Height> 
                <TablixCells>";
            for (int i = 0; i < columns.Length; i++)
            {
                ColumnCell   = columns[i].ColumnCell;
                padding      = ColumnCell.Padding;
                strTableRow += @"<TablixCell> 
                  <CellContents> 
                   " + GenerateTextBox("txtCell_" + table.ReportName + "_", ColumnCell.Name, "", true, padding) + @" 
                  </CellContents> 
                </TablixCell>";
            }
            strTableRow += @"</TablixCells></TablixRow>";
            return(strTableRow);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Obtiene un archivocon el reporte RptSelfGen&SelfGenTeam
        /// </summary>
        /// <param name="report">Nombre del reporte</param>
        /// <param name="fileFullPath">Ruta de archivo </param>
        /// <param name="filters">Filtros</param>
        /// <param name="lstReport">Datos del reporte</param>
        /// <param name="dtStart">Fecha Inicio</param>
        /// <param name="dtEnd">Fecha Fin</param>
        /// <history>
        /// [ecanul] 26/07/2016 Created
        /// </history>
        public static async Task <FileInfo> RptSelfGenAndSelfGenTeam(string report, string fileFullPath, List <Tuple <string, string> > filters, List <RptSelfGenTeam> lstReport, DateTime dtStart, DateTime dtEnd)
        {
            var data = lstReport.Select(c => new
            {
                c.Liner,
                c.SalesmanName,
                c.OOP,
                c.OFVol,
                c.OFUPS,
                c.OFSales,
                c.RGVol,
                c.RGUPS,
                c.RGSales,
                c.NVol,
                c.NUPS,
                c.NSales,
                c.TVol,
                c.TUPS,
                c.TSales,
                c.SelfGenType,
                EFF  = c.TUPS != 0 ? c.TVol / c.TUPS : 0,
                CPer = c.TUPS != 0 ? c.TSales / c.TUPS : 0,
                AVS  = c.TSales != 0 ? c.TVol / c.TSales : 0
            }).ToList();
            var dtData = TableHelper.GetDataTableFromList(data, true, true);

            return(await ReportBuilder.CreateCustomExcelAsync(dtData, filters, report, string.Empty, FormatReport.RptSelfGenAndSelfGenTeam(), blnShowSubtotal : true, blnRowGrandTotal : true, isRptQueue : true, filePath : fileFullPath, addEnumeration : true));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Devuele el reporte Efficiency Weekly
        /// </summary>
        /// <param name="report">Nombre del reporte</param>
        /// <param name="fileFullPath">Ruta a guardar</param>
        /// <param name="filters">Filtros Aplicados</param>
        /// <param name="lstReport">Listado con la informacion del reporte</param>
        /// <history>
        /// [ecanul] 16/08/2016 Created
        /// </history>
        public static async Task <FileInfo> RptEfficiencyWeekly(string report, string fileFullPath, List <Tuple <string, string> > filters, List <RptEfficiencyWeekly> lstReport, ClsFilter filtros)
        {
            var       nReport      = lstReport.Where(x => x.EfficiencyType != "Undefined Assistance").ToList();
            DataTable dtData       = TableHelper.GetDataTableFromList(nReport);
            var       unAssistance = lstReport.Where(x => x.EfficiencyType == "Undefined Assistance").ToList();

            if (filtros.blnSaveEfficiency)
            {
                Task <int> i = BREfficiency.SaveEfficiencies(nReport, filtros.LstSalesRooms.First(), filtros.DtmStart, filtros.DtmEnd);
            }

            StringBuilder str = new StringBuilder();

            if (unAssistance.Any())
            {
                str.AppendLine("The following salesmen are not have defined their assistance:");
                unAssistance.ForEach(x =>
                {
                    str.AppendLine($"{x.SalemanID} - {x.SalemanName}");
                });
                UIHelper.ShowMessage(str.ToString(), System.Windows.MessageBoxImage.Exclamation, "Front To Backs without Assistance");
            }

            return(await ReportBuilder.CreateCustomExcelAsync(dtData, filters, report, string.Empty, FormatReport.RptEfficiencyWeekly(), isRptQueue : true, filePath : fileFullPath, addEnumeration : true));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Obtiene un reporte de Aviables en formato Excel
        /// </summary>
        /// <param name="aviables">Lista de Aviables</param>
        /// <history>
        /// [ecanul] 19/04/2016 Created
        /// [jorcanche]  se agrego para abrir el archivo despues de guardar
        /// </history>
        public async static void AvailablesToExcel(List <RptAvailables> aviables, Window window)
        {
            filters = new List <Tuple <string, string> >();
            dt      = new DataTable();
            filters.Add(Tuple.Create("Lead Source", Context.User.LeadSource.lsID));
            DateTime date = BRHelpers.GetServerDate();

            if (aviables.Count > 0)
            {
                dt      = TableHelper.GetDataTableFromList(aviables, true);
                rptName = "Availables";
                string           dateRange = DateHelper.DateRangeFileName(date, date);
                ColumnFormatList format    = new ColumnFormatList();

                format.Add("GUID", "guID");
                format.Add("Reserv.#", "guHReservID");
                format.Add("Room", "guRoomNum");
                format.Add("LastName", "guLastName1");
                format.Add("Pax", "guPax", format: EnumFormatTypeExcel.DecimalNumber);
                format.Add("Check-In", "guCheckInD", format: EnumFormatTypeExcel.Date);
                format.Add("Check-Out", "guCheckOutD", format: EnumFormatTypeExcel.Date);
                format.Add("Country ID", "guco");
                format.Add("Country", "coN");
                format.Add("Agency ID", "guag");
                format.Add("Agency", "agN");
                format.Add("Av", "guAvail", format: EnumFormatTypeExcel.Boolean);
                format.Add("Info", "guInfo", format: EnumFormatTypeExcel.Boolean);
                format.Add("Inv", "guInvit", format: EnumFormatTypeExcel.Boolean);
                format.Add("PR B", "guPRInvit1");
                format.Add("Comments", "guComments");

                OpenFile(await ReportBuilder.CreateCustomExcelAsync(dt, filters, rptName, dateRange, format, addEnumeration: true), window);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Obtiene los datos para exportar a excel el reporte RptManifest
        /// </summary>
        /// <param name="report">Nombre del reporte</param>
        /// <param name="fileFullPath">Ruta completa del archivo</param>
        /// <param name="filters">Listado de filtros</param>
        /// <param name="lstReport">Contenido del reporte</param>
        /// <param name="dtStart">Fecha inicial del reporte</param>
        /// <param name="dtEnd">Fecha final del reporte</param>
        /// <history>
        ///  [ecanul] 07/06/2016 Created
        /// </history>
        public static async Task <FileInfo> RptManifest(string report, string fileFullPath, List <Tuple <string, string> > filters,
                                                        List <RptManifest> lstReport, DateTime dtStartm, DateTime dtEnd)
        {
            var dtData = TableHelper.GetDataTableFromList(lstReport, true, true);

            return(await ReportBuilder.CreateCustomExcelAsync(dtData, filters, report, string.Empty, FormatReport.RptManifest(), blnShowSubtotal : true, blnRowGrandTotal : true, blnColumnGrandTotal : false, isRptQueue : true, filePath : fileFullPath, addEnumeration : true));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Evento que se lanza cuando generamos nuestro reporte boton Print
        /// </summary>
        /// <history>
        /// [erosado] 23/Mar/2016 Created
        /// [emoguel] 09/09/2016 Modified. Ahora se abre el visor de reportes
        /// </history>
        private async void imgButtonPrint_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            List <SaleByCloser> listaSaleByCloser = dtgr.DataContext as List <SaleByCloser>;

            if (listaSaleByCloser != null)
            {
                //Obtenemos dateRange
                string dateRange         = DateHelper.DateRange(dtpkFrom.Value.Value, dtpkTo.Value.Value);
                string dateRangeFileName = DateHelper.DateRangeFileName(dtpkFrom.Value.Value, dtpkTo.Value.Value);
                //Obtenemos el nombre del reporte y el dateRange
                string rptName = "Sales By Closer";
                //Obtenemos el dataTable con la lista formateada
                DataTable dt = TableHelper.GetDataTableFromList(listaSaleByCloser, true);
                //Creamos el reporte
                FileInfo fi = await ReportBuilder.CreateCustomExcelAsync(dt, filtersReport, rptName, dateRangeFileName, Utilities.UseFulMethods.getExcelFormatTable(), addEnumeration : true);


                if (fi != null)
                {
                    frmDocumentViewer documentViewer = new frmDocumentViewer(fi, Context.User.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false);
                    documentViewer.Owner = this;
                    documentViewer.ShowDialog();
                }
            }
            else
            {
                UIHelper.ShowMessage("There is no info to make a report", MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Obtiene Un reporte de Arrivals en formato de Excel
        /// </summary>
        /// <param name="arrivlas">Lista de Arrivals para hacer el excel</param>}
        /// <history>
        /// [ecanul] 19/04/2016 Created
        /// [jorcanche]  se agrego para abrir el archivo despues de guardar
        /// </history>
        public async static void ArrivalsToExcel(List <RptArrivals> arrivlas, DateTime date, Window window)
        {
            filters = new List <Tuple <string, string> >();
            dt      = new DataTable();
            filters.Add(Tuple.Create("Lead Source", Context.User.LeadSource.lsID));


            if (arrivlas.Count > 0)
            {
                dt      = TableHelper.GetDataTableFromList(arrivlas, true);
                rptName = "Arrivals ";
                string           dateRange = DateHelper.DateRangeFileName(date, date);
                ColumnFormatList format    = new ColumnFormatList();
                format.Add("GUID", "guID", width: 7);
                format.Add("Reserv.#", "guHReservID", width: 8);
                format.Add("Room", "guRoomNum", width: 7);
                format.Add("LastName", "guLastName1", width: 20);
                format.Add("In", "guCheckIn", format: EnumFormatTypeExcel.Boolean, width: 4, aligment: OfficeOpenXml.Style.ExcelHorizontalAlignment.Center);
                format.Add("Pax", "guPax", format: EnumFormatTypeExcel.DecimalNumber, width: 6, aligment: OfficeOpenXml.Style.ExcelHorizontalAlignment.Center);
                format.Add("Check-Out", "guCheckOutD", format: EnumFormatTypeExcel.Date, width: 10);
                format.Add("Country", "coN", width: 13);
                format.Add("Agency", "agN", width: 15, wordWrap: true);
                format.Add("Av", "guAvail", format: EnumFormatTypeExcel.Boolean, width:  4, aligment: OfficeOpenXml.Style.ExcelHorizontalAlignment.Center);
                format.Add("Info", "guInfo", format: EnumFormatTypeExcel.Boolean, width: 4, aligment: OfficeOpenXml.Style.ExcelHorizontalAlignment.Center);
                format.Add("Inv", "guInvit", format: EnumFormatTypeExcel.Boolean, width: 4, aligment: OfficeOpenXml.Style.ExcelHorizontalAlignment.Center);
                format.Add("PR B", "guPRInvit1", width: 15);
                format.Add("Comments", "guComments", width: 40, wordWrap: true);
                format.Add("County ID", "guco", isVisible: false);
                format.Add("Agency ID", "guag", isVisible:  false);
                OpenFile(await ReportBuilder.CreateCustomExcelAsync(dt, filters, rptName, dateRange, format, addEnumeration: true, autoFit: false, numColumnsForApplicationName: 4), window);
            }
        }
        public void When_The_Report_Is_Submitted_Redirect_To_Home()
        {
            // arrange
            var url = "home/Index";
            UrlActionContext actualContext = null;

            _mockUrlHelper.Setup(h => h.Action(It.IsAny <UrlActionContext>())).Returns(url).Callback <UrlActionContext>(c => actualContext = c).Verifiable("Url.Action was never called");


            var report =
                new ReportBuilder()
                .WithValidSections()
                .WithEmployerId("ABCDEF")
                .ForCurrentPeriod()
                .WhereReportIsAlreadySubmitted()
                .Build();

            _mockReportService.Setup(s => s.GetReport(It.IsAny <string>(), It.IsAny <string>())).Returns(report).Verifiable();
            _mockReportService.Setup(s => s.CanBeEdited(report)).Returns(false).Verifiable();
            _controller.ObjectValidator = GetObjectValidator().Object;

            // act
            var result = _controller.Confirm();

            // assert
            Assert.AreEqual(typeof(RedirectResult), result.GetType());
            var redirectResult = result as RedirectResult;

            Assert.IsNotNull(redirectResult);
            Assert.AreEqual(url, redirectResult.Url);
            Assert.AreEqual(actualContext.Action, "Index");
            Assert.AreEqual(actualContext.Controller, actualContext.Controller);
        }
        public async Task WhenLinuxInstanceCreated_ThenReportContainsInstanceAndLicenseInfoFromItsDisk(
            [LinuxInstance] ResourceTask <InstanceLocator> testInstance,
            [Credential(Roles = new[] {
            PredefinedRole.ComputeViewer,
            PredefinedRole.LogsViewer
        })] ResourceTask <ICredential> credential)
        {
            await testInstance;
            var   instanceRef = await testInstance;

            var startDate = DateTime.UtcNow.AddDays(-1);
            var builder   = new ReportBuilder(
                new AuditLogAdapter(await credential),
                new AuditLogStorageSinkAdapter(
                    new StorageAdapter(await credential),
                    new AuditLogAdapter(await credential)),
                new ComputeEngineAdapter(await credential),
                AuditLogSources.Api,
                new[] { TestProject.ProjectId },
                startDate);
            var report = await builder.BuildAsync(CancellationToken.None);

            var instance = report.History.Instances.First(i => i.Reference == instanceRef);

            Assert.IsTrue(report.IsInstanceAnnotatedAs(
                              instance,
                              OperatingSystemTypes.Linux,
                              LicenseTypes.Unknown));
        }
        public void GenerateXml_WithInterfaces()
        {
            // TargetClass1 implements IDisposable
            var involvedType = new InvolvedType(typeof(TargetClass1));

            var reportGenerator = ReportBuilder.CreateInterfaceReportGenerator(_remotionReflector, _outputFormatter, involvedType);
            var output          = reportGenerator.GenerateXml();

            var memberReportGenerator = ReportBuilder.CreateMemberReportGenerator(typeof(IDisposable), _outputFormatter);
            var expectedOutput        = new XElement(
                "Interfaces",
                new XElement(
                    "Interface",
                    new XAttribute("id", "0"),
                    new XAttribute("assembly-ref", "0"),
                    new XAttribute("namespace", "System"),
                    new XAttribute("name", "IDisposable"),
                    new XAttribute("is-composed-interface", false),
                    memberReportGenerator.GenerateXml(),
                    new XElement(
                        "ImplementedBy",
                        new XElement(
                            "InvolvedType-Reference",
                            new XAttribute("ref", "0"))
                        )
                    ));

            Assert.That(output.ToString(), Is.EqualTo(expectedOutput.ToString()));
        }
Ejemplo n.º 14
0
        public override string ReportBody()
        {
            ReportBuilder.Clear();
            Dictionary <CrewMember, string> unhappyCrew = CrewManager.Instance.UnhappyCrewOutcomes;

            if (unhappyCrew.Count == 0)
            {
                return("No Crew Issues");
            }
            for (int i = 0; i < unhappyCrew.Count; i++)
            {
                KeyValuePair <CrewMember, string> unhappyCrewMember = unhappyCrew.ElementAt(i);
                ReportBuilder.AppendLine(unhappyCrewMember.Key.Name + ": " + unhappyCrewMember.Value);
            }

            if (SettingsClass.Instance.RetirementEnabled)
            {
                CrewManager.Instance.ProcessQuitters();
                for (int i = 0; i < CrewManager.Instance.Retirees.Count; i++)
                {
                    string s = CrewManager.Instance.Retirees.ElementAt(i);
                    ReportBuilder.AppendLine(s + " has retired");
                }
            }

            return(ReportBuilder.ToString());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 设备的年月统计图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="rate"></param>
        /// <param name="chartname"></param>
        /// <param name="startYearMM"></param>
        /// <param name="endYearMM"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ChartData YearMMChartByDevice(Device device, float rate, string chartname, string startYearMM, string endYearMM, string chartType, string unit)
        {
            if (device == null)
            {
                return(new ChartData());
            }
            string name = LanguageUtil.getDesc("CHART_TITLE_YEAR_ENERGY");

            int       startYear       = int.Parse(startYearMM.Substring(0, 4));
            int       endYear         = int.Parse(endYearMM.Substring(0, 4));
            Hashtable yearMonthEnergy = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, startYear, endYear);

            string[] ic = base.getXseriesFromYYYYMM(startYearMM, endYearMM).ToArray();

            string[] xAxis = formatXaxis(ic, ChartTimeType.YearMonth);

            string yname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name;

            KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>();

            if (yearMonthEnergy.Count > 0)
            {
                data = GenerateChartData(yname, ic, yearMonthEnergy, rate);
            }
            return(ReportBuilder.createJsonChartXY(name, xAxis, data, "", unit, chartType, fromApp));
        }
        /// <summary> Gets the given request. </summary>
        /// <param name="request"> The request. </param>
        /// <returns> A Task&lt;object&gt; </returns>
        public object Get(GetReportHeaders request)
        {
            if (string.IsNullOrEmpty(request.IncludeItemTypes))
            {
                return(null);
            }

            request.DisplayType = "Screen";
            ReportViewType reportViewType = ReportHelper.GetReportViewType(request.ReportView);

            List <ReportHeader> result = new List <ReportHeader>();

            switch (reportViewType)
            {
            case ReportViewType.ReportData:
                ReportBuilder dataBuilder = new ReportBuilder(_libraryManager);
                result = dataBuilder.GetHeaders(request);
                break;

            case ReportViewType.ReportActivities:
                ReportActivitiesBuilder activityBuilder = new ReportActivitiesBuilder(_libraryManager, _userManager);
                result = activityBuilder.GetHeaders(request);
                break;
            }

            return(result);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 设备的月天统计图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="rate"></param>
        /// <param name="chartname"></param>
        /// <param name="startYearMMDD"></param>
        /// <param name="endYearMMDD"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ChartData MonthDDChartByDevice(Device device, float rate, string chartname, string startYearMMDD, string endYearMMDD, string chartType, string unit)
        {
            if (device == null)
            {
                return(new ChartData());
            }
            string name = LanguageUtil.getDesc("CHART_TITLE_MONTH_ENERGY");

            string    startYearMM   = startYearMMDD.Substring(0, 6);
            string    endYearMM     = endYearMMDD.Substring(0, 6);
            Hashtable monthDDEnergy = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, startYearMM, endYearMM);

            string[] ic = base.getXseriesFromYYYYMMDD(startYearMMDD, endYearMMDD).ToArray();

            string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay);
            string   xname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name;

            KeyValuePair <string, float?[]> data = new KeyValuePair <string, float?[]>();

            if (monthDDEnergy.Count > 0)
            {
                data = GenerateChartData(xname, ic, monthDDEnergy, rate);
            }
            return(ReportBuilder.createJsonChartXY(name, xAxis, data, "", unit, chartType, fromApp));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Obtiene los datos para exportar a excel el reporte RptStatisticsByCloser
        /// </summary>
        /// <param name="report">Nombre del reporte</param>
        /// <param name="fileFullPath">Ruta completa del archivo</param>
        /// <param name="filters">Listado de filtros</param>
        /// <param name="lstReport">Contenido del reporte</param>
        /// <param name="groupedByTeams">Agrupado por equipos</param>
        /// <history>
        ///  [aalcocer] 13/07/2016 Created
        ///  [ecanul]   16/08/2016 Modified, Se ha cambiado el formato Pivote a Excel Custom
        /// </history>
        internal static async Task <FileInfo> RptStatisticsByCloser(string report, string fileFullPath, List <Tuple <string, string> > filters, List <RptStatisticsByCloser> lstReport, bool groupedByTeams)
        {
            DataTable dtData = TableHelper.GetDataTableFromList(lstReport);

            return(await ReportBuilder.CreateCustomExcelAsync(dtData, filters, report, string.Empty, FormatReport.RptStatisticsByCloser(groupedByTeams),
                                                              blnRowGrandTotal : true, blnShowSubtotal : groupedByTeams, isRptQueue : true, filePath : fileFullPath, addEnumeration : true));
        }
Ejemplo n.º 19
0
        private static string GetFooter(ReportBuilder reportBuilder)
        {
            string strFooter = "";

            if (reportBuilder.Page == null || reportBuilder.Page.ReportFooter == null)
            {
                return("");
            }
            strFooter = @"<PageFooter> 
                          <Height>0.68425in</Height> 
                          <PrintOnFirstPage>true</PrintOnFirstPage> 
                          <PrintOnLastPage>true</PrintOnLastPage> 
                          <ReportItems>";
            ReportTextBoxControl[] footerTxt = reportBuilder.Page.ReportFooter.ReportControlItems.TextBoxControls;
            if (footerTxt != null)
            {
                for (int i = 0; i < footerTxt.Count(); i++)
                {
                    strFooter += GetTextBox(footerTxt[i].Name, null, footerTxt[i].ValueOrExpression);
                }
            }
            strFooter += @"</ReportItems> 
                          <Style /> 
                        </PageFooter>";
            return(strFooter);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Obtiene los datos para exportar a excel el reporte RptStatisticsByFTB ByLocations
        /// </summary>
        /// <param name="report">Nombre del reporte</param>
        /// <param name="fileFullPath">Ruta completa del archivo</param>
        /// <param name="filters">Listado de filtros</param>
        /// <param name="lstReport">Contenido del reporte</param>
        /// <param name="groupedByTeams">Agrupado por equipos</param>
        /// <history>
        ///  [michan] 22/07/2016 Created
        /// </history>
        internal static async Task <FileInfo> RptStatisticsByFTBByCategories(string report, string fileFullPath, List <Tuple <string, string> > filters, List <RptStatisticsByFTBCategories> lstReport, bool groupedByTeams)
        {
            lstReport = lstReport.orderListBy("Team asc, Locations asc, Total desc, ClosingFactor desc, Efficiency desc, UPS desc, SalemanID desc");
            var dtData = TableHelper.GetDataTableFromList(lstReport, true, true);

            return(await ReportBuilder.CreateCustomExcelAsync(dtData, filters, report, string.Empty, FormatReport.RptStatisticsByFTBByCategories(groupedByTeams), blnShowSubtotal : true, blnRowGrandTotal : true, isRptQueue : true, filePath : fileFullPath, addEnumeration : true));
        }
Ejemplo n.º 21
0
        static string GetSortingDetails(ReportBuilder reportBuilder)
        {
            return("");

            ReportTable[]        tables     = reportBuilder.Body.ReportControlItems.ReportTable;
            ReportColumns[]      columns    = reportBuilder.Body.ReportControlItems.ReportTable[0].ReportDataColumns;
            ReportTextBoxControl sortColumn = new ReportTextBoxControl();

            if (columns == null)
            {
                return("");
            }

            string strSorting = "";

            strSorting = @" <SortExpressions>";
            for (int i = 0; i < columns.Length; i++)
            {
                sortColumn  = columns[i].ColumnCell;
                strSorting += "<SortExpression><Value>=Fields!" + sortColumn.Name + @".Value</Value>";
                if (columns[i].SortDirection == ReportSort.Descending)
                {
                    strSorting += "<Direction>Descending</Direction>";
                }
                strSorting += @"</SortExpression>";
            }
            strSorting += "</SortExpressions>";
            return(strSorting);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Obtiene los datos para exportar a excel el reporte Statics by Location Monthly
        /// </summary>
        /// <param name="report">Nombre del reporte</param>
        /// <param name="fileFullPath">Ruta completa del archivo</param>
        /// <param name="filters">Listado de filtros</param>
        /// <param name="lstReport">Contenido del reporte</param>
        /// <history>
        /// [ecanul] 10/05/2016 Created
        /// </history>
        public static async Task <FileInfo> RptStaticsByLocationMonthly(string report, string fileFullPath,
                                                                        List <Tuple <string, string> > filters, List <RptStatisticsByLocationMonthly> lstReport)
        {
            var dtData = TableHelper.GetDataTableFromList(lstReport, true, false);

            return(await ReportBuilder.CreateCustomExcelAsync(dtData, filters, report, string.Empty, FormatReport.RptStatisticsByLocationMonthly(), blnShowSubtotal : true, blnRowGrandTotal : true, isRptQueue : true, filePath : fileFullPath, addEnumeration : true));
        }
        public virtual ActionResult ExportReport(SupervisionPorfolioModel ModelSupervisionPorfolio, string Operations, string Supervisions, string Format)
        {
            string[] ParamOperations   = Operations.Split(',');
            string[] ParamSupervisions = Supervisions.Split(',');

            string URLSupervisionPorfolioReport = ReportBuilder.GetReportPreffix("ParamForSupervisionPortfolioReportReport");

            if (!string.IsNullOrEmpty(IDBContext.Current.CurrentLanguage))
            {
                URLSupervisionPorfolioReport += "&LANG=" + IDBContext.Current.CurrentLanguage.ToUpper();
            }
            else
            {
                URLSupervisionPorfolioReport += "&LANG=" + Globals.NeutralLanguage.ToUpper();
            }

            if (ParamOperations.Length == ParamSupervisions.Length)
            {
                for (int i = 0; i < ParamOperations.Length; i++)
                {
                    if (i == 0)
                    {
                        URLSupervisionPorfolioReport = URLSupervisionPorfolioReport + "&dato=" + ParamOperations[i] + "_" + ParamSupervisions[i];
                    }
                    else
                    {
                        URLSupervisionPorfolioReport = URLSupervisionPorfolioReport + "," + ParamOperations[i] + "_" + ParamSupervisions[i];
                    }
                }

                URLSupervisionPorfolioReport = URLSupervisionPorfolioReport + "&rs:Format=" + Format;
            }

            return(Content(URLSupervisionPorfolioReport));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Evento que se lanza cuando generamos nuestro reporte boton Print
        /// </summary>
        /// <history>
        /// [erosado] 23/Mar/2016 Created
        /// </history>
        private async void imgButtonPrint_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var listaSaleByPr = dtgr.DataContext as List <SaleByPR>;

            if (listaSaleByPr != null)
            {
                if (dtpkFrom.Value != null & dtpkTo.Value != null)
                {
                    //Obtenemos el dateRange(Nombre sugerido al momento de generar el archivo del reporte es una concatenacion de fechas From -> To )
                    var dateRangeFileName = DateHelper.DateRangeFileName(dtpkFrom.Value.Value, dtpkTo.Value.Value);
                    //Nombre del Reporte
                    const string rptName = "Sales By PR";
                    //Obtenemos el dataTable con la lista formateada
                    var dt = TableHelper.GetDataTableFromList(listaSaleByPr, true);
                    //Creamos el reporte
                    var fileInfo = await ReportBuilder.CreateCustomExcelAsync(dt, _filtersReport, rptName, dateRangeFileName, Utilities.UseFulMethods.getExcelFormatTable(),
                                                                              addEnumeration : true, blnRowGrandTotal : true);

                    if (fileInfo != null)
                    {
                        frmDocumentViewer documentViewer = new frmDocumentViewer(fileInfo, Context.User.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false);
                        documentViewer.Owner = this;
                        documentViewer.ShowDialog();
                    }
                }
            }
            else
            {
                UIHelper.ShowMessage("There is no info to make a report", MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 25
0
        public override string ReportBody()
        {
            ReportBuilder.Clear();
            ReportBuilder.AppendLine("Gross Budget: " + Utilities.Instance.GetGrossBudget());
            ReportBuilder.AppendLine("Staff Wages: " + Costs.Instance.GetWageCosts());
            ReportBuilder.AppendLine("Facility Maintenance Costs: " + Costs.Instance.GetFacilityMaintenanceCosts());
            ReportBuilder.AppendLine("Launch Costs: " + Costs.Instance.GetLaunchCosts());
            ReportBuilder.AppendLine("Total Maintenance Costs: " + Costs.Instance.GetTotalMaintenanceCosts());
            ReportBuilder.AppendLine("Mission Bonuses: " + CrewManager.Instance.LastBonus);
            ReportBuilder.AppendLine("Construction Department: " + FacilityManager.Instance.GetAllocatedFunding());
            ReportBuilder.AppendLine("Research Department: " + ResearchManager.Instance.GetAllocatedFunding());
            double netBudget = Utilities.Instance.GetNetBudget("Budget");

            ReportBuilder.AppendLine("Net Budget: " + Math.Max(0, netBudget));
            if (netBudget > 0 && netBudget < Funding.Instance.Funds)
            {
                ReportBuilder.AppendLine("We can't justify extending your funding");
            }
            // ReSharper disable once InvertIf
            if (netBudget < 0)
            {
                ReportBuilder.AppendLine("The budget didn't fully cover your space programs costs.");
                ReportBuilder.Append("A penalty of " + Math.Round(netBudget, 0) + " will be applied");
            }
            return(ReportBuilder.ToString());
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Muestra el Personnel Log en el DocumentViewer
        /// </summary>
        /// <history>
        /// [emoguel] 17/10/2016 created
        /// </history>
        private async void btnPrintlog_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                List <GetPersonnelLog> lstPersonnelLog = dtgPersonnelLog.ItemsSource as List <GetPersonnelLog>;

                FileInfo fileInfo = await ReportBuilder.CreateCustomExcelAsync(
                    TableHelper.GetDataTableFromList(lstPersonnelLog, true, true, true),
                    new List <Tuple <string, string> > {
                    Tuple.Create("Personnel ID", _idPersonnelLog)
                },
                    "Personnel Log",
                    DateHelper.DateRangeFileName(DateTime.Today, DateTime.Today),
                    EpplusHelper.OrderColumns(dtgPersonnelLog.Columns.ToList(), clsFormatReport.RptPersonnelLog()));

                if (fileInfo != null)
                {
                    frmDocumentViewer documentViewver = new frmDocumentViewer(fileInfo, Context.User.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false);
                    documentViewver.Owner = this;
                    documentViewver.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
Ejemplo n.º 27
0
        public void BeginNewScenario_sets_all_scenario_and_feature_properties(Guid scenarioIdentity,
                                                                              IFormatsObjectForReport formatter,
                                                                              IBuildsScenario scenarioBuilder,
                                                                              Builders.IGetsReport reportFactory,
                                                                              string scenarioId,
                                                                              string scenarioName,
                                                                              string featureId,
                                                                              string featureName,
                                                                              bool scenarioIdGenerated,
                                                                              bool featureIdGenerated)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            // Act
            sut.BeginNewScenario(scenarioId,
                                 scenarioName,
                                 featureName,
                                 featureId,
                                 scenarioIdentity,
                                 scenarioIdGenerated,
                                 featureIdGenerated);

            // Assert
            Mock.Get(scenarioBuilder).VerifySet(x => x.ScenarioIdName        = scenarioId, Times.Once, nameof(IBuildsScenario.ScenarioIdName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.ScenarioFriendlyName  = scenarioName, Times.Once, nameof(IBuildsScenario.ScenarioFriendlyName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.FeatureIdName         = featureId, Times.Once, nameof(IBuildsScenario.FeatureIdName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.FeatureFriendlyName   = featureName, Times.Once, nameof(IBuildsScenario.FeatureFriendlyName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.ScenarioIdIsGenerated = scenarioIdGenerated, Times.Once, nameof(IBuildsScenario.ScenarioIdIsGenerated));
            Mock.Get(scenarioBuilder).VerifySet(x => x.FeatureIdIsGenerated  = featureIdGenerated, Times.Once, nameof(IBuildsScenario.FeatureIdIsGenerated));
        }
Ejemplo n.º 28
0
 public T ProcessReport <T>(ReportBuilder <T> builder) where T : class
 {
     return(new ReportRequest <T>(Credentials, ServiceUrl, Timeout)
            .WithRequestLogger(RequestLogger)
            .WithWebProxy(WebProxy)
            .Execute(builder));
 }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            //Workbook.SetLicenseKey(Properties.Settings.Default.DioDocsForExcelKey);

            using (var invoiceStream = new MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.InvoiceXml)))
                using (var template = new MemoryStream(Properties.Resources.Invoice))
                    using (var outputStream = new FileStream("result.pdf", FileMode.Create))
                    {
                        var serializer = new XmlSerializer(typeof(Invoice));
                        var invoice    = (Invoice)serializer.Deserialize(invoiceStream);

                        var reportBuilder =
                            new ReportBuilder <InvoiceDetail>(template)
                            // 単一項目のSetterを設定
                            .AddSetter("$SalesOrderId", cell => cell.Value = invoice.SalesOrderId)
                            .AddSetter("$OrderDate", cell => cell.Value    = invoice.OrderDate)
                            .AddSetter("$CompanyName", cell => cell.Value  = invoice.CompanyName)
                            .AddSetter("$Name", cell => cell.Value         = invoice.Name)
                            .AddSetter("$Address", cell => cell.Value      = invoice.Address)
                            .AddSetter("$PostalCode", cell => cell.Value   = invoice.PostalCode)
                            // テーブルのセルに対するSetterを設定
                            .AddTableSetter("$ProductName", (cell, detail) => cell.Value   = detail.ProductName)
                            .AddTableSetter("$UnitPrice", (cell, detail) => cell.Value     = detail.UnitPrice)
                            .AddTableSetter("$OrderQuantity", (cell, detail) => cell.Value = detail.OrderQuantity);

                        reportBuilder.Build(invoice.InvoiceDetails, outputStream, SaveFileFormat.Pdf);
                    }
        }
Ejemplo n.º 30
0
        public void GenerateReport_ShouldGenerateReportForOneProject()
        {
            // Arrange
            var reportBuilder = new ReportBuilder();
            var projects      = new List <Project>
            {
                new Project
                {
                    Id         = 1,
                    Code       = "project_1",
                    Name       = "Project 1",
                    StartDate  = new DateTime(2019, 10, 10),
                    FinishDate = new DateTime(2019, 11, 11)
                }
            };

            // Act
            var report = reportBuilder.GenerateReport(projects);

            // Assert
            var sheet = report.Workbook.Worksheets[0];

            Assert.AreEqual("Project", sheet.Cells[1, 1].Value);
            Assert.AreEqual("project_1", sheet.Cells[1, 2].Value);
            Assert.AreEqual("Project 1", sheet.Cells[1, 3].Value);
            Assert.AreEqual(new DateTime(2019, 10, 10), sheet.Cells[1, 4].Value);
            Assert.AreEqual(new DateTime(2019, 11, 11), sheet.Cells[1, 5].Value);
        }
Ejemplo n.º 31
0
 public void WithNothingTest()
 {
     var report = new ReportBuilder();
     var result = ExecuteTest(report, null);
     Assert.AreEqual(1, result.Count, BasePath);
     Assert.AreEqual("No violations encountered", result[0]);
 }
Ejemplo n.º 32
0
        public void WithMultipleSolutionFilesTest()
        {
            var report = new ReportBuilder()
                            .WithSolutionsFiles(new List<string>() { Solution, Solution });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(7, result.Count, BasePath);
            Assert.AreEqual("16 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("AssemblyInfo.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("AssemblyInfo.cs"), result[2]);
            Assert.IsTrue(result[3].EndsWith("ClassOne.cs"), result[3]);
            Assert.IsTrue(result[4].EndsWith("ClassOne.cs"), result[4]);
            Assert.IsTrue(result[5].EndsWith("ClassTwo.cs"), result[5]);
            Assert.IsTrue(result[6].EndsWith("ClassTwo.cs"), result[6]);
        }
Ejemplo n.º 33
0
        public void WithMultiplePatternsTest()
        {
            var report = new ReportBuilder()
                            .WithProjectFiles(new List<string>() { Project })
                            .WithIgnorePatterns(new List<string>() { "ClassOne", "Info" });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(2, result.Count, BasePath);
            Assert.AreEqual("4 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("ClassTwo.cs"), result[1]);
        }
Ejemplo n.º 34
0
        private Rdl.Report CreateReport()
        {
            var builder = new ReportBuilder
                              {
                                  DataSources = CreateDataSources(),
                                  Body = CreateBody(),
                                  DataSets = CreateDataSets(),
                                  Width = maxWidth + "mm"
                              };

            var p = new Page
                         {
                             TopMargin = TopMargin + "mm",
                             BottomMargin = BottomMargin + "mm",
                             PageHeader = CreatPageHeader(),
                             PageFooter = CreatPageFooter()
                         };
            builder.Page = p.Create();

            return builder.Create();
        }
Ejemplo n.º 35
0
        public void DebugTesting()
        {
            var list = new List<string>();
            var report = new ReportBuilder()
                            .WithProjectFiles(new List<string>() { WildCardProject })
                            .WithDebug(x => { list.Add(x); });

            ExecuteTest(report, null);
            Assert.IsTrue(list.Count > 0);
        }
Ejemplo n.º 36
0
        public void XmlWriterTest()
        {
            var report = new ReportBuilder()
                            .WithFiles(new List<string>() { DirectoryPath + "ClassOne.cs", DirectoryPath + "SubNamespace" + Path.DirectorySeparatorChar + "ClassTwo.cs" });

            var result = new List<string>();
            report.WithOutputEventHandler((x, y) => { result.Add(((StyleCop.OutputEventArgs)y).Output); });
            var runner = new XmlRunner();
            report.Create(runner);

            // Only 1 item should be reported
            Assert.AreEqual(1, result.Count, BasePath);
            Assert.AreEqual("Violations were encountered.", result[0]);
        }
Ejemplo n.º 37
0
        public void WithRecursionTest()
        {
            var report = new ReportBuilder()
                            .WithDirectories(new List<string>() { DirectoryPath })
                            .WithRecursion();

            var result = ExecuteTest(report, null);
            Assert.AreEqual(4, result.Count, BasePath);
            Assert.AreEqual("8 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("ClassOne.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("AssemblyInfo.cs"), result[2]);
            Assert.IsTrue(result[3].EndsWith("ClassTwo.cs"), result[3]);
        }
Ejemplo n.º 38
0
        public void OutputReportTest()
        {
            var testReport = "test-output";
            var testReportFull = string.Format("{0}.xml", testReport);
            if (File.Exists(testReportFull))
            {
                File.Delete(testReportFull);
            }

            var report = new ReportBuilder();
            ExecuteTest(report, testReport + ".xml");
            Assert.IsTrue(File.Exists(testReportFull));
        }
Ejemplo n.º 39
0
        public void WithProcessorSymbolsTest()
        {
            var report = new ReportBuilder()
                            .WithDirectories(new List<string>() { DirectoryPath })
                            .WithProcessorSymbols(new List<string>() { "SOMEOTHER" });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(2, result.Count, BasePath);
            Assert.AreEqual("6 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("ClassOne.cs"), result[1]);
        }
Ejemplo n.º 40
0
        public void ViolationsTest()
        {
            var violationList = new List<string>();
            var report = new ReportBuilder()
                            .WithSolutionsFiles(new List<string>() { Solution })
                            .WithViolationEventHandler((x, y) => { violationList.Add(((StyleCop.ViolationEventArgs)y).Message); });

            ExecuteTest(report, null);
            violationList = violationList.OrderBy(value => value).ToList();
            Assert.AreEqual(8, violationList.Count);
            Assert.AreEqual("A closing curly bracket must not be preceded by a blank line.", violationList[0]);
            Assert.AreEqual("A closing curly bracket must not be preceded by a blank line.", violationList[1]);
            Assert.AreEqual("All using directives must be placed inside of the namespace.", violationList[2]);
            Assert.AreEqual("An opening curly bracket must not be followed by a blank line.", violationList[3]);
            Assert.AreEqual("An opening curly bracket must not be followed by a blank line.", violationList[4]);
            Assert.AreEqual("The class must have a documentation header.", violationList[5]);
            Assert.AreEqual("The class must have a documentation header.", violationList[6]);
            Assert.AreEqual("The file has no header, the header Xml is invalid, or the header is not located at the top of the file.", violationList[7]);
        }
Ejemplo n.º 41
0
        public void WithProjectUnload()
        {
            var report = new ReportBuilder()
                            .WithSolutionsFiles(new List<string>() { Solution })
                            .WithProjectUnloads(new List<string>() { TestName });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(1, result.Count, BasePath);
            Assert.AreEqual("No violations encountered", result[0]);

            // Now with an unload that doesn't match
            report = new ReportBuilder()
                            .WithSolutionsFiles(new List<string>() { Solution })
                            .WithProjectUnloads(new List<string>() { "non-matching-regex" });

            result = ExecuteTest(report, null);
            Assert.AreEqual(4, result.Count, BasePath);
            Assert.AreEqual("8 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("AssemblyInfo.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("ClassOne.cs"), result[2]);
            Assert.IsTrue(result[3].EndsWith("ClassTwo.cs"), result[3]);

            // Doesn't work against projects (or anything but solutions)
            report = new ReportBuilder()
                            .WithProjectFiles(new List<string>() { Project })
                            .WithProjectUnloads(new List<string>() { TestName });

            result = ExecuteTest(report, null);
            Assert.AreEqual(4, result.Count, BasePath);
            Assert.AreEqual("8 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("AssemblyInfo.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("ClassOne.cs"), result[2]);
            Assert.IsTrue(result[3].EndsWith("ClassTwo.cs"), result[3]);
        }
Ejemplo n.º 42
0
        public void WildCardTest()
        {
            var report = new ReportBuilder()
                            .WithProjectFiles(new List<string>() { WildCardProject });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(10, result.Count, BasePath);
            Assert.AreEqual("26 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("AssemblyInfo.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("AssemblyInfo.cs"), result[2]);
            Assert.IsTrue(result[3].EndsWith("ClassOne.cs"), result[3]);
            Assert.IsTrue(result[4].EndsWith("ClassOne.cs"), result[4]);
            Assert.IsTrue(result[5].EndsWith("ClassOne.cs"), result[5]);
            Assert.IsTrue(result[6].EndsWith("ClassOne.cs"), result[6]);
            Assert.IsTrue(result[7].EndsWith("ClassTwo.cs"), result[7]);
            Assert.IsTrue(result[8].EndsWith("ClassTwo.cs"), result[8]);
            Assert.IsTrue(result[9].EndsWith("ClassTwo.cs"), result[9]);
        }
Ejemplo n.º 43
0
        public void WithStyleCopSettingsFileTest()
        {
            var report = new ReportBuilder()
                            .WithSolutionsFiles(new List<string>() { Solution })
                            .WithStyleCopSettingsFile(JoinAll(BasePath, "LocalSettings.Setting"));

            var result = ExecuteTest(report, null);
            Assert.AreEqual(4, result.Count, BasePath);
            Assert.AreEqual("7 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("AssemblyInfo.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("ClassOne.cs"), result[2]);
            Assert.IsTrue(result[3].EndsWith("ClassTwo.cs"), result[3]);
        }
Ejemplo n.º 44
0
        public void WithMultipleDirectoriesTest()
        {
            var report = new ReportBuilder()
                            .WithDirectories(new List<string>() { DirectoryPath, DirectoryPath });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(3, result.Count, BasePath);
            Assert.AreEqual("6 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("ClassOne.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("ClassOne.cs"), result[2]);
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Executes the test.
 /// </summary>
 /// <returns>
 /// The output from StyleCop event output
 /// </returns>
 /// <param name='builder'>
 /// Input report for testing
 /// </param>
 /// <param name='outputFile'>
 /// Output file.
 /// </param>
 private static IList<string> ExecuteTest(ReportBuilder builder, string outputFile)
 {
     var outputList = new List<string>();
     builder.WithOutputEventHandler((x, y) => { outputList.Add(((StyleCop.OutputEventArgs)y).Output); });
     var runner = new ConsoleRunner();
     runner.OutputFile = outputFile;
     builder.Create(runner);
     return outputList.OrderBy(value => value).ToList();
 }
Ejemplo n.º 46
0
        public void WithMultipleFilesTest()
        {
            var report = new ReportBuilder()
                            .WithFiles(new List<string>() { DirectoryPath + "ClassOne.cs", DirectoryPath + "SubNamespace" + Path.DirectorySeparatorChar + "ClassTwo.cs" });

            var result = ExecuteTest(report, null);
            Assert.AreEqual(3, result.Count, BasePath);
            Assert.AreEqual("7 violations encountered.", result[0]);
            Assert.IsTrue(result[1].EndsWith("ClassOne.cs"), result[1]);
            Assert.IsTrue(result[2].EndsWith("ClassTwo.cs"), result[2]);
        }
Ejemplo n.º 47
0
        /// <summary>
        /// The entry-point method for this application.
        /// </summary>
        /// <param name="args">
        /// The command line arguments passed to this method.
        /// </param>
        private static void Main(string[] args)
        {
            IList<string> solutionFiles = new List<string>();
            IList<string> projectFiles = new List<string>();
            IList<string> ignorePatterns = new List<string>();
            IList<string> directories = new List<string>();
            IList<string> files = new List<string>();
            IList<string> symbols = new List<string>();
            string styleCopSettings = null;
            string outputXml = null;
            bool recurse = false;
            bool needHelp = false;
            bool violations = false;
            bool quiet = false;
            bool dedupe = false;
            opts = new OptionSet()
            {
                { "s=|solutionFiles=", "Visual studio solution files to check", opt => { solutionFiles.Add(opt); } },
                { "p=|projectFiles=", "Visual Studio project files to check", opt => { projectFiles.Add(opt); } },
                { "i=|ignoreFilePattern=", "Regular expression patterns to ignore files", opt => { ignorePatterns.Add(opt); } },
                { "d=|directories=", "Directories to check for CSharp files", opt => { directories.Add(opt); } },
                { "f=|files=", "Files to check", opt => { files.Add(opt); } },
                { "r|recurse", "Recursive directory search", opt => { recurse = opt != null; } },
                { "c=|styleCopSettingsFile=", "Use the given StyleCop settings file", opt => { styleCopSettings = opt; } },
                { "o=|outputXmlFile=", "The file the XML output is written to", opt => { outputXml = opt; } },
                { "x=|configurationSymbols=", "Configuration symbols to pass to StyleCop (ex. DEBUG, RELEASE)", opt => { symbols.Add(opt); } },
                { "v|violations", "Print all violation information instead of the summary", opt => { violations = true; } },
                { "q|quiet", "Do not print any information to console", opt => { quiet = true; } },
                { "?|help", "Print the usage information", opt => { needHelp = true; } },
                { "e|eliminate", "Eliminate checking duplicate files/projects", opt => { dedupe = true; } },
            };

            try
            {
                opts.Parse(args);
                needHelp = needHelp || (solutionFiles.Count == 0 && projectFiles.Count == 0 && directories.Count == 0 && files.Count == 0);
            }
            catch (OptionException error)
            {
                Console.WriteLine("Invalid arguments");
                Console.WriteLine(error);
                needHelp = true;
            }

            if (needHelp)
            {
                PrintUsageAndHelp();
                return;
            }

            var report = new ReportBuilder()
                .WithDedupe(dedupe)
                .WithStyleCopSettingsFile(styleCopSettings)
                .WithRecursion(recurse)
                .WithSolutionsFiles(solutionFiles)
                .WithProjectFiles(projectFiles)
                .WithDirectories(directories)
                .WithFiles(files)
                .WithIgnorePatterns(ignorePatterns);

            if (!quiet)
            {
                if (violations)
                {
                    report = report.WithViolationEventHandler(ViolationEncountered);
                }
                else
                {
                    report = report.WithOutputEventHandler(OutputGenerated);
                }
            }

            report.Create(outputXml);
        }
Ejemplo n.º 48
0
        /// <summary>
        /// The entry-point method for this application.
        /// </summary>
        /// <param name="args">
        /// The command line arguments passed to this method.
        /// </param>
        private static void Main(string[] args)
        {
            var options = GetOptions();
            Action<string> debugAction = null;
            try
            {
                opts.Parse(args);
                if (options.WithDebug)
                {
                    debugAction = x => { Console.WriteLine(x); };
                    PrintVersion(debugAction);
                }

                options.Validate();
            }
            catch (OptionException error)
            {
                Console.WriteLine("Invalid arguments");
                Console.WriteLine(error);
                options.NeedHelp = true;
            }

            if (options.NeedHelp)
            {
                PrintUsageAndHelp();
                return;
            }

            var report = new ReportBuilder()
                .WithDedupe(options.Dedupe)
                .WithStyleCopSettingsFile(options.StyleCopSettings)
                .WithRecursion(options.Recurse)
                .WithSolutionsFiles(options.SolutionFiles)
                .WithProjectFiles(options.ProjectFiles)
                .WithDirectories(options.Directories)
                .WithFiles(options.Files)
                .WithIgnorePatterns(options.IgnorePatterns)
                .WithDebug(debugAction)
                .WithAddins(options.Addins)
                .WithProjectUnloads(options.ProjectUnloads)
                .WithProcessorSymbols(options.Symbols);

            foreach (var opt in options.Optionals)
            {
                report = report.AddOptional(opt.Key, opt.Value);
            }

            RunReport(report, options.Generator, options.OutputXml, options.Quiet, options.Violations);
            if (options.MaxViolations.HasValue && violationCount > options.MaxViolations.Value)
            {
                Environment.Exit(1);
            }
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Run the report (validates settings against the generator given)
        /// </summary>
        /// <param name="report">The report object to perform the analysis</param>
        /// <param name="generator">Generator type given</param>
        /// <param name="outputXml">Output XML file name/path</param>
        /// <param name="quiet">Indicates if any console output should be available</param>
        /// <param name="violations">True to report each violation encountered</param>
        private static void RunReport(ReportBuilder report, string generator, string outputXml, bool quiet, bool violations)
        {
            var generatorType = Generator.Default;
            if (generator != null)
            {
                generatorType = (Generator)Enum.Parse(typeof(Generator), generator, true);
            }

            FileRunner runner;
            switch (generatorType)
            {
                case Generator.Xml:
                    report = report.WithOutputEventHandler(
                        (x, y) =>
                            {
                                violationCount++;
                                if (!quiet)
                                {
                                    OutputGenerated(x, y);
                                }
                            });

                    runner = new XmlRunner();
                    break;
                default:
                    EventHandler<StyleCop.ViolationEventArgs> callback = HadViolation;
                    if (!quiet)
                    {
                        if (violations)
                        {
                            callback = ViolationEncountered;
                        }
                        else
                        {
                            report = report.WithOutputEventHandler(OutputGenerated);
                        }
                    }

                    report = report.WithViolationEventHandler(callback);
                    runner = new ConsoleRunner();
                    break;
            }

            runner.OutputFile = string.IsNullOrEmpty(outputXml) ? null : string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}.xml", System.IO.Path.GetFileNameWithoutExtension(outputXml));
            report.Create(runner);
        }
Ejemplo n.º 50
0
        //private DataGrouping grouping=null;
        //public DataGrouping Grouping
        //{
        //    get { return grouping; }
        //    set { grouping = value; }
        //}
        private Rdl.Report CreateReport()
        {
            ReportBuilder builder = new ReportBuilder();
            builder.DataSources = CreateDataSources();
            builder.Body = CreateBody();
            builder.DataSets = CreateDataSets();
            builder.Width = A4Width+"mm";

            Page p = new Page();
            p.TopMargin = TopMargin.ToString() + "mm";
            //builder.RightMargin=RightMargin.ToString()+"mm";
            p.BottomMargin = BottomMargin.ToString() + "mm";
            p.PageHeader = CreatPageHeader();
            p.PageFooter = CreatPageFooter();
            builder.Page = p.Create();

            return builder.Create();
        }