예제 #1
0
        StartReportingActivities(Topic topic, Discussion disc, Session session)
        {
            _topic   = topic;
            _disc    = disc;
            _session = session;

            var moder = DbCtx.Get().Person.Single(p => p.Name.StartsWith("moder"));

            _clienRt = new ClientRT(disc.Id,
                                    ConfigManager.ServiceServer,
                                    moder.Name,
                                    moder.Id,
                                    DeviceType.Wpf);

            _clienRt.onJoin += OnJoined;

            _hardReportTCS       = new TaskCompletionSource <ReportCollector>();
            _remoteScreenshotTCS = new TaskCompletionSource <Dictionary <int, byte[]> >();

            Task.Factory.StartNew(async() =>
            {
                while (_servicingPhotonClient)
                {
                    _clienRt.Service();
                    await Utils.Delay(80);
                }
            },
                                  TaskCreationOptions.LongRunning);

            return(new Tuple <Task <Dictionary <int, byte[]> >,
                              Task <ReportCollector> >(_remoteScreenshotTCS.Task, _hardReportTCS.Task));
        }
예제 #2
0
        //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);
        }
        private void lstBxPersons_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SelectedPerson = e.AddedItems[0] as Person;

            decoration.SetGreetingName(SelectedPerson.Name);

            //enum all discussions of the person
            if (SelectedPerson != null)
            {
                DiscCtx ctx = DbCtx.Get();
                IQueryable <Discussion> myDiscussions =
                    (from t in ctx.Topic
                     where t.Person.Any(p0 => p0.Id == SelectedPerson.Id)
                     select t.Discussion).Distinct();

                _discussions.Clear();
                foreach (var d in myDiscussions)
                {
                    _discussions.Add(d);
                }

                //add dummy discussion for moderator
                if (SelectedPerson.Name.StartsWith("moder"))
                {
                    _discussions.Add(DummyDiscussion);
                }

                lblSelDiscussion.Visibility = Visibility.Visible;
            }
            else
            {
                lblSelDiscussion.Visibility = Visibility.Hidden;
            }
        }
예제 #4
0
        private void ShowLargeBadgeView(ArgPoint ap)
        {
            scene.IsHitTestVisible     = false;
            blockWorkingAreaTransforms = true;

            if (_lbv == null)
            {
                _lbv = new LargeBadgeView();
            }
            var ArgPointId = ap.Id;

            DbCtx.DropContext();//it can become stale while modal view was closed.
            _lbv.DataContext = DbCtx.Get().ArgPoint.FirstOrDefault(p0 => p0.Id == ArgPointId);
            _lbv.SetRt(UISharedRTClient.Instance);

            //mainGrid.Children.Add(_lbv);
            int indexOfLaserScene = mainGrid.Children.IndexOf(laserScene);

            if (!mainGrid.Children.Contains(_lbv))
            {
                mainGrid.Children.Insert(indexOfLaserScene, _lbv);
            }

            ResizeLargeBadgeView();

            _lbv.HorizontalAlignment = HorizontalAlignment.Center;
            _lbv.VerticalAlignment   = VerticalAlignment.Center;
        }
예제 #5
0
        private void LoginProcedure()
        {
            login = LoginDriver.Run(LoginFlow.ForEventGen);
            if (login == null)
            {
                System.Windows.Application.Current.Shutdown();
                return;
            }

            if (login.discussion == null)
            {
                MessageDlg.Show(
                    "In this application even moderator should select real, existing discussion");
                System.Windows.Application.Current.Shutdown();
                return;
            }

            Topics = new ObservableCollection <Topic>(login.discussion.Topic);

            Persons = new ObservableCollection <Person>(DaoHelpers.personsOfDiscussion(login.discussion));

            setPostLoginInfo();

            FillTopics(login.discussion);

            sharedClient.start(login, DbCtx.Get().Connection.DataSource, login.devType);
            sharedClient.clienRt.onStatsEvent += OnStatsEvent;
        }
