private void Window_Loaded(object sender, RoutedEventArgs e) { Splasher.SetStatusText("Загрузка новостной ленты"); if (_firstRun) { _firstRun = false; GetClasses(); SetBindings(); BindingLoginData(); MainFrame.Navigate(_newsFeed); if (App.AppArguments[0] == "-m") { var lastExit = AdministrationClass.LastModuleExit(AdministrationClass.Modules.NewsFeed); _newsFeed.ShowNews(lastExit); NotificationManager.ShowNotifications(AdministrationClass.CurrentWorkerId); _workshopMode = false; } } Splasher.CloseSplashWindow(); ShowInTaskbar = true; WindowState = WindowState.Maximized; }
private void GoHomeButton_Click(object sender, RoutedEventArgs e) { if (MainFrame.HasContent) { if (!(MainFrame.Content is NewsFeed)) { _newsFeed = new NewsFeed(); MainFrame.Navigate(_newsFeed); var lastExit = AdministrationClass.LastModuleExit(AdministrationClass.Modules.NewsFeed); _newsFeed.ShowNews(lastExit); NotificationManager.ShowNotifications(AdministrationClass.CurrentWorkerId); } } if (MenuPopupBorder.Child != null) { MenuPopupBorder.Child = null; MainGrid.Children.Add(MenuGrid); } MenuListBox.SelectedItems.Clear(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { App.BaseClass.GetNewsFeedClass(ref _newsFeedClass); if (_newsFeedClass != null && value != null) { if (parameter != null) { switch (parameter.ToString()) { case "CommentAttachmentsList": { int commentId; var success = Int32.TryParse(value.ToString(), out commentId); if (success) { var commentAttachmentsView = _newsFeedClass.CommentsAttachments.AsDataView(); commentAttachmentsView.RowFilter = string.Format("CommentID = {0}", commentId); return(commentAttachmentsView); } break; } case "EditCommentButtonsEnable": { int commentId; var success = Int32.TryParse(value.ToString(), out commentId); if (success) { var rows = _newsFeedClass.Comments.AsEnumerable() .Where(c => c.Field <Int64>("CommentID") == commentId); if (rows.Any()) { var comment = rows.First(); var workerId = System.Convert.ToInt32(comment["WorkerID"]); return(workerId == AdministrationClass.CurrentWorkerId); } } break; } case "IsNewComment": { var periodForNewComment = TimeSpan.FromMinutes(2); int commentId; var success = Int32.TryParse(value.ToString(), out commentId); if (success) { var rows = _newsFeedClass.Comments.AsEnumerable() .Where(c => c.Field <Int64>("CommentID") == commentId); if (rows.Any()) { var comment = rows.First(); var workerId = System.Convert.ToInt32(comment["WorkerID"]); if (workerId != AdministrationClass.CurrentWorkerId) { var commentDate = System.Convert.ToDateTime(comment["CommentDate"]); var currentModuleId = AdministrationClass.CurrentModuleId; var lastUpdate = AdministrationClass.LastModuleExit(currentModuleId); var updateTimeLimit = lastUpdate != DateTime.MinValue ? lastUpdate.Subtract(periodForNewComment) : DateTime.MinValue; return(commentDate > updateTimeLimit); } } } break; } } } } return(null); }
private void EnterButton_Click(object sender, RoutedEventArgs e) { if (WorkersNamesListBox.SelectedItems.Count == 0) { return; } if (WorkerPasswordBox.Password == string.Empty) { MessageBox.Show("Необходимо ввести пароль", "Информация", MessageBoxButton.OK, MessageBoxImage.Information); WorkerPasswordBox.Focus(); return; } //if (!_sc.CheckPassword(WorkerPasswordBox.Password, Convert.ToInt32(WorkersNamesListBox.SelectedValue))) //{ // MessageBox.Show("Неверный пароль!", "Информация", MessageBoxButton.OK, // MessageBoxImage.Information); // WorkerPasswordBox.Password = string.Empty; // WorkerPasswordBox.Focus(); // return; //} //LoadPageForWorker(Convert.ToInt32(WorkersNamesListBox.SelectedValue)); AdministrationClass.OpenNewProgramEntry(Convert.ToInt32(WorkersNamesListBox.SelectedValue)); AdministrationClass.OpenNewModuleEntry(AdministrationClass.Modules.NewsFeed); MenuListBox.ItemsSource = AdministrationClass.GetAvailableModulesForWorker().DefaultView; AdministrationClass.GetFavoritesModulesIdsForWorker(); MenuGroupsListBox.SelectedIndex = 0; MenuGroupsListBox_SelectionChanged(null, null); LoadPersonalInformation(); SetDefaultViewWorkingDayGrid(); CalculateWorkerTime(); var lastExit = AdministrationClass.LastModuleExit(AdministrationClass.Modules.NewsFeed); _newsFeed.ShowNews(lastExit); NotificationManager.ShowNotifications(AdministrationClass.CurrentWorkerId); WorkerLoginGrid.Visibility = Visibility.Collapsed; UserGrid.Visibility = Visibility.Visible; if (MenuPopupBorder.Child != null) { MenuPopupBorder.Child = null; MainGrid.Children.Add(MenuGrid); } MenuListBox.SelectedItems.Clear(); WorkersNamesListBox.SelectedIndex = 0; WorkerPasswordBox.Password = string.Empty; ClearModules(); //HideLoginGrid(); }