Ejemplo n.º 1
0
        public ActionResult TrovaConsuntivo(int Anno, int Settimana)
        {
            GalvanicaBLL         bll = new GalvanicaBLL();
            DateTime             dataInizioSettimana = DateTimeHelper.PrimoGiornoSettimana(Anno, Settimana);
            DateTime             dataFine            = dataInizioSettimana.AddDays(7);
            GalvanicaReportModel report = bll.EstraiConsutivo(dataInizioSettimana, dataFine);

            ViewData.Add("dataInizio", dataInizioSettimana.ToShortDateString());
            ViewData.Add("dataFine", dataFine.ToShortDateString());
            return(PartialView("GrigliaReportPartial", report));
        }
Ejemplo n.º 2
0
        public ActionResult ReportPDF(int Anno, int Settimana)
        {
            GalvanicaBLL         bll = new GalvanicaBLL();
            DateTime             dataInizioSettimana = DateTimeHelper.PrimoGiornoSettimana(Anno, Settimana);
            DateTime             dataFine            = dataInizioSettimana.AddDays(7);
            GalvanicaReportModel report = bll.EstraiConsutivo(dataInizioSettimana, dataFine);

            PDFHelper pdfHelper = new PDFHelper();

            byte[] fileContents = pdfHelper.EstraiGalvanicaReport(report, dataInizioSettimana, dataFine);

            return(File(fileContents, "application/pdf", "Report.pdf"));
        }
Ejemplo n.º 3
0
        public byte[] EstraiGalvanicaReport(GalvanicaReportModel report, DateTime dataInizio, DateTime dataFine)
        {
            InizializzaDocumento("Report Galvanica", "Report settimanale", "MetalWeb");

            _document.DefaultPageSetup.Orientation = Orientation.Landscape;
            _document.DefaultPageSetup.RightMargin = 20;
            _document.DefaultPageSetup.LeftMargin  = 20;
            _document.AddSection();
            _document.LastSection.AddParagraph("Report Galvanica", "Heading2");

            Paragraph paragraph = _document.LastSection.AddParagraph();

            paragraph.AddText("Report per la settimana dal ");
            paragraph.AddFormattedText(dataInizio.ToShortDateString(), TextFormat.Bold);
            paragraph.AddText(" al ");
            paragraph.AddFormattedText(dataFine.ToShortDateString(), TextFormat.Bold);
            paragraph.AddText(".");

            paragraph = _document.LastSection.AddParagraph();
            paragraph.AddText("Numero barre: ");
            paragraph.AddFormattedText(report.BarreTotali.ToString(), TextFormat.Bold);
            paragraph.AddText("  Durata totale: ");
            paragraph.AddFormattedText(DateTimeHelper.ToHoursMin(report.TempoTotale), TextFormat.Bold);
            paragraph.AddText("  Durata complessiva fermi: ");
            paragraph.AddFormattedText(DateTimeHelper.ToHoursMin(report.FermoTotale), TextFormat.Bold);
            paragraph.AddText("  Durata effettiva: ");
            paragraph.AddFormattedText(DateTimeHelper.ToHoursMin(report.DurataEffettiva), TextFormat.Bold);

            paragraph = _document.LastSection.AddParagraph();
            paragraph.AddText("  Numero barre in 1 ora: ");
            paragraph.AddFormattedText(report.BarreHH.ToString(), TextFormat.Bold);
            paragraph.AddText("  Minuti per barra: ");
            paragraph.AddFormattedText(report.MinBarre.ToString(), TextFormat.Bold);

            paragraph.Format.SpaceAfter = "1cm";

            CreaTabellaGalvanica(report);

            byte[] fileContents = EstraiByteDaDocumento();
            return(fileContents);
        }
        public GalvanicaReportModel EstraiConsutivo(DateTime dataInizio, DateTime dataFine)
        {
            List <GalvanicaConsuntivoModel> consuntivo = new List <GalvanicaConsuntivoModel>();

            GalvanicaDS ds = new GalvanicaDS();

            using (GalvanicaBusiness bGalvanica = new GalvanicaBusiness())
            {
                bGalvanica.FillRW_GALV_CONSUNTIVO(ds);
                bGalvanica.FillRW_GALV_FERMI(ds);
            }

            List <GalvanicaDS.RW_GALV_CONSUNTIVORow> elementiTrovati = ds.RW_GALV_CONSUNTIVO.Where(X => X.INIZIO_TURNO >= dataInizio && X.INIZIO_TURNO < dataFine).ToList();

            int      barreTotali  = 0;
            TimeSpan durataTotale = new TimeSpan();
            TimeSpan fermoTotale  = new TimeSpan();

            foreach (GalvanicaDS.RW_GALV_CONSUNTIVORow m in elementiTrovati)
            {
                GalvanicaConsuntivoModel model = CreaGalvanicaConsuntivo(m, ds);
                consuntivo.Add(model);
                barreTotali += model.Barre;
                durataTotale = durataTotale.Add(model.Durata);
                fermoTotale  = fermoTotale.Add(model.FermoTotale);
            }
            GalvanicaReportModel report = new GalvanicaReportModel();

            report.Consuntivo      = consuntivo;
            report.BarreTotali     = barreTotali;
            report.FermoTotale     = fermoTotale;
            report.TempoTotale     = durataTotale;
            report.DurataEffettiva = report.TempoTotale.Subtract(report.FermoTotale);
            report.BarreHH         = report.DurataEffettiva.TotalHours == 0 ? 0 : Math.Round((decimal)(report.BarreTotali / report.DurataEffettiva.TotalHours), 1);
            report.MinBarre        = report.BarreTotali == 0 ? 0 : Math.Round((decimal)(report.DurataEffettiva.TotalMinutes / report.BarreTotali), 1);
            return(report);
        }