예제 #6
0
        public void HandleRecontext()
        {
            SetStyle();

            Opacity = DataContext == null ? 0 : 1;

            //Drawing.HandleRecontext();

            var ap = DataContext as ArgPoint;

            _commentDismissalRecognizer.Reset(ap);

            UpdateLocalReadCounts(DbCtx.Get(), ap);
            new CommentNotificationDeferral(Dispatcher, DbCtx.Get(), lstBxComments1);
            UpdateRemoteReadCounts(DbCtx.Get(), ap);

            if (DataContext == null)
            {
                EditingMode = false;
            }
            else
            {
                EditingMode = SessionInfo.Get().person.Id == ap.Person.Id;
            }

            BeginSrcNumberInjection();
            UpdateOrderedSources();
            BeginAttachmentNumberInjection();
            UpdateOrderedMedia();

            ///commentsViewer.ScrollToBottom();
        }
예제 #7
0
        public static IEnumerable <Person> personsOfDiscussion(Discussion d)
        {
            var q = from p in DbCtx.Get().Person
                    where p.Topic.Any(t0 => t0.Discussion.Id == d.Id)
                    select p;

            return(q);
        }
예제 #8
0
        public static IEnumerable <Discussion> discussionsOfSession(Session s)
        {
            var sessionId = s.Id;
            var q         = from d in DbCtx.Get().Discussion
                            where d.GeneralSide.Any(gs0 => gs0.Person.Session.Id == sessionId)
                            select d;

            return(q);
        }
예제 #9
0
        void SaveProcedure()
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (DateTime.Now.Subtract(_lastSave).TotalMilliseconds < 100)
            {
                return;
            }

            _lastSave = DateTime.Now;

            var lastComment = ap.Comment.LastOrDefault();

            //finalize edited comment
            if (!string.IsNullOrWhiteSpace(txtNewComment.Text) &&
                DaoUtils.NEW_COMMENT != txtNewComment.Text)
            {
                if (lastComment == null || (lastComment != null && txtNewComment.Text != lastComment.Text))
                {
                    DaoUtils.HandleCommentCommit(txtNewComment.Text, ap);
                    //txtNewComment.Text = DaoUtils.NEW_COMMENT;
                    txtNewComment.Text = "";
                }
            }

            if (!ap.ChangesPending)
            {
                return;
            }

            ap.ChangesPending = false;

            //save changes
            try
            {
                DbCtx.Get().SaveChanges();
            }
            catch
            {
            }

            if (_sharedClient != null)
            {
                _sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                     SessionInfo.Get().person.Id,
                                                     ap.Topic.Discussion.Id,
                                                     ap.Topic.Id,
                                                     DeviceType.Wpf);

                _sharedClient.clienRt.SendArgPointChanged(ap.Id, ap.Topic.Id, SessionInfo.Get().person.Id);
            }
        }
예제 #10
0
        private void ArgPointChanged(int ArgPointId, int topicId, PointChangedType change, int personId)
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (ArgPointId != ap.Id)
            {
                return; //not our point
            }
            if (change != PointChangedType.Modified)
            {
                return;
            }

            //save edited comment
            //string editedCommentText = null;
            //var editedComment = ap.Comment.FirstOrDefault(c => c.Person == null &&
            //                                                   c.Text != DaoUtils.NEW_COMMENT);
            //if (editedComment != null)
            //    editedCommentText = editedComment.Text;

            //using db ctx here from login engine, not to spoil others
            DbCtx.DropContext();
            var ap2 = DbCtx.Get().ArgPoint.FirstOrDefault(p0 => p0.Id == ArgPointId);

            //BadgesCtx.DropContext();

            DataContext = null;

            //restore edited comment
            //if (!string.IsNullOrWhiteSpace(editedCommentText))
            //{
            //    var placeholder = ap2.Comment.FirstOrDefault(c => c.Person == null);
            //    if (placeholder != null)
            //    {
            //        placeholder.Text = editedCommentText;
            //        placeholder.Person = null;

            //        ////restore focus
            //        Dispatcher.BeginInvoke(
            //            DispatcherPriority.Background,
            //            (Action) (() => FocusCommentTextBox(placeholder))
            //            );
            //    }
            //}

            DataContext = ap2;

            scrollViewer.ScrollToBottom();
        }
