public MReportDIA SetEDIAS(ObservableCollection <DIA> obj) { try { MReportDIA _est = new MReportDIA(); List <string> _dia = new List <string>(); List <string> _ativos = new List <string>(); List <string> _ativosnd = new List <string>(); List <string> _vencidos = new List <string>(); List <string> _baixados = new List <string>(); foreach (DIA ab in obj) { if (ab.Situacao != "RENOVADO") { _dia.Add(ab.Emissao.Year.ToString()); } if (DateTime.Now < ab.Validade.Value) { _ativos.Add(ab.Emissao.Year.ToString()); } if (ab.Validade == new DateTime(2001, 1, 1)) { _ativosnd.Add(ab.Emissao.Year.ToString()); } if (DateTime.Now > ab.Validade && ab.Validade != new DateTime(2001, 1, 1) && ab.Situacao != "RENOVADO" && ab.Situacao != "BAIXADO") { _vencidos.Add(ab.Validade.Value.Year.ToString()); } if (ab.Situacao == "BAIXADO") { _baixados.Add(ab.Emissao.Year.ToString()); } } var c_dia = from x in _dia 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_dia) { _est.DIA.Add(new KeyValuePair <string, int>(x.Value, x.Count)); } var c_ativos = from x in _ativos 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_ativos) { _est.Ativo.Add(new KeyValuePair <string, int>(x.Value, x.Count)); } var c_ativosnd = from x in _ativosnd 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_ativosnd) { _est.AtivoND.Add(new KeyValuePair <string, int>(x.Value, x.Count)); } var c_vencidos = from x in _vencidos 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_vencidos) { _est.Vencido.Add(new KeyValuePair <string, int>(x.Value, x.Count)); } var c_baixado = from x in _baixados 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_baixado) { _est.Baixado.Add(new KeyValuePair <string, int>(x.Value, x.Count)); } return(_est); } catch (Exception ex) { return(null); throw new Exception(ex.Message); } }
private ObservableCollection <BarChartsColor> FlowChartPrint(MReportDIA _report) { ObservableCollection <BarChartsColor> _chart = new ObservableCollection <BarChartsColor>(); MReportDIA _rp = new MReportDIA(); foreach (KeyValuePair <string, int> x in _report.DIA) { _rp.DIA.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in _report.Ativo) { _rp.Ativo.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in _report.AtivoND) { _rp.AtivoND.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in _report.Vencido) { _rp.Vencido.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in _report.Baixado) { _rp.Baixado.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } if (_rp.DIA.Count > 0) { BarChartsColor bc = new BarChartsColor(); bc.Title = string.Format("D.I.A EMITIDOS"); bc.ItemsSource = _rp.DIA; _chart.Add(bc); } if (_rp.Ativo.Count > 0) { BarChartsColor bc = new BarChartsColor(); bc.Title = string.Format("D.I.A ATIVOS"); bc.ItemsSource = _rp.Ativo; _chart.Add(bc); } if (_rp.AtivoND.Count > 0) { BarChartsColor bc = new BarChartsColor(); bc.Title = string.Format("D.I.A ATIVO SEM DATA DE RENOVAÇÃO"); bc.ItemsSource = _rp.AtivoND; _chart.Add(bc); } if (_rp.Vencido.Count > 0) { BarChartsColor bc = new BarChartsColor(); bc.Title = string.Format("D.I.A VENCIDOS"); bc.ItemsSource = _rp.Vencido; _chart.Add(bc); } if (_rp.Baixado.Count > 0) { BarChartsColor bc = new BarChartsColor(); bc.Title = string.Format("D.I.A BAIXADOS"); bc.ItemsSource = _rp.Baixado; _chart.Add(bc); } return(_chart); }