public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(PostExecution).After<KnownStages.IOperationExecution>()
         .And.Before<KnownStages.IOperationResultInvocation>();
     pipelineRunner.Notify(RewriteResult).After<KnownStages.IOperationResultInvocation>()
         .And.Before<KnownStages.IResponseCoding>();
 }
        /// <summary>
        /// Creates the worker factory
        /// </summary>
        public ThreadPoolWorkerFactory(ITransport transport, IRebusLoggerFactory rebusLoggerFactory, IPipeline pipeline, IPipelineInvoker pipelineInvoker, Options options, Func<RebusBus> busGetter, BusLifetimeEvents busLifetimeEvents, ISyncBackoffStrategy backoffStrategy)
        {
            if (transport == null) throw new ArgumentNullException(nameof(transport));
            if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
            if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
            if (pipelineInvoker == null) throw new ArgumentNullException(nameof(pipelineInvoker));
            if (options == null) throw new ArgumentNullException(nameof(options));
            if (busGetter == null) throw new ArgumentNullException(nameof(busGetter));
            if (busLifetimeEvents == null) throw new ArgumentNullException(nameof(busLifetimeEvents));
            if (backoffStrategy == null) throw new ArgumentNullException(nameof(backoffStrategy));
            _transport = transport;
            _rebusLoggerFactory = rebusLoggerFactory;
            _pipeline = pipeline;
            _pipelineInvoker = pipelineInvoker;
            _options = options;
            _busGetter = busGetter;
            _backoffStrategy = backoffStrategy;
            _parallelOperationsManager = new ParallelOperationsManager(options.MaxParallelism);
            _log = _rebusLoggerFactory.GetCurrentClassLogger();

            if (_options.MaxParallelism < 1)
            {
                throw new ArgumentException($"Max parallelism is {_options.MaxParallelism} which is an invalid value");
            }

            if (options.WorkerShutdownTimeout < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException($"Cannot use '{options.WorkerShutdownTimeout}' as worker shutdown timeout as it");
            }

            busLifetimeEvents.WorkersStopped += WaitForContinuationsToFinish;
        }
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(ChallengeIfUnauthorized)
         .After<KnownStages.IOperationExecution>()
         .And
         .Before<KnownStages.IResponseCoding>();
 }
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(AuthoriseRequest)
         .After<KnownStages.IBegin>()
         .And
         .Before<KnownStages.IHandlerSelection>();
 }
        public NancyPipelineRoutes(IPipeline pipeline, INotificationTarget notifier)
        {
            Post["/bitbucket"] = parameters => {
                string notificationString = Request.Form.Payload;

                var commitNotification = JsonConvert.DeserializeObject<BitbucketPostReceiveNotification>(notificationString);
                commitNotification.Commits.ForEach(c => pipeline.AddToPipeline(new Commit(c.Author, c.Message, c.Branch)));

                return "THANKS BITBUCKET";
            };

            Post["/jenkins"] = parameters => {
                var buildNotification = this.Bind<JenkinsBuildNotification>();

                var buildStep = pipeline[buildNotification.Name];

                if (buildNotification.Build.Phase == "STARTED") {
                    buildStep.Start();
                } else if (buildNotification.Build.Phase == "FINISHED") {
                    if (buildNotification.Build.Status == "SUCCESS")
                    {
                        buildStep.Pass();
                    }
                    else
                    {
                        buildStep.Fail();
                    }
                }

                return "THANKS FOR THE BUILD DEETS";
            };
        }
 public MainPipelineExecutor(IBuilder builder, IEventAggregator eventAggregator, IPipelineCache pipelineCache, IPipeline<ITransportReceiveContext> mainPipeline)
 {
     this.mainPipeline = mainPipeline;
     this.pipelineCache = pipelineCache;
     this.builder = builder;
     this.eventAggregator = eventAggregator;
 }
