示例#1
0
        public ObservableCollection <BarChart> Atendimento(mReportAtendimentos reports, bool periodo)
        {
            ObservableCollection <BarChart> _chart = new ObservableCollection <BarChart>();

            _chart.Clear();

            if (periodo)
            {
                List <KeyValuePair <string, int> > Atendimentos = new List <KeyValuePair <string, int> >();

                foreach (KeyValuePair <string, int> x in reports.Atendimentos)
                {
                    Atendimentos.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value));
                }

                List <KeyValuePair <string, int> > Anos = new List <KeyValuePair <string, int> >();

                foreach (KeyValuePair <string, int> x in reports.Ano)
                {
                    Anos.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value));
                }

                List <KeyValuePair <string, int> > Origens = new List <KeyValuePair <string, int> >();

                foreach (KeyValuePair <string, int> x in reports.Origem)
                {
                    Origens.Add(new KeyValuePair <string, int>(x.Key, x.Value));
                }

                List <KeyValuePair <string, int> > Tipos = new List <KeyValuePair <string, int> >();

                foreach (KeyValuePair <string, int> x in reports.Tipo)
                {
                    Tipos.Add(new KeyValuePair <string, int>(x.Key, x.Value));
                }

                List <KeyValuePair <string, int> > Operadores = new List <KeyValuePair <string, int> >();

                foreach (KeyValuePair <string, int> x in reports.Operador)
                {
                    Operadores.Add(new KeyValuePair <string, int>(x.Key, x.Value));
                }

                if (Atendimentos.Count > 0)
                {
                    BarChart bc = new BarChart();

                    bc.Title       = string.Format("Total de Atendimentos");
                    bc.ItemsSource = Atendimentos;
                    _chart.Add(bc);

                    if (Anos.Count > 0)
                    {
                        BarChart bci = new BarChart();

                        bci.Title       = string.Format("Atendimentos / Anos");
                        bci.ItemsSource = Anos;

                        _chart.Add(bci);
                    }

                    if (Origens.Count > 0)
                    {
                        BarChart bci = new BarChart();

                        bci.Title       = string.Format("Atendimentos / Origem");
                        bci.ItemsSource = Origens;

                        _chart.Add(bci);
                    }


                    if (Tipos.Count > 0)
                    {
                        BarChart bci = new BarChart();

                        bci.Title       = string.Format("Atendimentos / Serviços");
                        bci.ItemsSource = Tipos;

                        _chart.Add(bci);
                    }

                    if (Operadores.Count > 0)
                    {
                        BarChart bci = new BarChart();

                        bci.Title       = string.Format("Atendimentos / Operador", reports.Periodo[0], reports.Periodo[1]);
                        bci.ItemsSource = Operadores;

                        //_chart.Add(bci);
                    }
                }
            }

            return(_chart);
        }