예제 #11
0
        //static bool NameUnique(string Name, Session session)
        //{
        //    var sessionId = session.Id;
        //    DbCtx.DropContext();
        //    var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0=>p0.Name==Name && p0.Session != null && p0.Session.Id == sessionId);
        //    return outrunnerPerson == null;
        //}

        private static bool placeAlreadyBusy(Session session, Seat seat)
        {
            var sessionId = session.Id;
            var seatId    = seat.Id;

            DbCtx.DropContext();
            var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Online &&
                                                                    p0.Session != null &&
                                                                    p0.Session.Id == sessionId &&
                                                                    p0.Seat != null && p0.Seat.Id == seatId);

            //only if outrunner person exists and online, the place is busy
            return(outrunnerPerson != null);
        }
예제 #12
0
        public static bool ArgPointInTopic(int apId, int topicId)
        {
            var ap = DbCtx.Get().ArgPoint.FirstOrDefault(p0 => p0.Id == apId);

            if (ap == null)
            {
                return(false);
            }

            if (ap.Topic == null)
            {
                return(false);
            }

            return(ap.Topic.Id == topicId);
        }
예제 #13
0
 void userJoins(DiscUser usr)
 {
     if (usr.usrDbId == loginInfo.person.Id && wndCtx == null)
     {
         var topic = DbCtx.Get().Topic.FirstOrDefault(t0 => t0.Name.StartsWith("d-editor"));
         wndCtx = new EditorWndCtx(scene,
                                   inkCanv,
                                   palette,
                                   inkPalette,
                                   this,//surface window for focus fix
                                   topic.Id,
                                   topic.Discussion.Id);
         DataContext = this;
         rt.clienRt.SendInitialSceneLoadRequest(topic.Id);
     }
 }
예제 #14
0
        //used for coloring shapes in graphics editor after users
        public static Color UserIdToColor(int id)
        {
            if (id == -1)
            {
                return(Colors.AliceBlue);
            }
            Person p = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Id == id);

            if (p == null)
            {
                return(Colors.AliceBlue);
            }
            else
            {
                return(Utils.IntToColor(p.Color));
            }
        }
예제 #15
0
        LoginResult testLoginStub()
        {
            var loginRes = new LoginResult();

            loginRes.discussion = DbCtx.Get().Discussion.FirstOrDefault(d0 => d0.Subject.StartsWith("d-editor"));
            loginRes.person     = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Name.StartsWith("moder"));
            if (loginRes.person.Online)
            {
                loginRes.person = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Name == "usr");
            }
            if (loginRes.person.Online)
            {
                loginRes.person = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Name == "usr2");
            }

            return(loginRes);
        }
예제 #16
0
        public MainWindow()
        {
            InitializeComponent();

            //var loginInfo = LoginDriver.Run(LoginFlow.Regular);
            loginInfo = testLoginStub();

            if (loginInfo == null)
            {
                Application.Current.Shutdown();
                return;
            }

            palette._ownerId     = loginInfo.person.Id;
            inkPalette.InkCanvas = inkCanv;

            rt.start(loginInfo, DbCtx.Get().Connection.DataSource, DeviceType.Wpf);
            setListeners(true);
        }
