public void YesterdayTest()
        {
            var date         = FuzzyDateTime.Parse("yesterday");
            var expectedDate = DateTime.Now.AddDays(-1);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void NextXSecondsTest([Range(0, 120)] int numOfSeconds)
        {
            var date         = FuzzyDateTime.Parse($"next {numOfSeconds} seconds");
            var expectedDate = DateTime.Now.AddSeconds(numOfSeconds);

            date.Should().BeCloseTo(expectedDate, 100);
        }
        public void LastOrNextYearTest(string direction, int yearsToAdd)
        {
            var date         = FuzzyDateTime.Parse($"{direction} year");
            var expectedDate = new DateTime(DateTime.Now.Year + yearsToAdd, 1, 1);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void XDaysBeforeOrAfterTheFirstOrLastOfTheMonthXMonthsAgoTest([Values(1, 2, 3)] int numOfDays,
                                                                             [Values("before", "after")] string daysDirection,
                                                                             [Values("first", "last")] string timeOfMonth,
                                                                             [Values(1, 2, 3)] int numOfMonths)
        {
            var date         = FuzzyDateTime.Parse($"{numOfDays} days {daysDirection} the {timeOfMonth} of the month {numOfMonths} months ago");
            var expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            if (timeOfMonth == "last")
            {
                expectedDate = expectedDate
                               .AddMonths(-numOfMonths + 1)
                               .AddDays(-1);
            }
            else
            {
                expectedDate = expectedDate
                               .AddMonths(-numOfMonths);
            }

            if (daysDirection == "before")
            {
                expectedDate = expectedDate
                               .AddDays(-numOfDays);
            }
            else
            {
                expectedDate = expectedDate
                               .AddDays(numOfDays);
            }

            date.Should().BeSameDateAs(expectedDate);
        }
        public void XMonthsFromToday([Values(-1000, -100, -10, -9, -1, 0, 1, 9, 10, 100, 1000)] int numOfMonths)
        {
            var date         = FuzzyDateTime.Parse($"{numOfMonths} months from today");
            var expectedDate = DateTime.Now.AddMonths(numOfMonths);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void TodayTest()
        {
            var date         = FuzzyDateTime.Parse("today");
            var expectedDate = DateTime.Now;

            date.Should().BeSameDateAs(expectedDate);
        }
        public void NextXYearsTest([Range(0, 100)] int numOfYears)
        {
            var date         = FuzzyDateTime.Parse($"next {numOfYears} years");
            var expectedDate = DateTime.Now.AddYears(numOfYears);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void XSecondsAgoTest([Range(0, 120)] int numOfSeconds)
        {
            var date         = FuzzyDateTime.Parse($"{numOfSeconds} seconds ago");
            var expectedDate = DateTime.Now.AddSeconds(-numOfSeconds);

            date.Should().BeCloseTo(expectedDate, 100);
        }
        public void XMinutesAgoTest([Range(0, 120)] int numOfMinutes)
        {
            var date         = FuzzyDateTime.Parse($"{numOfMinutes} minutes ago");
            var expectedDate = DateTime.Now.AddMinutes(-numOfMinutes);

            date.Should().BeCloseTo(expectedDate, 100);
        }
        public void NextXMinutesTest([Range(0, 120)] int numOfMinutes)
        {
            var date         = FuzzyDateTime.Parse($"next {numOfMinutes} minutes");
            var expectedDate = DateTime.Now.AddMinutes(numOfMinutes);

            date.Should().BeCloseTo(expectedDate, 100);
        }
        public void XHoursAgoTest([Range(0, 144)] int numOfHours)
        {
            var date         = FuzzyDateTime.Parse($"{numOfHours} hours ago");
            var expectedDate = DateTime.Now.AddHours(-numOfHours);

            date.Should().BeCloseTo(expectedDate, 100);
        }
        public void NextXHoursTest([Range(0, 144)] int numOfHours)
        {
            var date         = FuzzyDateTime.Parse($"next {numOfHours} hours");
            var expectedDate = DateTime.Now.AddHours(numOfHours);

            date.Should().BeCloseTo(expectedDate, 100);
        }
        public void NextXMonthsTest([Range(0, 100)] int numOfMonths)
        {
            var date         = FuzzyDateTime.Parse($"next {numOfMonths} months");
            var expectedDate = DateTime.Now.AddMonths(numOfMonths);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void XMonthsAgoTest([Range(0, 100)] int numOfMonths)
        {
            var date         = FuzzyDateTime.Parse($"{numOfMonths} months ago");
            var expectedDate = DateTime.Now.AddMonths(-numOfMonths);

            date.Should().BeSameDateAs(expectedDate);
        }
Ejemplo n.º 15
0
        private static ItemAndQueries CreateAuditingSession(string name, string email, string title, DateTime date)
        {
            var queries = new List <string>();

            var auditSession = new AuditSession(title);

            queries.AddRange(auditSession.ToInsertQueries());

            var auditor = new Auditor(name, name, new List <char>(), email);

            queries.AddRange(auditor.ToInsertQueries());

            var citation = new Citation("Audit Session_" + title, auditSession.Id);

            queries.AddRange(citation.ToInsertQueries());

            var auditDate = new FuzzyDateTime(date, citation.Id, auditSession.Id);

            queries.AddRange(auditDate.ToInsertQueries());

            queries.AddRange(new WhatHappenedWhen(auditSession.Id, auditDate.Id, citation.Id, auditSession.Id).ToInsertQueries());
            queries.AddRange(new WhoDidWhat(auditor.Id, auditSession.Id, citation.Id, auditSession.Id).ToInsertQueries());

            return(new ItemAndQueries(auditSession, queries));
        }
        public void TomorrowTest()
        {
            var date         = FuzzyDateTime.Parse("tomorrow");
            var expectedDate = DateTime.Now.AddDays(1);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void NextMonthTest()
        {
            var date         = FuzzyDateTime.Parse("next month");
            var expectedDate = DateTime.Now.AddMonths(1);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void NextXDaysTest([Values(0, 1, 9, 10, 100, 1000)] int numOfDays)
        {
            var date         = FuzzyDateTime.Parse($"next {numOfDays} days");
            var expectedDate = DateTime.Now.AddDays(numOfDays);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void XDaysAgoTest([Values(0, 1, 9, 10, 100, 1000)] int numOfDays)
        {
            var date         = FuzzyDateTime.Parse($"{numOfDays} days ago");
            var expectedDate = DateTime.Now.AddDays(-numOfDays);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void XYearsAgoTest([Range(0, 100)] int numOfYears)
        {
            var date         = FuzzyDateTime.Parse($"{numOfYears} years ago");
            var expectedDate = DateTime.Now.AddYears(-numOfYears);

            date.Should().BeSameDateAs(expectedDate);
        }
        public void DayXOfLastOrThisOrNextMonthTest([Range(1, 28)] int day,
                                                    [Values("last", "this", "next")] string direction)
        {
            var date         = FuzzyDateTime.Parse($"day {day} of {direction} month");
            var expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, day);

            expectedDate = direction switch
            {
                "last" => expectedDate.AddMonths(-1),
                "next" => expectedDate.AddMonths(1),
                _ => expectedDate
            };

            date.Should().BeSameDateAs(expectedDate);
        }
        public void FirstOrLastOfTheMonthXMonthsAgoTest([Values("first", "last")] string timeOfMonth,
                                                        [Range(0, 100)] int numOfMonths)
        {
            var date         = FuzzyDateTime.Parse($"{timeOfMonth} of the month {numOfMonths} months ago");
            var expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            if (timeOfMonth == "last")
            {
                expectedDate = expectedDate
                               .AddMonths(-numOfMonths + 1)
                               .AddDays(-1);
            }
            else
            {
                expectedDate = expectedDate
                               .AddMonths(-numOfMonths);
            }

            date.Should().BeSameDateAs(expectedDate);
        }
        public void LastOrNextDayOfWeekTest([Values("last", "next")] string direction,
                                            [Values("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")] string dayOfWeekStr)
        {
            var date      = FuzzyDateTime.Parse($"{direction} {dayOfWeekStr}");
            var dayOfWeek = Enum.Parse <DayOfWeek>(dayOfWeekStr, true);

            date.DayOfWeek.Should().BeEquivalentTo(dayOfWeek);

            if (direction == "last")
            {
                date.Should()
                .BeBefore(DateTime.Today).And
                .BeWithin(TimeSpan.FromDays(7));
            }
            else
            {
                date.Should()
                .BeAfter(DateTime.Today).And
                .BeWithin(TimeSpan.FromDays(7));
            }
        }
Ejemplo n.º 24
0
 private static bool OperatorCompletedBefore(SearchContext context, string argument)
 {
     if (!context.Task.Completed.HasValue)
         return false;
     FuzzyDateTime dateTime = DateConverter.ParseDateTime(argument, context.DateFormat);
     FuzzyDateTime completed = new FuzzyDateTime(context.Task.Completed.Value, true);
     return completed <= dateTime;
 }
Ejemplo n.º 25
0
 public FuzzyDateRange(FuzzyDateTime startDateTime, int daysSpan)
 {
     StartDateTime = startDateTime;
     EndDateTime   = new FuzzyDateTime(startDateTime.DateTime.AddDays(daysSpan), startDateTime.Format);
 }
Ejemplo n.º 26
0
 private static bool OperatorAddedBefore(SearchContext context, string argument)
 {
     FuzzyDateTime dateTime = DateConverter.ParseDateTime(argument, context.DateFormat);
     FuzzyDateTime added = new FuzzyDateTime(context.Task.Added, true);
     return added <= dateTime;
 }
Ejemplo n.º 27
0
        public static List <string> DataPopulationQueries()
        {
            var entries = new List <string>();

            var auditSessionAndQueries = CreateAuditingSession("Mike Minns", "*****@*****.**", "Session 1", DateTime.Now);

            entries.AddRange(auditSessionAndQueries.Queries);
            var auditSession = auditSessionAndQueries.Instance;

            var scrapbook = new Book("1st Derbyshire Yeomanry Scrapbook 1939 - 1947");

            entries.AddRange(scrapbook.ToInsertQueries());

            var citation1 = new Citation(scrapbook.Name, 1, auditSession.Id);

            entries.AddRange(citation1.ToInsertQueries());


            var uk = new Country("en-UK", citation1.Id, auditSession.Id);

            entries.AddRange(uk.ToInsertQueries());

            var derby = new Municipality("Derby", citation1.Id, auditSession.Id);

            entries.AddRange(derby.ToInsertQueries());
            entries.AddRange(new HostedBy(derby.Id, uk.Id, citation1.Id, auditSession.Id).ToInsertQueries());

            var catterick = new Municipality("Catterick", citation1.Id, auditSession.Id);

            entries.AddRange(catterick.ToInsertQueries());
            entries.AddRange(new HostedBy(catterick.Id, uk.Id, citation1.Id, auditSession.Id).ToInsertQueries());

            var london = new Municipality("London", citation1.Id, auditSession.Id);

            entries.AddRange(london.ToInsertQueries());
            entries.AddRange(new HostedBy(london.Id, uk.Id, citation1.Id, auditSession.Id).ToInsertQueries());



            /*
             * var scrapBook = new SimplePublication("1st Derbyshire Yeomanry Scrapbook 1939 - 1947",
             *  new VariousAuthors(),
             *  new UnknownEditors(),
             *  new UnknownPublicationDateTime(),
             *  new SimplePublisher("Bemrose & Sons Ltd",
             *      new List<IPostalAddress>() {
             *          new SimplePostalAddress(derby, uk),
             *          new SimplePostalAddress(london, uk)
             *      }
             *  )
             * );
             */


            var variousPerson = new Person("Various");

            entries.AddRange(variousPerson.ToInsertQueries());
            entries.AddRange(new Authored(variousPerson.Id, scrapbook.Id, citation1.Id, auditSession.Id).ToInsertQueries());

            var unknownPerson = new Person("Unknown");

            entries.AddRange(unknownPerson.ToInsertQueries());
            entries.AddRange(new Edited(unknownPerson.Id, scrapbook.Id, citation1.Id, auditSession.Id).ToInsertQueries());


            var bemrosePublisher = new Publisher("Bemrose & Sons Ltd", citation1.Id, auditSession.Id);

            entries.AddRange(bemrosePublisher.ToInsertQueries());

            entries.AddRange(new HostedBy(bemrosePublisher.Id, derby.Id, citation1.Id, auditSession.Id).ToInsertQueries());
            entries.AddRange(new Hosts(derby.Id, bemrosePublisher.Id, citation1.Id, auditSession.Id).ToInsertQueries());

            entries.AddRange(new HostedBy(bemrosePublisher.Id, london.Id, citation1.Id, auditSession.Id).ToInsertQueries());
            entries.AddRange(new Hosts(london.Id, bemrosePublisher.Id, citation1.Id, auditSession.Id).ToInsertQueries());

            entries.AddRange(new Published(bemrosePublisher.Id, scrapbook.Id, citation1.Id, auditSession.Id).ToInsertQueries());
            entries.AddRange(new PublishedBy(scrapbook.Id, bemrosePublisher.Id, citation1.Id, auditSession.Id).ToInsertQueries());


            /*
             *
             * var mobilisationDate = new FuzzyDateTime(new DateTime(1939, 7, 29), "yyyy/MM/dd");
             * var veDay = new FuzzyDateTime(new DateTime(1945, 5, 8), "yyyy/MM/dd");
             */

            var mobilisationDate = new FuzzyDateTime(new DateTime(1939, 7, 29), "yyyy/MM/dd", citation1.Id, auditSession.Id);

            entries.AddRange(mobilisationDate.ToInsertQueries());
            var mobilisationDay = new KeyDateTime("UK Mobilisation Day", citation1.Id, auditSession.Id);

            entries.AddRange(mobilisationDay.ToInsertQueries());
            entries.AddRange(new WhatHappenedWhen(mobilisationDay.Id, mobilisationDate.Id, citation1.Id, auditSession.Id).ToInsertQueries());
            entries.AddRange(new WhenWhatHappened(mobilisationDate.Id, mobilisationDay.Id, citation1.Id, auditSession.Id).ToInsertQueries());

            /*
             * entries.AddRange(mobilisationDay.ToInsertQueries());
             * entries.AddRange(new AuditedBy(mobilisationDay.Id, auditSession.Id).ToInsertQueries());
             *
             * var veDate = new FuzzyDateTime(new DateTime(1945, 5, 8), "yyyy/MM/dd", citation1.Id, auditSession.Id);
             * entries.AddRange(veDate.ToInsertQueries());
             * var veDay = new KeyDateTime("VE Day", citation1.Id, auditSession.Id);
             * entries.AddRange(new WhatHappenedWhen(veDay.Id, veDate.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new WhenWhatHappened(veDate.Id, veDay.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             */
            /*
             * var armouredCar = new TemporalRole(
             *  new Reconnaissance(),
             *  new FuzzyDateRange(
             *      mobilisationDate),
             *  GetCitationPage(1, scrapBook),
             *  audit);
             *
             */
            /*
             *
             * var firstDerbyshireYeomanry = new Unit("1st Derbyshire Yeomanry", "regiment", citation1.Id, auditSession.Id);
             * //var firstDerbyshireYeomanry = new Regiment("1st Derbyshire Yeomanry", citation1, auditSession);
             * var reconnaissance = new OrganisationRole("reconnaissance");
             *
             * var actedAs = new ActedAsDuring(firstDerbyshireYeomanry.Id, reconnaissance.Id, mobilisationDate.Id, citation1.Id, auditSession.Id);
             * entries.AddRange(firstDerbyshireYeomanry.ToInsertQueries());
             * entries.AddRange(reconnaissance.ToInsertQueries());
             * entries.AddRange(actedAs.ToInsertQueries());
             */

            /*
             * var siddalsRoad = new SimplePostalAddress(null, new SimpleStreetAddress(91, "Siddals Road"), derby, null, null, uk, null, null);
             * var siddalsRoadPosting = new TemporalLocation(siddalsRoad, new FuzzyDateRange(mobilisationDate),
             *                      GetCitationPage(1, scrapBook),
             *                      audit);
             */
            /*
             * var ninetyOne = new Building(91, citation1.Id, auditSession.Id);
             * entries.AddRange(ninetyOne.ToInsertQueries());
             *
             * var siddalsRoad = new Street("Siddals Road", citation1.Id, auditSession.Id);
             * entries.AddRange(siddalsRoad.ToInsertQueries());
             *
             * entries.AddRange(new Hosts(siddalsRoad.Id, ninetyOne.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(ninetyOne.Id, siddalsRoad.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(derby.Id, siddalsRoad.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(siddalsRoad.Id, derby.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             *
             *
             *
             * var latLong = new LatitudeLongtitude(0.0, 0.0, citation1.Id, auditSession.Id);
             * entries.AddRange(new Hosts(ninetyOne.Id, latLong.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(latLong.Id, ninetyOne.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(siddalsRoad.Id, latLong.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(latLong.Id, siddalsRoad.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(derby.Id, latLong.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(latLong.Id, derby.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(uk.Id, latLong.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(latLong.Id, uk.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             *
             * var address = new Address(citation1.Id, auditSession.Id);
             * entries.AddRange(new Hosts(address.Id, ninetyOne.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(ninetyOne.Id, address.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(address.Id, siddalsRoad.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(siddalsRoad.Id, address.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(address.Id, derby.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(derby.Id, address.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(address.Id, uk.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(uk.Id, address.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new Hosts(address.Id, latLong.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             * entries.AddRange(new HostedBy(latLong.Id, address.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             *
             * entries.AddRange(new LocatedInDuring(firstDerbyshireYeomanry.Id, address.Id, mobilisationDate.Id, citation1.Id, auditSession.Id).ToInsertQueries());
             */

            /*
             *
             * firstDerbyshireYeomanry.AddLocation(siddalsRoadPosting);
             *
             * var mccHarrison = new Person("M.C.C", "Harrision", null, uk, GetCitationPage(2, scrapBook),
             * audit);
             *
             * var commandFirstDerbyshireYeomanryPosting = new TemporalRole(new LieutenantColonel(firstDerbyshireYeomanry, mccHarrison),
             * new FuzzyDateRange(
             *  new FuzzyDateTime(new DateTime(1939, 11, 7), "yyy/MM"),
             *  new FuzzyDateTime(new DateTime(1941, 4, 1), "yyy/MM")
             * ),
             * GetCitationPage(1, scrapBook),
             * audit);
             *
             * firstDerbyshireYeomanry.AddPersonel(commandFirstDerbyshireYeomanryPosting);
             * mccHarrison.AddAppointment(commandFirstDerbyshireYeomanryPosting);
             *
             *
             *
             *
             *
             *
             *
             * var ashbourneRoad = new SimplePostalAddress(null, new SimpleStreetAddress("Ashbourne Road"), derby, null, null, uk, null, null);
             * var ashbourneRoadPosting = new TemporalLocation(ashbourneRoad, new FuzzyDateRange(new FuzzyDateTime(new DateTime(1939, 11, 1), "yyyy/MM"), new FuzzyDateTime(new DateTime(1940, 05, 1), "yyyy/MM")),
             * GetCitationPage(2, scrapBook),
             * audit);
             *
             * firstDerbyshireYeomanry.AddLocation(ashbourneRoadPosting);
             * mccHarrison.AddLocation(ashbourneRoadPosting);
             *
             *
             *
             *
             *
             * var cavalryDivison = new TemporalRole(
             * new Cavalry(),
             * new FuzzyDateRange(
             * mobilisationDate),
             * GetCitationPage(4, scrapBook),
             * audit);
             * var catterickGarrision = new SimplePostalAddress(null, null, catterick, null, null, uk, null, null);
             * var catterickGarrisionPosting = new TemporalLocation(catterickGarrision, new FuzzyDateRange(mobilisationDate, new FuzzyDateTime(new DateTime(1940, 05, 1), "yyyy/MM")),
             * GetCitationPage(4, scrapBook),
             * audit);
             *
             * var firstCavalryDivision = new Division("1st Cavalry", armouredCar, uk,
             * GetCitationPage(4, scrapBook),
             * audit);
             * firstCavalryDivision.AddLocation(catterickGarrisionPosting);
             *
             * var cocFirstDerbyshireYeomanry = new TemporalChainOfCommand(firstCavalryDivision, firstDerbyshireYeomanry, new FuzzyDateRange(mobilisationDate, new FuzzyDateTime(new DateTime(1940, 05, 1), "yyyy/MM")),
             * GetCitationPage(4, scrapBook),
             * audit);
             * firstCavalryDivision.AddHierarchy(cocFirstDerbyshireYeomanry);
             * firstDerbyshireYeomanry.AddHierarchy(cocFirstDerbyshireYeomanry);
             *
             * var search = new FuzzyDateRange(new FuzzyDateTime(new DateTime(1939, 1, 1), "yyyy/MM/dd"), new FuzzyDateTime(new DateTime(1940, 12, 31), "yyyy/MM/dd"));
             *
             *
             * var aSquadron = new Squadron("A", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
             * var bSquadron = new Squadron("B", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
             * var cSquadron = new Squadron("C", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
             * var dSquadron = new Squadron("D", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
             *
             *
             * EstablishChainOfCommand(firstDerbyshireYeomanry, aSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
             * EstablishChainOfCommand(firstDerbyshireYeomanry, bSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
             * EstablishChainOfCommand(firstDerbyshireYeomanry, cSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
             * EstablishChainOfCommand(firstDerbyshireYeomanry, dSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
             *
             * var caistor = new Municipality("Caistor");
             * var talbotArms = new SimplePostalAddress(null, new SimpleStreetAddress("16 High Street"), caistor, null, new SimplePostalCode("LN7 6QF"), uk, null, null);
             * var rotationStart = new DateTime(1939, 11, 27);
             * var rotationEnd = new DateTime(1940, 5, 24);
             * int rotation = 0;
             * while (rotationStart < rotationEnd)
             * {
             * var talbotArmsPostingRotation = new TemporalLocation(talbotArms, new FuzzyDateRange(new FuzzyDateTime(rotationStart, "yyyy/MM/dd"), 14),
             * GetCitationPage(2, scrapBook),
             * audit);
             * rotationStart = rotationStart.AddDays(14);
             * int i = rotation % 4;
             * switch (i)
             * {
             * case 0:
             * aSquadron.AddLocation(talbotArmsPostingRotation);
             * entries.Add(GetEntry(aSquadron, talbotArmsPostingRotation));
             * break;
             * case 1:
             * bSquadron.AddLocation(talbotArmsPostingRotation);
             * entries.Add(GetEntry(bSquadron, talbotArmsPostingRotation));
             * break;
             * case 2:
             * cSquadron.AddLocation(talbotArmsPostingRotation);
             * entries.Add(GetEntry(cSquadron, talbotArmsPostingRotation));
             * break;
             * case 3:
             * dSquadron.AddLocation(talbotArmsPostingRotation);
             * entries.Add(GetEntry(dSquadron, talbotArmsPostingRotation));
             * break;
             * }
             *
             * rotation++;
             * }
             *
             *
             * entries.Add(GetEntry(firstDerbyshireYeomanry, firstDerbyshireYeomanry.Locations[0]));
             * entries.Add(GetEntry(firstDerbyshireYeomanry, firstDerbyshireYeomanry.Locations[1]));
             * entries.Add(GetEntry(mccHarrison, mccHarrison.Locations[0]));
             * entries.Add(GetEntry(firstCavalryDivision, firstCavalryDivision.Locations[0]));
             *
             */
            return(entries);
        }
Ejemplo n.º 28
0
        private static List <Entry> SearchDataModel()
        {
            var entries = new List <Entry>();

            var uk        = new RegionInfo("en-UK");
            var derby     = new Municipality("Derby");
            var catterick = new Municipality("Catterick");
            var london    = new Municipality("London");
            var audit     = new SimpleAudit("*****@*****.**");

            var scrapBook = new SimplePublication("1st Derbyshire Yeomanry Scrapbook 1939 - 1947",
                                                  new VariousAuthors(),
                                                  new UnknownEditors(),
                                                  new UnknownPublicationDateTime(),
                                                  new SimplePublisher("Bemrose & Sons Ltd",
                                                                      new List <IPostalAddress>()
            {
                new SimplePostalAddress(derby, uk),
                new SimplePostalAddress(london, uk)
            }
                                                                      )
                                                  );

            var mobilisationDate = new FuzzyDateTime(new DateTime(1939, 7, 29), "yyyy/MM/dd");
            var veDay            = new FuzzyDateTime(new DateTime(1945, 5, 8), "yyyy/MM/dd");

            var armouredCar = new TemporalRole(
                new Reconnaissance(),
                new FuzzyDateRange(
                    mobilisationDate),
                GetCitationPage(1, scrapBook),
                audit);



            var firstDerbyshireYeomanry = new Regiment("1st Derbyshire Yeomanry", armouredCar, uk, GetCitationPage(1, scrapBook),
                                                       audit);

            var siddalsRoad        = new SimplePostalAddress(null, new SimpleStreetAddress(91, "Siddals Road"), derby, null, null, uk, null, null);
            var siddalsRoadPosting = new TemporalLocation(siddalsRoad, new FuzzyDateRange(mobilisationDate),
                                                          GetCitationPage(1, scrapBook),
                                                          audit);

            firstDerbyshireYeomanry.AddLocation(siddalsRoadPosting);

            var mccHarrison = new Person("M.C.C", "Harrision", null, uk, GetCitationPage(2, scrapBook),
                                         audit);

            var commandFirstDerbyshireYeomanryPosting = new TemporalRole(new LieutenantColonel(firstDerbyshireYeomanry, mccHarrison),
                                                                         new FuzzyDateRange(
                                                                             new FuzzyDateTime(new DateTime(1939, 11, 7), "yyy/MM"),
                                                                             new FuzzyDateTime(new DateTime(1941, 4, 1), "yyy/MM")
                                                                             ),
                                                                         GetCitationPage(1, scrapBook),
                                                                         audit);

            firstDerbyshireYeomanry.AddPersonel(commandFirstDerbyshireYeomanryPosting);
            mccHarrison.AddAppointment(commandFirstDerbyshireYeomanryPosting);



            var ashbourneRoad        = new SimplePostalAddress(null, new SimpleStreetAddress("Ashbourne Road"), derby, null, null, uk, null, null);
            var ashbourneRoadPosting = new TemporalLocation(ashbourneRoad, new FuzzyDateRange(new FuzzyDateTime(new DateTime(1939, 11, 1), "yyyy/MM"), new FuzzyDateTime(new DateTime(1940, 05, 1), "yyyy/MM")),
                                                            GetCitationPage(2, scrapBook),
                                                            audit);

            firstDerbyshireYeomanry.AddLocation(ashbourneRoadPosting);
            mccHarrison.AddLocation(ashbourneRoadPosting);



            var cavalryDivison = new TemporalRole(
                new Cavalry(),
                new FuzzyDateRange(
                    mobilisationDate),
                GetCitationPage(4, scrapBook),
                audit);
            var catterickGarrision        = new SimplePostalAddress(null, null, catterick, null, null, uk, null, null);
            var catterickGarrisionPosting = new TemporalLocation(catterickGarrision, new FuzzyDateRange(mobilisationDate, new FuzzyDateTime(new DateTime(1940, 05, 1), "yyyy/MM")),
                                                                 GetCitationPage(4, scrapBook),
                                                                 audit);

            var firstCavalryDivision = new Division("1st Cavalry", armouredCar, uk,
                                                    GetCitationPage(4, scrapBook),
                                                    audit);

            firstCavalryDivision.AddLocation(catterickGarrisionPosting);

            var cocFirstDerbyshireYeomanry = new TemporalChainOfCommand(firstCavalryDivision, firstDerbyshireYeomanry, new FuzzyDateRange(mobilisationDate, new FuzzyDateTime(new DateTime(1940, 05, 1), "yyyy/MM")),
                                                                        GetCitationPage(4, scrapBook),
                                                                        audit);

            firstCavalryDivision.AddHierarchy(cocFirstDerbyshireYeomanry);
            firstDerbyshireYeomanry.AddHierarchy(cocFirstDerbyshireYeomanry);

            var search = new FuzzyDateRange(new FuzzyDateTime(new DateTime(1939, 1, 1), "yyyy/MM/dd"), new FuzzyDateTime(new DateTime(1940, 12, 31), "yyyy/MM/dd"));


            var aSquadron = new Squadron("A", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
            var bSquadron = new Squadron("B", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
            var cSquadron = new Squadron("C", armouredCar, uk, GetCitationPage(7, scrapBook), audit);
            var dSquadron = new Squadron("D", armouredCar, uk, GetCitationPage(7, scrapBook), audit);


            EstablishChainOfCommand(firstDerbyshireYeomanry, aSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
            EstablishChainOfCommand(firstDerbyshireYeomanry, bSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
            EstablishChainOfCommand(firstDerbyshireYeomanry, cSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);
            EstablishChainOfCommand(firstDerbyshireYeomanry, dSquadron, mobilisationDate, veDay, GetCitationPage(4, scrapBook), audit);

            var caistor       = new Municipality("Caistor");
            var talbotArms    = new SimplePostalAddress(null, new SimpleStreetAddress("16 High Street"), caistor, null, new SimplePostalCode("LN7 6QF"), uk, null, null);
            var rotationStart = new DateTime(1939, 11, 27);
            var rotationEnd   = new DateTime(1940, 5, 24);
            int rotation      = 0;

            while (rotationStart < rotationEnd)
            {
                var talbotArmsPostingRotation = new TemporalLocation(talbotArms, new FuzzyDateRange(new FuzzyDateTime(rotationStart, "yyyy/MM/dd"), 14),
                                                                     GetCitationPage(2, scrapBook),
                                                                     audit);
                rotationStart = rotationStart.AddDays(14);
                int i = rotation % 4;
                switch (i)
                {
                case 0:
                    aSquadron.AddLocation(talbotArmsPostingRotation);
                    entries.Add(GetEntry(aSquadron, talbotArmsPostingRotation));
                    break;

                case 1:
                    bSquadron.AddLocation(talbotArmsPostingRotation);
                    entries.Add(GetEntry(bSquadron, talbotArmsPostingRotation));
                    break;

                case 2:
                    cSquadron.AddLocation(talbotArmsPostingRotation);
                    entries.Add(GetEntry(cSquadron, talbotArmsPostingRotation));
                    break;

                case 3:
                    dSquadron.AddLocation(talbotArmsPostingRotation);
                    entries.Add(GetEntry(dSquadron, talbotArmsPostingRotation));
                    break;
                }

                rotation++;
            }


            entries.Add(GetEntry(firstDerbyshireYeomanry, firstDerbyshireYeomanry.Locations[0]));
            entries.Add(GetEntry(firstDerbyshireYeomanry, firstDerbyshireYeomanry.Locations[1]));
            entries.Add(GetEntry(mccHarrison, mccHarrison.Locations[0]));
            entries.Add(GetEntry(firstCavalryDivision, firstCavalryDivision.Locations[0]));


            return(entries);
        }
Ejemplo n.º 29
0
        public static string FormatDateTime(FuzzyDateTime fuzzyDateTime, DateFormat dateFormat, TimeFormat timeFormat)
        {
            TimeSpan fromToday = fuzzyDateTime.DateTime.Subtract(DateTime.Today);

            string timeString = string.Empty;
            if (fuzzyDateTime.HasTime)
            {
                switch (timeFormat)
                {
                    case TimeFormat.TwelveHours:
                        timeString = fuzzyDateTime.DateTime.ToString("hh:mm tt");
                        break;
                    case TimeFormat.TwentyFourHours:
                    default:
                        timeString = fuzzyDateTime.DateTime.ToString("HH:mm");
                        break;
                }
            }

            if (fromToday.Days == 0)
            {
                if (fuzzyDateTime.HasTime)
                {
                    return timeString;
                }
                else
                {
                    return "Today";
                }
            }
            else if (fromToday.Days == 1)
            {
                string result = "Tomorrow";
                if (fuzzyDateTime.HasTime)
                    result += " " + timeString;
                return result;
            }
            else if (fromToday.Days == -1)
            {
                string result = "Yesterday";
                if (fuzzyDateTime.HasTime)
                    result += " " + timeString;
                return result;
            }
            else if (fromToday.Days > 0 && fromToday.Days <= 6)
            {
                string result = fuzzyDateTime.DateTime.DayOfWeek.ToString();
                if (fuzzyDateTime.HasTime)
                    result += " " + timeString;
                return result;
            }
            else if (fromToday.Days > 6 && fuzzyDateTime.DateTime.Year == DateTime.Today.Year)
            {
                string format = "MMM dd";
                switch (dateFormat)
                {
                    case DateFormat.European:
                        format = "dd MMM";
                        break;
                    case DateFormat.American:
                    default:
                        format = "MMM dd";
                        break;
                }
                string result = fuzzyDateTime.DateTime.ToString(format);
                if (fuzzyDateTime.HasTime)
                    result += " " + timeString;
                return result;
            }
            else
            {
                string format = "MM/dd/yy";
                switch (dateFormat)
                {
                    case DateFormat.European:
                        format = "dd/MM/yy";
                        break;
                    case DateFormat.American:
                    default:
                        format = "MM/dd/yy";
                        break;
                }
                string result = fuzzyDateTime.DateTime.ToString(format);
                if (fuzzyDateTime.HasTime)
                    result += " " + timeString;
                return result;
            }
        }
Ejemplo n.º 30
0
        private static void EstablishChainOfCommand(AbstractOrganisation superior, AbstractOrganisation inferior, FuzzyDateTime from, FuzzyDateTime to, ICitation citation, IAudit audit)
        {
            var coc = new TemporalChainOfCommand(superior, inferior, new FuzzyDateRange(from, to),
                                                 citation,
                                                 audit);

            inferior.AddHierarchy(coc);
            superior.AddHierarchy(coc);
        }