public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_processaArqBancario ");

            /// USER [ execute ]

            DataPortable csv_AllArchive = MemoryGet(input_st_id);

            ApplicationUtil var_util = new ApplicationUtil();

            string st_ids = csv_AllArchive.getValue("ids");

            Trace(st_ids);

            int total_records = var_util.indexCSV(st_ids);

            T_Faturamento fat = new T_Faturamento(this);

            for (int t = 0; t < total_records; ++t)
            {
                DataPortable port_line = MemoryGet(var_util.getCSV(t));

                string line = port_line.getValue("line");

                Trace(line);

                int pos = 0;

                //7
                //06
                //030908
                //7
                //0509629684
                //030908
                //0000000002108

                string fk        = line.Substring(pos, 25).Trim();    pos += 25;
                string cod       = line.Substring(pos, 2).Trim();    pos += 2;
                string dt_banco  = line.Substring(pos, 6).Trim();    pos += 6;
                string st_seuNum = line.Substring(pos, 10).Trim();    pos += 10;
                string st_nosNum = line.Substring(pos, 20).Trim();    pos += 20;
                string dt_venc   = line.Substring(pos, 6).Trim();    pos += 6;
                string vr_pago   = line.Substring(pos, 13).Trim();    pos += 13;

                vr_pago = vr_pago.TrimStart('0');

                Trace(line);

                fat.ExclusiveAccess();

                if (!fat.selectIdentity(fk))
                {
                    Registry("Registro " + fk + " desconhecido!");
                    fat.ReleaseExclusive();
                    continue;
                }

                fat.set_tg_retBanco(cod);

                if (cod == "00")
                {
                    fat.set_tg_situacao(TipoSitFat.PagoCC);
                }

                if (cod == "10")
                {
                    fat.set_tg_situacao(TipoSitFat.BaixaCfeInst);
                }

                if (cod == "06" ||
                    cod == "08" ||
                    cod == "15" ||
                    cod == "25")
                {
                    fat.set_tg_situacao(TipoSitFat.PagoDoc);
                }

                fat.set_dt_baixa(GetDataBaseTime(new DateTime(2000 + Convert.ToInt32(dt_banco.Substring(4, 2)),
                                                              Convert.ToInt32(dt_banco.Substring(2, 2)),
                                                              Convert.ToInt32(dt_banco.Substring(0, 2)))));

                if (!fat.synchronize_T_Faturamento())
                {
                    Registry("Registro " + fk + " não foi possível atualizar!");
                }

                fat.ReleaseExclusive();
            }

            /// USER [ execute ] END

            Registry("execute done exec_processaArqBancario ");

            return(true);
        }