Ejemplo n.º 5
0
        private void CreaTabellaGalvanica(GalvanicaReportModel report)
        {
            //12 colonne
            Table table = new Table();

            table.Borders.Width = 0.75;

            Column column = table.AddColumn(Unit.FromCentimeter(2));

            column.Format.Alignment = ParagraphAlignment.Center;

            table.AddColumn(Unit.FromCentimeter(3));
            table.AddColumn(Unit.FromCentimeter(3));
            table.AddColumn(Unit.FromCentimeter(1.5));

            table.AddColumn(Unit.FromCentimeter(1.5));
            table.AddColumn(Unit.FromCentimeter(1.5));
            table.AddColumn(Unit.FromCentimeter(1.5));
            table.AddColumn(Unit.FromCentimeter(1.5));
            table.AddColumn(Unit.FromCentimeter(1.5));

            table.AddColumn(Unit.FromCentimeter(9));

            table.AddColumn(Unit.FromCentimeter(2));

            table.Rows.Height   = 10;
            table.TopPadding    = 5;
            table.BottomPadding = 5;

            Row row = table.AddRow();

            row.Shading.Color = Colors.PaleGoldenrod;
            Cell cell = row.Cells[0];

            cell.AddParagraph("Giorno");
            cell = row.Cells[1];
            cell.AddParagraph("Inizio turno");
            cell = row.Cells[2];
            cell.AddParagraph("Fine turno");
            cell = row.Cells[3];
            cell.AddParagraph("Barre");
            cell = row.Cells[4];
            cell.AddParagraph("Durata");
            cell = row.Cells[5];
            cell.AddParagraph("Fermo");
            cell = row.Cells[6];
            cell.AddParagraph("Durata effettiva");
            cell = row.Cells[7];
            cell.AddParagraph("Barre/h");
            cell = row.Cells[8];
            cell.AddParagraph("Minuti/ Barra");
            cell = row.Cells[9];
            cell.AddParagraph("Fermi");
            cell = row.Cells[10];
            cell.AddParagraph("Operatore");


            foreach (GalvanicaConsuntivoModel consuntivo in report.Consuntivo)
            {
                row = table.AddRow();

                cell = row.Cells[0];
                cell.AddParagraph(consuntivo.InizioTurno.ToShortDateString());
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[1];
                cell.AddParagraph(consuntivo.InizioTurno.ToString("dd/MM/yyyy HH:mm"));
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[2];
                cell.AddParagraph(consuntivo.FineTurno.ToString("dd/MM/yyyy HH:mm"));
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[3];
                cell.AddParagraph(consuntivo.Barre.ToString());
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[4];
                cell.AddParagraph(consuntivo.Durata.ToString(@"hh\:mm"));
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[5];
                cell.AddParagraph(consuntivo.FermoTotale.ToString(@"hh\:mm"));
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[6];
                cell.AddParagraph(consuntivo.DurataEffettiva.ToString(@"hh\:mm"));
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[7];
                cell.AddParagraph(consuntivo.BarreHH.ToString());
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[8];
                cell.AddParagraph(consuntivo.MinBarre.ToString());
                cell.VerticalAlignment = VerticalAlignment.Top;


                cell = row.Cells[10];
                cell.AddParagraph(consuntivo.UIDUSER);
                cell.VerticalAlignment = VerticalAlignment.Top;


                for (int i = 0; i < consuntivo.Fermi.Count; i++)
                {
                    cell = row.Cells[9];
                    string fermo = string.Format("{0} {1} {2} {3}", consuntivo.Fermi[i].Tipo, consuntivo.Fermi[i].Ora, consuntivo.Fermi[i].Durata, consuntivo.Fermi[i].Motivo);
                    cell.AddParagraph(fermo);
                }
            }

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 1.5, Colors.Black);

            _document.LastSection.Add(table);
        }