Exemple #1
0
        public async Task <ManagementObjectSearcher> GetCardHolder(string idLenel)
        {
            ManagementScope          cardHolderScope    = _dataConduITMgr.GetManagementScope();
            ObjectQuery              cardHolderSearcher = new ObjectQuery("SELECT * FROM Lnl_CardHolder WHERE ID = " + idLenel);
            ManagementObjectSearcher getCardHolder      = new ManagementObjectSearcher(cardHolderScope, cardHolderSearcher);

            try { return(getCardHolder); }
            catch (Exception ex) { throw new Exception(ex.Message); }
        }
Exemple #2
0
        public async Task <ManagementObjectSearcher> GetBuildings(string path, string user, string password, int?id)
        {
            ManagementScope buildingScope    = _dataConduITMgr.GetManagementScope(path, user, password);
            ObjectQuery     buildingSearcher = new ObjectQuery();

            if (id != null)
            {
                buildingSearcher.QueryString = @"SELECT * FROM Lnl_Edificio WHERE ID = " + id;
            }
            else
            {
                buildingSearcher.QueryString = @"SELECT * FROM Lnl_Edificio";
            }

            ManagementObjectSearcher getBuildings = new ManagementObjectSearcher(buildingScope, buildingSearcher);

            try { return(getBuildings); }
            catch (Exception ex) { throw new Exception("error: " + ex.Message + " " + ex.StackTrace + " " + ex.InnerException); }
        }
Exemple #3
0
        public async Task <object> AddBadge(AddBadge_DTO newBadge, string path, string user, string pass)
        {
            try
            {
                ManagementScope badgeScope = _dataConduITMgr.GetManagementScope(path, user, pass);

                ManagementClass badgeClass = new ManagementClass(badgeScope, new ManagementPath("Lnl_Badge"), null);

                ManagementObject newBadgeInstance = badgeClass.CreateInstance();

                string fechaDesactivacion = newBadge.fechaActivacion.ToString("yyyyMMdd") + "000000.000000-300";

                newBadgeInstance["ID"]          = newBadge.id;
                newBadgeInstance["PERSONID"]    = newBadge.personId;
                newBadgeInstance["STATUS"]      = newBadge.status;     //Active
                newBadgeInstance["TYPE"]        = newBadge.type;       // Employee
                newBadgeInstance["DEST_EXEMPT"] = newBadge.dest_exemp; // Sometimes teh value is required
                newBadgeInstance["ACTIVATE"]    = newBadge.fechaActivacion.ToString("yyyyMMdd") + "000000.000000-300";
                newBadgeInstance["DEACTIVATE"]  = newBadge.fechaDesactivacion.ToString("yyyyMMdd") + "000000.000000-300";

                ManagementBaseObject inParams = badgeClass.GetMethodParameters("AddBadge");
                inParams.Properties["BadgeIn"].Value = newBadgeInstance;

                //Execute the method
                ManagementBaseObject outParamObject = badgeClass.InvokeMethod("AddBadge", inParams, null);

                if (outParamObject != null)
                {
                    //Display results
                    object outObj = outParamObject["BadgeOut"];
                    ManagementBaseObject addedBadge = (ManagementBaseObject)outObj;
                    return(addedBadge["BADGEKEY"]);
                }
                else
                {
                    throw new Exception("No se pudo crear el nuevo Badge");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #4
0
        public async Task <ManagementObjectSearcher> GetCardHolder(string idLenel, string path, string user, string password)
        {
            ManagementScope          cardHolderScope    = _dataConduITMgr.GetManagementScope(path, user, password);
            ObjectQuery              cardHolderSearcher = new ObjectQuery(@"SELECT * FROM Lnl_CardHolder WHERE OPHONE = '" + idLenel + "'");
            ManagementObjectSearcher getCardHolder      = new ManagementObjectSearcher(cardHolderScope, cardHolderSearcher);

            try { return(getCardHolder); }
            catch (Exception ex) { throw new Exception("error: " + ex.Message + " " + ex.StackTrace + " " + ex.InnerException); }
        }
        public async Task <ManagementObjectSearcher> GetCardHolder(string documento, string ssno,
                                                                   string path, string user, string password)
        {
            ManagementScope cardHolderScope    = _dataConduITMgr.GetManagementScope(path, user, password);
            ObjectQuery     cardHolderSearcher =
                new ObjectQuery(@"SELECT * FROM Lnl_CardHolder WHERE OPHONE = '" + documento + /*"' AND SSNO = '" + ssno +*/ "'");
            ManagementObjectSearcher getCardHolder = new ManagementObjectSearcher(cardHolderScope, cardHolderSearcher);

            try { return(getCardHolder); }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #6
0
        public async Task <ManagementObjectSearcher> GetReaderData(string panelID, string readerID,
                                                                   string path, string user, string pass)
        {
            ManagementScope readerScope = _dataConduITMgr.GetManagementScope(path, user, pass);

            if (readerScope == null)
            {
                throw new Exception("No fue posible establecer conexion con OnGuard");
            }

            ObjectQuery readerSearcher = new ObjectQuery("SELECT * FROM Lnl_Reader WHERE PanelID='" + panelID + "' " +
                                                         "AND ReaderID='" + readerID + "'");
            ManagementObjectSearcher getReader = new ManagementObjectSearcher(readerScope, readerSearcher);

            try { return(getReader); }
            catch (Exception ex) { throw new Exception(ex.Message); }
        }