Esempio n. 1
0
        public static IServiceCollection AddLoggerClientEventTypeControl(this IServiceCollection container)
        {
            var logger = new LoggerClientEventTypeControl();

            container.AddSingleton <ILoggerClientEventTypeControl>(logger);

            return(container);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            const string processContext = "Main";

            // Create the logger cliet for this program
            var loggerClient = new LoggerClientEventTypeControl(); // LoggerClientEventTypeControl.Implementation.LoggerClientEventTypeControl();
            //loggerClient.Log(new DefaultLoggerClientObject{OperationContext = "ConsoleApp.Main Start",ProcessContext = processContext,SolutionContext = SolutionContext});

            var provider = new ServiceCollection()
                           .BuildUp()
                           .BuildServiceProvider();

            // Set up different components
            //  var validatorFactory = provider.GetService<IValidatorFactory>();
            //  var controllerFactory = provider.GetService<IControllerFactory>();
            //   var resolverFactory = provider.GetService<IResolverFactory>();
            var leadCollector   = provider.GetService <ILeadCollector>();
            var campaignManager = provider.GetService <ICampaignManager>();
            var leadDispatcher  = provider.GetService <ILeadDispatcher>();
            //   var loggerClientEventTypeControl = provider.GetService<ILoggerClientEventTypeControl>();
            //   var campaign = provider.GetService<ICampaign>();

            // Mock leads to be sent through
            var leadEntities = CreateLeads();

            // Ask for user to select a lead to process
            WriteToConsole($"{GetLeadDirectory()}Select a lead [1-{leadEntities.Length}] to process: ", LogColors);
            int.TryParse(Console.ReadLine(), out var leadChoice);

            // Process the lead
            while (leadChoice >= 1 && leadChoice <= leadEntities.Length)
            {
                leadChoice--; //Since array indices start at 0
                WriteToConsole("\n_______________________________________________________________________________________________________________________________\n\n", LogColors);
                WriteToConsole($"Processing Activity ID {leadEntities[leadChoice].Context.First(ctx => ctx.Id == ContextKeys.ActivityGuidKey).Value}", LogColors);
                WriteToConsole(JsonConvert.SerializeObject(leadEntities[leadChoice], Formatting.Indented), ObjectLogColors);
                leadCollector.CollectLead(leadEntities[leadChoice]);
                Console.ReadLine();
                WriteToConsole($"{GetLeadDirectory()}Select a lead [1-{leadEntities.Length}] to process: ", LogColors);
                int.TryParse(Console.ReadLine(), out leadChoice);
            }


            //loggerClient.Log(new DefaultLoggerClientObject{OperationContext = "ConsoleApp.Main End",ProcessContext = processContext,SolutionContext = SolutionContext});

            //loggerClient.Log(new DefaultLoggerClientErrorObject{OperationContext = "Ending. Press any key to continue...",ProcessContext = processContext,SolutionContext = SolutionContext});
            WriteToConsole("The End.  Press any key to continue...", LogColors);
            Console.ReadKey();
        }