Exemple #1
0
        public IEnumerable <string> ListLogTypes(ObjectId householdId, DateTime start, DateTime end,
                                                 string deviceType = null)
        {
            FilterDefinition <BsonDocument> filterDefinition =
                Builders <BsonDocument> .Filter.Eq("HouseholdId", householdId);

            filterDefinition &= Builders <BsonDocument> .Filter.Gte("Timestamp", start);

            filterDefinition &= Builders <BsonDocument> .Filter.Lte("Timestamp", end);

            if (deviceType != null)
            {
                filterDefinition &= Builders <BsonDocument> .Filter.Gte("DeviceType", deviceType);
            }

            IEnumerable <BsonDocument> documentList = Uow.ExecuteRetrieveAll(CollectionName, filterDefinition);
            IEnumerable <string>       logTypeList  = null;

            if (documentList != null)
            {
                logTypeList = documentList.Select(x => x.GetValue("LogType").AsString).ToList();
            }

            return(logTypeList);
        }
Exemple #2
0
        public IEnumerable <AppLog> SelectQuery(ObjectId householdId, DateTime start, DateTime end,
                                                string logType = null, string deviceType = null)
        {
            FilterDefinition <BsonDocument> filterDefinition =
                Builders <BsonDocument> .Filter.Eq("HouseholdId", householdId);

            filterDefinition &= Builders <BsonDocument> .Filter.Gte("Timestamp", start);

            filterDefinition &= Builders <BsonDocument> .Filter.Lte("Timestamp", end);

            if (logType != null)
            {
                filterDefinition &= Builders <BsonDocument> .Filter.Gte("LogType", logType);
            }

            if (deviceType != null)
            {
                filterDefinition &= Builders <BsonDocument> .Filter.Gte("DeviceType", deviceType);
            }

            IEnumerable <BsonDocument> documentList = Uow.ExecuteRetrieveAll(CollectionName, filterDefinition);
            List <AppLog> appLogList = new List <AppLog>();

            foreach (BsonDocument document in documentList)
            {
                appLogList.Add(DeserializeDocument <AppLog>(document));
            }

            return(appLogList);
        }
        public IEnumerable <T> SelectAll()
        {
            IEnumerable <BsonDocument> documentList =
                Uow.ExecuteRetrieveAll(CollectionName, Builders <BsonDocument> .Filter.Empty);
            List <T> objectList = new List <T>();

            foreach (BsonDocument document in documentList)
            {
                objectList.Add(DeserializeDocument <T>(document));
            }

            return(objectList);
        }
        public List <Device> SelectByName(string name)
        {
            FilterDefinition <BsonDocument> filterDefinition = Builders <BsonDocument> .Filter.Eq("Name", name);

            IEnumerable <BsonDocument> documentList = Uow.ExecuteRetrieveAll(CollectionName, filterDefinition);
            List <Device> deviceList = new List <Device>();

            foreach (BsonDocument document in documentList)
            {
                deviceList.Add(DeserializeDocument <Device>(document));
            }

            return(deviceList);
        }
        public List <Device> SelectByHouseholdId(ObjectId householdId)
        {
            FilterDefinition <BsonDocument> filterDefinition = Builders <BsonDocument> .Filter.Eq("HouseholdId", householdId);

            IEnumerable <BsonDocument> documentList = Uow.ExecuteRetrieveAll(CollectionName, filterDefinition);
            List <Device> deviceList = new List <Device>();

            foreach (BsonDocument document in documentList)
            {
                deviceList.Add(DeserializeDocument <Device>(document));
            }

            return(deviceList);
        }
        public IEnumerable <DeviceLog> SelectFromDateRange(ObjectId householdId, DateTime start, DateTime end)
        {
            FilterDefinition <BsonDocument> filterDefinition =
                Builders <BsonDocument> .Filter.Eq("HouseholdId", householdId);

            filterDefinition &= Builders <BsonDocument> .Filter.Gte("DateTime", start);

            filterDefinition &= Builders <BsonDocument> .Filter.Lte("DateTime", end);

            IEnumerable <BsonDocument> documentList  = Uow.ExecuteRetrieveAll(CollectionName, filterDefinition);
            List <DeviceLog>           deviceLogList = new List <DeviceLog>();

            foreach (BsonDocument document in documentList)
            {
                deviceLogList.Add(DeserializeDocument <DeviceLog>(document));
            }

            return(deviceLogList);
        }