示例#2
0
        private FlowDocument PreviewInTable(mReportAtendimentos obj)
        {
            try
            {
                FlowDocument flow = new FlowDocument();

                flow.ColumnGap  = 0;
                flow.Background = Brushes.White;
                //flow.ColumnWidth = 8.5 * 96.0;
                //flow.ColumnWidth =  96.0 * 8.5;
                //flow.PageHeight = 11.5 * 96.0;
                //flow.PageWidth = 8.5 * 96.0;
                flow.PageHeight    = 768;
                flow.PageWidth     = 1104;
                flow.ColumnWidth   = 1104;
                flow.FontFamily    = new FontFamily("Segoe UI");
                flow.FontSize      = 11;
                flow.PagePadding   = new Thickness(40, 20, 40, 20);
                flow.TextAlignment = TextAlignment.Left;

                Paragraph pH = new Paragraph(new Run(new mFlowHeader().NameOrg));
                pH.Typography.Capitals = FontCapitals.SmallCaps;
                pH.Foreground          = Brushes.Black;
                pH.FontSize            = 16;
                pH.FontWeight          = FontWeights.Bold;
                pH.Margin = new Thickness(0);

                Paragraph pH1 = new Paragraph(new Run(new mFlowHeader().SloganOrg));
                pH1.Foreground = Brushes.Black;
                pH1.FontSize   = 9;
                pH1.Margin     = new Thickness(1, 0, 0, 0);

                Paragraph pH2 = new Paragraph(new Run(new mFlowHeader().DepOrg));
                pH2.Typography.Capitals = FontCapitals.SmallCaps;
                pH2.Foreground          = Brushes.Black;
                pH2.FontWeight          = FontWeights.Bold;
                pH2.FontSize            = 12;
                pH2.Margin = new Thickness(0, 10, 0, 0);

                Paragraph pH3 = new Paragraph(new Run(new mFlowHeader().SetorOrg));
                pH3.Typography.Capitals = FontCapitals.SmallCaps;
                pH3.FontWeight          = FontWeights.Bold;
                pH3.Foreground          = Brushes.Black;
                pH3.Margin = new Thickness(0, 0, 0, 20);

                flow.Blocks.Add(pH);
                flow.Blocks.Add(pH1);
                flow.Blocks.Add(pH2);
                flow.Blocks.Add(pH3);

                #region Tabela 1
                Table tb1 = new Table();
                tb1.Foreground      = Brushes.Black;
                tb1.CellSpacing     = 0;
                tb1.BorderThickness = new Thickness(0.5);
                tb1.BorderBrush     = Brushes.Black;

                tb1.Columns.Add(new TableColumn()
                {
                    Width = GridLength.Auto
                });
                tb1.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(100)
                });

                TableRowGroup rg1 = new TableRowGroup();
                rg1.Foreground = Brushes.Black;

                tb1.RowGroups.Add(rg1);

                TableRow hcnae1 = new TableRow();
                rg1.Rows.Add(hcnae1);

                int cont = 0;

                if (obj != null)
                {
                    foreach (KeyValuePair <string, int> x in obj.Atendimentos)
                    {
                        cont = x.Value;
                    }
                }

                hcnae1.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ATENDIMENTOs")))
                {
                    Padding = new Thickness(5)
                })
                {
                    BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                });
                hcnae1.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(cont.ToString())))
                {
                    Padding = new Thickness(5)
                })
                {
                    BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                });

                if (obj != null)
                {
                    foreach (KeyValuePair <string, int> x in obj.Ano)
                    {
                        TableRow row = new TableRow();
                        rg1.Foreground = Brushes.Black;
                        rg1.Rows.Add(row);
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                    }
                }

                flow.Blocks.Add(tb1);
                #endregion

                #region Tabela 2
                Table tb2 = new Table();
                tb2.Foreground      = Brushes.Black;
                tb2.CellSpacing     = 0;
                tb2.BorderThickness = new Thickness(0.5);
                tb2.BorderBrush     = Brushes.Black;

                tb2.Columns.Add(new TableColumn()
                {
                    Width = GridLength.Auto
                });
                tb2.Columns.Add(new TableColumn()
                {
                    Width = new GridLength(100)
                });

                TableRowGroup rg2 = new TableRowGroup();
                rg2.Foreground = Brushes.Black;

                tb2.RowGroups.Add(rg2);

                TableRow hcnae2 = new TableRow();
                rg2.Rows.Add(hcnae2);

                hcnae2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("SERVIÇOS REALIZADOS")))
                {
                    Padding = new Thickness(5)
                })
                {
                    ColumnSpan = 2, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                });

                if (obj != null)
                {
                    foreach (KeyValuePair <string, int> x in obj.Tipo)
                    {
                        TableRow row = new TableRow();
                        rg2.Foreground = Brushes.Black;
                        rg2.Rows.Add(row);
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                        row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                        {
                            Padding = new Thickness(5)
                        })
                        {
                            BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                        });
                    }
                }

                flow.Blocks.Add(tb2);
                #endregion

                if (isOrigem)
                {
                    #region Tabela 3
                    Table tb3 = new Table();
                    tb3.Foreground      = Brushes.Black;
                    tb3.CellSpacing     = 0;
                    tb3.BorderThickness = new Thickness(0.5);
                    tb3.BorderBrush     = Brushes.Black;

                    tb3.Columns.Add(new TableColumn()
                    {
                        Width = GridLength.Auto
                    });
                    tb3.Columns.Add(new TableColumn()
                    {
                        Width = new GridLength(100)
                    });

                    TableRowGroup rg3 = new TableRowGroup();

                    tb3.RowGroups.Add(rg3);

                    TableRow tbairro3 = new TableRow();
                    rg3.Rows.Add(tbairro3);

                    tbairro3.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ORIGEM DO ATENDIMENTO")))
                    {
                        Padding = new Thickness(5)
                    })
                    {
                        ColumnSpan = 2, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                    });

                    if (obj != null)
                    {
                        foreach (KeyValuePair <string, int> x in obj.Origem)
                        {
                            TableRow row = new TableRow();
                            rg3.Foreground = Brushes.Black;
                            rg3.Rows.Add(row);
                            row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key))
                            {
                                Padding = new Thickness(5)
                            })
                            {
                                BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                            });
                            row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                            {
                                Padding = new Thickness(5)
                            })
                            {
                                BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                            });
                        }
                    }

                    flow.Blocks.Add(tb3);
                    #endregion
                }

                if (isOperador)
                {
                    #region Tabela 4
                    Table tb4 = new Table();
                    tb4.Foreground      = Brushes.Black;
                    tb4.CellSpacing     = 0;
                    tb4.BorderThickness = new Thickness(0.5);
                    tb4.BorderBrush     = Brushes.Black;

                    tb4.Columns.Add(new TableColumn()
                    {
                        Width = GridLength.Auto
                    });
                    tb4.Columns.Add(new TableColumn()
                    {
                        Width = new GridLength(100)
                    });

                    TableRowGroup rg4 = new TableRowGroup();

                    tb4.RowGroups.Add(rg4);

                    TableRow tOP = new TableRow();
                    rg4.Rows.Add(tOP);

                    tOP.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("OPERADOR DO ATENDIMENTO")))
                    {
                        Padding = new Thickness(5)
                    })
                    {
                        ColumnSpan = 2, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                    });

                    if (obj != null)
                    {
                        foreach (KeyValuePair <string, int> x in obj.Operador)
                        {
                            TableRow row = new TableRow();
                            rg4.Foreground = Brushes.Black;
                            rg4.Rows.Add(row);
                            row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key))
                            {
                                Padding = new Thickness(5)
                            })
                            {
                                BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                            });
                            row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString()))
                            {
                                Padding = new Thickness(5)
                            })
                            {
                                BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black
                            });
                        }
                    }

                    flow.Blocks.Add(tb4);
                    #endregion
                }

                Paragraph r = new Paragraph();
                r.Margin   = new Thickness(0, 0, 0, 0);
                r.FontSize = 10;

                System.Reflection.Assembly         assembly = System.Reflection.Assembly.GetExecutingAssembly();
                System.Diagnostics.FileVersionInfo fvi      = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
                string version = fvi.FileVersion;

                //r.Inlines.Add(lrodape);
                r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper()));
                r.Inlines.Add(new Run(" / V" + version + " / "));
                r.Inlines.Add(new Bold(new Run(Accounts.AccountOn.Nome)));
                r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy")));
                r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString()));

                flow.Blocks.Add(r);

                return(flow);
            }
            catch { return(new FlowDocument()); }
        }