/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { IBargainFinderMaxData data = sharedContext.GetResult <IBargainFinderMaxData>(InputDataSharedContextKey); if (data == null) { throw new ArgumentException("No data found under key: " + InputDataSharedContextKey); } var security = await this.sessionPool.TakeSessionAsync(sharedContext.ConversationId); var service = this.soapServiceFactory.CreateBargainFinderMaxService(sharedContext.ConversationId, security); var request = this.CreateRequest(data); sharedContext.AddSerializedResultXML(RequestXmlSharedContextKey, request); try { var result = service.BargainFinderMaxRQ(request); sharedContext.AddSerializedResultXML(ResponseXmlSharedContextKey, result); EnhancedAirBookData enhancedAirBookData = this.CreateEnhancedAirBookData(result); sharedContext.AddResult(EnhancedAirBookActivity.InputDataSharedContextKey, enhancedAirBookData); return(new PassengerDetailsContactActivity(this.soapServiceFactory, this.sessionPool)); } catch (Exception ex) { sharedContext.AddResult(CommonConstants.ExceptionSharedContextKey, ex); sharedContext.IsFaulty = true; this.sessionPool.ReleaseSession(sharedContext.ConversationId); return(null); } }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { TravelItineraryReadRQ request = new TravelItineraryReadRQ { Version = "3.6.0", MessagingDetails = new TravelItineraryReadRQMessagingDetails { SubjectAreas = new[] { "PNR" } }, UniqueID = new TravelItineraryReadRQUniqueID { ID = sharedContext.GetResult <string>(TravelItineraryRefContextKey) } }; var security = await this.sessionPool.TakeSessionAsync(sharedContext.ConversationId); var service = this.soapServiceFactory.CreateTravelItineraryReadService(sharedContext.ConversationId, security); sharedContext.AddSerializedResultXML(RequestXmlSharedContextKey, request); try { TravelItineraryReadRS response = service.TravelItineraryReadRQ(request); sharedContext.AddResult(SharedContextKey, response); sharedContext.AddSerializedResultXML(ResponseXmlSharedContextKey, response); return(null); } catch (Exception ex) { sharedContext.AddResult(SharedContextKey, ex); sharedContext.IsFaulty = true; this.sessionPool.ReleaseSession(sharedContext.ConversationId); return(null); } }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { var security = await this.sessionPool.TakeSessionAsync(sharedContext.ConversationId); var service = this.soapServiceFactory.CreatePassengerDetailsService(sharedContext.ConversationId, security); IPassengerDetailsActivityData data = sharedContext.GetResult <IPassengerDetailsActivityData>(InputDataSharedContextKey); PassengerDetailsRQ request = this.CreateRequest(data); sharedContext.AddSerializedResultXML(RequestXmlSharedContextKey, request); try { PassengerDetailsRS response = service.PassengerDetailsRQ(request); sharedContext.AddResult(SharedContextKey, response); sharedContext.AddSerializedResultXML(ResponseXmlSharedContextKey, response); sharedContext.AddResult(TravelItineraryReadActivity.TravelItineraryRefContextKey, response.ItineraryRef.ID); return(new TravelItineraryReadActivity(this.soapServiceFactory, this.sessionPool)); } catch (Exception ex) { sharedContext.AddResult(CommonConstants.ExceptionSharedContextKey, ex); sharedContext.IsFaulty = true; this.sessionPool.ReleaseSession(sharedContext.ConversationId); return(null); } }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public Task <IActivity> RunAsync(SharedContext sharedContext) { sharedContext.AddResult(BargainFinderMaxSoapActivity.InputDataSharedContextKey, this.data); sharedContext.AddResult(PassengerDetailsContactActivity.InputDataSharedContextKey, this.data); sharedContext.AddResult(PassengerDetailsAgencyActivity.InputDataSharedContextKey, this.data); IActivity nextActivity = new BargainFinderMaxSoapActivity(this.soapServiceFactory, this.sessionPool); return(Task.FromResult(nextActivity)); }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { IgnoreTransactionRQ request = new IgnoreTransactionRQ { Version = "2.0.0" }; sharedContext.AddSerializedResultXML(RequestXmlSharedContextKey, request); Security security = await this.sessionPool.TakeSessionAsync(sharedContext.ConversationId); IgnoreTransactionService service = this.soapServiceFactory.CreateIgnoreTransactionService(sharedContext.ConversationId, security); try { IgnoreTransactionRS response = service.IgnoreTransactionRQ(request); sharedContext.AddSerializedResultXML(ResponseXmlSharedContextKey, response); } catch (Exception ex) { sharedContext.AddResult(CommonConstants.ExceptionSharedContextKey, ex); } sharedContext.IsFaulty = true; this.sessionPool.ReleaseSession(sharedContext.ConversationId); return(null); }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async System.Threading.Tasks.Task <IActivity> RunAsync(SharedContext sharedContext) { IDictionary <string, string> queryDictionary = new Dictionary <string, string> { { "origin", this.data.Origin }, { "destination", this.data.Destination }, { "lengthofstay", this.data.LengthOfStay.ToString() }, { "pointofsalecountry", this.data.PointOfSaleCountry }, { "departuredate", this.data.DepartureDate.ToString("yyyy-MM-dd") } }; if (this.data.MinFare.HasValue) { queryDictionary.Add("minfare", this.data.MinFare.Value.ToString()); } if (this.data.MaxFare.HasValue) { queryDictionary.Add("maxfare", this.data.MaxFare.Value.ToString()); } var httpResponse = await this.restClient.GetAsync <LeadPriceCalendarRS>(Endpoint, queryDictionary); sharedContext.AddRestResult(SharedContextKey, httpResponse, true, ResponseJsonSharedContextKey); sharedContext.AddResult(RequestUrlSharedContextKey, httpResponse.RequestUri); return(this.lastInWorkflow ? null : new InstaFlightsActivity(this.restClient)); }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { LeadPriceCalendarRS leadPriceCalendarRS = sharedContext.GetResult(LeadPriceCalendarActivity.SharedContextKey) as LeadPriceCalendarRS; HttpResponse <InstaFlightRS> httpResponse; if (this.data != null) { Dictionary <string, string> queryDictionary = new Dictionary <string, string> { { "origin", this.data.Origin }, { "destination", this.data.Destination }, { "departuredate", this.data.DepartureDate.ToString("yyyy-MM-dd") }, { "returndate", this.data.ReturnDate.ToString("yyyy-MM-dd") } }; httpResponse = await this.restClient.GetAsync <InstaFlightRS>(Endpoint, queryDictionary); } else { string uri = leadPriceCalendarRS.FareInfo.SelectMany(fi => fi.Links).Where(l => l.Rel == "shop").Select(l => l.Href).First(); httpResponse = await this.restClient.GetAsync <InstaFlightRS>(uri); } sharedContext.AddRestResult(SharedContextKey, httpResponse, true, JsonSharedContextKey); sharedContext.AddResult(RequestUriSharedContextKey, httpResponse.RequestUri); return(null); }
/// <summary> /// Adds the REST result (either deserialized model or error message) to shared context. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="sharedContext">The shared context.</param> /// <param name="key">The shared context key.</param> /// <param name="httpResponse">The HTTP response.</param> /// <param name="allowedNotFound">if set to <c>true</c>, then 404 Not Found is not treated as error.</param> /// <param name="jsonKey">The shared context key under which the reformatted JSON response will be placed.</param> public static void AddRestResult <TResult>( this SharedContext sharedContext, string key, HttpResponse <TResult> httpResponse, bool allowedNotFound = false, string jsonKey = null) { if (httpResponse.IsSuccess || (allowedNotFound && httpResponse.StatusCode == HttpStatusCode.NotFound)) { sharedContext.AddResult(key, httpResponse.Value); sharedContext.AddSerializedResultJson(jsonKey, httpResponse.Value); } else { sharedContext.AddResult(key, httpResponse.Message); sharedContext.IsFaulty = true; } }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { BargainFinderMaxRQ request = this.CreateRequest(this.data); sharedContext.AddSerializedResultJson(RequestJsonSharedContextKey, request); var httpResponse = await this.restClient.PostAsync <BargainFinderMaxRQ, BargainFinderMaxRS>(Endpoint, request); sharedContext.AddRestResult <BargainFinderMaxRS>(SharedContextKey, httpResponse, false, ResponseJsonSharedContextKey); sharedContext.AddResult(RequestUrlSharedContextKey, httpResponse.RequestUri); return(null); }
/// <summary> /// Runs the activity asynchronously. /// </summary> /// <param name="sharedContext">The shared context.</param> /// <returns> /// Next activity to be run or <c>null</c> if last in flow. /// </returns> public async Task <IActivity> RunAsync(SharedContext sharedContext) { var httpResult = await this.restClient.GetAsync <TravelSeasonalityAirportsLookupRS>(Endpoint); List <DestinationLocation> destinations = new List <DestinationLocation>(); if (httpResult.IsSuccess) { destinations.AddRange(httpResult.Value.DestinationLocations.Select(d => d.DestinationLocation)); } sharedContext.AddResult(SharedContextKey, destinations); return(null); }
/// <summary> /// Adds the result serialized to XML. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="sharedContext">The shared context.</param> /// <param name="sharedContextKey">The shared context key.</param> /// <param name="result">The result.</param> public static void AddSerializedResultXML <TResult>(this SharedContext sharedContext, string sharedContextKey, TResult result) { XmlSerializer serializer = new XmlSerializer(typeof(TResult)); XmlWriterSettings settings = new XmlWriterSettings { Indent = true }; using (StringWriter writer = new StringWriter()) using (XmlWriter xmlWriter = XmlWriter.Create(writer, settings)) { serializer.Serialize(xmlWriter, result); string resultXML = writer.ToString(); sharedContext.AddResult(sharedContextKey, resultXML); } }
/// <summary> /// Adds the result serialized as JSON to the shared context. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="sharedContext">The shared context.</param> /// <param name="key">The key.</param> /// <param name="result">The result.</param> public static void AddSerializedResultJson <TResult>(this SharedContext sharedContext, string key, TResult result) { string json = JsonConvert.SerializeObject(result, Formatting.Indented); sharedContext.AddResult(key, json); }