コード例 #1
0
ファイル: Test.cs プロジェクト: EugeneKrapivin/-CallIDViewer
        public void CompleteServerEvent()
        {
            List <EventModel> events = new List <EventModel>
            {
                new ClientRequestEventModel()
                {
                    System = new CallIDViewer.Events.System
                    {
                        Service = "Gator"
                    }
                    , To = new Target()
                    {
                        Service = "SitesService",
                        Method  = "GetSite"
                    }
                    , TotalTimeMs = 100,
                    CreateBy      = EventModel.Create.Real,
                }
            };
            var orderByFlow = new OrderManger();
            var orderFlow   = orderByFlow.EnrichDataClientOrServerEvent(events.ToArray());
            var result      = orderByFlow.OrderClientAndServer(orderFlow);

            Assert.AreEqual(result.Count, 2);
            Assert.AreEqual(result.First().GetType(), typeof(ClientRequestEventModel));
            Assert.AreEqual(result.Last().GetType(), typeof(ServerRequestEventModel));
        }
コード例 #2
0
        public Result Post([FromQuery] string callId, [FromBody] RowEvent[] rowEvents)
        {
            //   var rowEvents = JsonConvert.DeserializeObject<List<RowEvent>>(rawData);
            MermaidMarkdown mermaidMarkdown = new MermaidMarkdown();

            if (rowEvents.Any() == false)
            {
                Console.WriteLine("No event found");
                return(null);
            }
            Console.WriteLine($"Found event{rowEvents.Count()}");
            RowEventExport eventExport = new RowEventExport();

            eventExport.SaveEventToFile(rowEvents, callId);

            var events                = (new EventConvertor()).Convert(rowEvents);
            var orderManger           = new OrderManger();
            var serverAndClientEvents = orderManger.EnrichDataClientOrServerEvent(events);

            if (serverAndClientEvents.Any() == false)
            {
                if (rowEvents.Any() == false)
                {
                    Console.WriteLine("No flow found");
                    return(null);
                }
                else
                {
                    return(new Result
                    {
                        Events = events.ToList()
                        ,
                        MermaidMarkdown = mermaidMarkdown.Draw(events.Where(e => e is RequestEventModel)),
                        RequestTags = GetReqestTags(rowEvents).ToList()
                    });
                }
            }

            var orderClientAndServerOnly = orderManger.OrderClientAndServer(serverAndClientEvents);
            var orderEvents           = orderManger.AddRequest(events.SingleOrDefault(e => e is RequestEventModel), orderClientAndServerOnly);
            var mermaidMarkdownResult = mermaidMarkdown.Draw(orderEvents);

            return(new Result
            {
                Events = events.ToList(),
                MermaidMarkdown = mermaidMarkdownResult
                ,
                OrdererFlow = orderEvents.ToList()
                ,
                RequestTags = GetReqestTags(rowEvents)?.ToList()
            });
        }
コード例 #3
0
        public void ProductNotInStock()
        {
            var productStockRepositoryMock = new Mock <IProductStockRepository>();

            productStockRepositoryMock.Setup(m => m.IsInStock(It.IsAny <Product>())).Returns(false);

            var paymentServiceMock  = new Mock <PaymentService>();
            var shippingServiceMock = new Mock <IShippingService>();

            var orderManger = new OrderManger(productStockRepositoryMock.Object, paymentServiceMock.Object, shippingServiceMock.Object);

            Assert.ThrowsAny <Exception>(() => orderManger.Submit(Product.Keyboard, "1000200030004000", "0124"));
        }
コード例 #4
0
ファイル: Test.cs プロジェクト: EugeneKrapivin/-CallIDViewer
        public void test()
        {
            // string callID = args[0];// "0dd6e243c6854b3bbb1fe2988658cdae"; //"0dd6e243c6854b3bbb1fe2988658cdae";

            string callID = "0dd6e243c6854b3bbb1fe2988658cdae"; //"0dd6e243c6854b3bbb1fe2988658cdae";

            var rowEvents = JsonConvert.DeserializeObject <List <RowEvent> >(
                File.ReadAllText($@"C:\Users\I347253\Desktop\Ghrap\{callID}.json"));



            var convertEvent          = (new EventConvertor()).Convert(rowEvents);
            var orderManger           = new OrderManger();
            var serverAndClientEvents = orderManger.EnrichDataClientOrServerEvent(convertEvent.ToArray());
            var events  = orderManger.OrderClientAndServer(serverAndClientEvents);
            var events1 = orderManger
                          .AddRequest(convertEvent.SingleOrDefault(X => X.Type == "request"), events.ToArray()).ToList();
            MermaidMarkdown mermaidMarkdown = new MermaidMarkdown();
            var             result          = mermaidMarkdown.Draw(events1.ToArray());
        }
コード例 #5
0
        public static async Task Main(string[] args)
        {
            if (args.Length == 0 || args.Length > 2)
            {
                Console.WriteLine(
                    "You mast pass callID as the first argument there is also option to filter actor like Hades,Sql");
                Console.ReadLine();
                return;
            }

            string filter = null;
            string callId = args[0];

            if (args.Length == 2)
            {
                filter = args[1];
            }

            ElasticsearchAdapter   manger    = new ElasticsearchAdapter();
            IEnumerable <RowEvent> rowEvents = await manger.GetData(callId);

            if (rowEvents.Any() == false)
            {
                Console.WriteLine("No event found");
                return;
            }
            Console.WriteLine($"Found event{rowEvents.Count()}");
            RowEventExport eventExport = new RowEventExport();

            eventExport.SaveEventToFile(rowEvents, callId);

            var events                = (new EventConvertor()).Convert(rowEvents);
            var orderManger           = new OrderManger();
            var serverAndClientEvents = orderManger.EnrichDataClientOrServerEvent(events);

            if (serverAndClientEvents.Any() == false)
            {
                if (rowEvents.Any() == false)
                {
                    Console.WriteLine("No flow found");
                    return;
                }
            }

            var             orderClientAndServerOnly = orderManger.OrderClientAndServer(serverAndClientEvents);
            var             orderEvents     = orderManger.AddRequest(events.SingleOrDefault(e => e is RequestEventModel), orderClientAndServerOnly);
            MermaidMarkdown mermaidMarkdown = new MermaidMarkdown();
            var             result          = mermaidMarkdown.Draw(orderEvents);

            if (filter != null)
            {
                if (filter.Contains(","))
                {
                    var filterBy = filter.Split(',');
                    foreach (var f in filterBy)
                    {
                        result.RemoveAll(x => x.Contains(f));
                    }
                }
                else
                {
                    result.RemoveAll(x => x.Contains(filter));
                }
            }

            WebDraw.Draw(result, callId);
            var p = new Process
            {
                StartInfo = new ProcessStartInfo($@"{callId}.html")
                {
                    UseShellExecute = true
                }
            };

            p.Start();

            Console.WriteLine("Done");
        }