Beispiel #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;
        }
Beispiel #2
0
        private void ProcessConfig()
        {
            //Parse the JSON into a JOobject
            JObject JSONObject = JObject.Parse(this._JSON);

            //Dictionary to store function mapping
            Dictionary <string, Action> ProcessMapping = new Dictionary <string, Action>
            {
                { "SeedSimulationFromWTT", (() => this._Request = new SeedSimulationFromWTT(this._AppUserAPIKey, this._AppAPIKey, this._Environment, JSONObject["config"].ToString(), this.Authenticated)) }
            };

            //Map the task requested to the relevant IQueuerRequest object
            ProcessMapping[JSONObject["task"].ToString()]();
            this.Request.Responses.CountChanged += new EventHandler <ExtendedList <QueuerResponse> .ListEventArgs>(RequestResponsesChangeEvent);

            //Execute or Queue
            if (this._ExecuteNow)
            {
                this.SaveToDB();
                ExecuteProcess();
            }
            else
            {
                this.SaveToDB();
            }
        }
Beispiel #3
0
        private void ProcessConfig()
        {
            //Parse the JSON into a JOobject
            JObject JSONObject = JObject.Parse(this._JSON);

            //Dictionary to store function mapping
            Dictionary <string, Action> ProcessMapping = new Dictionary <string, Action>
            {
                { "SeedSimulationFromWTT", (() => this._Request = new SeedSimulationFromWTT(this._Key, this._AppUserAPIKey, this._AppAPIKey, this._Environment, JSONObject["config"].ToString())) }
            };

            //Map the task requested to the relevant IQueuerRequest object
            ProcessMapping[JSONObject["task"].ToString()]();

            //Execute or Queue
            if (this._ExecuteNow)
            {
                Task.Run(() => ExecuteProcess());
            }
            else
            {
                //TODO: Queue the process for later
                this.SaveToDB();
            }
        }
Beispiel #4
0
        internal QueuerProcess(QueuerProcessSurrogate SurrogateQueuerProcess, string Environment)
        {
            this._AppAPIKey     = SurrogateQueuerProcess.AppAPIKey;
            this._AppUserAPIKey = SurrogateQueuerProcess.AppUserAPIKey;
            this._QueueTime     = SurrogateQueuerProcess.QueueTime;
            this._ExecuteNow    = SurrogateQueuerProcess.ExecuteNow;
            this._Key           = SurrogateQueuerProcess.Key;
            this._Environment   = Environment;
            this._ID            = new ObjectId(SurrogateQueuerProcess._id);
            this._Authenticated = SurrogateQueuerProcess.Authenticated;
            string ConfigJSON = JsonConvert.SerializeObject(SurrogateQueuerProcess.Request.Config);

            //Dictionary to store function mapping
            Dictionary <string, Action> ProcessMapping = new Dictionary <string, Action>
            {
                { "GroundFrame.Core.Queuer.SeedSimulationFromWTT", (() => this._Request = new SeedSimulationFromWTT(this.AppUserAPIKey, this.AppAPIKey, this._Environment, ConfigJSON, this.Authenticated)) }
            };

            //Map the task requested to the relevant IQueuerRequest object
            ProcessMapping[SurrogateQueuerProcess.TaskType]();

            //Replace the request responses with those already that were already in the JSON and add the event handler to update the GroundFrame.MongoDB database
            this._Request.ReplaceResponses(SurrogateQueuerProcess.Request.Responses);
            this.Request.Responses.CountChanged += new EventHandler <ExtendedList <QueuerResponse> .ListEventArgs>(RequestResponsesChangeEvent);
        }
Beispiel #5
0
        internal QueuerProcess(QueuerProcessSurrogate SurrogateQueuerProcess, string Environment)
        {
            this._AppAPIKey     = SurrogateQueuerProcess.AppAPIKey;
            this._AppUserAPIKey = SurrogateQueuerProcess.AppUserAPIKey;
            this._QueueTime     = SurrogateQueuerProcess.QueueTime;
            this._ExecuteNow    = SurrogateQueuerProcess.ExecuteNow;
            this._Key           = SurrogateQueuerProcess.Key;
            this._Environment   = Environment;
            this._ID            = new ObjectId(SurrogateQueuerProcess._id);

            //Dictionary to store function mapping
            Dictionary <string, Action> ProcessMapping = new Dictionary <string, Action>
            {
                { "GroundFrame.Queuer.Tasks.SeedSimulationFromWTT", (() => this._Request = new SeedSimulationFromWTT(this._Key, this._AppUserAPIKey, this._AppAPIKey, this._Environment, SurrogateQueuerProcess.Request.Config.ToJson())) }
            };

            //Map the task requested to the relevant IQueuerRequest object
            ProcessMapping[SurrogateQueuerProcess.TaskType]();

            this._Request.ReplaceResponses(SurrogateQueuerProcess.Request.Responses);
        }