public override bool LerMarcacoes(Marcacoes marcacoes, AssepontoRep.Bridge.TipoImportacaoMarcacoes tipoimportacao) { Connect(TerminalDados.Indice); bool Result = false; int NRegistrosLidos = 0; DateTime DataInicial; DateTime DataFinal; StringBuilder PIS = new StringBuilder(11); StringBuilder DataHora = new StringBuilder(19); StringBuilder NSR = new StringBuilder(20); StringBuilder MensagemErro = new StringBuilder(256); //Marcacoes marcacoes = new Marcacoes(TerminalDados); if (!getPeriodo(out DataInicial, out DataFinal)) { return(false); } //REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_BuscaPonto(REPZPM_DLL.Handle, DataInicial.ToString("dd/MM/yyyy"), DataFinal.ToString("dd/MM/yyyy")); //if (REPZPM_DLL.ID_Comando == -4) //{ int count = 1; do { REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_BuscaPonto(REPZPM_DLL.Handle, DataInicial.ToString("dd/MM/yyyy"), DataFinal.ToString("dd/MM/yyyy")); if (REPZPM_DLL.ID_Comando == -4) { int timeout = REPZPM_DLL.DLLREP_LeTimeout(REPZPM_DLL.Handle); if (timeout != -1) { REPZPM_DLL.DLLREP_DefineTimeout(REPZPM_DLL.Handle, (timeout * (count + 1))); } else { REPZPM_DLL.DLLREP_DefineTimeout(REPZPM_DLL.Handle, 100000); } } count++; }while (REPZPM_DLL.ID_Comando == -4 && count <= 11); //} if (REPZPM_DLL.ID_Comando >= 0) { /*Retorna a quantidade de registros*/ NRegistros = REPZPM_DLL.DLLREP_TotalRetornos(REPZPM_DLL.Handle); log.AddLog(String.Format(Consts.MARCACOES_A_PROCESSAR, NRegistros)); if (NRegistros > 0) { for (int i = 1; i <= NRegistros; i++) { REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_RetornoPonto(REPZPM_DLL.Handle, i, PIS, DataHora, NSR); if (REPZPM_DLL.Retorno > 0) { marcacoes.Add(PIS.ToString(), Convert.ToDateTime(DataHora.ToString()), Convert.ToInt32(NSR.ToString())); log.AddLogUnformatted(PIS.ToString().PadRight(18) + DataHora + " " + NSR); NRegistrosLidos++; } else { //REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1); //log.AddLog(Convert.ToString(MensagemErro)); int ret = REPZPM_DLL.DLLREP_ObtemCodigoErro(REPZPM_DLL.Handle, REPZPM_DLL.Retorno); log.AddLog(REPZPM_DLL.Trata_Retorno_DLL(ret)); } } } else { log.AddLog(Consts.MARCACOES_NAO_HA_NOVAS); } Result = (NRegistrosLidos > 0); if (Result) { marcacoes.SaveToFile(); log.AddLogUnformatted(String.Format(Consts.ARQUIVO_GERADO, marcacoes.Arquivo)); log.AddLineBreak(); } else { log.AddLog(Consts.MARCACOES_NAO_HA_NOVAS); } } else { Result = false; log.AddLog(REPZPM_DLL.Trata_Retorno_DLL(REPZPM_DLL.ID_Comando)); } Disconnect(TerminalDados.Indice); return(Result); }
public override bool LerMarcacoes(Marcacoes marcacoes, AssepontoRep.Bridge.TipoImportacaoMarcacoes tipoimportacao) { Connect(TerminalDados.IP, TerminalDados.Porta); bool Result = false; int NRegistrosLidos = 0; DateTime DataInicial; DateTime DataFinal; StringBuilder PIS = new StringBuilder(11); StringBuilder DataHora = new StringBuilder(19); StringBuilder NSR = new StringBuilder(20); StringBuilder MensagemErro = new StringBuilder(256); //Marcacoes marcacoes = new Marcacoes(TerminalDados); if (!getPeriodo(out DataInicial, out DataFinal)) { return(false); } REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_BuscaPonto(REPZPM_DLL.Handle, DataInicial.ToString("dd/MM/yyyy"), DataFinal.ToString("dd/MM/yyyy")); if (REPZPM_DLL.ID_Comando > 0) { /*Retorna a quantidade de registros*/ NRegistros = REPZPM_DLL.DLLREP_TotalRetornos(REPZPM_DLL.Handle); log.AddLog(String.Format(Consts.MARCACOES_A_PROCESSAR, NRegistros)); if (NRegistros > 0) { for (int i = 1; i <= NRegistros; i++) { REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_RetornoPonto(REPZPM_DLL.Handle, i, PIS, DataHora, NSR); if (REPZPM_DLL.Retorno == 1) { marcacoes.Add(PIS.ToString(), Convert.ToDateTime(DataHora.ToString()), Convert.ToInt32(NSR.ToString())); log.AddLogUnformatted(PIS.ToString().PadRight(18) + DataHora + " " + NSR); NRegistrosLidos++; } else { REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1); log.AddLog(Convert.ToString(MensagemErro)); } } } else { log.AddLog(Consts.MARCACOES_NAO_HA_NOVAS); } } Result = (NRegistrosLidos > 0); if (REPZPM_DLL.ID_Comando == -2) { log.AddLog("Erro de comunicação!"); } else { if (Result) { marcacoes.SaveToFile(); log.AddLogUnformatted(String.Format(Consts.ARQUIVO_GERADO, marcacoes.Arquivo)); log.AddLineBreak(); } else { log.AddLog(Consts.MARCACOES_NAO_HA_NOVAS); } } return(Result); }
public override bool LerMarcacoes(Marcacoes marcacoes) { Connect(TerminalDados.IP, TerminalDados.Porta); bool Result = false; int NRegistrosLidos = 0; StringBuilder PIS = new StringBuilder(11); StringBuilder DataHora = new StringBuilder(19); StringBuilder NSR = new StringBuilder(20); StringBuilder MensagemErro = new StringBuilder(256); //Marcacoes marcacoes = new Marcacoes(TerminalDados); log.AddLog(Consts.INICIALIZANDO_IMPORTACAO_ARQUIVO); REPZPM_DLL.ID_Comando = REPZPM_DLL.DLLREP_BuscaPonto(REPZPM_DLL.Handle, DataInicio: ("dd/MM/yyyy"), DataFim: ("dd/MM/yyyy")); if (REPZPM_DLL.ID_Comando > 0) { /*Retorna a quantidade de registros*/ NRegistros = REPZPM_DLL.DLLREP_TotalRetornos(REPZPM_DLL.Handle); log.AddLog(String.Format(Consts.TOTAL_MARCACOES, NRegistros)); if (NRegistros > 0) { for (int i = 1; i <= NRegistros; i++) { REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_RetornoPonto(REPZPM_DLL.Handle, i, PIS, DataHora, NSR); if (REPZPM_DLL.Retorno == 1) { marcacoes.Add(PIS.ToString(), Convert.ToDateTime(DataHora.ToString()), Convert.ToInt32(NSR.ToString())); log.AddLogUnformatted(PIS.ToString().PadRight(18) + DataHora + " " + NSR); NRegistrosLidos++; } else { REPZPM_DLL.Retorno = REPZPM_DLL.DLLREP_ObtemMensagemErro(REPZPM_DLL.Handle, MensagemErro, 1); log.AddLog(Convert.ToString(MensagemErro)); } } } else { log.AddLog(Consts.SEM_MARCACOES_NOVAS); } } Result = (NRegistrosLidos > 0); if (Result) { marcacoes.SaveToFile(); log.AddLogUnformatted(String.Format(Consts.ARQUIVO_GERADO, marcacoes.Arquivo)); log.AddLineBreak(); } else { log.AddLog(Consts.SEM_MARCACOES_NOVAS); } return(Result); }
public bool Dimep_ImportarMarcacoes(int Terminal, string TerminalNome, Marcacoes marcacoes) { bool Result = false; DBApp db = new DBApp(); int ProximoNsr = db.getLastNsr(Terminal) + 1; int Contador = 0; MRPRecord[] registrosMRP; log.AddLog(AssepontoRep.Consts.INICIALIZANDO_IMPORTACAO_ARQUIVO); if (Dimep_Conectar()) { try { _watchComm.RepositioningMRPRecordsPointer(ProximoNsr.ToString()); registrosMRP = this._watchComm.InquiryMRPRecords(false, false, true, false); while (registrosMRP != null) { foreach (MRPRecord registroMRP in registrosMRP) { if (registroMRP is MRPRecord_RegistrationMarkingPoint) { string Pis = ((MRPRecord_RegistrationMarkingPoint)registroMRP).Pis; DateTime DataHora = ((MRPRecord_RegistrationMarkingPoint)registroMRP).DateTimeMarkingPoint; int Nsr = Convert.ToInt32(((MRPRecord_RegistrationMarkingPoint)registroMRP).NSR); marcacoes.Add(Pis, DataHora, Nsr); Contador++; if (Nsr > ProximoNsr) { ProximoNsr = Nsr; } } } registrosMRP = _watchComm.ConfirmationReceiptMRPRecords(); } if (Contador > 0) { string Arquivo = marcacoes.SaveToFile(); log.AddLog(String.Format(AssepontoRep.Consts.ARQUIVO_GERADO, Arquivo)); Result = true; db.setLastNsr(Terminal, ProximoNsr); } else { log.AddLog(AssepontoRep.Consts.SEM_MARCACOES); } } catch (Exception ex) { log.AddLog(ex.Message); } finally { Dimep_Desconectar(); } } return(Result); }