Example #7
0
 /// <summary>
 /// Creates the profiler
 /// </summary>
 public PipelineStepProfiler(IPipeline pipeline, PipelineStepProfilerStats profilerStats)
 {
     if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
     if (profilerStats == null) throw new ArgumentNullException(nameof(profilerStats));
     _pipeline = pipeline;
     _profilerStats = profilerStats;
 }
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(ProcessPostConditional)
         .Before<ConditionalLastModifiedContributor>()
         .And
         .Before<KnownStages.IResponseCoding>();
 }
 public void Initialize(IPipeline pipeline)
 {
     pipeline.Notify(WriteResponse).After<KnownStages.ICodecResponseSelection>();
     //.And
     //.Before<KnownStages.IEnd>();
     Log = NullLogger.Instance;
 }
 public TcpChannel(IPipeline pipeline, BufferPool pool)
 {
     _pipeline = pipeline;
     Pipeline.SetChannel(this);
     _readBuffer = pool.PopSlice();
     _stream = new PeekableMemoryStream(_readBuffer.Buffer, _readBuffer.StartOffset, _readBuffer.Capacity);
 }
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(WrapOperations)
         .After<KnownStages.IRequestDecoding>()
         .And
         .Before<KnownStages.IOperationExecution>();
 }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cache"/> class.
        /// </summary>
        /// <param name="pipeline">The pipeline component.</param>
        /// <param name="cachePruner">The cache pruner component.</param>
        public Cache(IPipeline pipeline, ICachePruner cachePruner)
        {
            Ensure.ArgumentNotNull(pipeline, "pipeline");
            Ensure.ArgumentNotNull(cachePruner, "cachePruner");

            this.Pipeline = pipeline;
            cachePruner.Start(this);
        }
 public FreeSwitchClient(SecureString password, FreeSwitchEventCollection eventCollection)
 {
     _eventCollection = eventCollection;
     var pipelineFactory = new FreeSwitchPipeline(password, this);
     _pipeline = pipelineFactory.Build();
     _channel = new TcpClientChannel(_pipeline);
     _waitingObjects = new AsyncJobQueue();
 }
Example #14
0
 public TcpServerChannel(IPipeline serverPipeline, IPipeline childPipeline, int maxNumberOfClients)
 {
     _bufferManager = new BufferManager(maxNumberOfClients, 65535);
     _argsPool = new ObjectPool<SocketAsyncEventArgs>(AllocateArgs);
     Pipeline = serverPipeline;
     _contexts = new ContextCollection(this);
     ChildPipeline = childPipeline;
 }
Example #15
0
        protected ProxyBase(Type contract, IPipeline<ClientActionContext> pipeline)
        {
            if (contract == null) throw new ArgumentNullException(nameof(contract));
            if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));

            Contract = contract;
            _pipeline = pipeline;
        }
 public void Initialize(IPipeline pipelineRunner)
 {
     _authentication = _resolver.Resolve<IAuthenticationProvider>();
     pipelineRunner.Notify(ReadCredentials)
         .After<KnownStages.IBegin>()
         .And
         .Before<KnownStages.IHandlerSelection>();
 }
Example #17
0
 /// <summary>
 /// Constructs the bus.
 /// </summary>
 public RebusBus(IWorkerFactory workerFactory, IRouter router, ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, ISubscriptionStorage subscriptionStorage)
 {
     _workerFactory = workerFactory;
     _router = router;
     _transport = transport;
     _pipeline = pipeline;
     _pipelineInvoker = pipelineInvoker;
     _subscriptionStorage = subscriptionStorage;
 }
        public object Execute(IContext context, IPipeline pipeline)
        {
            if (_instance == null)
                lock (this)
                    if (_instance == null)
                        _instance = pipeline.Execute();

            return _instance;
        }