Example #2
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_alteraLoja ");

            /// USER [ execute ]


            // ## Se container estiver preenchido, alterar dados
            // ## cadastrais da loja

            if (input_cont_dl.get_st_nome() != "")
            {
                loj.set_nu_CNPJ(input_cont_dl.get_nu_CNPJ());
                loj.set_st_nome(input_cont_dl.get_st_nome());
                loj.set_st_social(input_cont_dl.get_st_social());
                loj.set_st_endereco(input_cont_dl.get_st_endereco());
                loj.set_st_enderecoInst(input_cont_dl.get_st_enderecoInst());
                loj.set_nu_inscEst(input_cont_dl.get_nu_inscEst());

                loj.set_st_cidade(input_cont_dl.get_st_cidade());
                loj.set_st_estado(input_cont_dl.get_st_estado());
                loj.set_nu_CEP(input_cont_dl.get_nu_CEP());
                loj.set_nu_telefone(input_cont_dl.get_nu_telefone());
                loj.set_nu_fax(input_cont_dl.get_nu_fax());
                loj.set_st_contato(input_cont_dl.get_st_contato());
                loj.set_vr_mensalidade(input_cont_dl.get_vr_mensalidade());
                loj.set_nu_contaDeb(input_cont_dl.get_nu_contaDeb());
                loj.set_st_obs(input_cont_dl.get_st_obs());

                loj.set_vr_mensalidade(input_cont_dl.get_vr_mensalidade());
                loj.set_nu_pctValor(input_cont_dl.get_nu_pctValor());
                loj.set_vr_transacao(input_cont_dl.get_vr_transacao());
                loj.set_vr_minimo(input_cont_dl.get_vr_minimo());
                loj.set_nu_franquia(input_cont_dl.get_nu_franquia());
                loj.set_nu_periodoFat(input_cont_dl.get_nu_periodoFat());
                loj.set_nu_diavenc(input_cont_dl.get_nu_diavenc());
                loj.set_tg_tipoCobranca(input_cont_dl.get_tg_tipoCobranca());
                loj.set_nu_bancoFat(input_cont_dl.get_nu_bancoFat());
                loj.set_tg_isentoFat(input_cont_dl.get_tg_isento());
                loj.set_st_senha(input_cont_dl.get_st_senhaWeb());

                if (!loj.synchronize_T_Loja())
                {
                    return(false);
                }
            }

            // ## Alteração de convênios

            Hashtable hshEmps = new Hashtable();
            ArrayList lstEmps = new ArrayList();

            if (input_st_csv_empresas.Length > 0)
            {
                LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);

                // ## buscar e limpar todos os registros de convênio

                T_Empresa emp = new T_Empresa(this);

                if (loj_emp.select_fk_loja(loj.get_identity()))
                {
                    while (loj_emp.fetch())
                    {
                        hshEmps [loj_emp.get_fk_empresa()] = "0";

                        lstEmps.Add(loj_emp.get_fk_empresa());

                        if (!loj_emp.delete())
                        {
                            return(false);
                        }
                    }
                }

                ApplicationUtil util_taxa    = new ApplicationUtil();
                ApplicationUtil util_repasse = new ApplicationUtil();
                ApplicationUtil util_banco   = new ApplicationUtil();
                ApplicationUtil util_ag      = new ApplicationUtil();
                ApplicationUtil util_conta   = new ApplicationUtil();

                // ## Indexa as taxas

                util_taxa.indexCSV(input_st_csv_taxas);
                util_repasse.indexCSV(input_st_csv_dias);

                util_banco.indexCSV(input_st_csv_banco);
                util_ag.indexCSV(input_st_csv_ag);
                util_conta.indexCSV(input_st_csv_conta);

                // ## Percorre todas as empresas vinculadas

                for (int t = 0; t < var_util.indexCSV(input_st_csv_empresas); ++t)
                {
                    string empresa = var_util.getCSV(t);

                    if (!emp.select_rows_empresa(empresa))
                    {
                        return(false);
                    }

                    if (!emp.fetch())
                    {
                        return(false);
                    }

                    // ## Cria o relacionamento

                    loj_emp.set_fk_empresa(emp.get_identity());
                    loj_emp.set_fk_loja(loj.get_identity());

                    loj_emp.set_tx_admin(util_taxa.getCSV(t));
                    loj_emp.set_nu_dias_repasse(util_repasse.getCSV(t));
                    loj_emp.set_st_banco(util_banco.getCSV(t));
                    loj_emp.set_st_ag(util_ag.getCSV(t));
                    loj_emp.set_st_conta(util_conta.getCSV(t));

                    if (!loj_emp.create_LINK_LojaEmpresa())
                    {
                        return(false);
                    }

                    if (hshEmps [emp.get_identity()] != null)
                    {
                        hshEmps [emp.get_identity()] = "1";
                    }
                }

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

                    if (hshEmps [tag] != null)
                    {
                        if (hshEmps [tag].ToString() == "0")
                        {
                            // foi removido

                            emp.selectIdentity(tag);

                            LOG_Audit aud = new LOG_Audit(this);

                            aud.set_tg_operacao(TipoOperacao.RemoveConvenio);
                            aud.set_fk_usuario(input_cont_header.get_st_user_id());
                            aud.set_dt_operacao(GetDataBaseTime());
                            aud.set_st_observacao(emp.get_st_fantasia());
                            aud.set_fk_generic(loj.get_identity());

                            if (!aud.create_LOG_Audit())
                            {
                                return(false);
                            }
                        }
                    }
                }

                PublishNote("Convênios atualizados para loja " + input_cont_dl.get_nu_CNPJ());
            }
            else
            {
                PublishNote("Cadastro atualizado para loja " + input_cont_dl.get_nu_CNPJ());
            }

            /// USER [ execute ] END

            Registry("execute done exec_alteraLoja ");

            return(true);
        }
        public override bool execute( )
        {
            Registry("execute infra_SchedulerDispatcher ");

            /// USER [ execute ]

            I_Scheduler sch      = new I_Scheduler(this);
            DateTime    time_now = DateTime.Now;

            if (sch.selectAll())
            {
                while (sch.fetch())
                {
                    bool Exec = false;

                    if (sch.get_tg_status() == Context.CLOSED)
                    {
                        continue;
                    }

                    switch (sch.get_tg_type())
                    {
                    case Scheduler.Specific:
                    {
                        DateTime time = Convert.ToDateTime(sch.get_dt_specific());

                        if (time_now.Year == time.Year)
                        {
                            if (time_now.Month == time.Month)
                            {
                                if (time_now.Day == time.Day)
                                {
                                    if (time_now.Hour == time.Hour)
                                    {
                                        if (time_now.Minute == time.Minute)
                                        {
                                            Exec = true;
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case Scheduler.Daily:
                    {
                        int daily_hh = Convert.ToInt32(sch.get_st_daily_hhmm().Substring(0, 2));
                        int daily_mm = Convert.ToInt32(sch.get_st_daily_hhmm().Substring(2, 2));

                        if (time_now.Hour == daily_hh)
                        {
                            if (time_now.Minute == daily_mm)
                            {
                                Exec = true;
                            }
                        }

                        break;
                    }

                    case Scheduler.Weekly:
                    {
                        long weekly_dow = sch.get_int_st_weekly_dow();
                        long weekly_hh  = Convert.ToInt64(sch.get_st_daily_hhmm().Substring(0, 2));
                        long weekly_mm  = Convert.ToInt64(sch.get_st_daily_hhmm().Substring(2, 2));

                        switch (weekly_dow)
                        {
                        case 0: if (time_now.DayOfWeek != DayOfWeek.Sunday)
                            {
                                continue;
                            }
                            break;

                        case 1: if (time_now.DayOfWeek != DayOfWeek.Monday)
                            {
                                continue;
                            }
                            break;

                        case 2: if (time_now.DayOfWeek != DayOfWeek.Tuesday)
                            {
                                continue;
                            }
                            break;

                        case 3: if (time_now.DayOfWeek != DayOfWeek.Wednesday)
                            {
                                continue;
                            }
                            break;

                        case 4: if (time_now.DayOfWeek != DayOfWeek.Thursday)
                            {
                                continue;
                            }
                            break;

                        case 5: if (time_now.DayOfWeek != DayOfWeek.Friday)
                            {
                                continue;
                            }
                            break;

                        case 6: if (time_now.DayOfWeek != DayOfWeek.Saturday)
                            {
                                continue;
                            }
                            break;

                        default: break;                                         // 7 is everyday
                        }

                        if (time_now.Hour == weekly_hh)
                        {
                            if (time_now.Minute == weekly_mm)
                            {
                                Exec = true;
                            }
                        }

                        break;
                    }

                    case Scheduler.Monthly:
                    {
                        long monthly_dd = sch.get_int_nu_monthly_day();
                        long monthly_hh = Convert.ToInt64(sch.get_st_monthly_hhmm().Substring(0, 2));
                        long monthly_mm = Convert.ToInt64(sch.get_st_monthly_hhmm().Substring(2, 2));

                        if (time_now.Day == monthly_dd)
                        {
                            if (time_now.Hour == monthly_hh)
                            {
                                if (time_now.Minute == monthly_mm)
                                {
                                    Exec = true;
                                }
                            }
                        }

                        break;
                    }

                    case Scheduler.Minute:
                    {
                        Exec = true;
                        break;
                    }

                    default:
                    {
                        Registry("Unrecognized code! " + sch.get_tg_type());
                        break;
                    }
                    }

                    if (Exec)
                    {
                        Registry(sch.get_st_job() + " >> MATCH!");
                    }

                    Registry(sch.get_st_job());

                    if (!Exec)
                    {
                        Registry(sch.get_st_job() + " >> Checking backlog....");

                        DateTime tim = Convert.ToDateTime(sch.get_dt_prev());

                        Registry(tim.ToString());
                        Registry(time_now.ToString());

                        if (time_now >= tim)
                        {
                            Registry("Back log for: " + sch.get_st_job());
                            Exec = true;
                        }
                    }

                    if (!Exec)
                    {
                        continue;
                    }

                    Registry("Running: " + sch.get_st_job());

                    ApplicationUtil var_util = new ApplicationUtil();

                    int    max_params = var_util.indexCSV(sch.get_st_job(), ';');
                    string job        = var_util.getCSV(0);

                    string path = var_SessionKey +
                                  "\\Log_" +
                                  DateTime.Now.Year.ToString() +
                                  DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Day.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Hour.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Minute.ToString().PadLeft(2, '0') +
                                  DateTime.Now.Second.ToString().PadLeft(2, '0') +
                                  "_" +
                                  job +
                                  "_" +
                                  sch.get_identity() +
                                  ".txt.wrk";

                    FileStream   logFile;
                    StreamWriter logStream;

                    if (File.Exists(path))
                    {
                        logFile = new FileStream(path, FileMode.Append, FileAccess.Write);
                    }
                    else
                    {
                        logFile = new FileStream(path, FileMode.Create, FileAccess.Write);
                    }

                    logStream           = new StreamWriter(logFile);
                    logStream.AutoFlush = true;

                    var_Comm.Clear();

                    DB_Access new_access = new DB_Access(ref m_gen_my_access);

                    var_disp.var_Translator = var_Translator;

                    if (max_params >= 3)
                    {
                        DataPortable port = new DataPortable();

                        for (int t = 1; t < max_params;)
                        {
                            string ident     = var_util.getCSV(t); ++t;
                            string ident_val = var_util.getCSV(t); ++t;

                            port.setValue(ident, ident_val);
                        }

                        string buffer = "";

                        port.ExportBuffer(ref buffer);

                        Registry(buffer);

                        new_access.MemorySave("input", ref port);
                    }

                    // Runnig in a new thread
                    var_disp.ExecuteThreadTransaction(job,
                                                      Convert.ToInt32(sch.get_identity()),
                                                      ref logStream,
                                                      ref var_Comm,
                                                      ref new_access,
                                                      path);
                }
            }

            /// USER [ execute ] END

            Registry("execute done infra_SchedulerDispatcher ");

            return(true);
        }
Example #4
0
        public override bool execute( )
        {
            Registry("execute fetch_memory ");

            /// USER [ execute ]

            StringBuilder   sb       = new StringBuilder();
            ApplicationUtil var_util = new ApplicationUtil();

            int memory = Convert.ToInt32(new InstallData().maxPacket) / Convert.ToInt32(input_st_bytes);

            // ###
            // ###  Obtem todos os id´s que o relatório gerou
            // ###

            DataPortable dp_container = MemoryGet(input_st_block);

            string ids   = dp_container.getValue("ids");
            string final = "";



            int total_records = var_util.indexCSV(ids);



            // ###
            // ###  Compila uma lista de id´s que cabem na memoria
            // ###

            bool Term = false;

            for (int y = 0; y < total_records; ++y)
            {
                sb.Append(var_util.getCSV(y));
                sb.Append(",");

                if (--memory == 0 || y == total_records - 1)
                {
                    final = sb.ToString();

                    // se for ultimo registro
                    if (y == total_records - 1)
                    {
                        Term = true;


                        final = final.TrimEnd(',');
                    }

                    break;
                }
            }

            if (Term != true && final.Length > 0)
            {
                // ###
                // ### Atualiza a lista com id´s que ainda nao foram devolvidos
                // ###

                string new_batch = ids.Replace(final, "");



                DataPortable dp_new_recs = new DataPortable();

                dp_new_recs.setValue("ids", new_batch);

                // ###
                // ### Obtem novo id da lista
                // ###

                output_st_new_block = MemorySave(ref dp_new_recs);
            }

            // ###
            // ### Copia itens da memoria
            // ###

            final = final.TrimEnd(',');

            var_util.clearPortable();

            total_records = var_util.indexCSV(final);

            for (int y = 0; y < total_records; ++y)
            {
                output_array_generic_lst.Add(MemoryGet(var_util.getCSV(y)));
            }

            /// USER [ execute ] END

            Registry("execute done fetch_memory ");

            return(true);
        }
Example #5
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_processaArqConvenio ");

            /// USER [ execute ]

            DataPortable csv_AllArchive = MemoryGet(input_st_id);

            ApplicationUtil var_util = new ApplicationUtil();

            string st_ids = csv_AllArchive.getValue("ids");

            Trace(st_ids);

            int total_records = var_util.indexCSV(st_ids);

            T_Empresa emp = new T_Empresa(this);

            if (!emp.select_rows_empresa(input_st_empresa))
            {
                PublishError("");
                return(false);
            }

            if (!emp.fetch())
            {
                PublishError("");
                return(false);
            }

            T_Cartao                cart     = new T_Cartao(this);
            T_Cartao                cart_mat = new T_Cartao(this);
            T_Proprietario          prot     = new T_Proprietario(this);
            T_InfoAdicionais        info     = new T_InfoAdicionais(this);
            T_Dependente            dep      = new T_Dependente(this);
            LINK_ProprietarioCartao lpc      = new LINK_ProprietarioCartao(this);

            int linha = 0;

            for (int t = 0; t < total_records; ++t)
            {
                linha++;

                DataPortable port_line = MemoryGet(var_util.getCSV(t));

                string line = port_line.getValue("line");

                Trace(line);

                int pos = 0;

                try
                {
                    string st_mat     = line.Substring(pos, 6).Trim();    pos += 6;
                    string cpf        = line.Substring(pos, 11).Trim();   pos += 11;
                    string tit        = line.Substring(pos, 2).Trim();   pos += 2;
                    string nome       = line.Substring(pos, 50).Trim();   pos += 50;
                    string end        = line.Substring(pos, 40).Trim();   pos += 40;
                    string bairro     = line.Substring(pos, 20).Trim();   pos += 20;
                    string cep        = line.Substring(pos, 8).Trim();   pos += 8;
                    string cidade     = line.Substring(pos, 20).Trim();   pos += 20;
                    string tel        = line.Substring(pos, 10).Trim();   pos += 10;
                    string email      = line.Substring(pos, 50).Trim();   pos += 50;
                    string dt_nasc    = line.Substring(pos, 8).Trim();   pos += 8;
                    string lim_mensal = line.Substring(pos, 12).Trim().TrimStart('0').PadLeft(1, '0');     pos += 12;
                    string lim_total  = line.Substring(pos, 12).Trim().TrimStart('0').PadLeft(1, '0');     pos += 12;

                    if (lim_total == "0")
                    {
                        lim_total = lim_mensal;
                    }

                    st_mat = st_mat.PadLeft(6, '0');

                    bool found = false;

                    if (cart_mat.select_rows_empresa_matricula(input_st_empresa, st_mat))
                    {
                        PublishNote("Matricula " + st_mat + " já cadastrada. Registro descartado");
                        continue;
                    }

                    if (Convert.ToInt32(tit) == 1)                          // titular
                    {
                        if (prot.select_rows_cpf(cpf))
                        {
                            if (prot.fetch())
                            {
                                if (cart.select_rows_prop(prot.get_identity()))
                                {
                                    while (cart.fetch())
                                    {
                                        if (cart.get_st_empresa() == input_st_empresa)
                                        {
                                            if (cart.get_st_titularidade() == "01")
                                            {
                                                found = true;
                                                break;
                                            }
                                        }
                                    }

                                    if (found)
                                    {
                                        continue;                                         // descarta pois cartão já foi criado
                                    }
                                }
                            }

                            // não precisa criar dadosproprietario, só o cartão desta empresa
                            found = true;
                        }

                        if (!found)
                        {
                            // cria dados proprietario

                            prot.Reset();

                            prot.set_st_nome(nome);
                            prot.set_st_cpf(cpf);
                            prot.set_st_endereco(end);
                            prot.set_st_bairro(bairro);
                            prot.set_st_cidade(cidade);
                            prot.set_st_telefone(tel);
                            prot.set_st_email(email);

                            if (dt_nasc == "00000000")
                            {
                                dt_nasc = GetDataBaseTime();
                            }
                            else
                            {
                                int year  = Convert.ToInt32(dt_nasc.Substring(4, 4));
                                int month = Convert.ToInt32(dt_nasc.Substring(2, 2));
                                int day   = Convert.ToInt32(dt_nasc.Substring(0, 2));

                                dt_nasc = GetDataBaseTime(new DateTime(year, month, day));
                            }

                            prot.set_dt_nasc(dt_nasc);

                            prot.create_T_Proprietario();
                        }

                        info.Reset();

                        info.set_st_empresa(input_st_empresa);
                        info.set_st_matricula(st_mat);

                        info.create_T_InfoAdicionais();

                        cart.Reset();

                        cart.set_st_empresa(input_st_empresa);
                        cart.set_st_matricula(st_mat);
                        cart.set_st_titularidade(tit.PadLeft(2, '0'));

                        cart.set_tg_emitido(StatusExpedicao.NaoExpedido);

                        cart.set_fk_dadosProprietario(prot.get_identity());
                        cart.set_fk_infoAdicionais(info.get_identity());

                        cart.set_vr_limiteMensal(lim_mensal);
                        cart.set_vr_limiteTotal(lim_total);

                        cart.set_tg_tipoCartao("0");
                        cart.set_st_venctoCartao(DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                                 (DateTime.Now.Year + 5).ToString().Substring(2, 2));

                        cart.set_tg_status("0");
                        cart.set_nu_viaCartao("1");

                        cart.create_T_Cartao();
                    }
                    else                     // dependente
                    {
                        // busca proprietario
                        if (prot.select_rows_cpf(cpf))
                        {
                            if (prot.fetch())
                            {
                                dep.Reset();

                                dep.set_st_nome(nome);
                                dep.set_nu_titularidade(tit);
                                dep.set_fk_proprietario(prot.get_identity());

                                dep.create_T_Dependente();

                                info.Reset();

                                info.set_st_empresa(input_st_empresa);
                                info.set_st_matricula(st_mat);

                                info.create_T_InfoAdicionais();

                                cart.Reset();

                                cart.set_st_empresa(input_st_empresa);
                                cart.set_st_titularidade(tit.PadLeft(2, '0'));
                                cart.set_st_matricula(st_mat);

                                cart.set_tg_emitido(StatusExpedicao.NaoExpedido);

                                cart.set_fk_dadosProprietario(prot.get_identity());
                                cart.set_fk_infoAdicionais(info.get_identity());

                                cart.set_vr_limiteMensal(lim_mensal);
                                cart.set_vr_limiteTotal(lim_total);

                                cart.set_tg_tipoCartao("0");
                                cart.set_st_venctoCartao(DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                                         (DateTime.Now.Year + 5).ToString().Substring(2, 2));

                                cart.set_tg_status("0");
                                cart.set_nu_viaCartao("1");

                                cart.create_T_Cartao();
                            }
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    ex.ToString();

                    PublishError("Arquivo com registro inválido na linha " + linha);
                    return(false);
                }
            }

            /// USER [ execute ] END

            Registry("execute done exec_processaArqConvenio ");

            return(true);
        }
Example #6
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_cotaExtraEmpresa ");

            /// USER [ execute ]

            T_Empresa emp = new T_Empresa(this);

            if (!emp.select_rows_empresa(input_emp.PadLeft(6, '0')))
            {
                return(false);
            }

            if (!emp.fetch())
            {
                return(false);
            }

            ApplicationUtil var_util = new ApplicationUtil();

            T_Cartao cart     = new T_Cartao(this);
            T_Cartao cart_upd = new T_Cartao(this);

            if (cart.select_rows_empresa(input_emp.PadLeft(6, '0')))
            {
                while (cart.fetch())
                {
                    if (input_csv_excluded.Contains(cart.get_st_matricula()))
                    {
                        continue;
                    }

                    if (cart.get_tg_status() != CartaoStatus.Habilitado)
                    {
                        continue;
                    }

                    cart_upd.ExclusiveAccess();

                    cart_upd.selectIdentity(cart.get_identity());
                    cart_upd.set_vr_extraCota(input_valor);

                    cart_upd.synchronize_T_Cartao();
                    cart_upd.ReleaseExclusive();
                }
            }

            int tot = var_util.indexCSV(input_csv_excluded);

            for (int t = 0; t < tot; ++t)
            {
                cart_upd.ExclusiveAccess();

                cart_upd.select_rows_empresa_matricula(input_emp.PadLeft(6, '0'), var_util.getCSV(t));
                cart_upd.fetch();
                cart_upd.set_vr_extraCota("0");

                cart_upd.synchronize_T_Cartao();
                cart_upd.ReleaseExclusive();
            }

            PublishNote("Cota extra aplicada com sucesso!\nEstes valores serão zerados no próximo fechamento mensal.");

            /// USER [ execute ] END

            Registry("execute done exec_cotaExtraEmpresa ");

            return(true);
        }
Example #7
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_agenda ");

            /// USER [ execute ]

            LINK_Agenda l_a = new LINK_Agenda(this);

            // ## Busca todos os registros de agendamento

            if (l_a.selectAll())
            {
                StringBuilder sb = new StringBuilder();

                T_Empresa   emp = new T_Empresa(this);
                I_Scheduler sch = new I_Scheduler(this);

                ApplicationUtil var_util = new ApplicationUtil();

                while (l_a.fetch())
                {
                    // ## Cria container de dados

                    DadosAgenda da = new DadosAgenda();

                    // ## Valida links para outras tabelas

                    if (!emp.selectIdentity(l_a.get_fk_empresa()))
                    {
                        continue;
                    }

                    if (!sch.selectIdentity(l_a.get_fk_schedule()))
                    {
                        continue;
                    }

                    var_util.indexCSV(sch.get_st_job(), ';');

                    string aff = "";
                    string job = var_util.getCSV(0);

                    if (sch.get_st_job().IndexOf("afiliada") > 0)
                    {
                        if (job == "schedule_fech_mensal")
                        {
                            aff = " - " + var_util.getCSV(4);
                        }
                    }

                    // ## Copia dados

                    da.set_fk_agenda(l_a.get_identity());
                    da.set_st_empresa(emp.get_st_empresa() + aff);
                    da.set_st_nome_empresa(emp.get_st_fantasia());
                    da.set_en_atividade(l_a.get_en_atividade());
                    da.set_dt_ultima(sch.get_dt_last());

                    // ## Formata

                    switch (sch.get_tg_type())
                    {
                        #region - Monthly -

                    case Scheduler.Monthly:
                    {
                        da.set_st_info("Mensal, Dia " +
                                       sch.get_nu_monthly_day() +
                                       ", Hora " +
                                       sch.get_st_monthly_hhmm().Substring(0, 2) +
                                       ":" +
                                       sch.get_st_monthly_hhmm().Substring(2, 2));

                        break;
                    }

                        #endregion

                        #region - Weekly -

                    case Scheduler.Weekly:
                    {
                        string dia = "";

                        switch (sch.get_st_weekly_dow())
                        {
                        case "0": dia = "Domingo";      break;

                        case "1": dia = "Segunda";      break;

                        case "2": dia = "Terça";                break;

                        case "3": dia = "Quarta";       break;

                        case "4": dia = "Quinta";       break;

                        case "5": dia = "Sexta";                break;

                        case "6": dia = "Sábado";       break;
                        }

                        da.set_st_info("Semanal, Dia " +
                                       dia +
                                       ", Hora " +
                                       sch.get_st_weekly_hhmm().Substring(0, 2) +
                                       ":" +
                                       sch.get_st_weekly_hhmm().Substring(2, 2));

                        break;
                    }

                        #endregion

                        #region - Daily -

                    case Scheduler.Daily:
                    {
                        da.set_st_info("Diariamente " +
                                       sch.get_st_daily_hhmm().Substring(0, 2) +
                                       ":" +
                                       sch.get_st_daily_hhmm().Substring(2, 2));

                        break;
                    }

                        #endregion
                    }

                    // ## Guarda em memória

                    DataPortable mem_rtc = da as DataPortable;

                    sb.Append(MemorySave(ref mem_rtc));
                    sb.Append(",");
                }

                // ## Guarda todos os identificadores em um bloco

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

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                // ## Envia para client a identificação do bloco

                output_st_csv = MemorySave(ref dp);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_agenda ");

            return(true);
        }
Example #8
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute ins_loja ");

            /// USER [ execute ]

            if (loj.select_rows_loja(input_cont_dl.get_st_loja()))
            {
                PublishError("Loja " + input_cont_dl.get_st_loja() + " previamente cadastrada");
                return(false);
            }

            loj.set_st_loja(input_cont_dl.get_st_loja());
            loj.set_nu_CNPJ(input_cont_dl.get_nu_CNPJ());
            loj.set_st_nome(input_cont_dl.get_st_nome());
            loj.set_st_social(input_cont_dl.get_st_social());
            loj.set_st_endereco(input_cont_dl.get_st_endereco());
            loj.set_st_enderecoInst(input_cont_dl.get_st_enderecoInst());
            loj.set_nu_inscEst(input_cont_dl.get_nu_inscEst());

            loj.set_st_cidade(input_cont_dl.get_st_cidade());
            loj.set_st_estado(input_cont_dl.get_st_estado());
            loj.set_nu_CEP(input_cont_dl.get_nu_CEP());
            loj.set_nu_telefone(input_cont_dl.get_nu_telefone());
            loj.set_nu_fax(input_cont_dl.get_nu_fax());
            loj.set_st_contato(input_cont_dl.get_st_contato());
            loj.set_vr_mensalidade(input_cont_dl.get_vr_mensalidade());
            loj.set_nu_contaDeb(input_cont_dl.get_nu_contaDeb());
            loj.set_st_obs(input_cont_dl.get_st_obs());
            loj.set_tg_blocked(Context.FALSE);

            loj.set_vr_mensalidade(input_cont_dl.get_vr_mensalidade());
            loj.set_nu_pctValor(input_cont_dl.get_nu_pctValor());
            loj.set_vr_transacao(input_cont_dl.get_vr_transacao());
            loj.set_vr_minimo(input_cont_dl.get_vr_minimo());
            loj.set_nu_franquia(input_cont_dl.get_nu_franquia());
            loj.set_nu_periodoFat(input_cont_dl.get_nu_periodoFat());
            loj.set_nu_diavenc(input_cont_dl.get_nu_diavenc());
            loj.set_tg_tipoCobranca(input_cont_dl.get_tg_tipoCobranca());
            loj.set_nu_bancoFat(input_cont_dl.get_nu_bancoFat());
            loj.set_tg_isentoFat(input_cont_dl.get_tg_isento());
            loj.set_st_senha(input_cont_dl.get_st_senhaWeb());

            if (!loj.create_T_Loja())
            {
                return(false);
            }

            LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);
            T_Empresa        emp     = new T_Empresa(this);

            ApplicationUtil util_taxa    = new ApplicationUtil();
            ApplicationUtil util_repasse = new ApplicationUtil();

            util_taxa.indexCSV(input_st_csv_taxas);
            util_repasse.indexCSV(input_st_csv_dias);

            for (int t = 0; t < var_util.indexCSV(input_st_csv_empresas); ++t)
            {
                string empresa = var_util.getCSV(t);

                if (!emp.select_rows_empresa(empresa))
                {
                    return(false);
                }

                if (!emp.fetch())
                {
                    return(false);
                }

                loj_emp.set_fk_empresa(emp.get_identity());
                loj_emp.set_fk_loja(loj.get_identity());
                loj_emp.set_tx_admin(util_taxa.getCSV(t));
                loj_emp.set_nu_dias_repasse(util_repasse.getCSV(t));

                if (!loj_emp.create_LINK_LojaEmpresa())
                {
                    return(false);
                }
            }

            PublishNote("Loja " +
                        input_cont_dl.get_st_nome() +
                        " (" + input_cont_dl.get_nu_CNPJ() +
                        ") cadastrada com sucesso");

            /// USER [ execute ] END

            Registry("execute done ins_loja ");

            return(true);
        }