예제 #17
0
        private void Submit_Click_1(object sender, RoutedEventArgs e)
        {
            foreach (var te in _timelineModel.Events)
            {
                DaoHelpers.recordEvent(te, _baseDateTime);
            }

            try
            {
                DbCtx.Get().SaveChanges();
            }
            catch (Exception e1)
            {
                MessageDlg.Show(e1.ToString(),
                                "Cannot submit events due to error: " + e1,
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            Close();
        }
예제 #18
0
        public static void recordEvent(TimelineEvent evt, DateTime startTime)
        {
            var _ctx = DbCtx.Get();

            var pers = _ctx.Person.FirstOrDefault(p0 => p0.Id == evt.userId);
            var disc = _ctx.Discussion.FirstOrDefault(d0 => d0.Id == evt.discussionId);

            if (disc == null)
            {
                return;
            }
            var topic = _ctx.Topic.FirstOrDefault(t0 => t0.Id == evt.topicId);

            var s = new StatsEvent();

            s.DiscussionId   = evt.discussionId;
            s.DiscussionName = disc.Subject;

            s.TopicId = evt.topicId;
            if (topic != null)
            {
                s.TopicName = topic.Name;
            }
            else
            {
                s.TopicName = "";
            }

            s.UserId     = evt.userId;
            s.UserName   = pers.Name;
            s.Event      = (int)evt.e;
            s.Time       = startTime.Add(evt.Span);
            s.DeviceType = (int)evt.devType;

            _ctx.AddToStatsEvent(s);
        }
예제 #19
0
        public EventViewModel(StEvent eventCode, int userId, DateTime stamp, DeviceType device)
        {
            dateTime = stamp.ToString();

            var usr = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Id == userId);

            if (usr != null)
            {
                userName  = usr.Name;
                userColor = new SolidColorBrush(Utils2.IntToColor(usr.Color));
            }
            else
            {
                userName  = "******";
                userColor = new SolidColorBrush(Colors.Aqua);
            }

            switch (eventCode)
            {
            case StEvent.RecordingStarted:
                evt = "enabled event recording";
                break;

            case StEvent.RecordingStopped:
                evt = "disabled event recording";
                break;

            case StEvent.BadgeCreated:
                evt = "created badge";
                break;

            case StEvent.BadgeEdited:
                evt = "edited badge";
                break;

            case StEvent.BadgeMoved:
                evt = "moved badge";
                break;

            case StEvent.BadgeZoomIn:
                evt = "zoomed in badge";
                break;

            case StEvent.ClusterCreated:
                evt = "created cluster";
                break;

            case StEvent.ClusterDeleted:
                evt = "deleted cluster";
                break;

            case StEvent.ClusterIn:
                evt = "cluster-in";
                break;

            case StEvent.ClusterOut:
                evt = "cluster-out";
                break;

            case StEvent.ClusterMoved:
                evt = "moved cluster";
                break;

            case StEvent.ClusterTitleAdded:
                evt = "cluster title added";
                break;

            case StEvent.ClusterTitleRemoved:
                evt = "cluster title removed";
                break;

            case StEvent.ClusterTitleEdited:
                evt = "cluster title edited";
                break;

            case StEvent.LinkCreated:
                evt = "created link";
                break;

            case StEvent.LinkRemoved:
                evt = "removed link";
                break;

            case StEvent.FreeDrawingCreated:
                evt = "created free drawing";
                break;

            case StEvent.FreeDrawingRemoved:
                evt = "removed free drawing";
                break;

            case StEvent.FreeDrawingResize:
                evt = "resized free drawing";
                break;

            case StEvent.FreeDrawingMoved:
                evt = "moved free drawing";
                break;

            case StEvent.SceneZoomedIn:
                evt = "zoomed in scene";
                break;

            case StEvent.SceneZoomedOut:
                evt = "zoomed out scene";
                break;

            case StEvent.ArgPointTopicChanged:
                evt = "point transfer";
                break;

            case StEvent.SourceAdded:
                evt = "added source";
                break;

            case StEvent.SourceRemoved:
                evt = "removed source";
                break;

            case StEvent.ImageAdded:
                evt = "added image file";
                break;

            case StEvent.ImageUrlAdded:
                evt = "added link to image";
                break;

            case StEvent.PdfAdded:
                evt = "added PDF";
                break;

            case StEvent.PdfUrlAdded:
                evt = "added link to PDF";
                break;

            case StEvent.YoutubeAdded:
                evt = "added Youtube video";
                break;

            case StEvent.ScreenshotAdded:
                evt = "added screenshot";
                break;

            case StEvent.MediaRemoved:
                evt = "removed media";
                break;

            case StEvent.CommentAdded:
                evt = "added comment";
                break;

            case StEvent.CommentRemoved:
                evt = "removed comment";
                break;

            case StEvent.ImageOpened:
                evt = "opened image";
                break;

            case StEvent.VideoOpened:
                evt = "opened video";
                break;

            case StEvent.ScreenshotOpened:
                evt = "opened screenshot";
                break;

            case StEvent.PdfOpened:
                evt = "opened PDF";
                break;

            case StEvent.SourceOpened:
                evt = "opened source";
                break;

            case StEvent.LaserEnabled:
                evt = "laser enabled";
                break;

            default:
                throw new NotSupportedException();
            }

            switch (device)
            {
            case DeviceType.Android:
                devType = "App";
                break;

            case DeviceType.Wpf:
                devType = "Windows";
                break;

            case DeviceType.Sticky:
                devType = "Sticky";
                break;

            default:
                throw new NotSupportedException();
            }
        }
예제 #20
0
 public void RecontextBadge()
 {
     _badge.DataContext = null;
     _badge.DataContext = DbCtx.Get().ArgPoint.FirstOrDefault(ap => ap.Id == _argPtId);
 }
예제 #21
0
        void OnDismiss(ArgPoint ap)
        {
            //Console.Beep();

            CommentDismissalRecognizer.pushDismissal(ap, DbCtx.Get());
        }
예제 #22
0
        //if given seat was not used in current session, and user takes the seat, new user is created in DB.
        //if user takes seat that was used in this session, then no new user is created. instead, the user
        //is recognized as the same user who took the seat in current session, though during second login user
        //enters name again (effectively changing name)
        private static Person RegisterOrLogin(string name, Discussion discussion, Session session, Seat seat)
        {
            //was the seat taken by some user?
            var sessionId = session.Id;
            var seatId    = seat.Id;

            DbCtx.DropContext();
            var outrunnerPerson =
                DbCtx.Get().Person.FirstOrDefault(p0 => p0.Session != null && p0.Session.Id == sessionId &&
                                                  p0.Seat != null && p0.Seat.Id == seatId);

            //the user already took the place, just change name
            if (outrunnerPerson != null)
            {
                outrunnerPerson.Name = name;

                //do we need general side ?
                var ctx             = DbCtx.Get();
                var previousGenSide = ctx.GeneralSide.FirstOrDefault(gs0 => gs0.Discussion.Id == discussion.Id &&
                                                                     gs0.Person.Id == outrunnerPerson.Id);
                if (previousGenSide == null)
                {
                    //the person takes part in this discussion first time, create general
                    //side of the person in this discussion
                    var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id);
                    outrunnerPerson.GeneralSide.Add(
                        CreateGeneralSide(
                            outrunnerPerson,
                            disc,
                            (int)SideCode.Neutral
                            )
                        );

                    //assign person to all topics of selected discussion
                    foreach (var topic in disc.Topic)
                    {
                        outrunnerPerson.Topic.Add(topic);
                    }
                }

                DbCtx.Get().SaveChanges();

                return(outrunnerPerson);
            }
            else
            {
                //seat was not used in this session, create new user
                var ctx = DbCtx.Get();
                var p   = new Person();
                p.Name    = name;
                p.Session = ctx.Session.FirstOrDefault(s0 => s0.Id == session.Id);
                p.Seat    = ctx.Seat.FirstOrDefault(s0 => s0.Id == seat.Id);

                var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id);
                p.GeneralSide.Add(CreateGeneralSide(p, disc, (int)SideCode.Neutral));

                //person inherits color of seat
                p.Color = p.Seat.Color;

                p.Email = "no-email";

                //assign person to all topics of selected discussion
                foreach (var topic in disc.Topic)
                {
                    p.Topic.Add(topic);
                }

                ctx.AddToPerson(p);
                DbCtx.Get().SaveChanges();
                return(p);
            }
        }