Example #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cache"/> class.
        /// </summary>
        /// <param name="pipeline">The pipeline component.</param>
        /// <param name="cachePruner">The cache pruner component.</param>
        public Cache(IPipeline pipeline, ICachePruner cachePruner)
        {
            Ensure.ArgumentNotNull(pipeline, "pipeline");
            Ensure.ArgumentNotNull(cachePruner, "cachePruner");

            _entries = new Multimap<IBinding, CacheEntry>();
            Pipeline = pipeline;
            cachePruner.Start(this);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AprsPacketSpout" /> class.
 /// </summary>
 /// <param name="pipeline">The pipeline.</param>
 public AprsPacketSpout(IPipeline<byte[]> pipeline)
 {
     _user = ConfigurationManager.AppSettings["user"];
     var password = ConfigurationManager.AppSettings["password"] ?? "-1";
     _hostname = ConfigurationManager.AppSettings["hostname"];
     _port = int.Parse(ConfigurationManager.AppSettings["port"]);
     _logon = Encoding.UTF8.GetBytes("user " + _user + " pass " + password + "\n");
     _pipeline = pipeline.Create(string.Empty);
 }
Example #21
0
        public override ITestContractStateFullAsync GetProxy(IPipeline<ClientActionContext> pipeline = null, bool open = true)
        {
            ITestContractStateFullAsync proxy = ClientConfiguration.ProxyFactory.CreateProxy<ITestContractStateFullAsync>(pipeline ?? CreatePipeline());
            if (open)
            {
                proxy.OpenSessionAsync("arg").GetAwaiter().GetResult();
            }

            return proxy;
        }
        public SubscriberService(ISubscriberRecordRepository subscriberRecordRepository, IPipeline<SubscriberRecord> pipeline, ISubscriberRecordService subscriberRecordService)
        {
            Check.If(subscriberRecordRepository).IsNotNull();
            Check.If(pipeline).IsNotNull();
            Check.If(subscriberRecordService).IsNotNull();

            _subscriberRecordRepository = subscriberRecordRepository;
            _pipeline = pipeline;
            _subscriberRecordService = subscriberRecordService;
        }
Example #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TcpChannel"/> class.
 /// </summary>
 /// <param name="pipeline">The pipeline used to send messages upstream.</param>
 /// <param name="pool">Buffer pool.</param>
 public TcpChannel(IPipeline pipeline, BufferPool pool)
 {
     _pipeline = pipeline;
     _pool = pool;
     Pipeline.SetChannel(this);
     if (pool == null)
         _readBuffer = new BufferSlice(new byte[65535], 0, 65535, 0);
     else
         _readBuffer = pool.PopSlice();
     _stream = new PeekableMemoryStream(_readBuffer.Buffer, _readBuffer.StartOffset, _readBuffer.Capacity);
 }
Example #24
0
        protected ProxyBase(ProxyBase proxy)
        {
            if (proxy == null)
            {
                throw new ArgumentNullException(nameof(proxy));
            }

            Contract = proxy.Contract;
            _pipeline = proxy.Pipeline;
            State = proxy.State;
        }
Example #25
0
 /// <summary>
 /// Constructs the worker factory
 /// </summary>
 public ThreadWorkerFactory(ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, int maxParallelism)
 {
     if (transport == null) throw new ArgumentNullException("transport");
     if (pipeline == null) throw new ArgumentNullException("pipeline");
     if (pipelineInvoker == null) throw new ArgumentNullException("pipelineInvoker");
     if (maxParallelism <= 0) throw new ArgumentOutOfRangeException(string.Format("Cannot use value '{0}' as max parallelism!", maxParallelism));
     _transport = transport;
     _pipeline = pipeline;
     _pipelineInvoker = pipelineInvoker;
     _parallelOperationsManager = new ParallelOperationsManager(maxParallelism);
 }
Example #26
0
 public bool TryGetValue(string key, out IPipeline value)
 {
     Pipeline pipeline;
     if (_pipelines.TryGetValue(key, out pipeline))
     {
         value = pipeline;
         return true;
     }
     value = null;
     return false;
 }
 public DefaultMessageHolder(
     string topic, 
     string partitionKey, 
     object body,
     IPipeline<IFuture<SendResult>> pipeline,
     ISystemClockService systemClockService)
 {
     this.message = new ProducerMessage(topic, body);
     this.message.PartitionKey = partitionKey;
     this.pipeline = pipeline;
     this.systemClockService = systemClockService;
 }
        public void Initialize(IPipeline pipelineRunner)
        {
            pipelineRunner.Notify(ReadCredentials)
                .After<KnownStages.IBegin>()
                .And
                .Before<KnownStages.IHandlerSelection>();

            pipelineRunner.Notify(WriteCredentialRequest)
                .After<KnownStages.IOperationResultInvocation>()
                .And
                .Before<KnownStages.IResponseCoding>();
        }
        public when_flowing_an_event_through_a_complete_event_and_reflow_pipeline()
        {
            pipelet_1 = new SamplePipelet();
            pipelet_2 = new SamplePipelet();
            pipelet_3 = new GeneratesOneEventOnInitialFlowPipelet();
            pipelet_4 = new SamplePipelet();

            pipe_line = new CompleteAndReflowPipeline(new List<IPipelet>
                {
                    pipelet_1,
                    pipelet_2,
                    pipelet_3,
                    pipelet_4,
                });
        }
        public when_flowing_an_event_through_a_queued_pipeline()
        {
            pipelet_1 = new SamplePipelet();
            pipelet_2 = new SamplePipelet();
            pipelet_3 = new GeneratesOneEventOnInitialFlowPipelet();
            pipelet_4 = new SamplePipelet();

            pipe_line = new QueuedEventsPipeline(new List<IPipelet>
                {
                    pipelet_1,
                    pipelet_2,
                    pipelet_3,
                    pipelet_4,
                });
        }
Example #31
0
        private static AtlasPackingResult MergeAtlasPackingResultStackBonA(AtlasPackingResult a,
                                                                           AtlasPackingResult b, int maxWidthDim, int maxHeightDim, bool stretchBToAtlasWidth, IPipeline pipeline)
        {
            Debug.Assert(a.usedW == a.atlasX);
            Debug.Assert(a.usedH == a.atlasY);
            Debug.Assert(b.usedW == b.atlasX);
            Debug.Assert(b.usedH == b.atlasY);
            Debug.Assert(a.usedW <= maxWidthDim, a.usedW + " " + maxWidthDim);
            Debug.Assert(a.usedH <= maxHeightDim, a.usedH + " " + maxHeightDim);
            Debug.Assert(b.usedH <= maxHeightDim);
            Debug.Assert(b.usedW <= maxWidthDim, b.usedW + " " + maxWidthDim);

            Rect AatlasToFinal;
            Rect BatlasToFinal;

            // first calc height scale and offset
            int atlasX;
            int atlasY;

            pipeline.MergeAtlasPackingResultStackBonAInternal(a, b, out AatlasToFinal, out BatlasToFinal, stretchBToAtlasWidth, maxWidthDim, maxHeightDim, out atlasX, out atlasY);

            Rect[]         newRects   = new Rect[a.rects.Length + b.rects.Length];
            AtlasPadding[] paddings   = new AtlasPadding[a.rects.Length + b.rects.Length];
            int[]          srcImgIdxs = new int[a.rects.Length + b.rects.Length];
            Array.Copy(a.padding, paddings, a.padding.Length);
            Array.Copy(b.padding, 0, paddings, a.padding.Length, b.padding.Length);
            Array.Copy(a.srcImgIdxs, srcImgIdxs, a.srcImgIdxs.Length);
            Array.Copy(b.srcImgIdxs, 0, srcImgIdxs, a.srcImgIdxs.Length, b.srcImgIdxs.Length);
            Array.Copy(a.rects, newRects, a.rects.Length);
            for (int i = 0; i < a.rects.Length; i++)
            {
                Rect r = a.rects[i];
                r.x       = AatlasToFinal.x + r.x * AatlasToFinal.width;
                r.y       = AatlasToFinal.y + r.y * AatlasToFinal.height;
                r.width  *= AatlasToFinal.width;
                r.height *= AatlasToFinal.height;
                Debug.Assert(r.max.x <= 1f);
                Debug.Assert(r.max.y <= 1f);
                Debug.Assert(r.min.x >= 0f);
                Debug.Assert(r.min.y >= 0f);
                newRects[i]   = r;
                srcImgIdxs[i] = a.srcImgIdxs[i];
            }

            for (int i = 0; i < b.rects.Length; i++)
            {
                Rect r = b.rects[i];
                r.x       = BatlasToFinal.x + r.x * BatlasToFinal.width;
                r.y       = BatlasToFinal.y + r.y * BatlasToFinal.height;
                r.width  *= BatlasToFinal.width;
                r.height *= BatlasToFinal.height;
                Debug.Assert(r.max.x <= 1f);
                Debug.Assert(r.max.y <= 1f);
                Debug.Assert(r.min.x >= 0f);
                Debug.Assert(r.min.y >= 0f);
                newRects[a.rects.Length + i]   = r;
                srcImgIdxs[a.rects.Length + i] = b.srcImgIdxs[i];
            }

            AtlasPackingResult res = new AtlasPackingResult(paddings);

            res.atlasX     = atlasX;
            res.atlasY     = atlasY;
            res.padding    = paddings;
            res.rects      = newRects;
            res.srcImgIdxs = srcImgIdxs;
            res.CalcUsedWidthAndHeight();
            return(res);
        }
Example #32
0
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(DoNothing).After <ContributorB>();
 }
