public override void Process(PipelineStep pipelineStep, PipelineContext pipelineContext) { var logger = pipelineContext.PipelineBatchContext.Logger; if (CanProcess(pipelineStep, pipelineContext)) { var identifierValue = GetIdentifierValue(pipelineStep, pipelineContext); if (string.IsNullOrWhiteSpace(identifierValue)) { logger.Error("Pipeline step processing will abort because no identifier value was resolved. (pipeline step: {0})", (object)pipelineStep.Name); } else { var readJsonObjectsSettings = pipelineStep.GetPlugin <ReadJsonObjectsSettings>(); var endpoint = pipelineStep.GetEndpointSettings().EndpointFrom; JObject jObject = ReadJsonData(endpoint, pipelineContext, readJsonObjectsSettings.Api, identifierValue); var resolvedObject = ExtractObject(readJsonObjectsSettings, logger, jObject); SaveResolvedObject(pipelineStep, pipelineContext, resolvedObject); } } }
public void PrependStep(PipelineStep <TKey, TMessage> step) { var currentHead = _head; _head = step; _head.Next = currentHead; }
public virtual ApiPipelineStepServerResponseModel MapEntityToModel( PipelineStep item) { var model = new ApiPipelineStepServerResponseModel(); model.SetProperties(item.Id, item.Name, item.PipelineStepStatusId, item.ShipperId); if (item.PipelineStepStatusIdNavigation != null) { var pipelineStepStatusIdModel = new ApiPipelineStepStatusServerResponseModel(); pipelineStepStatusIdModel.SetProperties( item.PipelineStepStatusIdNavigation.Id, item.PipelineStepStatusIdNavigation.Name); model.SetPipelineStepStatusIdNavigation(pipelineStepStatusIdModel); } if (item.ShipperIdNavigation != null) { var shipperIdModel = new ApiEmployeeServerResponseModel(); shipperIdModel.SetProperties( item.ShipperIdNavigation.Id, item.ShipperIdNavigation.FirstName, item.ShipperIdNavigation.IsSalesPerson, item.ShipperIdNavigation.IsShipper, item.ShipperIdNavigation.LastName); model.SetShipperIdNavigation(shipperIdModel); } return(model); }
protected override void ReadData( Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } if (pipelineStep == null) { throw new ArgumentNullException("pipelinestep"); } if (pipelineContext == null) { throw new ArgumentNullException("pipelineContext"); } var logger = pipelineContext.PipelineBatchContext.Logger; // //get the file path from the plugin on the endpoint var settings = endpoint.GetDatabaseSettings(); if (settings == null) { return; } if (string.IsNullOrWhiteSpace(settings.ConnectionString)) { logger.Error( "No connection string is specified on the endpoint. " + "(pipeline step: {0}, endpoint: {1})", pipelineStep.Name, endpoint.Name); return; } var querySettings = pipelineStep.GetPlugin <QuerySettings>(); if (string.IsNullOrWhiteSpace(querySettings.Query)) { logger.Error( "No query has been configured" + "(pipeline step: {0}, endpoint: {1})", pipelineStep.Name, endpoint.Name); return; } SynchronizationSettings synchronizationSettings = pipelineContext.GetSynchronizationSettings(); Dictionary <string, string> source = null; if (synchronizationSettings != null) { source = synchronizationSettings.Source as Dictionary <string, string>; } ////add the data that was read from the file to a plugin var dataSettings = new IterableDataSettings(GetEnumerable(settings.ConnectionType, settings.ConnectionString, querySettings.Query, source, logger)); pipelineContext.Plugins.Add(dataSettings); }
//protected override void ReadData(Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext, ILogger logger) //{ // if (endpoint == null) // { // throw new ArgumentNullException(nameof(endpoint)); // } // if (pipelineStep == null) // { // throw new ArgumentNullException(nameof(pipelineStep)); // } // if (pipelineContext == null) // { // throw new ArgumentNullException(nameof(pipelineContext)); // } // var redditSettings = endpoint.GetPlugin<RedditSettings>(); // if (redditSettings != null) // { // pipelineContext.PipelineBatchContext.Logger.Info( // "Creating Reddit Items for:" + redditSettings.BlogPath); // RedditFeed(pipelineContext, redditSettings.BlogPath); // pipelineContext.PipelineBatchContext.Logger.Info( // "Done Creating Reddit Items for:" + redditSettings.BlogPath); // } //} //private void RedditFeed(PipelineContext pipelineContext, string blogpath) //{ // var reddit = new Reddit(); // var subreddit = reddit.GetSubreddit(blogpath); // var dataSettings = new IterableDataSettings(subreddit.New.Take(25)); // pipelineContext.AddPlugin(dataSettings); //} protected override void ReadData(Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext, ILogger logger) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (pipelineStep == null) { throw new ArgumentNullException(nameof(pipelineStep)); } if (pipelineContext == null) { throw new ArgumentNullException(nameof(pipelineContext)); } var redditSettings = endpoint.GetPlugin <RedditSettings>(); if (redditSettings != null) { pipelineContext.PipelineBatchContext.Logger.Info( "Creating Reddit Items for:" + redditSettings.BlogPath); RedditFeed(pipelineContext, redditSettings.BlogPath); pipelineContext.PipelineBatchContext.Logger.Info( "Done Creating Reddit Items for:" + redditSettings.BlogPath); } }
protected virtual void ProcessPipelines(PipelineStep pipelineStep, ICollection <Pipeline> subPipelines, PipelineContext pipelineContext) { if (pipelineStep == null) { throw new ArgumentNullException("pipelineStep"); } if (subPipelines == null) { throw new ArgumentNullException("subPipelines"); } if (pipelineContext == null) { throw new ArgumentNullException("pipelineContext"); } ILogger logger = pipelineContext.PipelineBatchContext.Logger; if (!subPipelines.Any <Pipeline>()) { logger.Error("Pipeline step processing will abort because no pipelines are assigned to the pipeline step. (pipeline step: {0})", (object)pipelineStep.Name); } else { List <Pipeline> pipelineList = new List <Pipeline>(); foreach (Pipeline subPipeline in (IEnumerable <Pipeline>)subPipelines) { RunSubPipelines(pipelineContext, subPipeline); } } }
protected override void ReadData(Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext, ILogger logger) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (pipelineStep == null) { throw new ArgumentNullException(nameof(pipelineStep)); } if (pipelineContext == null) { throw new ArgumentNullException(nameof(pipelineContext)); } try { var settings = endpoint.GetWordpressSettings(); if (settings == null) { logger.Error("Empty WordPress settings"); return; } List <Category> categories = _wordpressService.Read <Category>(settings.CategoriesUrl, logger); var categoriesData = new IterableDataSettings(categories); pipelineContext.AddPlugin(categoriesData); } catch (Exception ex) { logger.Error($"Error in ReadCategoriesStepProcessor: {ex.InnerException}"); pipelineContext.CriticalError = true; } }
public override bool CanProcess(PipelineStep pipelineStep, PipelineContext pipelineContext) { var canProcess = false; var logger = pipelineContext.PipelineBatchContext.Logger; if (base.CanProcess(pipelineStep, pipelineContext)) { var identifierSettings = pipelineStep.GetResolveIdentifierSettings(); //NOTE FHE RequiredPipelineStepPlugins if (identifierSettings.IdentifierValueAccessor == null) { logger.Error("Unable to get value accessor for identifier. (pipeline step: {0})", pipelineStep.Name); } else { var identifierValueReader = identifierSettings.IdentifierValueAccessor.ValueReader; if (identifierValueReader == null) { logger.Error("Unable to get value reader for identifier. (pipeline step: {0})", pipelineStep.Name); } else { canProcess = true; } } } return(canProcess); }
public async Task It_returns_same_value_to_concurrent_requests() { var seed = 0; var barrier = new Barrier(3); var producer = new PipelineStep <int>(() => Task.FromResult(++seed)); var firstConsumer = Task.Run(() => { barrier.SignalAndWait(); return(producer.GetLatestAsync()); }); var secondConsumer = Task.Run(() => { barrier.SignalAndWait(); return(producer.GetLatestAsync()); }); var thirdConsumer = Task.Run(() => { barrier.SignalAndWait(); return(producer.GetLatestAsync()); }); var values = await Task.WhenAll(firstConsumer, secondConsumer, thirdConsumer); values.Should().HaveCount(3).And.OnlyContain(i => i == 1); }
private void AddCreateSitecoreItemSettings(ItemModel source, PipelineStep step) { //The default ResolveSitecoreItemSettings sitecoreItemSettings = new ResolveSitecoreItemSettings() { ParentItemIdItem = this.GetGuidValue(source, "ParentForItem"), MatchingFieldValueAccessor = this.ConvertReferenceToModel <IValueAccessor>(source, "MatchingFieldValueAccessor"), TemplateForNewItem = this.GetGuidValue(source, "TemplateForNewItem"), ItemNameValueAccessor = this.ConvertReferenceToModel <IValueAccessor>(source, "ItemNameValueAccessor") }; step.Plugins.Add((IPlugin)sitecoreItemSettings); //My endpoint and Language var settings = new ResolveSitecoreItemWithLanguageSettings(); var endpointFrom = base.ConvertReferenceToModel <Endpoint>(source, ResolveSitecoreItemWithLanguageStepItemModel.EndpointFrom); if (endpointFrom != null) { settings.EndpointFrom = endpointFrom; } settings.LanguageField = base.GetStringValue(source, ResolveSitecoreItemWithLanguageStepItemModel.LanguageField); step.Plugins.Add(settings); }
public async Task It_produces_a_new_value_when_there_is_none() { var producer = new PipelineStep <string>(() => Task.FromResult("something")); var value = await producer.GetLatestAsync(); value.Should().Be("something"); }
public override void Process(PipelineStep pipelineStep, PipelineContext pipelineContext) { var logger = pipelineContext.PipelineBatchContext.Logger; var settings = pipelineStep.GetPlugin <PublishContentSettings>(); if (settings == null) { logger.Error( "No Publish Content Settings Detected. " + "(pipeline step: {0})", pipelineStep.Name); return; } Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master"); Sitecore.Data.Database target = Sitecore.Configuration.Factory.GetDatabase(settings.Target); var rootItem = master.GetItem(new Sitecore.Data.ID(settings.RootItem)); logger.Info("About to Start Publish"); Sitecore.Publishing.PublishManager.PublishItem(rootItem, new Sitecore.Data.Database[] { target }, settings.Languages.ToArray(), settings.ChildItems, true, //always smart publish settings.RelatedItems); logger.Info("Publish Started for {0}", rootItem.Name); }
private void StartStep(PipelineStep step) { Parallel.ForEach( PipelineQueues[step.InputQName].GetConsumingEnumerable(), item => { string outputQueueName; try { outputQueueName = step.Run(item); } catch (Exception e) { item.TaskCompletionSource.SetException(e); item.Status = ItemStatus.Abandoned; return; } if (item.Status == ItemStatus.Abandoned) { PipelineQueues[LOG_QUEUE_NAME].Add(item); PipelineQueues[OutputQName].Add(item); } else { PipelineQueues[outputQueueName].Add(item); } }); }
protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep) { var settings = new WriteToTagSettings(); var database = Settings.GetSetting("DEF.WriteToTagStepConverter.Db"); using (var db = new DatabaseSwitcher(Database.GetDatabase(database))) { var createPath = base.GetStringValue(source, WriteToTagSettingsItemModel.CreatePath); if (createPath != null) { var parentTagItem = Sitecore.Context.Data.Database.GetItem(createPath); settings.CreatePath = parentTagItem; } var destinationTemplate = base.GetStringValue(source, WriteToTagSettingsItemModel.DestinationTemplate); if (createPath != null) { var desiredTemplate = Sitecore.Context.Data.Database.GetItem(ID.Parse(destinationTemplate)); settings.DestinationTemplate = (TemplateItem)desiredTemplate; } } var sourceField = base.GetStringValue(source, WriteToTagSettingsItemModel.SourceField); var destinationField = base.GetStringValue(source, WriteToTagSettingsItemModel.DestinationField); var countField = base.GetStringValue(source, WriteToTagSettingsItemModel.CountField); settings.SourceField = sourceField; settings.DestinationField = destinationField; settings.CountField = countField; pipelineStep.Plugins.Add(settings); }
public async void Get() { var mock = new ServiceMockFacade <IPipelineStepRepository>(); var record = new PipelineStep(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new PipelineStepService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.PipelineStepModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLPipelineStepMapperMock, mock.DALMapperMockFactory.DALPipelineStepMapperMock, mock.BOLMapperMockFactory.BOLHandlerPipelineStepMapperMock, mock.DALMapperMockFactory.DALHandlerPipelineStepMapperMock, mock.BOLMapperMockFactory.BOLOtherTransportMapperMock, mock.DALMapperMockFactory.DALOtherTransportMapperMock, mock.BOLMapperMockFactory.BOLPipelineStepDestinationMapperMock, mock.DALMapperMockFactory.DALPipelineStepDestinationMapperMock, mock.BOLMapperMockFactory.BOLPipelineStepNoteMapperMock, mock.DALMapperMockFactory.DALPipelineStepNoteMapperMock, mock.BOLMapperMockFactory.BOLPipelineStepStepRequirementMapperMock, mock.DALMapperMockFactory.DALPipelineStepStepRequirementMapperMock); ApiPipelineStepResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async Task When_invalidated_while_producing_a_value_the_consumer_waiting_will_wait_for_latest_production_to_be_finished() { var seed = 0; var barrier = new Barrier(2); PipelineStep <int> producer = null; producer = new PipelineStep <int>(() => { // will require all consumer to reach this point to move on barrier.SignalAndWait(3.Seconds()); barrier.RemoveParticipant(); producer.Invalidate(); return(Task.FromResult(Interlocked.Increment(ref seed))); }); var values = await Task.WhenAll( producer.GetLatestAsync(), producer.GetLatestAsync()); values.Should().BeEquivalentTo(2, 2); // var values = await Task.WhenAll(firstConsumer, secondConsumer); // values.Should().HaveCount(2).And.OnlyContain(i => i == 2); }
List <PipelineStepContainer> _pipelineSteps = new List <PipelineStepContainer>(); // Reference to all steps public Pipeline <TPipelineIn, TPipelineOut> AddStepAndStart <TIn, TOut>(IPipelineProcessor <TIn, TOut> processor) { var step = new PipelineStep <TIn, TOut>(processor); int stepIndex = _pipelineSteps.Count; // Alternatively, I can store a list of the Task.Run() handlers here and then run them at a later point // Start the step Task.Run(() => { // Cached next step IBufferable <TOut> nextBuffer = null; foreach (Item <TIn> input in step.Buffer.GetConsumingEnumerable()) { // Give us the most up-to-date status on our current position in the pipeline bool isLastStep = stepIndex == _pipelineSteps.Count - 1; TOut outputValue; // Attempt to process value try { outputValue = processor.Process(input.Value); } catch (Exception e) { input.TaskCompletionSource.SetException(e); continue; } // Move to next step if (isLastStep) { input.TaskCompletionSource.SetResult((TPipelineOut)(object)outputValue); } else { nextBuffer = nextBuffer ?? _pipelineSteps[stepIndex + 1].Value as IBufferable <TOut>; try // In the case of the pipeline closing prematurely, catch the error and throw an exception to the task { nextBuffer.Buffer.Add(new Item <TOut> { Value = outputValue, TaskCompletionSource = input.TaskCompletionSource }); } catch (InvalidOperationException e) { input.TaskCompletionSource.SetException(e); } } } }); _pipelineSteps.Add(new PipelineStepContainer { Value = step, }); return(this); }
public override void Process(PipelineStep pipelineStep, PipelineContext pipelineContext) { var logger = pipelineContext.PipelineBatchContext.Logger; if (!this.CanProcess(pipelineStep, pipelineContext)) { logger.Error("Pipeline step processing will abort because the pipeline step cannot be processed. (pipeline step: {0})", (object)pipelineStep.Name); return; } Contact contact = this.GetTargetObjectAsContact(pipelineStep, pipelineContext); if (contact == null) { logger.Error("Target Item is not a contact. (pipeline step: {0})", (object)pipelineStep.Name); return; } if (contact.ContactId == null || contact.ContactId == Guid.Empty) { logger.Error("Contact Id does not Exist. (pipeline step: {0})", (object)pipelineStep.Name); return; } var settings = pipelineStep.GetPlugin <ClearFacetCollectionSettings>(); if (settings == null) { logger.Error("Cannot access ClearFacetCollectionSettings. (pipeline step: {0})", (object)pipelineStep.Name); return; } //Use Reflection to get Collection if (!contact.Facets.Keys.Contains(settings.FacetName)) { logger.Warn("Facet {0} does not exist on contact)", settings.FacetName); return; } var facet = contact.Facets[settings.FacetName]; var collectionProperty = facet.GetType().GetProperty(settings.CollectionMemberName).GetValue(facet) as IElementCollection <IElement>; if (collectionProperty == null) { logger.Error("Member Name {0} is not a IElementCollection of IElement", settings.CollectionMemberName); return; } int ctnRemoved = 0; while (collectionProperty.Count() > 0) { collectionProperty.Remove(0); ctnRemoved++; } logger.Info("Removed {0} elements.", ctnRemoved); }
private IItemModelRepository GetItemModelRepository(PipelineStep pipelineStep) { var endpointSettings = pipelineStep.GetEndpointSettings(); var endpointTo = endpointSettings?.EndpointTo; var repositorySettings = endpointTo?.GetItemModelRepositorySettings(); return(repositorySettings?.ItemModelRepository); }
[Fact] public async Task Sequence_of_steps_produce_a_value() { var step1 = new PipelineStep <int>(() => Task.FromResult(1)); var step2 = step1.Then((number) => Task.FromResult($"{number} {number}")); var value1 = await step2.GetLatestAsync(); value1.Should().Be("1 1"); }
private void AddDataLocationSettingsPlugin(ItemModel source, PipelineStep pipelineStep) { string stringValue = this.GetStringValue(source, "DataLocation"); pipelineStep.Plugins.Add((IPlugin) new DataLocationSettings() { DataLocation = stringValue }); }
private void AddAuditDictionarySettingsPlugin(ItemModel source, PipelineStep pipelineStep) { var settings = new AuditDictionarySettings(); settings.Context = base.GetStringValue(source, AuditDictionaryStepItemModel.Context); pipelineStep.Plugins.Add(settings); }
private void AddEndpointSettings(ItemModel source, PipelineStep pipelineStep) { var settings = new EndpointSettings { EndpointFrom = base.ConvertReferenceToModel <Endpoint>(source, RedditReadStepItemModel.EndpointFrom) }; pipelineStep.AddPlugin(settings); }
private void AddIterateThroughGroupedDataSettingsPlugin(ItemModel source, PipelineStep pipelineStep) { string groupFieldKey = this.GetStringValue(source, IterateThroughGroupedDataItemModel.GroupFieldKey); pipelineStep.Plugins.Add((IPlugin) new IterateThroughGroupedDataSettings() { GroupFieldKey = groupFieldKey }); }
protected void AddReadResourceDataSettings(ItemModel source, PipelineStep pipelineStep) { var readResourceDataSettings = new ReadResourceDataSettings { PathExpression = this.GetStringValue(source, ReadResourceDataPipelineStepItemModel.PathExpression) }; pipelineStep.Plugins.Add(readResourceDataSettings); }
/// <summary> /// The process. /// </summary> /// <param name="pipelineStep"> /// The pipeline step. /// </param> /// <param name="pipelineContext"> /// The pipeline context. /// </param> public override void Process(PipelineStep pipelineStep, PipelineContext pipelineContext) { var exampleSettings = pipelineStep.GetPlugin <ExampleSettings>(); if (exampleSettings != null) { pipelineContext.PipelineBatchContext.Logger.Info( "Hello world! Create some items here..." + exampleSettings.CreatePath); } }
protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep) { base.AddPlugins(source, pipelineStep); var settings = new JsonSettings() { JPath = GetStringValue(source, JPathFieldName) }; pipelineStep.AddPlugin(settings); }
public async Task It_does_not_produces_a_new_value_when_invalidated_until_asked_for_latest_value() { var seed = 0; var producer = new PipelineStep <int>(() => Task.FromResult(Interlocked.Increment(ref seed))); var value = await producer.GetLatestAsync(); value.Should().Be(1); producer.Invalidate(); seed.Should().Be(1); }
protected override void ReadData( Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } if (pipelineStep == null) { throw new ArgumentNullException("pipelineStep"); } if (pipelineContext == null) { throw new ArgumentNullException("pipelineContext"); } var logger = pipelineContext.PipelineBatchContext.Logger; // //get the file path from the plugin on the endpoint var settings = endpoint.GetFileSystemSettings(); if (settings == null) { return; } if (string.IsNullOrWhiteSpace(settings.Path)) { logger.Error( "No path is specified on the endpoint. " + "(pipeline step: {0}, endpoint: {1})", pipelineStep.Name, endpoint.Name); return; } //not a file or directory if (!System.IO.File.Exists(settings.Path) && !Directory.Exists(settings.Path)) { logger.Error( "The path specified on the endpoint does not exist. " + "(pipeline step: {0}, endpoint: {1}, path: {2})", pipelineStep.Name, endpoint.Name, settings.Path); return; } var dataSettings = new IterableDataSettings(GetEnumerable(settings, logger)); logger.Info( "path: {0} was processed.. (pipeline step: {1}, endpoint: {2})", settings.Path, pipelineStep.Name, endpoint.Name); // //add the plugin to the pipeline context pipelineContext.Plugins.Add(dataSettings); }
protected override void ReadData( Endpoint endpoint, PipelineStep pipelineStep, PipelineContext pipelineContext, ILogger logger) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (pipelineStep == null) { throw new ArgumentNullException(nameof(pipelineStep)); } if (pipelineContext == null) { throw new ArgumentNullException(nameof(pipelineContext)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } // //get the file path from the plugin on the endpoint var settings = endpoint.GetTextFileSettings(); if (settings == null) { return; } if (string.IsNullOrWhiteSpace(settings.Path)) { logger.Error( "No path is specified on the endpoint. " + "(pipeline step: {0}, endpoint: {1})", pipelineStep.Name, endpoint.Name); return; } if (!File.Exists(settings.Path)) { logger.Error( "The path specified on the endpoint does not exist. " + "(pipeline step: {0}, endpoint: {1}, path: {2})", pipelineStep.Name, endpoint.Name, settings.Path); return; } // //add the data that was read from the file to a plugin var data = this.GetIterableData(settings); var dataSettings = new IterableDataSettings(data); // //add the plugin to the pipeline context pipelineContext.AddPlugin(dataSettings); }
public Pipeline(ManosApp app, IHttpTransaction transaction) { this.app = app; this.transaction = transaction; pending = AppHost.Pipes == null ? 1 : AppHost.Pipes.Count; step = PipelineStep.PreProcess; handle = GCHandle.Alloc (this); transaction.Response.OnEnd += HandleEnd; }
public Pipeline(Application application, ITransaction transaction) { this.application = application; this.transaction = transaction; pending = ApplicationHost.Pipes == null ? 1 : ApplicationHost.Pipes.Count; step = PipelineStep.PreProcess; handle = GCHandle.Alloc(this); transaction.Response.OnEnd += HandleEnd; }
private void Execute() { step = PipelineStep.WaitingForEnd; ctx = new ManosContext (transaction); // TODO: // var handler = OnPreProcessTarget (ctx); // if (handler == null) var handler = app.Routes.Find (transaction.Request); if (handler == null) { ctx.Response.StatusCode = 404; ctx.Response.End (); return; } ctx.Response.StatusCode = 200; // TODO: // OnPostProcessTarget (ctx, handler); try { handler.Invoke (app, ctx); } catch (Exception e) { Console.Error.WriteLine ("Exception in transaction handler:"); Console.Error.WriteLine (e); ctx.Response.StatusCode = 500; ctx.Response.End (); // // TODO: Maybe the cleanest thing to do is // have a HandleError, HandleException thing // on HttpTransaction, along with an UnhandledException // method/event on ManosModule. // // end = true; } if (ctx.Response.StatusCode == 404) { step = PipelineStep.WaitingForEnd; ctx.Response.End (); return; } }
public StepExecutionResult(PipelineStep step, bool success) { Step = step; Success = success; }
private void Execute() { step = PipelineStep.WaitingForEnd; context = new Context(transaction); var handler = application.Routes.Find(transaction.Request); PipePreProcessTarget((newHandler) => { if (newHandler != handler) { handler = newHandler; } }); if (handler == null) { context.Response.StatusCode = 404; context.Response.End(application.Get404Response()); return; } context.Response.StatusCode = 200; Error.Log.Call<System.Exception>(() => handler.Invoke(application, context), e => { Console.Error.WriteLine("Exception in transaction handler:"); Console.Error.WriteLine(e); context.Response.StatusCode = 500; context.Response.End(application.Get500Response()); // // TODO: Maybe the cleanest thing to do is // have a HandleError, HandleException thing // on HttpTransaction, along with an UnhandledException // method/event on ManosModule. // // end = true; }); PipePostProcessTarget(handler); if (context.Response.StatusCode == 404) { step = PipelineStep.WaitingForEnd; context.Response.End(); return; } }