Exemple #1
0
 public void ExtractCaptureFromRisk(InputPolDataElement risk, Action <string, Guid, Guid, string> onValueExtraction)
 {
     GreenLogger.Log("Extracting capture from risk for {0}", State.ProductLine);
     foreach (XElement riskSectionElement in risk.InnerXElement.Elements())
     {
         State.Sections[riskSectionElement.Name.LocalName].ExtractCaptureFromRiskSection(riskSectionElement, onValueExtraction);
     }
 }
Exemple #2
0
        public void ExtractCaptureFromRequest(string request, Action <string, Guid, Guid, string> onValueExtraction)
        {
            GreenLogger.Log("Extracting capture from request");

            RequestBodyElement body = request.ToXDocument().GetInsureServeMessage().RequestBody;
            ProductLineCode    code = ProductLineCode.Parse(body.BusinessTransaction.ProductLineCode.Value);

            State.ProductLines[code].ExtractCaptureFromRisk(body.PolMessage.InputPolData, onValueExtraction);
        }
Exemple #3
0
        public void Handle(CreateProductLineSchema message)
        {
            GreenLogger.Log("Creating schema {0}", message.Schema);

            runner.ExecuteCommand(string.Format(
                                      CultureInfo.InvariantCulture,
                                      "CREATE SCHEMA [{0}] AUTHORIZATION [dbo]",
                                      message.Schema));
        }
Exemple #4
0
        public void ExtractCaptureFromRiskItem(XElement riskItem, Action <string, Guid, Guid, string> onValueExtraction)
        {
            GreenLogger.Log("Extracting capture from risk item for {0}", riskItem.Name.LocalName);

            onValueExtraction(
                State.ProductLine,
                State.RiskSectionId,
                State.RiskItemId,
                riskItem.Attributes().Single(e => e.Name.LocalName == ValAttribute.AttributeName).Value);
        }
        public void Handle(CreateRiskTableColumn message)
        {
            GreenLogger.Log("Creating column {0} in table {1}.{2}", message.ColumnName, message.Schema, message.TableName);

            runner.ExecuteCommand(string.Format(
                                      CultureInfo.InvariantCulture,
                                      "ALTER TABLE [{0}].[{1}] ADD {2} NVARCHAR(250) NULL ",
                                      message.Schema,
                                      message.TableName,
                                      message.ColumnName));
        }
Exemple #6
0
        public void ExtractCaptureFromRiskSection(XElement sectionElement, Action <string, Guid, Guid, string> onValueExtraction)
        {
            GreenLogger.Log("Extracting capture from risk section for {0}", sectionElement.Name.LocalName);

            foreach (XElement riskItemElement in sectionElement.Elements())
            {
                if (State.Items.ContainsKey(riskItemElement.Name.LocalName))
                {
                    State.Items[riskItemElement.Name.LocalName].ExtractCaptureFromRiskItem(riskItemElement, onValueExtraction);
                }
            }
        }
Exemple #7
0
        public void ExtractMapFromRiskSection(XElement sectionElement)
        {
            GreenLogger.Log("Extracting map from risk section for {0}", sectionElement.Name.LocalName);

            foreach (XElement riskItemElement in sectionElement.Elements())
            {
                if (!State.Items.ContainsKey(riskItemElement.Name.LocalName) && riskItemElement.Attributes().Any(e => e.Name.LocalName == ValAttribute.AttributeName))
                {
                    GreenLogger.Log("new risk item mapped for {0}", State.RiskSectionId, riskItemElement.Name.LocalName);

                    Then(new NewRiskItemMapped(Guid.NewGuid(), State.ProductLine, State.RiskSectionId, sectionElement.Name.LocalName, riskItemElement.Name.LocalName));
                }
            }
        }
Exemple #8
0
        public void ExtractMapFromRequest(string request)
        {
            GreenLogger.Log("Extract risk capture map from request");

            RequestBodyElement body        = request.ToXDocument().GetInsureServeMessage().RequestBody;
            ProductLineCode    productLine = ProductLineCode.Parse(body.BusinessTransaction.ProductLineCode.Value);

            if (!State.ProductLines.ContainsKey(productLine))
            {
                GreenLogger.Log("new risk product line mapped for {0}", productLine);
                Then(new NewRiskProductLineMapped(productLine));
            }

            State.ProductLines[productLine].ExtractMapFromRisk(body.PolMessage.InputPolData);
        }