Example #33
0
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(RunOperationResult);
 }
Example #34
0
 public virtual void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(DoNothing).Before <T>();
 }
Example #35
0
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(DoNowt).After <ContributorThatThrows>();
 }
Example #36
0
 public Elevator(IPipeline <TStateInner> inner, Func <TStateOuter, TStateInner> selector)
 {
     this.inner    = inner;
     this.selector = selector;
 }
Example #37
0
 /**
  * @param next the next pipeline if any.
  */
 public PdfWriterPipeline(IPipeline next) : base(next)
 {
 }
 public static void IsGet(this ControlComponent component, string pathRegex, IPipeline pipeline)
 {
     component.When(BuildGetFilter(pathRegex), pipeline);
 }
Example #39
0
 /// <summary>
 /// Creates the profiler
 /// </summary>
 public PipelineStepProfiler(IPipeline pipeline, PipelineStepProfilerStats profilerStats)
 {
     _pipeline      = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
     _profilerStats = profilerStats ?? throw new ArgumentNullException(nameof(profilerStats));
 }
Example #40
0
 public HttpDataProvider(HttpPipeline pipeline) : base(pipeline.TransPipeline)
 {
     this.pipeline = pipeline;
 }
Example #41
0
        public void SetTo(IPipeline pipeline, IPipelineUseCase useCase)
        {
            _useCase = useCase;

            _pipeline = pipeline;
            if (_pipeline != null)
            {
                _pipeline.ClearAllInjections();
            }

            //clear the diagram
            flpPipelineDiagram.Controls.Clear();

            pipelineSmiley.Reset();

            try
            {
                //if there is a pipeline
                if (_pipeline != null)
                {
                    try
                    {
                        _pipelineFactory = new DataFlowPipelineEngineFactory(_useCase, _pipeline);

                        //create it
                        IDataFlowPipelineEngine pipelineInstance = _pipelineFactory.Create(pipeline, new ThrowImmediatelyDataLoadEventListener());

                        //initialize it (unless it is design time)
                        if (!_useCase.IsDesignTime)
                        {
                            pipelineInstance.Initialize(_useCase.GetInitializationObjects().ToArray());
                        }
                    }
                    catch (Exception ex)
                    {
                        pipelineSmiley.Fatal(ex);
                    }

                    //There is a pipeline set but we might have been unable to fully realize it so setup stuff based on PipelineComponents

                    //was there an explicit instance?
                    if (_useCase.ExplicitSource != null)
                    {
                        AddExplicit(_useCase.ExplicitSource);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.SourcePipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.SourcePipelineComponent_ID, DataFlowComponentVisualisation.Role.Source, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Source);    //the user hasn't put one in yet
                    }
                    foreach (var middleComponent in pipeline.PipelineComponents.Where(c => c.ID != pipeline.SourcePipelineComponent_ID && c.ID != pipeline.DestinationPipelineComponent_ID).OrderBy(comp => comp.Order))
                    {
                        AddPipelineComponent(middleComponent, DataFlowComponentVisualisation.Role.Middle);//add the possibly broken PipelineComponent to the diagram
                    }
                    //was there an explicit instance?
                    if (_useCase.ExplicitDestination != null)
                    {
                        AddDividerIfReorderingAvailable();
                        AddExplicit(_useCase.ExplicitDestination);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.DestinationPipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.DestinationPipelineComponent_ID, DataFlowComponentVisualisation.Role.Destination, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddDividerIfReorderingAvailable();
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);    //the user hasn't put one in yet
                    }


                    return;
                }


                //Fallback
                //user has not picked a pipeline yet, show him the shell (factory)
                //factory has no source, add empty source
                if (_useCase.ExplicitSource == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Source);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitSource);
                }


                //factory has no source, add empty source
                if (_useCase.ExplicitDestination == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitDestination);
                }
            }
            finally
            {
                Invalidate();
            }
        }
 protected CollectionPipe(IPipeline <List <TInput> > nextPipeItem) : base(nextPipeItem)
 {
 }
