Esempio n. 1
0
        private void sendGateToServer()
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

            TcpClient cliente = new TcpClient(IP, PORT);

            NetworkStream stream = cliente.GetStream();

            foreach (KeyValuePair <string, Zone.GateDefinition> puerta in actualZone.listaPuertas)
            {
                if (puerta.Value.type != Zone.GateAccessType.Forbidden)
                {
                    actualGate = puerta.Key;
                    break;
                }
            }

            Zone.GateAccessType tipoPuerta = actualZone.listaPuertas[actualGate].type;

            string Ordinal1 = actualZone.listaPuertas[actualGate].from.Ordinal.ToString();
            string Ordinal2 = actualZone.listaPuertas[actualGate].to.Ordinal.ToString();

            string comando = "TYPE:LNL_DEFINEGATE,DEVICEID:" + PANELID + ",READERID:" + READERID + ",ORGANIZATION:" + ORGANIZATIONID.ToString() + ",ACCESSTYPE:" + tipoPuerta.ToString() + ",ORD1:" + Ordinal1 + ",ORD2:" + Ordinal2;

            byte[] arrayBytesComando = encoding.GetBytes(comando);
            stream.WriteTimeout = 3000;
            stream.Write(arrayBytesComando, 0, arrayBytesComando.Length);
            stream.Flush();
        }
Esempio n. 2
0
        private string obtenerGateColor(Zone.GateAccessType v_gateType)
        {
            string res = Zone.GateColorAccessForbidden;

            switch (v_gateType)
            {
            case Zone.GateAccessType.Granted:
                res = Zone.GateColorAccessGranted;
                break;

            case Zone.GateAccessType.Forbidden:
                res = Zone.GateColorAccessForbidden;
                break;

            case Zone.GateAccessType.Entrance:
                res = Zone.GateColorAccessEntry;
                break;

            case Zone.GateAccessType.Exit:
                res = Zone.GateColorAccessExit;
                break;
            }

            return(res);
        }
        /// <summary>
        /// Envia la definicion de un segmento al sever
        /// </summary>
        /// <param name="v_gate"></param>
        private void sendGateToServer(string v_gate)
        {
            try
            {
                Zone.GateAccessType tipoPuerta = actualZone.listaPuertas[v_gate].type;

                string Ordinal1            = actualZone.listaPuertas[v_gate].from.Ordinal.ToString();
                string Ordinal2            = actualZone.listaPuertas[v_gate].to.Ordinal.ToString();
                int    lnlEntranceReaderID = actualZone.listaPuertas[v_gate].LNLEntranceReaderID;
                int    lnlExitReaderID     = actualZone.listaPuertas[v_gate].LNLExitReaderID;

                string errDesc = "";
                int    errCode = -1;

                WebServiceAPI.GetInstance().DefineGate(DEVICEID, lnlEntranceReaderID.ToString(), lnlExitReaderID.ToString(), ORGANIZATIONID.ToString(), tipoPuerta.ToString(), Ordinal1, Ordinal2, out errDesc, out errCode);
            }
            catch (Exception ex)
            {
                Tools.GetInstance().DoLog("Excepcion en sendGateToServer: " + ex.Message);
            }
        }
Esempio n. 4
0
        public Dictionary <int, KeyValuePair <Zone.GateAccessType, string> > cargarReadersList(string DeviceID, string orgID)
        {
            Dictionary <int, KeyValuePair <Zone.GateAccessType, string> > listaReaders = new Dictionary <int, KeyValuePair <Zone.GateAccessType, string> >();

            try
            {
                int    errCode = -1;
                string errDesc = "";

                string datosReaders = WebServiceAPI.GetInstance().GetReadersFromVZone(DeviceID, orgID, out errDesc, out errCode);

                Regex regexDatos  = new Regex(@"READERLIST:(.*)");
                Match matchHeader = regexDatos.Match(datosReaders);

                if (matchHeader.Success)
                {
                    string[] dReaders = getMatchData(matchHeader, 1).Split(',');

                    for (int i = 0; i < dReaders.Length; i = i + 3)
                    {
                        int    readerID    = int.Parse(dReaders[i]);
                        string readername  = dReaders[i + 1];
                        string tipoGateStr = dReaders[i + 2];

                        Zone.GateAccessType GateType = (Zone.GateAccessType)Enum.Parse(typeof(Zone.GateAccessType), tipoGateStr);

                        if (!listaReaders.ContainsKey(readerID))
                        {
                            listaReaders.Add(readerID, new KeyValuePair <Zone.GateAccessType, string>(GateType, readername));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Tools.GetInstance().DoLog("Excepcion en cargarReadersList: " + ex.Message);
            }

            return(listaReaders);
        }