Esempio n. 1
0
        public bool InsertMachineProperties(Machine prmMachine)
        {
            bool resultMachineInsert = false;

            try
            {
                MongoHelperDAL.ConnectToMongoService();
                MongoHelperDAL.machineCollection = MongoHelperDAL.database.GetCollection <Machine>("MachineProperties");
                MongoHelperDAL.machineCollection.InsertOneAsync(prmMachine);
                resultMachineInsert = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Ha ocurrido un error insertando propiedades: " + ex.ToString());
            }
            return(resultMachineInsert);
        }
Esempio n. 2
0
        public List <Machine> GetMachinePropertiesByIP(string prmIPAddress)
        {
            List <Machine> listMachineProperties = new List <Machine>();

            try
            {
                MongoHelperDAL.ConnectToMongoService();
                MongoHelperDAL.machineCollection = MongoHelperDAL.database.GetCollection <Machine>("MachineProperties");
                var filter = Builders <Machine> .Filter.Ne("Ip", "");

                listMachineProperties = MongoHelperDAL.machineCollection.Find(filter).ToList();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Ha ocurrido un error insertando propiedades: " + ex.ToString());
            }
            return(listMachineProperties);
        }