public PersonDiscConfigWnd(Discussion d, Person p) { InitializeComponent(); this.WindowState = WindowState.Normal; this.Width = 336; personSelector.onSelected += onPersonSelected; _d = d; person = p; lblDiscussion.Content = "Discussion: " + d.Subject; int currentSide = DaoUtils.GetGeneralSide(p, d); if (currentSide != -1) { selector1.SelectedSide = currentSide; } else { selector1.SelectedSide = (int)SideCode.Neutral; } personSelector.Set(PublicBoardCtx.Get().Person, "Name"); }
//void EnsureNonNullDiscussion() //{ // if (EditedDiscussion == null) // btnAddDiscussion_Click(null,null); //} private void btnRemove_Click(object sender, RoutedEventArgs e) { if (EditedDiscussion != null && Ctors.DiscussionExists(EditedDiscussion)) { BusyWndSingleton.Show("Deleting discussion..."); try { if (SessionInfo.Get().discussion != null) { if (SessionInfo.Get().discussion.Id == EditedDiscussion.Id) { SessionInfo.Get().discussion = null; } } DaoUtils.DeleteDiscussion(EditedDiscussion); discussionSelector.Set(PublicBoardCtx.Get().Discussion, "Subject"); EditedDiscussion = null; } finally { BusyWndSingleton.Hide(); } } }
private void updateStopWatch(Topic displayedTopic, TimeSpan passedSinceLastUpdate) { var discId = SessionInfo.Get().discussion.Id; var freshDisc = PublicBoardCtx.Get().Discussion.FirstOrDefault(d0 => d0.Id == discId); bool needSave = false; foreach (var topic in freshDisc.Topic) { if (!topic.Running) { if (topic.Id == displayedTopic.Id) { stopWatch.Text = TimeSpan.FromSeconds((double)topic.CumulativeDuration).ToString(); } continue; } needSave = true; topic.CumulativeDuration += passedSinceLastUpdate.Seconds; if (topic.Id == displayedTopic.Id) { stopWatch.Text = TimeSpan.FromSeconds((double)topic.CumulativeDuration).ToString(); } } if (needSave) { PublicBoardCtx.Get().SaveChanges(); } }
private void ForgetDBDiscussionState() { //forget cached state PublicBoardCtx.DropContext(); _discussion = SessionInfo.Get().discussion; DataContext = this; }
private void btnOk_Click(object sender, RoutedEventArgs e) { var ctx = PublicBoardCtx.Get(); foreach (var p in persons) { bool prevExists; Person prev = DaoUtils.PersonSingleton(p, out prevExists); if (!prevExists) { try { ctx.AddToPerson(prev); } catch (Exception) { //persons in modified are ignored } } } ctx.SaveChanges(); if (changesExist) { _sharedClient.clienRt.SendUserAccPlusMinus(); } Close(); }
//returns current person taken from the same context as entity is attached to public Person getPerson(object entity) { if (_person == null) { return(null); } if (entity == null) { entity = discussion; } //discussion not set if (entity == null) { return(_person); } if (IsAttachedTo(PrivateCenterCtx.Get(), entity)) { return(PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == _person.Id)); } else if (IsAttachedTo(PublicBoardCtx.Get(), entity)) { return(PublicBoardCtx.Get().Person.FirstOrDefault(p0 => p0.Id == _person.Id)); } else if (IsAttachedTo(DbCtx.Get(), entity)) { return(DbCtx.Get().Person.FirstOrDefault(p0 => p0.Id == _person.Id)); } return(_person); }
public static void RemoveAnnotation(Annotation a) { a.Person = null; a.Discussion = null; PublicBoardCtx.Get().Annotation.DeleteObject(a); }
private void SaveParticipants(Topic t = null) { if (t == null) { t = EditedTopic; } if (t == null || EditedDiscussion == null) { return; } foreach (Topic top in EditedDiscussion.Topic) { top.Person.Clear(); foreach (var p in tmpPersons) { if (p.Name == "Name") { continue; } bool prevExists; Person prev = DaoUtils.PersonSingleton(p, out prevExists); if (!top.Person.Contains(prev)) { top.Person.Add(prev); } } } PublicBoardCtx.Get().SaveChanges(); }
public static IEnumerable <Annotation> GetAnnotations(Discussion d) { var q = from ans in PublicBoardCtx.Get().Annotation where ans.Discussion.Id == d.Id select ans; return(q); }
private void CommitAvaNameChanges(Person pers) { var userId = pers.Id; var usr = PublicBoardCtx.Get().Person.FirstOrDefault(p0 => p0.Id == userId); usr.Name = pers.Name; PublicBoardCtx.Get().SaveChanges(); }
public DiscussionAutoCreatorWnd() { InitializeComponent(); DataContext = this; lstDiscussions.ItemsSource = PublicBoardCtx.Get().Discussion; }
private void btnAdd_Click(object sender, RoutedEventArgs e) { var s = new Seat(); s.SeatName = "<Seat>"; s.Color = Utils.ColorToInt(Colors.LawnGreen); Seats.Add(s); PublicBoardCtx.Get().AddToSeat(s); }
private void SaveDiscussion() { if (_d == null) { return; } DaoUtils.EnsureBgExists(_d); _d.Background.Text = ""; _d.HtmlBackground = plainHtml.Text; PublicBoardCtx.Get().SaveChanges(); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { var ss = SelectedSeat; if (ss == null) { return; } Seats.Remove(ss); PublicBoardCtx.Get().DeleteObject(ss); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { var s = new Session(); s.Name = "<Session>"; s.EstimatedDateTime = DateTime.Now; s.EstimatedEndDateTime = DateTime.Now.Add(TimeSpan.FromHours(1)); s.EstimatedTimeSlot = (int)TimeSlot.Morning; Sessions.Add(s); PublicBoardCtx.Get().AddToSession(s); }
private void btnRefresh_Click(object sender, System.Windows.RoutedEventArgs e) { PublicBoardCtx.DropContext(); _sessions = new ObservableCollection <Session>(PublicBoardCtx.Get().Session); //trigger update of seat/users var prevSelSession = lstSessions.SelectedItem; lstSessions.SelectedItem = null; lstSessions.SelectedItem = prevSelSession; }
//used for coloring shapes in graphics editor after users public static Color UserIdToColor(int id) { Person p = PublicBoardCtx.Get().Person.FirstOrDefault(p0 => p0.Id == id); if (p == null) { return(Colors.AliceBlue); } else { return(Utils.IntToColor(p.Color)); } }
private void btnAddDiscussion_Click(object sender, RoutedEventArgs e) { var newDisc = new Discussion(); newDisc.Subject = txtBxDiscussion.Text; newDisc.Background = new RichText(); newDisc.Background.Text = ""; EditedDiscussion = newDisc; PublicBoardCtx.Get().AddToDiscussion(EditedDiscussion); PublicBoardCtx.Get().SaveChanges(); discussionSelector.Set(PublicBoardCtx.Get().Discussion, "Subject"); discussionSelector.Select(EditedDiscussion); }
public static void EnsureModerExists() { var ctx = PublicBoardCtx.Get(); var q = from p in ctx.Person where p.Name.IndexOf(MODER_SUBNAME) != -1 select p; if (q.Count() == 0) { ctx.AddToPerson(Ctors.NewPerson("moderator", "moder-mail")); ctx.SaveChanges(); } }
private void removeMedia_Click(object sender, RoutedEventArgs e) { var at = ((ContentControl)sender).DataContext as Attachment; at.Discussion = null; var mediaData = at.MediaData; at.MediaData = null; if (mediaData != null) { PublicBoardCtx.Get().DeleteObject(mediaData); } PublicBoardCtx.Get().Attachment.DeleteObject(at); }
public static void removePersonsAndTopic(Topic t) { if (t == null) { return; } var ctx = PublicBoardCtx.Get(); t.Person.Clear(); t.ArgPoint.Clear(); t.Discussion = null; ctx.SaveChanges(); }
public static void UpdateToNewCtx() { if (_inst == null) { return; } var ctx = PublicBoardCtx.Get(); if (_inst.discussion != null) { _inst.discussion = ctx.Discussion.FirstOrDefault(d0 => d0.Id == _inst.discussion.Id); } }
private void ParticipantChanged(object selected) { _discussion = null; _person = selected as Person; //enum all discussions of the person DiscCtx ctx = PublicBoardCtx.Get(); IQueryable <Discussion> lookup = (from t in ctx.Topic where t.Person.Any(p0 => p0.Id == _person.Id) select t.Discussion).Distinct(); discSelector.Set(lookup, "Subject"); discSelector.IsEnabled = true; }
public SpeakerLogin() { InitializeComponent(); participantSelector.onSelected += ParticipantChanged; var persons = from p in PublicBoardCtx.Get().Person where p.Name != "Name" select p; participantSelector.Set(persons, "Name"); discSelector.onSelected += DiscussionChanged; }
private void LogoutProcedures() { if (sharedClient.clienRt != null) { sharedClient.clienRt.SendLiveRequest(); } SetListeners(sharedClient, false); _discWindows.CloseAndDispose(); SessionInfo.Reset(); PublicBoardCtx.DropContext(); PrivateCenterCtx.DropContext(); }
public static List <EventViewModel> GetRecentEvents() { var res = new List <EventViewModel>(); var events = (from s in PublicBoardCtx.Get().StatsEvent orderby s.Time descending select s).Take(10); foreach (var e in events.ToArray().Reverse()) { res.Add(new EventViewModel((StEvent)e.Event, e.UserId, e.Time, (DeviceType)e.DeviceType)); } return(res); }
private void btnRemovePoint_Click(object sender, RoutedEventArgs e) { if (DateTime.Now.Subtract(_recentRemovalStamp).TotalSeconds < 2.0) { return; } _recentRemovalStamp = DateTime.Now; ArgPoint ap; Topic t; getPointAndTopic(out ap, out t); if (ap == null) { return; } if (ap.Person.Id != SessionInfo.Get().person.Id) { return; } BusyWndSingleton.Show("Removing argument..."); try { if (ap.Topic != null) { Topic t1 = ap.Topic; recentlyDeleted = new PointRemoveRecord(); recentlyDeleted.person = ap.Person; recentlyDeleted.point = ap; recentlyDeleted.topic = ap.Topic; PublicBoardCtx.DropContext(); DaoUtils.UnattachPoint(ap); RenumberPointsAfterDeletion(t1, SessionInfo.Get().person.Id); UpdatePointsOfTopic(t1); saveProcedure(ap, t1.Id); } } finally { BusyWndSingleton.Hide(); } }
public static bool ArgPointInTopic(int apId, int topicId) { var ap = PublicBoardCtx.Get().ArgPoint.FirstOrDefault(p0 => p0.Id == apId); if (ap == null) { return(false); } if (ap.Topic == null) { return(false); } return(ap.Topic.Id == topicId); }
/// <summary> /// Default constructor. /// </summary> public PersonManagerWnd(UISharedRTClient sharedClient, Main.OnDiscFrmClosing closing) { InitializeComponent(); _sharedClient = sharedClient; // Add handlers for window availability events AddWindowAvailabilityHandlers(); _closing = closing; persons = new ObservableCollection <Person>(PublicBoardCtx.Get().Person); DataContext = this; this.WindowState = WindowState.Normal; }
public static Person PersonSingleton(Person template, out bool prevExists) { Person prev = PublicBoardCtx.Get().Person.FirstOrDefault(p0 => p0.Name == template.Name && p0.Email == template.Email); if (prev != null) { prevExists = true; return(prev); } else { prevExists = false; return(template); } }