Exemplo n.º 1
0
        public void Show(ObservableCollection <mAtendimento> lista_atendimento)
        {
            try
            {
                List <string> _ano         = new List <string>();
                List <string> _periodo     = new List <string>();
                List <string> _atendimento = new List <string>();
                List <string> _tipo        = new List <string>();
                List <string> _origem      = new List <string>();
                List <string> _operador    = new List <string>();

                foreach (mAtendimento at in lista_atendimento)
                {
                    _atendimento.Add("Atendimentos".ToUpper());

                    _ano.Add(at.Data.Year.ToString());

                    string[] words = at.TipoString.ToString().Split(';');

                    foreach (string sv in words)
                    {
                        if (sv != null && sv != string.Empty)
                        {
                            _tipo.Add(sv);
                        }
                    }

                    //_tipo.Add(at.TipoString);
                    _origem.Add(at.OrigemString);
                    _operador.Add(at.Operador);
                }

                var c_atendimento = from x in _atendimento
                                    group x by x into g
                                    let count = g.Count()
                                                orderby count descending
                                                select new { Value = g.Key, Count = count };

                foreach (var x in c_atendimento)
                {
                    Atendimentos.Add(new KeyValuePair <string, int>(x.Value, x.Count));
                }

                var c_ano = from x in _ano
                            group x by x into g
                            let count = g.Count()
                                        orderby count descending
                                        select new { Value = g.Key, Count = count };

                foreach (var x in c_ano)
                {
                    Ano.Add(new KeyValuePair <string, int>(x.Value, x.Count));
                }

                var c_tipo = from x in _tipo
                             group x by x into g
                             let count = g.Count()
                                         orderby count descending
                                         select new { Value = g.Key, Count = count };

                foreach (var x in c_tipo)
                {
                    Tipo.Add(new KeyValuePair <string, int>(x.Value, x.Count));
                }

                var c_origem = from x in _origem
                               group x by x into g
                               let count = g.Count()
                                           orderby count descending
                                           select new { Value = g.Key, Count = count };

                foreach (var x in c_origem)
                {
                    Origem.Add(new KeyValuePair <string, int>(x.Value, x.Count));
                }

                var c_operador = from x in _operador
                                 group x by x into g
                                 let count = g.Count()
                                             orderby count descending
                                             select new { Value = g.Key, Count = count };

                foreach (var x in c_operador)
                {
                    Operador.Add(new KeyValuePair <string, int>(x.Value, x.Count));
                }
            }
            catch { }
        }