コード例 #1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute graph_transacoes ");

            /// USER [ execute ]

            LOG_Transacoes ltr = new LOG_Transacoes(this);

            StringBuilder sb_global = new StringBuilder();

            T_Loja    loj = new T_Loja(this);
            T_Empresa emp = new T_Empresa(this);

            DateTime t_start = Convert.ToDateTime(input_dt_ini);
            DateTime t_end   = Convert.ToDateTime(input_dt_fim).AddHours(23).AddMinutes(59).AddSeconds(59);

            if (t_start.Day == t_end.Day)
            {
                if (t_start.Month == t_end.Month)
                {
                    PublishError("Favor informar período com datas diferentes");
                    return(false);
                }
            }

            for (int u = 0; u < input_array_generic_lst.Count; ++u)
            {
                DadosConsultaGraficoTransLojas dl = new DadosConsultaGraficoTransLojas(input_array_generic_lst[u] as DataPortable);

                ltr.Reset();

                Hashtable hsh_globalday = new Hashtable();
                ArrayList lst_globalday = new ArrayList();

                if (dl.get_tg_tipo() == "E")
                {
                    if (emp.select_rows_empresa(dl.get_nu_cod()))
                    {
                        if (emp.fetch())
                        {
                            if (!ltr.select_rows_dt_emp(GetDataBaseTime(t_start),
                                                        GetDataBaseTime(t_end),
                                                        emp.get_identity()))
                            {
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    if (loj.select_rows_loja(dl.get_nu_cod()))
                    {
                        if (loj.fetch())
                        {
                            if (!ltr.select_rows_dt_loj(GetDataBaseTime(t_start),
                                                        GetDataBaseTime(t_end),
                                                        loj.get_identity()))
                            {
                                continue;
                            }
                        }
                    }
                }

                long nu_tot = 0;

                while (ltr.fetch())
                {
                    string day = ltr.get_dt_transacao().Substring(0, 10);

                    if (hsh_globalday [day] == null)
                    {
                        hsh_globalday [day] = (long)nu_tot;
                        lst_globalday.Add(day);
                    }

                    hsh_globalday [day] = ++nu_tot;
                }

                for (int t = 0; t < lst_globalday.Count; ++t)
                {
                    string day = lst_globalday[t].ToString();

                    long nu_trans = (long)hsh_globalday [day];

                    DadosConsultaGraficoTransLojas dgtl = new DadosConsultaGraficoTransLojas();

                    dgtl.set_dt_trans(day + " 00:00");
                    dgtl.set_nu_trans(nu_trans.ToString());
                    dgtl.set_nu_id(u.ToString());

                    DataPortable mem = dgtl as DataPortable;

                    sb_global.Append(MemorySave(ref mem));
                    sb_global.Append(",");
                }
            }

            string list_ids = sb_global.ToString().TrimEnd(',');

            if (list_ids == "")
            {
                PublishNote("Nenhum registro encontrado");
                return(false);
            }

            DataPortable dp = new DataPortable();

            dp.setValue("ids", list_ids);

            output_st_csv = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done graph_transacoes ");

            return(true);
        }