Exemple #9
0
        public void Handle(ProcessRiskCapture message)
        {
            GreenLogger.Log("Processing risk capture");

            using (repository.StartUnitOfWork())
            {
                var mapId = new MapId();
                var map   = repository.Get <Map>(mapId);
                map.ExtractMapFromRequest(message.Request);

                var captureId = RiskCaptureId.Parse(message.Request.ToXDocument().GetHeader().SequenceId.Value);
                var capture   = repository.Get <RiskCapture>(captureId);
                capture.ExtractCaptureFromRequest(captureId, message.Request, map);
            }
        }
Exemple #10
0
        public void ExtractMapFromRisk(InputPolDataElement risk)
        {
            GreenLogger.Log("Extracting map from risk for {0}", State.ProductLine);
            foreach (XElement riskSectionElement in risk.InnerXElement.Elements())
            {
                if (!State.Sections.ContainsKey(riskSectionElement.Name.LocalName))
                {
                    GreenLogger.Log("new risk section mapped for {0}", riskSectionElement.Name.LocalName);

                    Then(new NewRiskSectionMapped(State.ProductLine, Guid.NewGuid(), riskSectionElement.Name.LocalName));
                }

                State.Sections[riskSectionElement.Name.LocalName].ExtractMapFromRiskSection(riskSectionElement);
            }
        }
Exemple #11
0
        public void Handle(CreateRiskTable message)
        {
            GreenLogger.Log("Creating table {0}.{1}", message.Schema, message.Name);

            const string CreateTableSql = @"
CREATE TABLE [{0}].[{1}](
	[Id] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_{0}_{1}] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]";

            runner.ExecuteCommand(string.Format(CultureInfo.InvariantCulture, CreateTableSql, message.Schema, message.Name));
        }
        public void Handle(UpdateRiskTableColumnValue message)
        {
            var mapping = projectionStore
                          .GetProjection <RiskCaptureItemToDataWarehouseColumnMapping>(RiskCaptureItemToDataWarehouseColumnMappingId.Parse(message.Schema))
                          .Single(i => i.ItemId == message.Id);

            GreenLogger.Log("Updating column {0} in table {1}.{2} with value {3}", mapping.TableName, message.Schema, mapping.ColumnName, message.ColumnValue);

            const string UpsertSql = @"
IF NOT EXISTS (SELECT * FROM [{0}].[{1}] WHERE Id = '{2}') 
	INSERT INTO [{0}].[{1}](Id,{3}) VALUES('{2}','{4}') 
ELSE 
	UPDATE [{0}].[{1}] SET {3} = '{4}' WHERE Id = '{2}'"    ;

            runner.ExecuteCommand(string.Format(
                                      CultureInfo.InvariantCulture,
                                      UpsertSql,
                                      message.Schema,
                                      mapping.ColumnName,
                                      message.Id,
                                      mapping.TableName,
                                      message.ColumnValue));
        }
 public void Merge(string fieldName, string fieldValue)
 {
     GreenLogger.Log("Merging {0} into document with value {1}", fieldName, fieldValue);
     Text = Text.Replace("{{" + fieldName + "}}", fieldValue);
 }
