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); }
/// <summary> /// Override method to deserialize a JSON string into a QueuerProcess /// </summary> /// <returns></returns> public override object ReadJson(JsonReader Reader, Type ObjectType, object ExistingValue, JsonSerializer Serializer) { //Validate Arguments //if (Serializer == null) //{ // throw new ArgumentNullException(ExceptionHelper.GetStaticException("GeneralNullArgument", new string[] { "Serializer" }, new System.Globalization.CultureInfo("en-GB"))); //} //if (Reader == null) //{ // throw new ArgumentNullException(ExceptionHelper.GetStaticException("GeneralNullArgument", new string[] { "Reader" }, new System.Globalization.CultureInfo("en-GB"))); //} //Deserialize reader into surrogate object QueuerProcessSurrogate SurrogateQueuerProcess = Serializer.Deserialize <QueuerProcessSurrogate>(Reader); return(new QueuerProcess(SurrogateQueuerProcess, this._Environment)); }