예제 #1
0
        //metodo que registra la salida punto de partida para el evento
        public void registraSalida(string soleada)
        {
            reader_status = reader.getReaderStatus();

            DateTime dt = DateTime.Now;

            this.ponReloj(dt);

            string sql = "INSERT INTO salida (oleada,fecha_hora_ini_local,milis_ini_local,fecha_hora_ini_antena,milis_ini_antena) VALUES ('" + soleada + "','" + dt.ToString("yyyy-MM-dd HH:mm:ss") + "'," + dt.Millisecond + ",'" + reader_status.UTC_Time.ToUniversalTime() + "'," + reader_status.UTC_Time.ToUniversalTime().Millisecond + ");";

            MySqlConnection dbConn = new MySqlConnection(strConexion);
            dbConn.Open();
            MySqlCommand cmd = new MySqlCommand(sql, dbConn);
            cmd.ExecuteNonQuery();

            dbConn.Close();
            dbConn = null;
        }
예제 #2
0
        public READER_STATUS getReaderStatus()
        {
            string cmd = "getReaderStatus";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            READER_STATUS status = new READER_STATUS();
            int year, month, day, hour, minute, second;

            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command={1}&username={2}&password={3}", httpUri.AbsoluteUri, cmd, LoginName, LoginPassword));

                string resp = sendHTTPRequest(sbReq.ToString());
                if (resp == null) return null;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resp);
                if (isCSLResponse(ref doc, cmd) == false) return null;

                XmlNode node = doc.SelectSingleNode("CSL/Model");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Model = atts["name"].InnerXml;
                    status.Protocol_Supported = atts["protocol"].InnerXml;
                }
                else
                {
                    parseErrorCode(ref doc);
                    return null;
                }

                node = doc.SelectSingleNode("CSL/Reader");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Description = atts["desc"].InnerXml;
                    status.ID = atts["reader_id"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/ReaderVersion");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.DSP_Version = atts["dsp"].InnerXml;
                    status.EdgeServer_Version = atts["edgeServer"].InnerXml;
                    status.FPGA_Version = atts["fpga"].InnerXml;
                    status.LibMapi_Version = atts["libMapi"].InnerXml;
                    status.Middleware_Version = atts["middleware"].InnerXml;
                    status.ModemController_Version = atts["modemController"].InnerXml;
                    status.Firmware_Version = atts["version"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/Timezone");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.DaylightSaving = atts["daylight_saving"].InnerXml;
                    status.TimeZone = atts["tz"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/Logout");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Session_Timeout = atts["time"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/UserStatus");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Client_IP = atts["client_ip"].InnerXml;
                    status.Host_IP = atts["host_ip"].InnerXml;
                    status.User_Level = atts["level"].InnerXml;
                    status.Login_Status = atts["login_status"].InnerXml;
                    status.Session_Id = atts["session_id"].InnerXml;
                    status.Username = atts["username"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/AccessMode");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Access_Mode = atts["mode"].InnerXml;
                    status.Access_Mode_Description = atts["name"].InnerXml;
                }

                node = doc.SelectSingleNode("CSL/OperationProfile");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    status.Antenna_Ports = atts["antennaPort"].InnerXml;
                    status.Capture_Mode = atts["captureMode"].InnerXml;
                    status.Profile_ID = atts["profile_id"].InnerXml;
                    status.Trigger_Methed = atts["triggerMethod"].InnerXml;
                }

                status.Active_Event = new System.Collections.ArrayList();
                node = doc.SelectSingleNode("CSL/ActiveEventList/Event");
                while (node != null)
                {
                    EVENT_INFO eventInfo = new EVENT_INFO();
                    XmlAttributeCollection atts = node.Attributes;
                    eventInfo.id = atts["event_id"].InnerXml;
                    eventInfo.desc = atts["desc"].InnerXml;
                    status.Active_Event.Add(eventInfo);
                    node = node.NextSibling;
                }

                node = doc.SelectSingleNode("CSL/CurrentLocalTime");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    year = int.Parse(atts["year"].InnerXml);
                    month = int.Parse(atts["month"].InnerXml);
                    day = int.Parse(atts["day"].InnerXml);
                    hour = int.Parse(atts["hour"].InnerXml);
                    minute = int.Parse(atts["minute"].InnerXml);
                    second = int.Parse(atts["second"].InnerXml);
                    status.Local_Time = new DateTime(year, month, day, hour, minute, second);
                }

                node = doc.SelectSingleNode("CSL/CurrentUTCTime");
                if (node != null)
                {
                    XmlAttributeCollection atts = node.Attributes;
                    year = int.Parse(atts["year"].InnerXml);
                    month = int.Parse(atts["month"].InnerXml);
                    day = int.Parse(atts["day"].InnerXml);
                    hour = int.Parse(atts["hour"].InnerXml);
                    minute = int.Parse(atts["minute"].InnerXml);
                    second = int.Parse(atts["second"].InnerXml);
                    status.UTC_Time = new DateTime(year, month, day, hour, minute, second);
                }

                ErrorCode = ERR_CODE_NO_ERROR;
                ErrorMsg = "";
                return status;
            }
            catch
            {
                ErrorCode = ERR_CODE_UNKNOWN_ERROR;
                ErrorMsg = ERR_MSG_UNKNOWN_ERROR;
                return null;
            }
        }