Exemple #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting");
            var yLogger = new YellowLogger();
            var cLogger = new CyanLogger();
            var wLogger = new WhiteLogger();
            var gLogger = new GreenLogger();
            // Started


            /* Cold Subscription */

            // create Observable generator
            var source = ObservableTickers(50);

            Thread.Sleep(1300);
            //subscribe to observable
            var coldThread1 = new Thread(() =>
            {
                var subsCold = source
                               //.Where(c => c.TypeId > 400 && c.TypeId < 500)
                               .Subscribe(
                    x => yLogger.Log(() => Console.WriteLine("Cold OnNext: {0}", x)),
                    ex => yLogger.Log(() => Console.WriteLine("Cold OnError: {0}", ex.Message)),
                    () => yLogger.Log(() => Console.WriteLine("Cold OnCompleted")));
                subsCold.Dispose();
            });
            //subscribe to observable
            var coldThread2 = new Thread(() =>
            {
                var subs2Cold = source
                                //.Where(c => c.TypeId > 400 && c.TypeId < 500)
                                .Subscribe(
                    x => cLogger.Log(() => Console.WriteLine("Cold OnNext: {0}", x)),
                    ex => cLogger.Log(() => Console.WriteLine("Cold OnError: {0}", ex.Message)),
                    () => cLogger.Log(() => Console.WriteLine("Cold OnCompleted")));
                // kill subscription
                subs2Cold.Dispose();
            });

            coldThread1.Start();
            coldThread2.Start();


            /* Hot Subscription - 1 */
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkGray;
            var tab = "                                                                                            ";

            Console.WriteLine(tab + "/* Hot Subscription - 1 */");
            Console.WriteLine();
            // http://rxwiki.wikidot.com/101samples#toc48
            IConnectableObservable <ILogItem> hotSource = Observable.Publish <ILogItem>(ObservableTickers(100));

            Thread.Sleep(2000);
            wLogger.Log(() => Console.WriteLine(tab + "Стартую первый"));
            IDisposable hots = hotSource
                               //.Where(c => c.TypeId >= 1000)
                               .Subscribe(
                x => yLogger.Log(() => Console.WriteLine(tab + "Hot1 Observer 1: OnNext: {0}", x)),
                ex => yLogger.Log(() => Console.WriteLine(tab + "Hot1 Observer 1: OnError: {0}", ex.Message)),
                () => yLogger.Log(() => Console.WriteLine(tab + "Hot1 Observer 1: OnCompleted")));

            wLogger.Log(() => Console.WriteLine(tab + "Коннект"));
            var threadHot1 = new Thread(() => hotSource.Connect());

            threadHot1.Start();

            Thread.Sleep(1500);
            wLogger.Log(() => Console.WriteLine(tab + "Стартую второй"));
            IDisposable hots2 = hotSource
                                //.Where(c => c.TypeId < 1000)
                                .Subscribe(
                x => cLogger.Log(() => Console.WriteLine(tab + "Hot1 Observer 2: OnNext: {0}", x)),
                ex => cLogger.Log(() => Console.WriteLine(tab + "Hot1 Observer 2: OnError: {0}", ex.Message)),
                () => cLogger.Log(() => Console.WriteLine(tab + "Hot1 Observer 2: OnCompleted")));

            //hotSource.Connect();       // hot is connected to source and starts pushing value to subscribers
            Thread.Sleep(3000);
            wLogger.Log(() => Console.WriteLine("Уничтожил Hot1 Observer 1"));
            hots.Dispose();

            /* Hot Subscription - 2 */
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("/* Hot Subscription - 2 */");
            Console.WriteLine();
            var observer = new Subject <ILogItem>();

            var thread = new Thread(() => TickerPopulation(observer, 1000));

            thread.Start();
            Thread.Sleep(2000);
            wLogger.Log(() => Console.WriteLine("Стартую первый"));
            var subs1 = observer.Where(c => c.TypeId >= 1000).Subscribe(Observer.Create <ILogItem>(c => cLogger.Log(() => Console.WriteLine("Hot2 Observer 1: OnNext: {0}", c))));


            Thread.Sleep(2000);
            wLogger.Log(() => Console.WriteLine("Стартую второй"));
            var subs2 = observer.Where(c => c.TypeId < 1000).Subscribe(Observer.Create <ILogItem>(c => yLogger.Log(() => Console.WriteLine("Hot2 Observer 2: OnNext: {0}", c))));

            Thread.Sleep(2000);
            subs1.Dispose();
            wLogger.Log(() => Console.WriteLine("Уничтожил первый"));

            Thread.Sleep(2000);
            wLogger.Log(() => Console.WriteLine("Стартую третий"));
            var subs3 = observer.Where(c => c.TypeId < 1000).Subscribe(Observer.Create <ILogItem>(c => gLogger.Log(() => Console.WriteLine("Hot2 Observer 3: OnNext: {0}", c))));

            Thread.Sleep(2000);
            subs2.Dispose();
            wLogger.Log(() => Console.WriteLine("Уничтожил второй"));

            Thread.Sleep(2000);
            subs3.Dispose();
            wLogger.Log(() => Console.WriteLine("Уничтожил третий"));

            Thread.Sleep(2000);
            observer.Dispose();
            wLogger.Log(() => Console.WriteLine("Уничтожил observer"));


            //// Finish
            Console.WriteLine("Press to exit");
            Console.ReadKey();
        }