private List <CheckInListModel> GetViewCheckInList() { var reservations = new List <Reservation>( _reservationHandler.GetReservationsCheckInToday(DateTimeHandler.GetCurrentStartTime())); var models = new List <CheckInListModel>(); foreach (Reservation reservation in reservations) { Guest firstGuest = reservation.Guests.OrderBy(guest => guest.Order).FirstOrDefault(); var firstName = ""; var lastName = ""; if (firstGuest != null) { firstName = firstGuest.FirstName; lastName = firstGuest.LastName; } if (reservation.CheckInDate == null && !reservation.IsCancelled) { models.Add(new CheckInListModel { Id = reservation.Id, FirstName = firstName, LastName = lastName, CheckInDate = reservation.StartDate, CheckOutDate = reservation.EndDate }); } } return(models); }
/// <summary> /// Convert deadline from DateTime to string /// </summary> /// <param name="sender"> Sender</param> /// <param name="e"> Routed events</param> private void ConvertDeadlineDate(object sender, RoutedEventArgs e) { _dateTimeHandler = new DateTimeHandler(); var a = _dateTimeHandler.Convert(((DatePicker)sender).SelectedDate); ((CreateProjectViewModel)DataContext).Deadline = (string)a; }
///-------------------------------------------------------------------------------------------------------- /// public override async Task OnMessage(Telegram.Bot.Types.Message message) { if (commandState == eCommandState.WaitOpt) { long requesterId = message.Chat.Id; if (requesterId == optWaitUserId) { commandState = eCommandState.Ready; string otpStr = message.Text.Trim(); if (OtpChecker.CheckOtp(otpStr)) { string response = await MakeResponse(requesterId, DateTimeHandler.ToLocalTime(message.Date)); await SendMessage(requesterId, response); } else { await SendMessage(requesterId, strings.GetString("Otp 인증에 실패 했습니다.")); } Logger.Log("주소 생성 응답 완료.\n"); IsCompleted = true; } } await Task.Run(() => { }); }
// Retrieve and show a single image's metadata in the datagrid, although filter out any metadata whose value is not a valid date. private void MetadataExtractorShowImageMetadata() { this.metadataDictionary = ImageMetadataDictionary.LoadMetadata(this.filePath); // If there is no metadata, this is an easy way to inform the user if (this.metadataDictionary.Count == 0) { this.metadataDictionary.Add("Empty", new Timelapse.Util.ImageMetadata("Empty", "No metadata found in the currently displayed image", "Navigate to a displayable image")); this.noMetadataAvailable = true; } else { this.noMetadataAvailable = false; } // In order to populate the datagrid, we have to unpack the dictionary as a list containing four values List <Tuple <string, string, string, string> > metadataList = new List <Tuple <string, string, string, string> >(); foreach (KeyValuePair <string, ImageMetadata> metadata in this.metadataDictionary) { if (metadata.Value == null || metadata.Value.Value == null) { // Rare case where a user had a camera with a null Value.Value field continue; } if (DateTimeHandler.TryParseMetadataDateTaken(metadata.Value.Value.ToString(), out DateTime _)) { metadataList.Add(new Tuple <string, string, string, string>(metadata.Key, metadata.Value.Directory, metadata.Value.Name, metadata.Value.Value)); } } this.AvailableMetadataDataGrid.ItemsSource = metadataList; }
private List <CheckOutListModel> GetViewCheckoutListAll() { var reservations = new List <Reservation>( _reservationHandler.GetAllReservationsCanBeCheckedOut(DateTimeHandler.GetCurrentEndTime().AddDays(1))); var models = new List <CheckOutListModel>(); foreach (Reservation reservation in reservations) { var firstGuest = reservation.Guests.ToList().ToGuestModelList().FirstOrDefault(); var firstName = ""; var lastName = ""; if (firstGuest != null) { firstName = firstGuest.FirstName; lastName = firstGuest.LastName; } if (reservation.CheckInDate != null && reservation.CheckOutDate == null && !reservation.IsCancelled) { models.Add(new CheckOutListModel { Id = reservation.Id, FirstName = firstName, LastName = lastName, CheckInDate = reservation.StartDate, CheckOutDate = reservation.EndDate, ActualCheckInDate = reservation.CheckInDate ?? DateTimeHandler.GetCurrentTime().Subtract(TimeSpan.FromDays(1)) }); } } return(models); }
public Task LoadImageAsync(Action OnImageLoadComplete) { // Set the loader's file member. this.RequiresDatabaseInsert = true; // Skip the per-file call to the database this.File = this.dataHandler.FileDatabase.FileTable.NewRow(this.fileInfo); this.File.Folder = Path.GetFileName(this.imageSetFolderPath); this.File.RelativePath = this.relativePath; this.File.SetDateTimeOffsetFromFileInfo(this.FolderPath); // By default, file image quality is ok (i.e., not dark) this.File.ImageQuality = FileSelectionEnum.Ok; return(Task.Run(() => { // Try to set the metadata fields specified in MetadataOnLoad, as well as the date from either the metadata or the file time depending on what is available if (GlobalReferences.TimelapseState.MetadataOnLoad != null && GlobalReferences.TimelapseState.MetadataOnLoad.SelectedMetadataDataLabels != null && GlobalReferences.TimelapseState.MetadataOnLoad.SelectedMetadataDataLabels.Count > 0) { this.File.TryReadMetadataAndSetMetadataFields(this.FolderPath, GlobalReferences.TimelapseState.MetadataOnLoad); } // Try to update the datetime (which is currently recorded as the file's date) with the metadata date time the image was taken instead // Note that videos do not have these metadata fields // Strategy is to set date from either the metadata or the file time depending on what is available this.File.TryReadDateTimeOriginalFromMetadata(this.FolderPath, DateTimeHandler.GetNeutralTimeZone()); // This completes processing, but it may be some time before the task is checked for completion. // for purposes of reporting progress, call the completion delegate provided. OnImageLoadComplete?.Invoke(); })); }
/// <summary> /// Corresponde a la funcion que cumple el boton Start. /// </summary> /// <param name="sender">parametro requerido para el correcto funcionamiento del evento.</param> /// <param name="e">parametro requerido para el correcto funcionamiento del evento.</param> private void StartButtonCallback(object sender, System.EventArgs e) { string tempMessage; Popup popup = new Popup(); var dialogResult = popup.ShowDialog(); if (chatting) { tempMessage = shopKeeper.SayGoodbye() + "\n"; richTextBox1.Text += tempMessage; log.AppendMessage(tempMessage); tempMessage = "\n## " + DateTimeHandler.GetString("date") + " / " + DateTimeHandler.GetString("time") + " - Fin de la conversacion.\n"; richTextBox1.Text += "\n" + tempMessage; log.AppendMessage(tempMessage); } chatting = true; shopKeeper = new Chatbot(seed); user = new Usuario(cash); this.richTextBox1.Clear(); tempMessage = tempMessage = "# " + DateTimeHandler.GetString("date") + " / " + DateTimeHandler.GetString("time") + " - Inicia una nueva conversacion.\n\n"; this.richTextBox1.Text = tempMessage; log.AppendMessage(tempMessage); tempMessage = shopKeeper.SayHello() + "\n"; this.richTextBox1.Text += tempMessage; log.AppendMessage(tempMessage); }
///-------------------------------------------------------------------------------------------------------- /// 확인 요청에 대한 응답메세지 생성 private async Task <string> MakeResponse(long requesterId, DateTime requestTime) { string msgDateStr = string.Format("{0:yyyy/MM/dd HH:mm:ss}", requestTime); Dictionary <string, double> balances = null; QtumHandler.GetInfo(out balances); string addressListStr = ""; foreach (KeyValuePair <string, double> elem in balances) { await SendMessage(requesterId, GetAddressLink(elem.Key)); await SendMessage(requesterId, elem.Value.ToString()); addressListStr += string.Format("\n{0} : {1}", GetAddressLink(elem.Key), elem.Value.ToString()); } var response = strings.Format(@" --------------------------------- 요청 : {0} 응답 : {1:yyyy/MM/dd HH:mm:ss} {2} ---------------------------------", msgDateStr, DateTimeHandler.GetTimeZoneNow(), addressListStr); Logger.Log(response); Logger.Log(""); return(response); }
///-------------------------------------------------------------------------------------------------------- /// 채굴 시작 요청에 대한 응답메세지 생성 private static string MakeStartStakingResponse(DateTime requestTime, out bool invalidPassword) { string msgDateStr = ""; invalidPassword = false; msgDateStr = string.Format("{0:yyyy/MM/dd HH:mm:ss}", requestTime); string resultStr = QtumHandler.StartSaking(); var response = strings.Format(@" --------------------------------- 요청 : {0} 응답 : {1:yyyy/MM/dd HH:mm:ss} 결과 : {2} ---------------------------------", msgDateStr, DateTimeHandler.GetTimeZoneNow(), resultStr.Count() == 0 ? "Success" : resultStr); Logger.Log(response); Logger.Log(""); if (resultStr == strings.GetString("패스워드 오류")) { invalidPassword = true; } return(response); }
// Helper method for above DateTime changes. private void DateTimeUpdate(DateTimePicker dateTimePicker, DateTime dateTime) { // update file data table and write the new DateTime, Date, and Time to the database this.ImageCache.Current.SetDateTimeOffset(dateTime); dateTimePicker.ToolTip = DateTimeHandler.ToStringDisplayDateTime(dateTime); List <ColumnTuplesWithWhere> imageToUpdate = new List <ColumnTuplesWithWhere>() { this.ImageCache.Current.GetDateTimeColumnTuples() }; this.FileDatabase.UpdateFiles(imageToUpdate); // update date and time controls if they're displayed DataEntryDateTime control = (DataEntryDateTime)dateTimePicker.Tag; if (control.DateControl != null) { control.DateControl.SetContentAndTooltip(this.ImageCache.Current.Date); } if (control.TimeControl != null) { control.TimeControl.SetContentAndTooltip(this.ImageCache.Current.Time); } }
public void SetDateTimeOffset(DateTimeOffset dateTime) { this.Date = DateTimeHandler.ToStringDisplayDate(dateTime); this.DateTime = dateTime.UtcDateTime; this.UtcOffset = dateTime.Offset; this.Time = DateTimeHandler.ToStringDisplayTime(dateTime); }
/// <summary> /// Convert deadline from DateTime to string /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ConvertStartDate(object sender, RoutedEventArgs e) { _dateTimeHandler = new DateTimeHandler(); var a = _dateTimeHandler.Convert(((DatePicker)sender).SelectedDate); ((SingleSprintViewModel)DataContext).Sprint[0].StartDate = (string)a; }
public DateTimeSetTimeZone(FileDatabase fileDatabase, ImageRow imageToCorrect, Window owner) { // Check the arguments for null ThrowIf.IsNullArgument(fileDatabase, nameof(fileDatabase)); ThrowIf.IsNullArgument(imageToCorrect, nameof(imageToCorrect)); this.InitializeComponent(); this.displayingPreview = false; this.fileDatabase = fileDatabase; this.Owner = owner; // get the image's current time DateTimeOffset currentDateTime = imageToCorrect.DateTimeIncorporatingOffset; this.originalDate.Content = DateTimeHandler.ToStringDisplayDateTimeUtcOffset(currentDateTime); // get the image filename and display it this.FileName.Content = imageToCorrect.File; this.FileName.ToolTip = this.FileName.Content; // display the image this.image.Source = imageToCorrect.LoadBitmap(this.fileDatabase.FolderPath, out bool isCorruptOrMissing); // configure timezone picker TimeZoneInfo imageSetTimeZone = this.fileDatabase.ImageSet.GetSystemTimeZone(); this.TimeZones.SelectedItem = imageSetTimeZone.DisplayName; this.TimeZones.SelectionChanged += this.TimeZones_SelectionChanged; }
///-------------------------------------------------------------------------------------------------------- /// protected override async Task <bool> OnStart(long requesterId, string requesterName, DateTime requestTime, params object[] args) { await SendMessage(requesterId, strings.Format("{0} 채굴을 중지합니다.", requesterName)); bool invalidPassword = false; var taskResponse = Task <string> .Run(() => MakeStopStakingResponse(requestTime, out invalidPassword)); string response = await taskResponse; await SendMessage(requesterId, response); if (invalidPassword) { System.IO.File.Delete(PasswordManager.passwordFile); await SendMessage(requesterId, strings.Format("잘못된 암호로 실패했습니다. 봇 프로그램에서 퀀텀 월렛 암호 설정을 확인 해주세요.")); } Logger.Log("채굴 중지 응답 완료.\n"); if (invalidPassword == false) { Command.ICommand command = Command.CommandFactory.CreateCommand(Command.eCommand.CheckState); if (command != null) { await command.Process(-1, "", DateTimeHandler.GetTimeZoneNow()); } } IsCompleted = true; return(invalidPassword == false); }
// Set the value for the column identified by its datalabel. // We don't do this directly, as some values have to be converted public void SetValueFromDatabaseString(string dataLabel, string value) { switch (dataLabel) { case Constant.DatabaseColumn.DateTime: this.DateTime = DateTimeHandler.ParseDatabaseDateTimeString(value); break; case Constant.DatabaseColumn.UtcOffset: this.UtcOffset = DateTimeHandler.ParseDatabaseUtcOffsetString(value); break; case Constant.DatabaseColumn.ImageQuality: if (Enum.TryParse(value, out FileSelectionEnum result)) { // The parse succeeded, where the result is in result this.ImageQuality = result; } else { // The parse did not succeeded. The result contains the default enum value, ie, the same as returning default(Enum) this.ImageQuality = default; } // this.ImageQuality = (FileSelectionEnum)Enum.Parse(typeof(FileSelectionEnum), value); break; default: this.Row.SetField(dataLabel, value); break; } }
public ActionResult Result(string sessionId) { if (!ReservationHandler.SearchResultPool.ContainsKey(sessionId)) { return(RedirectToAction("Error", "Reservation", new ErrorViewModel { ErrorMsg = "The reservation is expired or submitted" })); } if (!ModelState.IsValid || string.IsNullOrEmpty(sessionId) || ReservationHandler.SearchResultPool[sessionId] == null) { return(RedirectToAction("Search", "Reservation")); } var resultModel = ReservationHandler.SearchResultPool[sessionId] as RoomSearchResultModel; if (resultModel == null || resultModel.Expiration < DateTimeHandler.GetCurrentTime()) { return(RedirectToAction("Expired", "Reservation")); } var result = ReservationHandler.SearchResultPool[sessionId] as RoomSearchResultModel; return(View(new ResultViewModel { SessionId = result.SessionId, Expiration = result.Expiration, RoomPriceDetails = result.RoomPriceDetails })); }
/// <summary> /// Convert end date of sprint from DateTime to string /// </summary> /// <param name="sender">object sender</param> /// <param name="e">routedEventArgs e</param> private void ConvertEndDate(object sender, RoutedEventArgs e) { this._dateTimeHandler = new DateTimeHandler(); var a = _dateTimeHandler.Convert(((DatePicker)sender).SelectedDate); ((CreateSprintViewModel)DataContext).EndDate = (string)a; }
///-------------------------------------------------------------------------------------------------------- /// static public string BackupWallet() { string fileName = string.Format("{0:yyyy_MM_dd-HH_mm_ss}.dat", DateTimeHandler.GetTimeZoneNow()); string cmdResult = commandline.Process(string.Format("backupwallet \"./backups/{0}\"", fileName)); return(cmdResult + "\n" + fileName); }
public void CalculateDays_WhenCalled_ReturnCountOfWeekDaysInRange(string startDate, string endDate, float days) { var dateTimeHandler = new DateTimeHandler(); var result = dateTimeHandler.CalculateDays(startDate, endDate); Assert.That(result, Is.EqualTo(days)); }
// DateTime value public ColumnTuple(string column, DateTime value) : this(column, DateTimeHandler.ToStringDatabaseDateTime(value)) { if (value.Kind != DateTimeKind.Utc) { throw new ArgumentOutOfRangeException(nameof(value)); } }
// DEFUNCT AS WE NO LONGER USE THE TIME ZONE //public DateTimeOffset GetDateTime(int dateTimeSearchTermIndex, TimeZoneInfo imageSetTimeZone) //{ // // Check the arguments for null // ThrowIf.IsNullArgument(imageSetTimeZone, nameof(imageSetTimeZone)); // DateTime dateTime = this.SearchTerms[dateTimeSearchTermIndex].GetDateTime(); // return DateTimeHandler.FromDatabaseDateTimeIncorporatingOffset(dateTime, imageSetTimeZone.GetUtcOffset(dateTime)); //} public DateTimeOffset GetDateTime(int dateTimeSearchTermIndex, TimeSpan offset) { // Get the date/time correcting for the offset, if any. // Note that as of this version, all offsets should be 0 so this may not be necessary DateTime dateTime = this.SearchTerms[dateTimeSearchTermIndex].GetDateTime(); return(DateTimeHandler.FromDatabaseDateTimeIncorporatingOffset(new DateTime((dateTime + offset).Ticks), TimeSpan.Zero)); }
public void SetDatabaseValue(DateTimeOffset dateTime) { if (this.DataLabel != Constant.DatabaseColumn.DateTime) { throw new NotSupportedException(String.Format("Attempt to retrieve date/time from a SearchTerm with data label {0}.", this.DataLabel)); } this.DatabaseValue = DateTimeHandler.ToStringDatabaseDateTime(dateTime); }
public TimeSpan GetUtcOffset() { if (this.DataLabel != Constant.DatabaseColumn.UtcOffset) { throw new NotSupportedException(String.Format("Attempt to retrieve UTC offset from a SearchTerm with data label {0}.", this.DataLabel)); } return(DateTimeHandler.ParseDatabaseUtcOffsetString(this.DatabaseValue)); }
public DateTime GetDateTime() { if (this.DataLabel != Constant.DatabaseColumn.DateTime) { throw new NotSupportedException(String.Format("Attempt to retrieve date/time from a SearchTerm with data label {0}.", this.DataLabel)); } return(DateTimeHandler.ParseDatabaseDateTimeString(this.DatabaseValue)); }
private IEnumerable<Unicorn> ApplQueryToHandler(string queryValue) { var handler = new DateTimeHandler<Unicorn>(); var prop = Unicorns.GetProperty(u => u.BirthDate); var q = PropertyQuery.Create(prop.Name, queryValue); return handler.ApplyQuery(Unicorns.All, prop, q); }
public async Task <ActionResult> CheckOut(Guid?confirmationNum) { return(View(new CheckInOutModel { ConfirmationNum = confirmationNum ?? Guid.Empty, IsSuccess = _reservationHandler.CheckOut(confirmationNum ?? Guid.Empty, DateTimeHandler.GetCurrentTime()) })); }
public DateTimeOffset GetDateTime(int dateTimeSearchTermIndex, TimeZoneInfo imageSetTimeZone) { // Check the arguments for null ThrowIf.IsNullArgument(imageSetTimeZone, nameof(imageSetTimeZone)); DateTime dateTime = this.SearchTerms[dateTimeSearchTermIndex].GetDateTime(); return(DateTimeHandler.FromDatabaseDateTimeIncorporatingOffset(dateTime, imageSetTimeZone.GetUtcOffset(dateTime))); }
private static void TstDateTimeHandler() { _logger.Log("Begin"); var handler = new DateTimeHandler(); handler.Run(); _logger.Log("End"); }
public ActionResult Index() { if (User != null) { ViewBag.isStaff = User.IsInRole("staff"); } return(View(new GlobalTimeViewModel { CurrentTime = DateTimeHandler.GetCurrentTime() })); }
public void SetDateTimeOffset(DateTimeOffset dateTime) { // Convert the dateTime to an offset of zero this.Date = DateTimeHandler.ToStringDisplayDate(dateTime); DateTimeOffset dto = new DateTimeOffset(dateTime.Ticks, TimeSpan.Zero); this.DateTime = dto.UtcDateTime; this.UtcOffset = TimeSpan.Zero; this.Time = DateTimeHandler.ToStringDisplayTime(dateTime); }
public ActionResult Search(SearchInputModel model) { if (!ModelState.IsValid) { return(View(model)); } if (model.StartDate.Date >= model.EndDate.Date) { return(RedirectToAction("Error", "Reservation", new ErrorViewModel { ErrorMsg = "start date must be before end date" })); } if (model.StartDate.Date < DateTimeHandler.GetCurrentDate()) { return(RedirectToAction("Error", "Reservation", new ErrorViewModel { ErrorMsg = "Start date must not be before today" })); } ViewBag.NoResult = false; var startDate = model.StartDate.GetStartDateTime(); var endDate = model.EndDate.Date.GetEndDateTime(); var availableRooms = new List <RoomPriceDetail>(); foreach (ROOM_TYPE type in Enum.GetValues(typeof(ROOM_TYPE))) { if (_roomHandler.IsAvailable(type, startDate, endDate)) { availableRooms.Add(GetPriceDetails(startDate, endDate, type)); } } if (availableRooms.Count <= 0) { return(RedirectToAction("Error", "Reservation", new ErrorViewModel { ErrorMsg = "No available room, please search again" })); } var sessionId = Guid.NewGuid().ToString(); ReservationHandler.SearchResultPool[sessionId] = new RoomSearchResultModel { SessionId = sessionId, Expiration = DateTimeHandler.GetCurrentTime().AddMinutes(10), RoomPriceDetails = availableRooms }; return(RedirectToAction("Result", "Reservation", new { SessionId = sessionId })); }