Example #43
0
 /**
  * @param hpc the initial {@link HtmlPipelineContext}
  * @param next the next pipe in row
  */
 public HtmlPipeline(HtmlPipelineContext hpc, IPipeline next) : base(next)
 {
     this.hpc = hpc;
 }
Example #44
0
 public void Initialize(IPipeline pipeline)
 {
     pipeline.NotifyAsync(WriteResponseEntity);
 }
Example #45
0
            /**
             * @param next
             */

            public AbstractPipelineExtension(IPipeline next) : base(next)
            {
            }
 public MergeShoeDefinitionTask(IRepository <Ucommerce.EntitiesV2.ProductDefinition> productDefinitionRepository,
                                IPipeline <IDefinition> saveDefinitionPipeline)
 {
     _productDefinitionRepository = productDefinitionRepository;
     _saveDefinitionPipeline      = saveDefinitionPipeline;
 }
Example #47
0
        /// <summary>
        /// Returns the PDF stream of the given receipt.
        /// </summary>
        /// <param name="userId">User Id.</param>
        /// <param name="receiptId">Receipt Id.</param>
        /// <returns>Stream.</returns>
        public Stream GetReceiptStream(int userId, int receiptId)
        {
            User                  user           = null;
            Stream                ret            = null;
            XMLWorker             worker         = null;
            IPipeline             pipeline       = null;
            XMLParser             xmlParse       = null;
            string                html           = string.Empty;
            ICSSResolver          cssResolver    = null;
            PaymentHistoryEntry   receipt        = null;
            HtmlPipelineContext   htmlContext    = null;
            Func <string, string> valueOrDefault = v => !string.IsNullOrWhiteSpace(v) ? v : "-";

            if (userId > 0 && receiptId > 0)
            {
                receipt = _payments.Select(receiptId);

                if (receipt != null && receipt.UserId == userId)
                {
                    user = Resolver.Resolve <IRepository <User> >().Select(receipt.UserId);

                    if (user != null)
                    {
                        using (var stream = Assembly.GetExecutingAssembly()
                                            .GetManifestResourceStream("Ifly.Resources.PaymentReceiptTemplate.html"))
                        {
                            using (var reader = new StreamReader(stream))
                                html = reader.ReadToEnd();
                        }

                        if (!string.IsNullOrEmpty(html))
                        {
                            html = Utils.Input.FormatWith(html, new
                            {
                                Date             = receipt.Date.ToString("R", _culture),
                                UserName         = string.Format("{0} ({1})", valueOrDefault(user.Name), valueOrDefault(user.Email)),
                                CompanyName      = valueOrDefault(user.CompanyName),
                                CompanyAddress   = valueOrDefault(user.CompanyAddress),
                                SubscriptionType = Enum.GetName(typeof(SubscriptionType), receipt.SubscriptionType),
                                Amount           = receipt.Amount.ToString("F"),
                                ChargedTo        = valueOrDefault(receipt.ChargedTo),
                                TransactionId    = valueOrDefault(receipt.TransactionId)
                            });

                            using (Document doc = new Document(PageSize.A4, 30, 30, 30, 30))
                            {
                                using (var s = new MemoryStream())
                                {
                                    using (var writer = PdfWriter.GetInstance(doc, s))
                                    {
                                        doc.Open();

                                        htmlContext = new HtmlPipelineContext(null);
                                        htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());

                                        cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
                                        pipeline    = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(doc, writer)));
                                        worker      = new XMLWorker(pipeline, true);

                                        xmlParse = new XMLParser(true, worker);
                                        xmlParse.Parse(new StringReader(html));
                                        xmlParse.Flush();

                                        doc.Close();
                                        doc.Dispose();

                                        ret = new MemoryStream(s.ToArray());
                                        ret.Seek(0, SeekOrigin.Begin);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(ret);
        }
Example #48
0
        public ConsoleGuiRunPipeline(IBasicActivateItems activator, IPipelineUseCase useCase, IPipeline pipeline)
        {
            Modal          = true;
            this.activator = activator;
            this._useCase  = useCase;
            this._pipeline = pipeline;

            ColorScheme          = ConsoleMainWindow.ColorScheme;
            _compatiblePipelines = useCase.FilterCompatiblePipelines(activator.RepositoryLocator.CatalogueRepository.GetAllObjects <Pipeline>()).ToArray();

            Width  = Dim.Fill();
            Height = Dim.Fill();

            if (pipeline == null && _compatiblePipelines.Length == 1)
            {
                this._pipeline = _compatiblePipelines[0];
            }

            Add(_lblPipeline = new Label("Pipeline:" + (this._pipeline?.Name ?? "<<NOT SELECTED>>"))
            {
                Width = Dim.Fill() - 20
            });

            var btnChoose = new Button("Choose Pipeline")
            {
                X = Pos.Right(_lblPipeline)
            };

            btnChoose.Clicked += BtnChoose_Clicked;
            Add(btnChoose);

            var btnRun = new Button("Run")
            {
                Y = 1
            };

            btnRun.Clicked += BtnRun_Clicked;
            Add(btnRun);

            var btnCancel = new Button("Cancel")
            {
                Y = 1, X = Pos.Right(btnRun)
            };

            btnCancel.Clicked += BtnCancel_Clicked;
            Add(btnCancel);

            var btnClose = new Button("Close")
            {
                Y = 1, X = Pos.Right(btnCancel)
            };

            btnClose.Clicked += () => Application.RequestStop();
            Add(btnClose);

            Add(_tableView = new TableView()
            {
                Y = 2, Width = Dim.Fill(), Height = 7
            });
            _tableView.Style.ShowHorizontalHeaderOverline  = false;
            _tableView.Style.AlwaysShowHeaders             = true;
            _tableView.Style.ShowVerticalCellLines         = true;
            _tableView.Style.ShowHorizontalHeaderUnderline = false;

            progressDataTable = new DataTable();
            progressDataTable.Columns.Add("Name");
            progressDataTable.Columns.Add("Progress", typeof(int));

            _tableView.Table = progressDataTable;

            Add(_results = new ListView(this)
            {
                Y = Pos.Bottom(_tableView), Width = Dim.Fill(), Height = Dim.Fill()
            });
            _results.KeyPress += Results_KeyPress;
        }
Example #49
0
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(Close).Before <KnownStages.IResponseCoding>();
 }
Example #50
0
 private void BtnChoose_Clicked()
 {
     _pipeline         = (IPipeline)activator.SelectOne("Pipeline", _compatiblePipelines);
     _lblPipeline.Text = "Pipeline:" + (_pipeline?.Name ?? "<<NOT SELECTED>>");
 }
 public void TearDown()
 {
     mPipeline.Stop();
     mPipeline = null;
 }
Example #52
0
 public PipelineAdapter(IPipeline pipeline)
 {
     _pipeline = pipeline;
 }
Example #53
0
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(Do).After <KnownStages.IBegin>();
 }
Example #54
0
 public TestPipeline(IPipeline pipeline)
 {
     InternalPipeline = new PipelineAdapter(pipeline);
 }
Example #55
0
 public void Initialize(IPipeline pipelineRunner)
 {
     pipelineRunner.Notify(DoNothing).After <KnownStages.IBegin>().And.After <RecursiveB>();
 }
Example #56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TcpChannel"/> class.
 /// </summary>
 /// <param name="pipeline">The pipeline used to send messages upstream.</param>
 public TcpChannel(IPipeline pipeline)
 {
     _pipeline = pipeline;
     Pipeline.SetChannel(this);
     _readBuffer = new BufferSlice(new byte[65535], 0, 65535, 0);
 }
 public virtual void SetUp()
 {
     _previousDefaultPipeline = PipelineRegistry.DefaultPipeline;
     PipelineRegistry.SetDefaultPipeline(Pipeline);
 }
Example #58
0
 public CustomAbstractPipeline(IPipeline next)
     : base(next)
 {
 }
 public PipelineStage(IPipeline pipeline, PipelineStage ownerStage)
     : this(pipeline)
 {
     OwnerStage = ownerStage;
 }
Example #60
0
 /// <summary>
 /// Constructs the bus.
 /// </summary>
 public RebusBus(IWorkerFactory workerFactory, IRouter router, ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, ISubscriptionStorage subscriptionStorage, Options options, IRebusLoggerFactory rebusLoggerFactory)
 {
     _workerFactory       = workerFactory;
     _router              = router;
     _transport           = transport;
     _pipeline            = pipeline;
     _pipelineInvoker     = pipelineInvoker;
     _subscriptionStorage = subscriptionStorage;
     _options             = options;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }