示例#1
0
        public void EnviaDataHora(string IP, int Porta)
        {
            // Monta a data e hora
            string data = DateTime.Now.Date.ToString("ddMMyyyy");

            string hora = DateTime.Now.Hour.ToString();

            if (hora.Length < 2)
            {
                hora = "0" + hora;
            }
            string min = DateTime.Now.Minute.ToString();

            if (min.Length < 2)
            {
                min = "0" + min;
            }
            string sec = DateTime.Now.Second.ToString();

            if (sec.Length < 2)
            {
                sec = "0" + sec;
            }

            string horario = hora + min + sec;
            string msg     = "";

            msg = data + horario;

            Comando cmd  = new Comando(Protocolo.CMD_DATA_HORA, Protocolo.SET, msg);
            Rede    rede = new Rede(IP, Porta, edLog);

            rede.EnviaComandoTCP(cmd);
        }
示例#2
0
        //private static byte[] ReadFile(string filePath)
        //{
        //    byte[] buffer;
        //    FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
        //    try
        //    {
        //        int length = (int)fileStream.Length;  // get file length
        //        buffer = new byte[length];            // create buffer
        //        int count;                            // actual number of bytes read
        //        int sum = 0;                          // total number of bytes read

        //        // read until Read method returns 0 (end of the stream has been reached)
        //        while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
        //            sum += count;  // sum is a buffer offset for next reading
        //    }
        //    finally
        //    {
        //        fileStream.Close();
        //    }
        //    return buffer;
        //}

        private void EnviarBiometria(int Terminal, string IP, int Porta, string PIS, string Nome, int Funcionario, string Arquivo)
        {
            string bio = ReadFile(Arquivo);
            string pis = PIS;

            for (int i = pis.Length; i < 12; i++)
            {
                pis = "0" + pis;
            }

            string msg = pis + "1" + bio;

            Comando cmd  = new Comando(Protocolo.CMD_BIOMETRIA, Protocolo.SET, msg);
            Rede    rede = new Rede(IP, Porta, edLog);

            if (rede.EnviaComandoTCP(cmd, Nome) == true)
            {
                DB db = new DB();
                db.ExecuteCommand(
                    "UPDATE TerminaisFuncionarios " +
                    "SET TRMF_BIOMETRIA_ENVIADA_EM = GETDATE() " +
                    "WHERE TRMF_TERMINAL = " + Terminal.ToString() + " " +
                    "AND TRMF_FUNC = " + Funcionario.ToString()
                    );
            }
        }
示例#3
0
        private void ExcluirFuncionario(int Terminal, string IP, int Porta, string PIS, string Nome, int Funcionario)
        {
            string  msg  = MontaMensagemExclusaoFuncionario(PIS);
            Comando cmd  = new Comando(Protocolo.CMD_EXCLUSAO, Protocolo.SET, msg);
            Rede    rede = new Rede(IP, Porta, edLog);

            rede.AddLog("EXCLUINDO " + Nome);
            rede.EnviaComandoTCP(cmd);

            DB db = new DB();

            db.ExecuteCommand(
                "UPDATE TerminaisFuncionarios " +
                "SET TRMF_ARMAZENADO_EM = NULL " +
                "WHERE TRMF_TERMINAL = " + Terminal.ToString() + " " +
                "AND TRMF_FUNC = " + Funcionario.ToString()
                );
        }
示例#4
0
        public void EnviaInfoEmpresa(int Terminal, string IP, int Porta)
        {
            string Identificador;
            string Nome;
            string Cei;
            string Endereco;
            byte   IdentificadorTipo;

            DB db = new DB();

            db.LerEmpresa(Terminal, out IdentificadorTipo, out Identificador, out Nome, out Cei, out Endereco);

            string  mensagem = MontaMensagemEmpresa(Identificador, Nome, Cei, Endereco);
            Comando cmd      = MontaComando(mensagem, Protocolo.CMD_EMPRESA, Protocolo.SET);
            Rede    rede     = new Rede(IP, Porta, edLog);

            rede.EnviaComandoTCP(cmd);
        }
示例#5
0
        private void EnviarFuncionario(int Terminal, string IP, int Porta, string Cartao, string PIS, string Senha, string Nome, int Funcionario, bool CodigoBarras, bool Proximidade, bool Biometria, bool Teclado)
        {
            Rede rede = new Rede(IP, Porta, edLog);

            if (PIS == string.Empty)
            {
                rede.AddLog(String.Format("{0}: PIS NÃO INFORMADO", Nome));
                return;
            }

            string  msg = MontaMensagemFuncionario(Cartao, PIS, Senha, Nome, CodigoBarras, Proximidade, Biometria, Teclado);
            Comando cmd = new Comando(Protocolo.CMD_FUNCIONARIO, Protocolo.SET, msg);
            DB      db  = new DB();

            if (rede.EnviaComandoTCP(cmd) == true)
            {
                db.ExecuteCommand(
                    "UPDATE TerminaisFuncionarios " +
                    "SET TRMF_ARMAZENADO_EM = GETDATE() " +
                    "WHERE TRMF_TERMINAL = " + Terminal.ToString() + " " +
                    "AND TRMF_FUNC = " + Funcionario.ToString()
                    );
            }
        }