private async Task GetNotifications() { try { var notificationModels = await _notificationService.GetAllAsync(ApiPriority.UserInitiated); var notifications = new List <INotification>(); if (notificationModels?.Notifications != null) { foreach (var notificationModel in notificationModels.Notifications) { // Get user notifications.Add(ToModel(notificationModel, notificationModels.RelatedItems)); } } Items = new ExtendedObservableCollection <INotification>(notifications.Where(n => n != null).OrderByDescending(n => n.CreationDateTime)); SendUpdateUnread(); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
private void SetResources() { try { _numberCommentTextSingle = Settings.GetResource(ResKeys.mobile_feed_comments); _numberCommentTextMultiple = Settings.GetResource(ResKeys.mobile_feed_comment); _numberLikeTextSingle = Settings.GetResource(ResKeys.mobile_feed_likes); _numberLikeTextMultiple = Settings.GetResource(ResKeys.mobile_feed_like); _serverErrorText = Settings.GetResource(ResKeys.mobile_error_server_error); _reportMessageText = Settings.GetResource(ResKeys.mobile_report_post_message); _reportMessageTitle = Settings.GetResource(ResKeys.mobile_report_post_title); _yesText = Settings.GetResource(ResKeys.mobile_btn_yes); _noText = Settings.GetResource(ResKeys.mobile_btn_no); _reportSuccessText = Settings.GetResource(ResKeys.mobile_report_success); _reportFailedText = Settings.GetResource(ResKeys.mobile_report_failed); _okText = Settings.GetResource(ResKeys.mobile_btn_ok); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init(Guid userId, bool enableChat = true) { EnableChat = enableChat; try { _user = await _userService.GetUserAsync(userId, ApiPriority.UserInitiated); if (_user != null) { UserId = _user.Id; _isCurrentUser = _user.Id != Settings.UserId; RaiseAllPropertiesChanged(); } else { // TODO : Wat dan? } } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init(Guid id) { try { _personalModel = await _userService.GetPersonalModelAsync(ApiPriority.UserInitiated); var messageModels = await _chatService.GetConversationAsync(ApiPriority.UserInitiated, id, null); var userModels = await _userService.GetAllPublicUsersAsync(ApiPriority.UserInitiated); await _chatService.SetHasReadAsync(ApiPriority.UserInitiated, id); UpdateCollection(messageModels, userModels); // TODO : Only 1 user for now because no group chat var user = userModels.FirstOrDefault(u => u.Id == id); // TODO : Move unknown user to user service? Title = user != null ? user.DisplayName : "Unknown user"; Id = id; AvatarUrl = user?.Avatar?.Small; UserId = id; _conversationUsers = new List <ApiWhitelabelPublicUserModel> { user }; } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init(Guid roomId, DateTime dateTime) { try { var timeList = new List <TimePickerData>(); for (var i = 9; i < 24; i++) { var hour = ((i % 12) == 0) ? 12 : (i % 12); var timeItem = new TimePickerData(i, 0, false); timeList.Add(timeItem); } var viewModelList = new List <TimePickerItemViewModel>(); foreach (var timePickerData in _availableTimeList) { viewModelList.Add(new TimePickerItemViewModel(timePickerData)); } TimeList = new ObservableCollection <TimePickerItemViewModel>(viewModelList); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
private async Task GetRoomsAsync() { try { var roomModels = await _bookingService.GetAllRoomsAsync(ApiPriority.UserInitiated); var reservations = await _bookingService.GetAllReservationsForDayAsync(ApiPriority.UserInitiated, DateTime.Now.Year, DateTime.Now.DayOfYear); var roomViewModels = new List <RoomIndexItemViewModel>(); roomModels = roomModels.OrderBy(r => r.Order).ToList(); foreach (var apiRoomModel in roomModels) { // Get the room image var headerUrl = apiRoomModel.Header != null ? apiRoomModel.Header.Medium : Defaults.RoomHeaderDefault; var currentReservations = reservations.Where(r => r.RoomId == apiRoomModel.Id && r.ReservationStart <DateTime.Now && r.ReservationEnd> DateTime.Now).ToList(); var available = !currentReservations.Any(); roomViewModels.Add(new RoomIndexItemViewModel(new RoomData(apiRoomModel.Id, headerUrl, apiRoomModel.Name, available))); } RoomList = new ObservableCollection <RoomIndexItemViewModel>(roomViewModels); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init() { while (true) { try { // Get the platform await GetPlatformModelAsync(); } catch (Exception ex) { ExceptionService.HandleException(ex); } if (Settings.DefaultLanguage == null) { // No platform and no selected language yet, first time, show connection error await UserDialogs.AlertAsync("Connection error, please make sure you are connected to the internet and press OK"); } else { // Language is set, meanse we have platform, continue break; } } SetResources(); IsBusy = false; }
public void ChecksIfTheBufferedEventRegistrationWorks() { var buffercount = 0; var exceptionService = new ExceptionService(); exceptionService.ExceptionBuffered += (sender, args) => { Assert.IsInstanceOf(typeof(DivideByZeroException), args.BufferedException); buffercount++; }; exceptionService.Register <DivideByZeroException>(exception => { }, null) .UsingTolerance(9, TimeSpan.FromSeconds(10.0)); var index = 0; var exceptionHandledAt10Th = false; for (; index < 10; index++) { ThreadHelper.Sleep(100); exceptionHandledAt10Th = exceptionService.HandleException(new DivideByZeroException()); } Assert.IsTrue(exceptionHandledAt10Th); Assert.AreEqual(10, index); Assert.AreEqual(9, buffercount); }
public async Task Init() { try { } catch (Exception ex) { ExceptionService.HandleException(ex); } }
private async Task GetConversationsAsync() { try { // Get data from services var messageModels = await _chatService.GetLastMessagesAsync(ApiPriority.UserInitiated); var unreadMessageModels = await _chatService.GetUnreadAsync(ApiPriority.UserInitiated); var publicUserModels = await _userService.GetAllPublicUsersAsync(ApiPriority.UserInitiated); SendUnreadChatMessagesUpdate(unreadMessageModels.Count); var ownId = Settings.UserId; var conversationViewModels = new List <ConversationListViewModel>(); foreach (var messageModel in messageModels) { // Get the conversation ID var conversationId = messageModel.FromId != ownId ? messageModel.FromId : messageModel.ToId; // Get the user var userModel = publicUserModels.FirstOrDefault(u => u.Id == conversationId); // Check if message is unread var unreadMessage = unreadMessageModels.FirstOrDefault(m => m.Id == messageModel.Id); if (userModel != null) { var conversationViewModel = GetConversation(unreadMessage ?? messageModel, userModel); if (conversationViewModel != null) { // Get all unread messages for the count conversationViewModel.NumberUnread = unreadMessageModels.Count(m => m.FromId == conversationViewModel.Id || m.ToId == conversationViewModel.Id); conversationViewModels.Add(conversationViewModel); } } } var orderedConversations = conversationViewModels.OrderByDescending(c => c.LastMessageDateTime).ToList(); Conversations = new ExtendedObservableCollection <ConversationListViewModel>(orderedConversations); } catch (Exception ex) { ExceptionService.HandleException(ex); Conversations = new ExtendedObservableCollection <ConversationListViewModel>(new List <ConversationListViewModel>()); } }
public void PerformsHandleForNotRegisteredTypeViaInheritance() { var exceptionService = new ExceptionService(); var originalException = new DivideByZeroException("achieved"); var value = string.Empty; exceptionService.Register <Exception>(exception => { value = exception.Message; }, null); Assert.IsTrue(exceptionService.HandleException(originalException)); Assert.AreEqual("achieved", value); }
public void SetResources() { try { PasswordPlaceholder = GetResource(ResKeys.mobile_sign_password); EmailPlaceholder = GetResource(ResKeys.mobile_signin_email); SigninButtonTitle = GetResource(ResKeys.mobile_signin_btn_signin); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init(Guid roomId) { try { _roomId = roomId; var roomModel = await _bookingService.GetRoomAsync(ApiPriority.UserInitiated, roomId); var roomReservations = await _bookingService.GetReservationsAsync(ApiPriority.UserInitiated, roomId); if (roomModel != null) { // Room info Title = roomModel.Name; AboutRoomTitle = $"About {roomModel.Name}"; AboutRoomText = roomModel.Description; AboutRoomVisible = !string.IsNullOrWhiteSpace(roomModel.Description); NumberOfPersons = $"{roomModel.NumberOfGuests} Persons"; // Room images var imageList = roomModel.Images.Select(roomModelImage => new BodySliderData(roomModelImage.Medium)).ToList(); foreach (var bodySliderData in imageList) { RoomList.Add(new BodySliderItemViewModel(bodySliderData, () => { ShowViewModel <ImageZoomViewModel>(new { url = bodySliderData.ImageUrl }); })); } ImageUrl = roomModel.Header == null ? Defaults.RoomHeaderDefault : roomModel.Header.Medium; // Check reservations at this current time IsAvailable = !roomReservations.Any(t => t.ReservationStart <DateTime.Now && t.ReservationEnd> DateTime.Now); var locationModel = await PlatformService.GetLocationAsync(ApiPriority.UserInitiated, roomModel.LocationId); if (locationModel != null) { LocationName = locationModel.Name; AboutLocationTitle = $"About {locationModel.Name}"; AboutLocationText = locationModel.AboutText; AboutLocationVisible = !string.IsNullOrWhiteSpace(locationModel.AboutText); } } } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init(Guid id) { try { _id = id; var myreservations = await _bookingService.GetMyReservationsAsync(); var reservation = myreservations?.Reservations?.FirstOrDefault(r => r.Id == id); if (reservation != null) { var roomModel = myreservations.Rooms?.FirstOrDefault(r => r.Id == reservation.RoomId); if (roomModel != null) { ImageUrl = roomModel.Header != null ? roomModel.Header.Large : Defaults.RoomHeaderDefault; ReservationCode = reservation.ReservationCode; Date = reservation.ReservationStart.ToString("D"); Checkin = reservation.ReservationStart.ToString("t"); Checkout = reservation.ReservationEnd.ToString("t"); Room = roomModel.Name; IsPrivate = reservation.IsPrivate; Message = reservation.Message; Title = reservation.Title; foreach (var roomModelImage in roomModel.Images) { RoomList.Add(new BodySliderItemViewModel(new BodySliderData(roomModelImage.Medium), () => { ShowViewModel <ImageZoomViewModel>(new { url = roomModelImage.Large }); })); } // Get location var locationmodel = await PlatformService.GetLocationAsync(ApiPriority.UserInitiated, roomModel.LocationId); Location = locationmodel?.Name; } } else { // TODO : Show some error? } } catch (Exception ex) { ExceptionService.HandleException(ex); } }
private async Task <ApiWhitelabelEventModel> GetEventAsync(Guid id) { try { var eventModel = await _eventService.GetAsync(ApiPriority.UserInitiated, id); return(eventModel); } catch (Exception ex) { ExceptionService.HandleException(ex); return(null); } }
public async Task Init(Guid categoryId) { try { _categoryId = categoryId; await SetTitleAsync(); await LoadEvents(); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init(ManageType type) { try { _personalModel = await _userService.GetPersonalModelAsync(ApiPriority.UserInitiated); } catch (Exception ex) { ExceptionService.HandleException(ex); } Type = type; Items = Type == ManageType.Default ? GetDefaultItems() : await GetLanguageItems(); }
public async Task Init() { try { var bisnerClient = Mvx.Resolve <ISignalRClient>(); bisnerClient.NewPrivateMessage += _newPrivateMessageHandler; await GetConversationsAsync(); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task InvokeAsync(HttpContext httpContext) { try { await _next(httpContext); } catch (CustomException ex) { await ExceptionService.HandleCustomException(httpContext, ex); } catch (Exception ex) { await ExceptionService.HandleException(httpContext, ex); } }
private void TryGetUserPosition() { DispatcherHelper.CheckBeginInvokeOnUI(async() => { Debug.WriteLine("[MainVm] TryGetUserPosition: request location"); try { await _geo.GetUserLocation(); Debug.WriteLine("[MainVm] TryGetUserPosition: got answer"); } catch (Exception e) { _exceptionService.HandleException(e, "getUserPosition"); Debug.WriteLine("[MainVm] TryGetUserPosition: something happened: ", e.Message); } }); }
private async Task UpdateUnreadAsync() { try { var unreadChatMessages = await _chatService.GetUnreadAsync(ApiPriority.Background); SendUnreadChatMessagesUpdate(unreadChatMessages.Count); var unreadNotifications = await _notificationService.GetNumberUnreadAsync(); SendUnreadNotificationsUpdate(unreadNotifications); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public async Task Init() { List <IEvent> events; try { var firstFour = await _eventService.GetUpcomingAsync(ApiPriority.UserInitiated, 4); events = firstFour.Select(e => e.ToModel(_eventClosedText, _unattendButtonText, _attendButtonText, _peopleAttendingText, _eventInfoText, _eventDateText, _eventTimeLabel, _eventLocationLabel, _aboutHeaderLabel)).ToList(); } catch (Exception ex) { ExceptionService.HandleException(ex); events = new List <IEvent>(); } await BuildEventCategories(events); }
public void MultipleExceptionsOfSameTypeThrownTooManyTimesProducesOnlyOneException() { var exceptionService = new ExceptionService(); exceptionService.Register <DivideByZeroException>(exception => { }, null) .UsingTolerance(9, TimeSpan.FromSeconds(10.0)); var index = 0; var exceptionHandledAt10Th = false; for (; index < 10; index++) { ThreadHelper.Sleep(100); exceptionHandledAt10Th = exceptionService.HandleException(new DivideByZeroException()); } Assert.IsTrue(exceptionHandledAt10Th); Assert.AreEqual(10, index); }
public async Task Init(Guid id, FeedType feedType) { Debug.WriteLine("FeedViewModel INIT with id = {0}", id); SetResources(); //IsRefreshing = true; FeedId = id; FeedType = feedType; // For the postbox //await SetUserInfo(); // Check company if this is company feed if (feedType == FeedType.Company) { await GetCompany(); } // Check group if this is a group feed if (feedType == FeedType.Group) { await GetGroup(); } try { var items = await GetFeedItemsAsync(null); _olderThen = items.Any() ? items.Min(p => p.DateTime) : DateTime.MaxValue; AddHeader(items); Items = new ExtendedObservableCollection <IFeedItem>(items); } catch (Exception ex) { ExceptionService.HandleException(ex); IsRefreshing = false; } }
private async Task RefreshAsync() { if (!IsRefreshing) { try { var firstFour = await _eventService.GetUpcomingAsync(ApiPriority.UserInitiated, 4); await BuildEventCategories(firstFour.Select(e => e.ToModel(_eventClosedText, _unattendButtonText, _attendButtonText, _peopleAttendingText, _eventInfoText, _eventDateText, _eventTimeLabel, _eventLocationLabel, _aboutHeaderLabel))); } catch (Exception ex) { ExceptionService.HandleException(ex); } finally { IsRefreshing = false; } } }
public async Task Init() { if (!_isInitializing && _lastInitTime < DateTime.Now.AddMinutes(3)) { _isInitializing = true; try { await PlatformService.GetPublicPlatformAsync(ApiPriority.Background); await _userService.GetPersonalModelAsync(ApiPriority.Background); } catch (Exception ex) { ExceptionService.HandleException(ex); } _isInitializing = false; _lastInitTime = DateTime.Now; } }
public async Task Init() { try { await RefreshAsync(); //Items = new ObservableCollection<AccessControlItemViewModel> //{ // new AccessControlItemViewModel // { // Title = "Front door", // SubTitle = "Free entry", // State = LockState.Close // }, // new AccessControlItemViewModel // { // Title = "Conference room A", // SubTitle = "Limited access", // State = LockState.Close // }, // new AccessControlItemViewModel // { // Title = "Meeting room B", // SubTitle = "Free entry", // State = LockState.Close // }, // new AccessControlItemViewModel // { // Title = "Conference room C", // SubTitle = "Limited access", // State = LockState.Close // }, //}; } catch (Exception ex) { ExceptionService.HandleException(ex); Items = new ObservableCollection <AccessControlItemViewModel>(); } }
public async Task LoadEvents() { IsLoading = true; try { var eventModels = await _eventService.GetAllAsync(ApiPriority.UserInitiated, _categoryId != Guid.Empty?_categoryId : (Guid?)null); var events = eventModels.Select(e => e.ToModel(_eventClosedText, _unattendButtonText, _attendButtonText, _peopleAttendingText, _eventInfoText, _eventDateText, _eventTimeLabel, _eventLocationLabel, _aboutHeaderLabel)); Items = new List <IEvent>(events); } catch (Exception ex) { // TODO: Wat dan? ExceptionService.HandleException(ex); } finally { IsLoading = false; } }
public async Task Init() { try { Locations = await PlatformService.GetLocationsAsync(ApiPriority.UserInitiated); _personalModel = await _userService.GetPersonalModelAsync(ApiPriority.UserInitiated); // Header image AvatarUrl = $"{_personalModel.Avatar.Medium}"; // About DisplayName = _personalModel.DisplayName; FirstName = _personalModel.FirstName; LastName = _personalModel.LastName; Email = _personalModel.Email; // Profile ShortIntro = _personalModel.ShortAbout; About = _personalModel.About; City = _personalModel.City; LinkedInUrl = _personalModel.LinkedInUrl; FacebookUrl = _personalModel.FacebookUrl; TwitterUrl = _personalModel.TwitterUrl; GoogleUrl = _personalModel.GooglePlusUrl; InstagramUrl = _personalModel.InstagramUrl; SelectedLocation = Locations.Find(l => l.Id == _personalModel.LocationId); SelectedLanguage = Settings.SelectedLanguageId.ToString(); OnEnableUpdate(false); } catch (Exception ex) { ExceptionService.HandleException(ex); UserDialogs.Alert(GetResource(ResKeys.mobile_error_server_error)); } }
public async Task Init(Guid postId) { PostId = postId; try { SetResources(); var feedResponseModel = await _feedService.GetPostAsync(ApiPriority.UserInitiated, postId); var posts = BuildItems(feedResponseModel); var post = posts.FirstOrDefault(); if (post == null) { await UserDialogs.AlertAsync(ResKeys.mobile_error_server_error); Debug.WriteLine("Could not find post with id {0} in repository", PostId); Close(this); return; } var comments = feedResponseModel.Posts.FirstOrDefault()?.Comments.Select(c => c.ToModel()); // Add post var items = new List <IItemBase>(posts); // Add comments items.AddRange(comments.OrderBy(p => p.DateTime).ToList()); Items = new ExtendedObservableCollection <IItemBase>(items); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public void ChecksIfTheBufferedEventRegistrationWorks() { var buffercount = 0; var exceptionService = new ExceptionService(); exceptionService.ExceptionBuffered += (sender, args) => { Assert.IsInstanceOfType(args.BufferedException, typeof (DivideByZeroException)); buffercount++; }; exceptionService.Register<DivideByZeroException>(exception => { }) .UsingTolerance(9, TimeSpan.FromSeconds(10.0)); var index = 0; var exceptionHandledAt10Th = false; for (; index < 10; index++) { ThreadHelper.Sleep(100); exceptionHandledAt10Th = exceptionService.HandleException(new DivideByZeroException()); } Assert.IsTrue(exceptionHandledAt10Th); Assert.AreEqual(10, index); Assert.AreEqual(9, buffercount); }
public void MultipleExceptionsOfSameTypeThrownTooManyTimesProducesOnlyOneException() { var exceptionService = new ExceptionService(); exceptionService.Register<DivideByZeroException>(exception => { }) .UsingTolerance(9, TimeSpan.FromSeconds(10.0)); var index = 0; var exceptionHandledAt10Th = false; for (; index < 10; index++) { ThreadHelper.Sleep(100); exceptionHandledAt10Th = exceptionService.HandleException(new DivideByZeroException()); } Assert.IsTrue(exceptionHandledAt10Th); Assert.AreEqual(10, index); }
public void PerformsHandleForNotRegisteredTypeViaInheritance() { var exceptionService = new ExceptionService(); var originalException = new DivideByZeroException("achieved"); var value = string.Empty; exceptionService.Register<Exception>(exception => { value = exception.Message; }); Assert.IsTrue(exceptionService.HandleException(originalException)); Assert.AreEqual("achieved", value); }
public void ThrowsArgumentNullExceptionForNullParameter() { var exceptionService = new ExceptionService(); ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => exceptionService.HandleException(null)); }