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); }
public override bool execute( ) { if (base.execute() == false) { return(false); } Registry("execute fetch_proprietario "); /// USER [ execute ] T_Proprietario prot = new T_Proprietario(this); // ## Busca de proprietário pelo cpf if (prot.select_rows_cpf(input_st_cpf)) { // ## por todos os registros if (prot.fetch()) { // ## Copia dados para saida output_cont_dp.set_tg_found(Context.TRUE); output_cont_dp.set_st_nome(prot.get_st_nome()); output_cont_dp.set_st_endereco(prot.get_st_endereco()); output_cont_dp.set_st_numero(prot.get_st_numero()); output_cont_dp.set_st_complemento(prot.get_st_complemento()); output_cont_dp.set_st_bairro(prot.get_st_bairro()); output_cont_dp.set_st_cidade(prot.get_st_cidade()); output_cont_dp.set_st_UF(prot.get_st_UF()); output_cont_dp.set_st_CEP(prot.get_st_cep()); output_cont_dp.set_st_ddd(prot.get_st_ddd()); output_cont_dp.set_st_telefone(prot.get_st_telefone()); DateTime ti = Convert.ToDateTime(prot.get_dt_nasc()); output_cont_dp.set_dt_nasc(ti.Day.ToString().PadLeft(2, '0') + ti.Month.ToString().PadLeft(2, '0') + ti.Year.ToString()); output_cont_dp.set_st_email(prot.get_st_email()); output_cont_dp.set_vr_renda(prot.get_vr_renda()); output_cont_dp.set_id_instrucao("0"); } } // ## Não encontrou CPF else { output_cont_dp.set_tg_found(Context.FALSE); } /// USER [ execute ] END Registry("execute done fetch_proprietario "); return(true); }
public override bool execute( ) { Registry("execute web_fetch_edu_inicial "); /// USER [ execute ] output_tg_resp = Context.FALSE; if (input_st_cpf.Length > 0) { T_Proprietario prot = new T_Proprietario(this); if (!prot.select_rows_cpf(input_st_cpf)) { PublishError("CPF inválido"); return(false); } if (!prot.fetch()) { return(false); } if (prot.get_st_senhaEdu() != input_st_senha) { PublishError("Senha de responsável inválida"); return(false); } output_tg_resp = Context.TRUE; LINK_ProprietarioCartao prop_cart = new LINK_ProprietarioCartao(this); if (!prop_cart.select_fk_proprietario(prot.get_identity())) { PublishError("Nenhum cartão educacional cadastrado"); return(false); } T_Cartao cart = new T_Cartao(this); bool found = false; while (prop_cart.fetch()) { if (!cart.selectIdentity(prop_cart.get_fk_cartao())) { return(false); } if (cart.get_tg_tipoCartao() == TipoCartao.educacional) { found = true; break; } Trace(input_st_senha); } if (!found) { PublishError("Nenhum cartão educacional encontrado"); return(false); } } else if (input_st_cartao.Length > 0) { input_st_cartao = input_st_cartao.PadLeft(14, '0'); T_Cartao cart = new T_Cartao(this); cart.ExclusiveAccess(); if (!cart.select_rows_tudo(input_st_cartao.Substring(0, 6), input_st_cartao.Substring(6, 6), input_st_cartao.Substring(12, 2))) { PublishError("Cartão inválido"); return(false); } if (!cart.fetch()) { return(false); } T_WebBlock ip_block = new T_WebBlock(this); if (ip_block.select_rows_ip(input_st_ip, GetDataBaseTime(), cart.get_identity())) { PublishError("Senha de aluno inválida"); return(false); } if (cart.get_st_senha() != input_st_senha) { long senhas_erradas = cart.get_int_nu_webSenhaErrada() + 1; if (senhas_erradas >= 4) { ip_block.set_dt_expire(GetDataBaseTime(DateTime.Now.AddDays(1))); ip_block.set_st_ip(input_st_ip); ip_block.set_fk_cartao(cart.get_identity()); if (!ip_block.create_T_WebBlock()) { return(false); } } cart.set_nu_webSenhaErrada(senhas_erradas.ToString()); if (!cart.synchronize_T_Cartao()) { return(false); } PublishError("Senha de aluno inválida"); return(false); } cart.set_nu_webSenhaErrada("0"); if (!cart.synchronize_T_Cartao()) { return(false); } output_tg_resp = Context.FALSE; } /// USER [ execute ] END Registry("execute done web_fetch_edu_inicial "); return(true); }
public override bool execute( ) { Registry("execute web_exec_alterSenhaEdu "); /// USER [ execute ] if (input_tg_resp == Context.TRUE) { T_Proprietario prot = new T_Proprietario(this); prot.ExclusiveAccess(); if (!prot.select_rows_cpf(input_st_cpf)) { PublishError("CPF inválido"); return(false); } if (!prot.fetch()) { return(false); } if (prot.get_st_senhaEdu() != input_st_senha) { PublishError("Senha atual inválida"); return(false); } prot.set_st_senhaEdu(input_st_novaSenha); if (!prot.synchronize_T_Proprietario()) { return(false); } } else { T_Cartao cart = new T_Cartao(this); cart.ExclusiveAccess(); if (cart.select_rows_tudo(input_st_cpf.Substring(0, 6), input_st_cpf.Substring(6, 6), "01")) { if (!cart.fetch()) { return(false); } cart.set_st_senha(input_st_novaSenha); if (!cart.synchronize_T_Cartao()) { return(false); } } } PublishNote("Senha trocada com sucesso"); /// USER [ execute ] END Registry("execute done web_exec_alterSenhaEdu "); return(true); }
public override bool execute( ) { Registry("execute web_fetch_resp_alunos "); /// USER [ execute ] ArrayList lstEscolas = new ArrayList(); if (input_st_cpf.Length > 0) { T_Proprietario prot = new T_Proprietario(this); if (!prot.select_rows_cpf(input_st_cpf)) { PublishError("CPF inválido"); return(false); } if (!prot.fetch()) { return(false); } if (prot.get_st_senhaEdu() != input_st_senha) { PublishError("Senha inválida"); return(false); } output_st_nomeResp = prot.get_st_nome(); LINK_ProprietarioCartao prop_cart = new LINK_ProprietarioCartao(this); if (!prop_cart.select_fk_proprietario(prot.get_identity())) { PublishError("Nenhum cartão educacional cadastrado"); return(false); } T_Cartao cart = new T_Cartao(this); while (prop_cart.fetch()) { if (!cart.selectIdentity(prop_cart.get_fk_cartao())) { return(false); } if (cart.get_tg_tipoCartao() == TipoCartao.educacional) { DadosCartaoEdu dce = new DadosCartaoEdu(); if (!lstEscolas.Contains(cart.get_st_empresa())) { lstEscolas.Add(cart.get_st_empresa()); } dce.set_st_aluno(cart.get_st_aluno()); dce.set_st_cartao(cart.get_st_empresa() + cart.get_st_matricula() + cart.get_st_titularidade()); dce.set_vr_disp(cart.get_vr_disp_educacional()); output_array_generic_lst.Add(dce); } } } T_Empresa escola = new T_Empresa(this); T_MensagemEdu msg_edu = new T_MensagemEdu(this); for (int t = 0; t < lstEscolas.Count; ++t) { string t_escola = lstEscolas[t].ToString(); if (!escola.select_rows_empresa(t_escola)) { continue; } if (!escola.fetch()) { continue; } if (msg_edu.select_rows_dt(escola.get_identity(), GetDataBaseTime(), GetDataBaseTime())) { while (msg_edu.fetch()) { DadosEduMessage dem = new DadosEduMessage(); DateTime tim = Convert.ToDateTime(msg_edu.get_dt_ini()); dem.set_st_title(escola.get_st_fantasia() + " - " + tim.ToLongDateString()); string db_msg = msg_edu.get_st_mens(); string final_msg = ""; for (int g = 0; g < db_msg.Length; ++g) { if (db_msg[g] == 13) { final_msg += "<br>"; } else { final_msg += db_msg[g].ToString(); } } dem.set_st_msg(final_msg); output_array_generic_lstMsg.Add(dem); } } } /// USER [ execute ] END Registry("execute done web_fetch_resp_alunos "); return(true); }
public override bool execute( ) { if (base.execute() == false) { return(false); } Registry("execute fetch_consultaCartao "); /// USER [ execute ] // ## Filtro para busca de cartões StringBuilder sb = new StringBuilder(); T_Cartao cart = new T_Cartao(this); T_Proprietario prot = new T_Proprietario(this); T_Parcelas parc = new T_Parcelas(this); ApplicationUtil util = new ApplicationUtil(); string st_cart = input_cont_dcc.get_st_cartao(); string st_cpf = input_cont_dcc.get_st_cpf(); // ## Se for cartão especifico if (st_cart.Length > 0) { // admin ou oper if (input_cont_dcc.get_st_empresa().Length > 0) { if (!cart.select_rows_empresa_matricula(input_cont_dcc.get_st_empresa(), st_cart.PadLeft(6, '0'))) { return(true); } } else // root { if (!cart.select_rows_mat(st_cart.PadLeft(6, '0'))) { return(true); } } } // ## Se cpf ou cnpj for informado else if (st_cpf.Length > 0) { if (prot.select_rows_cpf(st_cpf)) { prot.fetch(); if (!cart.select_rows_prop(prot.get_identity())) { return(true); } } } // ## Se for de código de empresa específica else if (input_cont_dcc.get_st_empresa().Length > 0) { if (!cart.select_rows_empresa(input_cont_dcc.get_st_empresa())) { return(true); } } // ## Busca todos registros else { if (!cart.selectAll()) { return(true); } } bool nome = false, total = false, mensal = false, cotaExtra = false, cidade = false, estado = false; string st_nome = input_cont_dcc.get_st_nome().ToUpper(), st_cidade = input_cont_dcc.get_st_cidade(), st_estado = input_cont_dcc.get_st_estado(), expedido = input_cont_dcc.get_tg_expedido(); int i_total = 0, i_mensal = 0, i_cota = 0; // ## Prepara flags de filtro if (st_nome.Length > 0) { nome = true; } if (input_cont_dcc.get_vr_limTotal().Length > 0) { total = true; } if (input_cont_dcc.get_vr_limMensal().Length > 0) { mensal = true; } if (input_cont_dcc.get_vr_cotaExtra().Length > 0) { cotaExtra = true; } if (st_cidade.Length > 0) { cidade = true; } if (st_estado.Length > 0) { estado = true; } // ## Obtem valores rápidos para comparação if (total) { i_total = Convert.ToInt32(input_cont_dcc.get_vr_limTotal()); } if (mensal) { i_mensal = Convert.ToInt32(input_cont_dcc.get_vr_limMensal()); } if (cotaExtra) { i_cota = Convert.ToInt32(input_cont_dcc.get_vr_cotaExtra()); } // ## Busca todos os registros selecionados bool todos = false; bool hab = false; bool bloq = false; bool canc = false; bool adminGift = false; if (input_cont_dcc.get_tg_bloqueado() == "3") // todos { todos = true; } else { if (input_cont_dcc.get_tg_bloqueado() == Context.FALSE) // 0 { hab = true; } else if (input_cont_dcc.get_tg_bloqueado() == Context.TRUE) // 1 { bloq = true; } else { canc = true; // 2 } } if (input_cont_header.get_tg_user_type() == TipoUsuario.AdminGift) { adminGift = false; } T_Dependente dep_f = new T_Dependente(this); T_Cartao cart_prop = new T_Cartao(this); while (cart.fetch()) { string dep = ""; if (cart.get_tg_emitido() != expedido) { continue; } if (adminGift) { if (cart.get_fk_dadosProprietario() == "0") { continue; } } if (!todos) { if (bloq) { if (cart.get_tg_status() != CartaoStatus.Bloqueado) { continue; } } else if (canc) { if (cart.get_tg_status() != CartaoStatus.Bloqueado) { continue; } if (cart.get_tg_status() == CartaoStatus.Bloqueado && cart.get_tg_motivoBloqueio() != MotivoBloqueio.CANCELAMENTO) { continue; } } else if (hab) { if (cart.get_tg_status() != CartaoStatus.Habilitado) { continue; } } } if (total) { if (cart.get_int_vr_limiteTotal() < i_total) { continue; } } if (mensal) { if (cart.get_int_vr_limiteMensal() < i_mensal) { continue; } } if (cotaExtra) { if (cart.get_int_vr_extraCota() < i_cota) { continue; } } if (cart.get_fk_dadosProprietario() != Context.NONE) { if (!prot.selectIdentity(cart.get_fk_dadosProprietario())) { return(false); } } if (cidade) { if (!prot.get_st_cidade().Contains(st_cidade)) { continue; } } if (estado) { if (!prot.get_st_UF().Contains(st_estado)) { continue; } } if (cart.get_st_titularidade() != "01") { if (!dep_f.select_rows_prop_tit(cart.get_fk_dadosProprietario(), cart.get_st_titularidade())) { continue; } if (!dep_f.fetch()) { continue; } dep = dep_f.get_st_nome().ToUpper(); // Dependente if (nome) { if (!dep.Contains(st_nome)) { continue; } } } else { if (nome) { if (!prot.get_st_nome().ToUpper().Contains(st_nome)) { continue; } } } DadosCartao dc = new DadosCartao(); dc.set_st_empresa(cart.get_st_empresa()); dc.set_st_matricula(cart.get_st_matricula()); dc.set_st_titularidade(cart.get_st_titularidade() + ":" + cart.get_nu_viaCartao()); if (cart.get_fk_dadosProprietario() != Context.NONE) { if (dep.Length > 0) { dc.set_st_proprietario(dep); } else { dc.set_st_proprietario(prot.get_st_nome()); } dc.set_st_cpf(prot.get_st_cpf()); } dc.set_tg_status(cart.get_tg_status()); if (cart.get_tg_tipoCartao() == TipoCartao.presente) { dc.set_vr_limiteTotal("0"); dc.set_vr_limiteMensal("0"); dc.set_vr_extraCota("0"); dc.set_vr_dispMes("0"); dc.set_vr_dispTotal(cart.get_vr_limiteTotal()); } else { long dispMensal = 0, dispTotal = 0; if (cart.get_st_titularidade() != "01") { if (!cart_prop.select_rows_tudo(cart.get_st_empresa(), cart.get_st_matricula(), "01")) { continue; } if (!cart_prop.fetch()) { continue; } dc.set_vr_limiteTotal(cart_prop.get_vr_limiteTotal()); dc.set_vr_limiteMensal(cart_prop.get_vr_limiteMensal()); dc.set_vr_extraCota(cart_prop.get_vr_extraCota()); dispMensal = cart_prop.get_int_vr_limiteMensal() + cart_prop.get_int_vr_extraCota(); dispTotal = cart_prop.get_int_vr_limiteTotal() + cart_prop.get_int_vr_extraCota(); } else { dc.set_vr_limiteTotal(cart.get_vr_limiteTotal()); dc.set_vr_limiteMensal(cart.get_vr_limiteMensal()); dc.set_vr_extraCota(cart.get_vr_extraCota()); dispMensal = cart.get_int_vr_limiteMensal() + cart.get_int_vr_extraCota(); dispTotal = cart.get_int_vr_limiteTotal() + cart.get_int_vr_extraCota(); } // ## Obtem saldo disponível util.GetSaldoDisponivel(ref cart, ref dispMensal, ref dispTotal); dc.set_vr_dispMes(dispMensal.ToString()); dc.set_vr_dispTotal(dispTotal.ToString()); } DataPortable tmp = dc as DataPortable; // ## obtem identificador sb.Append(MemorySave(ref tmp)); sb.Append(","); } string list_ids = sb.ToString().TrimEnd(','); if (list_ids == "") { PublishNote("Nenhum resultado foi encontrado"); return(true); } DataPortable dp = new DataPortable(); dp.setValue("ids", list_ids); // ## Copia para saida um identificador de bloco output_st_csv_cartao = MemorySave(ref dp); /// USER [ execute ] END Registry("execute done fetch_consultaCartao "); return(true); }