Ejemplo n.º 1
0
        private void GetFromDB()
        {
            //BSON document to store the data from the GroundFrame.MongoDB
            BsonDocument Document;

            using (GFMongoConnector MongoConnector = Globals.GetGFMongoConnector(this._Environment))
            {
                IMongoDatabase db         = MongoConnector.MongoClient.GetDatabase("groundframeQueuer");
                var            collection = db.GetCollection <BsonDocument>("processQueue");

                string filter = string.Format(@"{{ key: '{0}'}}", this._Key);
                Document = collection.Find(filter).FirstOrDefault();
            }

            string JSON = JsonConvert.SerializeObject(BsonTypeMapper.MapToDotNetValue(Document));

            QueuerProcess TempQueuerProcess = JsonConvert.DeserializeObject <QueuerProcess>(JSON, new QueuerProcessConverter(this._Environment));

            this._Request       = TempQueuerProcess.Request;
            this._Key           = TempQueuerProcess.Key;
            this._AppAPIKey     = TempQueuerProcess.AppAPIKey;
            this._AppUserAPIKey = TempQueuerProcess.AppUserAPIKey;
            this._Authenticated = TempQueuerProcess.Authenticated;
            this._ID            = TempQueuerProcess.ID;
            this._ExecuteNow    = TempQueuerProcess.ExecuteNow;
            this._QueueTime     = TempQueuerProcess.QueueTime;
            this._Authenticated = TempQueuerProcess.Authenticated;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the QueuerProess object to the GroundFrame.MongoDB
        /// </summary>
        public void SaveToDB()
        {
            //Get the groundframeQueuer database

            using GFMongoConnector MongoConnector = Globals.GetGFMongoConnector(this._Environment);
            IMongoDatabase db = MongoConnector.MongoClient.GetDatabase("groundframeQueuer");
            //Get the processQueue collection
            var collection = db.GetCollection <BsonDocument>("processQueue");

            BsonDocument ProcessBSON; //Variable to store the BSON

            //If this _ID is empty then it's a new record
            if (this._ID == ObjectId.Empty)
            {
                //Gnerate a new ID
                this._ID    = ObjectId.GenerateNewId();
                ProcessBSON = this.ToBSON();
                //Insert the document
                collection.InsertOne(ProcessBSON);
            }
            else
            {
                var filter = Builders <BsonDocument> .Filter.Eq("key", this.Key);

                ProcessBSON = this.ToBSON();
                collection.ReplaceOne(filter, ProcessBSON);
            }
        }