private static async Task MakeyLoggey() { var logger = new Logger(); var start = new DateTimeOffset(2017, 1, 1, 0, 0, 0, 0, TimeSpan.FromHours(-5)); var startUtc = start.UtcDateTime; var dateTime = new DateTimeWrapper(startUtc); var time = new TimeDilationClock(MinutesPerSecond, start, dateTime); var stopTime = new DateTimeOffset(2018, 1, 1, 0, 0, 0, 0, TimeSpan.FromHours(-5)); var now = time.GetCurrentLocalDateTime(); var date = now.Date; System.Console.WriteLine($"{date} ({now.Offset})"); IEnumerable <IActor> actors = new IActor[] { new DrCurlyHoward(Calendar), new DrLarryFine(Calendar), new DrShempHoward(Calendar) }; while (now < stopTime) { date = await Tick(actors, now, date, logger); now = time.GetCurrentLocalDateTime(); } }
public void DeserializeObject() { string json = @" { ""Value"": ""2017-12-05T21:59:00"" }"; DateTimeWrapper c1 = JsonConvert.DeserializeObject <DateTimeWrapper>(json, new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Utc }); DateTimeWrapper c2 = JsonConvert.DeserializeObject <DateTimeWrapper>(json, new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Local }); DateTimeWrapper c3 = JsonConvert.DeserializeObject <DateTimeWrapper>(json, new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); DateTimeWrapper c4 = JsonConvert.DeserializeObject <DateTimeWrapper>(json); Assert.AreEqual(DateTimeKind.Utc, c1.Value.Kind); Assert.AreEqual(DateTimeKind.Local, c2.Value.Kind); Assert.AreEqual(DateTimeKind.Unspecified, c3.Value.Kind); Assert.AreEqual(DateTimeKind.Unspecified, c4.Value.Kind); }
public void DeserializeFromJObject() { string json = @" { ""Value"": ""2017-12-05T21:59:00"" }"; JObject jo = JObject.Parse(json); DateTimeWrapper c1 = jo.ToObject <DateTimeWrapper>(JsonSerializer.Create(new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Utc })); DateTimeWrapper c2 = jo.ToObject <DateTimeWrapper>(JsonSerializer.Create(new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Local })); DateTimeWrapper c3 = jo.ToObject <DateTimeWrapper>(JsonSerializer.Create(new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified })); DateTimeWrapper c4 = jo.ToObject <DateTimeWrapper>(); Assert.AreEqual(DateTimeKind.Utc, c1.Value.Kind); Assert.AreEqual(DateTimeKind.Local, c2.Value.Kind); Assert.AreEqual(DateTimeKind.Unspecified, c3.Value.Kind); Assert.AreEqual(DateTimeKind.Unspecified, c4.Value.Kind); }
public ActionResult Index() { var model = new DateTimeWrapper(); model.Now = DateTime.Now; return(View(model)); }
public HttpResponseMessage GetByDateOfBirth(DataSourceLoadOptions loadOptions, string dateOfBirth) { DateTime date = DateTimeWrapper.ParseClientSideDate(dateOfBirth); var employees = phoneBookContext.Employees.Where( x => DbFunctions.TruncateTime(x.DateOfBirth) == date ); return(Request.CreateResponse(DataSourceLoader.Load(employees, loadOptions))); }
public Task AddProjectUploading(DomainActionData actionData, string projectId, string projectName, ProjectType projectType, ProjectSubtype projectSubtype) { string eventId = GuidWraper.Generate(); DateTime curDateTime = DateTimeWrapper.CurrentDateTime(); StatProjectUploadingV2Entity projectUploadingEntity = StatEntityFactory.CreateProjectUploadingEntity(eventId, curDateTime, actionData, projectId, projectName, projectType, projectSubtype); ITableRepository <StatProjectUploadingV2Entity> projectUploadingRepository = RepositoryFactory.Create <StatProjectUploadingV2Entity>(); return(projectUploadingRepository.AddAsync(projectUploadingEntity)); }
public Task AddUserRegistration(DomainActionData domain) { string eventId = GuidWraper.Generate(); DateTime curDateTime = DateTimeWrapper.CurrentDateTime(); StatUserRegistrationV2Entity userRegistrationEntity = StatEntityFactory.CreateUserRegistrationEntity(eventId, curDateTime, domain); ITableRepository <StatUserRegistrationV2Entity> userRegistrationRepository = RepositoryFactory.Create <StatUserRegistrationV2Entity>(); return(userRegistrationRepository.AddAsync(userRegistrationEntity)); }
public Task AddProjectDeletion(DomainActionData domain, string projectId) { string eventId = GuidWraper.Generate(); DateTime curDateTime = DateTimeWrapper.CurrentDateTime(); StatProjectDeletionV2Entity statProjectDeletionEntity = StatEntityFactory.CreateProjectDeletionEntity(eventId, curDateTime, domain, projectId); ITableRepository <StatProjectDeletionV2Entity> projectDeletionRepository = RepositoryFactory.Create <StatProjectDeletionV2Entity>(); return(projectDeletionRepository.AddAsync(statProjectDeletionEntity)); }
public Task AddWatching(DomainActionData domain, string projectId) { string eventId = GuidWraper.Generate(); DateTime curDateTime = DateTimeWrapper.CurrentDateTime(); StatWatchingV2Entity watchingEntity = StatEntityFactory.CreateWatchingEntity(eventId, curDateTime, domain, projectId); ITableRepository <StatWatchingV2Entity> watchingRepository = RepositoryFactory.Create <StatWatchingV2Entity>(); return(watchingRepository.AddAsync(watchingEntity)); }
/// <summary> /// Initializes a new instance of the TimePickerPage control. /// </summary> public TimePickerPage() { InitializeComponent(); // Hook up the data sources PrimarySelector.DataSource = DateTimeWrapper.CurrentCultureUsesTwentyFourHourClock() ? (DataSource)(new TwentyFourHourDataSource()) : (DataSource)(new TwelveHourDataSource()); SecondarySelector.DataSource = new MinuteDataSource(); TertiarySelector.DataSource = new AmPmDataSource(); InitializeDateTimePickerPage(PrimarySelector, SecondarySelector, TertiarySelector); }
private static void InternetConnectionExamine() { Logger logger = new Logger(); PingWrapper pingWrapper = new PingWrapper(); DateTimeWrapper dateTimeWrapper = new DateTimeWrapper(); PingHandler _pingHandler = new PingHandler(logger, pingWrapper, dateTimeWrapper); while (true) { Thread.Sleep(60000); _pingHandler.Ping(); GC.Collect(); } }
public ItemFactory() { DateTimeProvider = new DateTimeWrapper(); }
public Pantry() { DateTimeProvider = new DateTimeWrapper(); }
public ActionResult MatchCleaners(SearchVM searchCriteria, String CleanerId = null) { Boolean searchByCriteria = true; if (!String.IsNullOrWhiteSpace(CleanerId)) { searchByCriteria = false; ModelState.Clear(); } // if specific id peovided ignore the criteria and find the cleaner if (searchByCriteria) { if (searchCriteria.WeeklyJob || searchCriteria.WeeklyJob) { searchCriteria.ServiceDate = DateTime.MinValue; } if (searchCriteria == null) { ModelState.AddModelError(string.Empty, $"No search criteria specified."); } if (searchCriteria.ServiceLengthMins > SystemSettings.WorkSessionMaxHours * 60) { ModelState.AddModelError(string.Empty, $"Service duration can not exceed { SystemSettings.WorkSessionMaxHours} hours."); } if ((searchCriteria.OneOffJob || searchCriteria.VacateClean) && ((searchCriteria.ServiceDate - DateTime.Now.ToUTC()).TotalDays > SystemSettings.BookingsDaysAllowed)) { ModelState.AddModelError(string.Empty, $"Services can't be booked more than {SystemSettings.BookingsDaysAllowed} days in advance."); } } if (ModelState.IsValid) { try { searchCriteria.HasCriteria = true; searchCriteria.StoreSearchCookieCiteria("cleanerMatch"); StringBuilder sql = new StringBuilder(@"select * from Cleaners C inner join Addresses Ph on C.PhysicalAddressRefId = Ph.ID where C.IsActive=1" ); if (searchByCriteria) { if (searchCriteria.RequireIroning) { sql.Append($" and Ironing = {searchCriteria.RequireIroning}"); } if (searchCriteria.FilterRating > 0) { sql.Append($" and C.Rating >= {searchCriteria.FilterRating}"); } if (searchCriteria.OneOffJob || searchCriteria.VacateClean) { // not on leave sql.Append($" and C.ID not in (select distinct PrimaryCleanerRefId from CleanerLeave where '{searchCriteria.ServiceDate.ToUTC().FormatDatabaseDate()}' between DATE(StartDate) and DATE(EndDate))"); } else { } // and rostered for weekday sql.Append($" and C.ID in (select distinct PrimaryCleanerRefId from CleanerRoster where Upper(WeekDay) = Upper('{searchCriteria.ServiceDay}'))"); } else { sql.Append($" and C.ID = '{CleanerId}'"); } sql.Append(" order by LastName, FirstName"); List <CleanerMatchResultVM> _vmResults; using (DBManager db = new DBManager()) { var _orderedResults = db.getConnection().Query <Cleaner, Address, Cleaner>(sql.ToString(), (cl, phys) => { cl.PhysicalAddress = phys; return(cl); }).ToList(); _vmResults = Mapper.Map <List <Cleaner>, List <CleanerMatchResultVM> >(_orderedResults); } foreach (CleanerMatchResultVM _item in _vmResults) { _item.PrimaryZoneList = new List <string>(new string[] { _item.PrimaryZone }); _item.SelectedRosterDay = searchCriteria.ServiceDay.ToDayOfWeek(); _item.SelectedServiceDate = (searchCriteria.WeeklyJob || searchCriteria.FortnightlyJob) ? DateTimeWrapper.FindNextDateForDay(_item.SelectedRosterDay) : searchCriteria.ServiceDate; if (!String.IsNullOrWhiteSpace(_item.SecondaryZone)) { _item.SecondaryZoneList = _item.SecondaryZone.Split(new char[] { ',', ';' }) .Distinct() .ToList(); } else { _item.SecondaryZoneList = new List <string>(); } if (!String.IsNullOrWhiteSpace(_item.ApprovedZone)) { _item.ApprovedZoneList = _item.ApprovedZone.Split(new char[] { ',', ';' }) .Distinct() .ToList(); } else { _item.ApprovedZoneList = new List <string>(); } } if (searchByCriteria) { BookingFactory resultsProcessor = new BookingFactory(_vmResults, searchCriteria); if (!resultsProcessor.ValidSearchZone) { ModelState.AddModelError(string.Empty, $"The suburb '{searchCriteria.Suburb.ToUpper()}' does not have any zones defined yet."); } else { var results = resultsProcessor.GetProcessedResults().ToList <CleanerMatchResultVM>().Where(x => x != null); return(new JsonNetResult() { Data = new { SearchResults = results }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } else { var results = _vmResults[0]; return(new JsonNetResult() { Data = new { SearchResults = results }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, $"Error performing search ({ex.Message})"); LogHelper log = new LogHelper(); log.Log(LogHelper.LogLevels.Error, "Error performing search", nameof(SearchController), ex, null); } } if (!ModelState.IsValid) { Helpers.LogFormValidationErrors(ModelState, nameof(SearchController), null); } return(JsonFormResponse()); }
public static void Save(IValueSink sink, DateTimeWrapper value) { Value<DateAndTime>.Save(sink, value.Item); }
public static void Save(IValueSink sink, DateTimeWrapper value) { Value <DateAndTime> .Save(sink, value.Item); }
protected void LoadClientState(string clientState) { this.Data = JSONSerializerExecute.Deserialize <DateTimeWrapper>(clientState); }
protected void LoadClientState(string clientState) { this.Data = JSONSerializerExecute.Deserialize<DateTimeWrapper>(clientState); }