public void DeleteTrainingDay_EntryWithReminder() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.RemindBefore = TimeSpan.FromMinutes(10); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); var count = Session.QueryOver <ReminderItem>().RowCount(); Assert.AreEqual(0, count); }
public void TestDeleteTrainingDay_Mode_OnlyWithoutMyTraining_TrainingDayShouldBeDeleted() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; param.Mode = DeleteTrainingDayMode.OnlyWithoutMyTraining; Service.DeleteTrainingDay(data.Token, param); }); Assert.AreEqual(0, Session.QueryOver <TrainingDay>().RowCount()); Assert.AreEqual(0, Session.QueryOver <SizeEntry>().RowCount()); }
protected override void FillImplementation(SaveTrainingDayResult originalEntry) { viewModel.Fill(GpsTrackerEntry); if (GpsTrackerEntry.HasCoordinates) { ThreadPool.QueueUserWorkItem(x => { Helper.EnsureThreadLocalized(); viewModel.RetrieveGpsCoordinates(); if (viewModel.GPSPoints == null || viewModel.GPSPoints.Count == 0) { return; } UIHelper.BeginInvoke(new Action(() => { RefreshGui(true); }), Dispatcher); }); } else { viewModel.GpsCoordinatesStatus = GPSStrings.usrGPSTrackerEntry_InfoEntryWithoutGpsData; } }
public void AddTwoComments() { var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile, ClientInformation); TrainingDayDTO day = new TrainingDayDTO(DateTime.Now); day.ProfileId = profile.GlobalId; BlogEntryDTO blogEntry = new BlogEntryDTO(); blogEntry.Comment = "jakis tekst"; day.AllowComments = true; day.AddEntry(blogEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); TrainingDayCommentDTO comment = new TrainingDayCommentDTO(); comment.Profile = profile; comment.Comment = "msg"; DateTime time = DateTime.UtcNow; RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = time; TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam(); arg.TrainingDayId = day.GlobalId; arg.Comment = comment; arg.OperationType = TrainingDayOperationType.Add; Service.TrainingDayCommentOperation(data.Token, arg); }); data = CreateNewSession(profile1, ClientInformation); comment = new TrainingDayCommentDTO(); comment.Profile = profile1; comment.Comment = "msg1"; time = DateTime.UtcNow.AddHours(2); RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = time; TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam(); arg.TrainingDayId = day.GlobalId; arg.Comment = comment; arg.OperationType = TrainingDayOperationType.Add; Service.TrainingDayCommentOperation(data.Token, arg); }); var dbDay = Session.QueryOver <TrainingDay>().SingleOrDefault(); Assert.IsNotNull(dbDay); Assert.AreEqual(2, dbDay.CommentsCount); Assert.IsTrue(dbDay.LastCommentDate.Value.CompareDateTime(time)); }
public void DeleteTrainingDay_AnotherProfile() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); data = CreateNewSession((ProfileDTO)profiles[1].Tag, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); }
protected override void FillImplementation(SaveTrainingDayResult originalEntry) { usrHtmlEditor1.ClearContent(); usrApplicationName.Fill(BlogEntry); usrHtmlEditor1.SetHtml(BlogEntry.Comment); //cmbAllowComments.SelectedIndex = blogEntry.AllowComments ? 0 : 1; updateReadOnly(); }
public void TestDeleteTrainingDay_LatestNotChanged() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); date = DateTime.Now; var day1 = new TrainingDayDTO(DateTime.Now); day1.ProfileId = profile.GlobalId; sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day1.AddEntry(sizeEntry); RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day1); day1 = result.TrainingDay; }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(2, dbProfile.Statistics.TrainingDaysCount); Assert.AreEqual(date.Date, dbProfile.Statistics.LastEntryDate.Value); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param);; }); dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(1, dbProfile.Statistics.TrainingDaysCount); Assert.AreEqual(date.Date, dbProfile.Statistics.LastEntryDate.Value); }
public void AddComment_SetLoginData() { var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile, ClientInformation); TrainingDayDTO day = new TrainingDayDTO(DateTime.Now); day.ProfileId = profile.GlobalId; BlogEntryDTO blogEntry = new BlogEntryDTO(); blogEntry.Comment = "jakis tekst"; day.AllowComments = true; day.AddEntry(blogEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); LoginData loginData = new LoginData(); loginData.ApiKey = apiKey; loginData.ApplicationVersion = "1.0.0"; loginData.LoginDateTime = DateTime.UtcNow; loginData.ApplicationLanguage = "en"; loginData.PlatformVersion = "NUnit"; insertToDatabase(loginData); data = CreateNewSession(profile1, ClientInformation, loginData); TrainingDayCommentDTO comment = new TrainingDayCommentDTO(); comment.Profile = profile1; comment.Comment = "msg"; DateTime time = DateTime.UtcNow; RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = time; TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam(); arg.TrainingDayId = day.GlobalId; arg.Comment = comment; arg.OperationType = TrainingDayOperationType.Add; Service.TrainingDayCommentOperation(data.Token, arg); }); var dbDay = Session.QueryOver <TrainingDay>().SingleOrDefault(); Assert.AreEqual(loginData.ApiKey.ApiKey, dbDay.Comments.First().LoginData.ApiKey.ApiKey); }
private void displayNotificationAboutRecords(SaveTrainingDayResult saveResult) { if (saveResult == null) { return; } foreach (var currentRecord in saveResult.NewRecords) { RecordNotifyObject notifyObject = new RecordNotifyObject(currentRecord); MainWindow.Instance.ShowNotification(notifyObject); } }
public void AddComment_SendEMailAndMessage() { var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; profiles[0].Settings.NotificationBlogCommentAdded = ProfileNotification.Message | ProfileNotification.Email; insertToDatabase(profiles[0]); SessionData data = CreateNewSession(profile, ClientInformation); TrainingDayDTO day = new TrainingDayDTO(DateTime.Now); day.ProfileId = profile.GlobalId; BlogEntryDTO blogEntry = new BlogEntryDTO(); blogEntry.Comment = "jakis tekst"; day.AllowComments = true; day.AddEntry(blogEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); data = CreateNewSession(profile1, ClientInformation); TrainingDayCommentDTO comment = new TrainingDayCommentDTO(); comment.Profile = profile1; comment.Comment = "msg"; DateTime time = DateTime.UtcNow; RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = time; TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam(); arg.TrainingDayId = day.GlobalId; arg.Comment = comment; arg.OperationType = TrainingDayOperationType.Add; Service.TrainingDayCommentOperation(data.Token, arg); Assert.True(((MockEmailService)Service.EMailService).EMailSent); }); var messages = Session.QueryOver <Message>().Where(x => x.Receiver == profiles[0]).SingleOrDefault(); Assert.IsNotNull(messages); Assert.IsNotNull(messages.Content); Assert.AreEqual(MessagePriority.System, messages.Priority); }
private bool createNewEntryControl(EntryObjectDTO entry, bool @select, SaveTrainingDayResult saveResult) { if (entry.IsLoaded) { try { var ctrl = (Control)Activator.CreateInstance(EntryObjectControlManager.Instance.Controls[entry.GetType()]); // var tabPage = new TabItem(); string text = entry.GetEntryObjectText(); ctrl.Tag = entry; var entryCtrl = (IEntryObjectControl)ctrl; entryCtrl.ReadOnly = ReadOnly || entry.Status == EntryObjectStatus.System; TabItemViewModel tabItem = new TabItemViewModel(); tabItem.CloseButtonVisible = !ReadOnly; tabItem.Header = text; tabItem.Content = ctrl; tabItem.IsFromReservation = entry.ReservationId.HasValue; tabItem.EntryObject = entry; tabs.Add(tabItem); xtraTabControl1.SelectedItem = tabItem; //EntryObjectDTO originalEntry = null; //if(originalDay!=null) //{ // originalEntry=originalDay.Objects.Where(x => x.GlobalId == entry.GlobalId).SingleOrDefault(); // if(originalEntry==null) // {//when originalDay is not null then we now that this is a Saving mode. So we imitate empty instance to have a comparison // originalEntry = (EntryObjectDTO)Activator.CreateInstance(entry.GetType()); // } //} entryCtrl.Fill(entry, saveResult); updateButtons(); } catch (TrainingIntegrationException ex) { ExceptionHandler.Default.Process(ex, Strings.ErrorTrainingIntegrity, ErrorWindow.MessageBox); return(false); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, Strings.ErrorUnhandledException, ErrorWindow.EMailReport); return(false); } } return(true); }
public void Fill(EntryObjectDTO entry, SaveTrainingDayResult originalEntry) { isFilling = true; this.entry = entry; FillImplementation(originalEntry); if (detailsControl != null) { detailsControl.Fill(this.entry); } if (progressControl != null) { progressControl.Fill(this.entry); } isFilling = false; }
async protected Task applySave(SaveTrainingDayResult result, SynchronizationItemViewModel item) { var newDay = result.TrainingDay; var customerId = item.DayInfo.TrainingDay.CustomerId; var holder = appState.GetTrainingDayHolder(customerId); TrainingDayInfo newInfo = null; if (newDay != null) { var oldInfo = holder.TrainingDays[newDay.TrainingDate]; newDay.FillInstaneId(oldInfo.TrainingDay, true); //oldInfo.TrainingDay.GlobalId = newDay.GlobalId; //find all gps tracker entries and set correct globalid (we need this in uploading gps coordinates) //foreach (var gpsEntry in newDay.Objects.OfType<GPSTrackerEntryDTO>()) //{ // var oldEntry=oldInfo.TrainingDay.Objects.OfType<GPSTrackerEntryDTO>().Where(x => x.Exercise.GlobalId == gpsEntry.Exercise.GlobalId && x.StartDateTime==gpsEntry.StartDateTime && x.EndDateTime==gpsEntry.EndDateTime ).FirstOrDefault(); // if (oldEntry != null) // { // oldEntry.GlobalId = gpsEntry.GlobalId; // gpsEntry.InstanceId = oldEntry.InstanceId; // } //} //now check if gps entry has been removed on the server and if yes remove also gps coordinates uploading foreach (var source in Items.Where(x => x.DayInfo == oldInfo && x.ItemType == ItemType.GPSCoordinates).ToList()) { var oldEntry = newDay.Objects.OfType <GPSTrackerEntryDTO>().Where(x => (source.GPSEntry.GlobalId != Guid.Empty && x.GlobalId == source.GPSEntry.GlobalId) || (x.Exercise.GlobalId == source.GPSEntry.Exercise.GlobalId && x.StartDateTime == source.GPSEntry.StartDateTime && x.EndDateTime == source.GPSEntry.EndDateTime)).FirstOrDefault(); if (oldEntry == null) { source.GPSEntry = null; } } newInfo = holder.SetTrainingDay(newDay); newInfo.IsModified = false; } else { holder.TrainingDays.Remove(item.DayInfo.TrainingDay.TrainingDate); } item.DayInfo.IsConflict = false; item.DayInfo = newInfo; item.State = MergeState.Finished; Items.Remove(item); }
protected override void FillImplementation(SaveTrainingDayResult originalEntry) { ExercisesReposidory.Instance.BeginEnsure();//start fetching exercises viewModel.IsReadOnly = ReadOnly; viewModel.Fill(this.StrengthTrainingEntry); viewModel.SelectedGroup = GridGroupMode.None; DataContext = viewModel; changeSetNumbers(); grid.Fill(this.StrengthTrainingEntry, viewModel); updateReadOnly(); updateToolbar(); displayNotificationAboutRecords(originalEntry); }
void refreshTabs(FilterType filterType, SaveTrainingDayResult saveResult) { this.filterType = filterType; //tsbFilterAll.IsChecked = filterType == FilterType.All; //tsbFilterOnlyReservation.IsChecked = filterType == FilterType.OnlyReservations; //tsbFilterOnlyNotReservation.IsChecked = filterType == FilterType.OnlyNotReservations; tabs.Clear(); for (int index = day.Objects.Count - 1; index >= 0; index--) { var entry = day.Objects.ElementAt(index); bool showByFilter = filterType == FilterType.All || (filterType == FilterType.OnlyReservations && entry.ReservationId.HasValue) || (filterType == FilterType.OnlyNotReservations && !entry.ReservationId.HasValue); if (showByFilter && !createNewEntryControl(entry, false, saveResult)) { //exception during creating new entry so we delete it from training day day.RemoveEntry(entry); } } NotifyOfPropertyChange(() => IsFilterAll); NotifyOfPropertyChange(() => IsFilterOnlyNotReservations); NotifyOfPropertyChange(() => IsFilterOnlyReservations); }
public void AddComment_AnotherProfile() { var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile, ClientInformation); TrainingDayDTO day = new TrainingDayDTO(DateTime.Now); day.ProfileId = profile.GlobalId; BlogEntryDTO blogEntry = new BlogEntryDTO(); blogEntry.Comment = "jakis tekst"; day.AllowComments = true; day.AddEntry(blogEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); data = CreateNewSession(profile1, ClientInformation); TrainingDayCommentDTO comment = new TrainingDayCommentDTO(); comment.Profile = profile; comment.Comment = "msg"; DateTime time = DateTime.UtcNow; RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = time; TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam(); arg.TrainingDayId = day.GlobalId; arg.Comment = comment; arg.OperationType = TrainingDayOperationType.Add; Service.TrainingDayCommentOperation(data.Token, arg); }); }
public void TestDeleteTrainingDay_DataInfo_Refresh() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); var dbProfile = Session.Get <Profile>(profile.GlobalId); var oldHash = dbProfile.DataInfo.TrainingDayHash; RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = DateTime.UtcNow.AddHours(1); var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreNotEqual(oldHash, dbProfile.DataInfo.TrainingDayHash); }
protected override void FillImplementation(SaveTrainingDayResult originalEntry) { updateReadOnly(); this.usrWymiaryEditor1.Fill(SizeEntry.Wymiary); }
protected override void FillImplementation(SaveTrainingDayResult originalEntry) { viewModel = new SupplementsGridViewModel(SupplementsEntry, ReadOnly); DataContext = viewModel; updateReadOnly(); }
protected abstract void FillImplementation(SaveTrainingDayResult originalEntry);
protected override void FillImplementation(SaveTrainingDayResult originalEntry) { ReadOnly = ReadOnly || Entry.MyTraining.TrainingEnd != TrainingEnd.NotEnded; fillDaysCombo(); }