Beispiel #1
0
        private static void PersistEvents(IMongoCollection <ReiEventBase> coll, ReportingEntityInstance instance)
        {
            var validations = instance.GetUncommittedChanges();

            coll.InsertMany(validations.OfType <ReiEventBase>());
            instance.MarkChangesAsCommitted();
        }
Beispiel #2
0
        private static ReportingEntityInstance LoadDomain(IMongoCollection <ReiEventBase> coll, string formId, string rei)
        {
            var instance = new ReportingEntityInstance(formId, rei);
            var events   = coll.Find <ReiEventBase>(veb => veb.FormId == formId && veb.ReportingEntityInstanceId == rei)
                           .SortBy(veb => veb.Timestamp);

            instance.LoadFromHistory(events.ToEnumerable());
            return(instance);
        }
Beispiel #3
0
 private static void PersistEvents(IMongoCollection<ReiEventBase> coll, ReportingEntityInstance instance)
 {
     var validations = instance.GetUncommittedChanges();
     coll.InsertMany(validations.OfType<ReiEventBase>());
     instance.MarkChangesAsCommitted();
 }
Beispiel #4
0
 private static ReportingEntityInstance LoadDomain(IMongoCollection<ReiEventBase> coll, string formId, string rei)
 {
     var instance = new ReportingEntityInstance(formId, rei);
     var events = coll.Find<ReiEventBase>(veb => veb.FormId == formId && veb.ReportingEntityInstanceId == rei)
                      .SortBy(veb => veb.Timestamp);
     instance.LoadFromHistory(events.ToEnumerable());
     return instance;
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            var coll = SetupMongoMaps();

            var timestamp = DateTime.UtcNow.Ticks;

            PrintInstructions();

            Console.WriteLine("Form ID: ");
            var formId = Console.ReadLine();

            Console.WriteLine("Reporting Entity Instance ID: ");
            var rei = Console.ReadLine();

            ReportingEntityInstance instance = LoadDomain(coll, formId, rei);

            while (true)
            {
                var cmd      = Console.ReadLine();
                var cmdParts = cmd.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                switch (cmdParts[0])
                {
                case "Q":
                    Console.WriteLine("BYE!!");
                    return;

                    break;

                case "L":
                    formId   = cmdParts[1];
                    rei      = cmdParts[2];
                    instance = LoadDomain(coll, formId, rei);
                    Console.WriteLine($"Form ID {formId} REI ID {rei} loaded!!");
                    break;

                case "F":
                    var failures = instance.GetFailingControls();
                    Console.WriteLine("Current failing controls...");
                    foreach (var fail in failures)
                    {
                        Console.WriteLine($"{fail.ControlId} {fail.State} {fail.Validator} {fail.Message}");
                    }
                    Console.WriteLine("");
                    break;

                case "S":
                    Console.WriteLine("Current status for all controls...");

                    var status = instance.GetStatus();
                    foreach (var stat in status)
                    {
                        Console.WriteLine($"{stat.ControlId} {stat.State} {stat.Validator} {stat.Message}");
                    }
                    Console.WriteLine("");
                    break;

                case "P":
                    PersistEvents(coll, instance);

                    timestamp = DateTime.UtcNow.Ticks;

                    Console.WriteLine("PERSISTED!");
                    Console.WriteLine("");
                    break;

                case "C":
                    PrintInstructions();
                    break;

                case "ADD":
                    var isPass = cmdParts[1].Equals("PASS");
                    if (isPass)
                    {
                        instance.PassValidation(cmdParts[2], cmdParts[3], cmdParts[4], timestamp, cmdParts[5]);
                    }
                    else
                    {
                        instance.FailValidation(cmdParts[2], cmdParts[3], cmdParts[4], timestamp, cmdParts[5]);
                    }
                    break;

                default:
                    break;
                }
            }
        }