コード例 #1
0
ファイル: SessionInfo.cs プロジェクト: z-saffarpour/duscusys
        //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);
        }
コード例 #2
0
ファイル: DaoUtils.cs プロジェクト: z-saffarpour/duscusys
        public static ArgPoint NewPoint(Topic t, int orderNumber)
        {
            if (t == null)
            {
                return(null);
            }

            //create new point
            ArgPoint pt = new ArgPoint();

            pt.Point = "Your title here/タイトル";
            pt.RecentlyEnteredSource   = "Your web url link here/URLリンク";
            pt.RecentlyEnteredMediaUrl = "Your media link here/画像URLリンク";
            DaoUtils.EnsurePtDescriptionExists(pt);

            pt.Description.Text = NEW_DESCRIPTION;
            pt.Topic            = PrivateCenterCtx.Get().Topic.FirstOrDefault(t0 => t0.Id == t.Id);
            int selfId = SessionInfo.Get().person.Id;
            var pers   = PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == selfId);

            pt.Person         = pers;
            pt.SharedToPublic = true;
            pt.SideCode       = DaoUtils.GetGeneralSide(SessionInfo.Get().person,
                                                        SessionInfo.Get().discussion);
            pt.OrderNumber = orderNumber;

            return(pt);
        }
コード例 #3
0
        //publish/unpublish
        private void SurfaceCheckBox_Click(object sender, RoutedEventArgs e)
        {
            ArgPoint ap = (((SurfaceCheckBox)sender).DataContext) as ArgPoint;

            if (ap == null)
            {
                return;
            }

            Topic    t;
            ArgPoint ap1;

            getPointAndTopic(out ap1, out t);
            if (t == null)
            {
                return;
            }

            if (((SurfaceCheckBox)sender).IsChecked.Value)
            {
                ap.SharedToPublic = true;
            }
            else
            {
                if (PrivateCenterCtx.Get().ObjectStateManager.GetObjectStateEntry(ap).State == EntityState.Modified ||
                    PrivateCenterCtx.Get().ObjectStateManager.GetObjectStateEntry(ap).State == EntityState.Unchanged)
                {
                    PrivateCenterCtx.Get().Refresh(RefreshMode.StoreWins, ap);
                    DaoUtils.UnpublishPoint(ap);
                }
            }

            saveProcedure(null, -1);
        }
コード例 #4
0
        private void removeMedia_Click(object sender, RoutedEventArgs e)
        {
            var at = ((ContentControl)sender).DataContext as Attachment;
            var ap = DataContext as ArgPoint;

            ap.Attachment.Remove(at);

            var mediaData = at.MediaData;

            at.MediaData = null;
            ap.RecentlyEnteredMediaUrl = "";
            if (mediaData != null)
            {
                PrivateCenterCtx.Get().DeleteObject(mediaData);
            }
            PrivateCenterCtx.Get().DeleteObject(at);

            ap.ChangesPending = true;
            UISharedRTClient.Instance.clienRt.SendStatsEvent(
                StEvent.MediaRemoved,
                ap.Person.Id,
                ap.Topic.Discussion.Id,
                ap.Topic.Id,
                DeviceType.Wpf);
            UpdateOrderedMedia();
            BeginAttachmentNumberInjection();
        }
コード例 #5
0
 private void ForgetDBDiscussionState()
 {
     //forget cached state
     PrivateCenterCtx.DropContext();
     TimingCtx.Drop();
     //////////////////////
 }
コード例 #6
0
        public PrivateCenter3(UISharedRTClient sharedClient, Main.OnDiscFrmClosing closing)
        {
            InitializeComponent();

            _closing      = closing;
            _sharedClient = sharedClient;

            theBadge.Hide();

            PrivateCenterCtx.DropContext();
            TimingCtx.Drop();

            SetListeners(true);

            Title2 = string.Format("{0} on {1} - private dashboard",
                                   SessionInfo.Get().person.Name,
                                   SessionInfo.Get().discussion.Subject);

            lstTopics.ItemsSource            = TopicsOfDiscussion;
            lstPoints.ItemsSource            = OwnArgPoints;
            lstOtherUsers.ItemsSource        = OtherUsers;
            lstBadgesOfOtherUser.ItemsSource = ArgPointsOfOtherUser;

            lblWelcome.Content = SessionInfo.Get().person.Name;

            _commentDismissalRecognizer         = new CommentDismissalRecognizer(bigBadgeScroller, OnDismiss);
            theBadge.CommentDismissalRecognizer = _commentDismissalRecognizer;

            initializing = true;
            DiscussionSelectionChanged();
            initializing = false;
        }
コード例 #7
0
        private void LoginProcedures()
        {
            DaoUtils.EnsureModerExists();

            LoginResult login = SessionInfo.Get().ExperimentMode
                                    ? LoginDriver.Run(LoginFlow.ForExperiment)
                                    : LoginDriver.Run(LoginFlow.Regular);

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

            if (login.session != null && login.discussion != null)
            {
                lblSessionInfo.Content = SessionStr(login.session, login.discussion);
            }
            else
            {
                lblSessionInfo.Content = "";
            }

            SessionInfo.Get().discussion = login.discussion;
            SessionInfo.Get().setPerson(login.person);

            _discWindows.mainWnd = this;

            avatar.DataContext = login.person;

            //start rt client
            sharedClient.start(login, PrivateCenterCtx.Get().Connection.DataSource, DeviceType.Wpf);

            SetListeners(sharedClient, true);
        }
コード例 #8
0
ファイル: CopyDlg.xaml.cs プロジェクト: z-saffarpour/duscusys
        private void btnConfirm_Click_1(object sender, RoutedEventArgs e)
        {
            var dstTopic = lstDstTopics.SelectedItem as Topic;

            if (dstTopic == null)
            {
                MessageDlg.Show("Target topic not selected");
                return;
            }

            BusyWndSingleton.Show("Copying points...");
            try
            {
                var ownId  = SessionInfo.Get().person.Id;
                var discId = SessionInfo.Get().discussion.Id;
                foreach (var ap in dstPoints)
                {
                    copyArgPointTo(ap, dstTopic);
                }

                PrivateCenterCtx.SaveChangesIgnoreConflicts();

                _sharedClient.clienRt.SendNotifyStructureChanged(dstTopic.Id, ownId, DeviceType.Wpf);
                var srcTopic = lstSrcTopics.SelectedItem as Topic;
                _sharedClient.clienRt.SendStatsEvent(StEvent.ArgPointTopicChanged, ownId, discId, srcTopic.Id,
                                                     DeviceType.Wpf); //src
                _sharedClient.clienRt.SendStatsEvent(StEvent.ArgPointTopicChanged, ownId, discId, dstTopic.Id,
                                                     DeviceType.Wpf); //dst
            }
            finally
            {
                BusyWndSingleton.Hide();
            }
        }
コード例 #9
0
ファイル: CopyDlg.xaml.cs プロジェクト: z-saffarpour/duscusys
        public CopyDlg(UISharedRTClient sharedClient, int topicToSelect)
        {
            InitializeComponent();

            _sharedClient = sharedClient;

            var dId  = SessionInfo.Get().discussion.Id;
            var disc = PrivateCenterCtx.Get().Discussion.FirstOrDefault(d0 => d0.Id == dId);

            var topics = disc.Topic;

            srcTopics = new ObservableCollection <Topic>(topics);
            dstTopics = new ObservableCollection <Topic>(topics);

            srcPoints = new ObservableCollection <ArgPoint>();
            dstPoints = new ObservableCollection <ArgPoint>();

            DataContext = this;

            //select topic that was selected in main board
            var selectedTopic = disc.Topic.FirstOrDefault(t0 => t0.Id == topicToSelect);

            lstSrcTopics.SelectedItem = selectedTopic;
            updateSrcPoints(selectedTopic);

            if (dstTopics.Count > 0)
            {
                lstDstTopics.SelectedIndex = 0;
            }
        }
コード例 #10
0
        //returns back recently deleted point (own), if there is one and its topic still exists
        private void TryUndo()
        {
            if (recentlyDeleted == null)
            {
                Console.Beep();
                return;
            }

            var np = DaoUtils.clonePoint(PrivateCenterCtx.Get(),
                                         recentlyDeleted.point,
                                         recentlyDeleted.topic,
                                         recentlyDeleted.person,
                                         recentlyDeleted.point.Point);

            DaoUtils.DeleteArgPoint(PrivateCenterCtx.Get(), recentlyDeleted.point);
            recentlyDeleted = null;
            if (np == null)
            {
                return;
            }

            lstTopics.SelectedItem = null;
            lstTopics.SelectedItem = np.Topic;
            lstPoints.SelectedItem = new ArgPointExt(np);

            saveProcedure(null, -1);
        }
コード例 #11
0
        private void btnAttachScreenshot_Click_1(object sender, RoutedEventArgs e)
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            var screenshotWnd = new ScreenshotCaptureWnd((System.Drawing.Bitmap b) =>
            {
                var attach = AttachmentManager.AttachScreenshot(ap, b);
                if (attach != null)
                {
                    var seldId    = SessionInfo.Get().person.Id;
                    attach.Person = PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == seldId);

                    ap.ChangesPending = true;
                    UISharedRTClient.Instance.clienRt.SendStatsEvent(
                        StEvent.ScreenshotAdded,
                        ap.Person.Id,
                        ap.Topic.Discussion.Id,
                        ap.Topic.Id,
                        DeviceType.Wpf);

                    UpdateOrderedMedia();
                    BeginAttachmentNumberInjection();
                }
            });

            screenshotWnd.ShowDialog();
        }
コード例 #12
0
        //returns lists of IDs of those of own points, which have been changed (added, removed, edited)
        private void GetChangeLists(out List <ArgPoint> created, out List <ArgPoint> edited, out List <ArgPoint> deleted)
        {
            created = new List <ArgPoint>();
            edited  = new List <ArgPoint>();
            deleted = new List <ArgPoint>();

            var ctx = PrivateCenterCtx.Get();

            foreach (var ap in OwnArgPoints)
            {
                //if point is unnatached (removed in UI but preserved for UNDO),
                //for this method it's removed
                if (ap.Ap.Person == null || ap.Ap.Topic == null)
                {
                    deleted.Add(ap.Ap);
                    continue;
                }

                switch (ctx.ObjectStateManager.GetObjectStateEntry(ap.Ap).State)
                {
                case EntityState.Added:
                    created.Add(ap.Ap);
                    break;

                case EntityState.Deleted:
                    deleted.Add(ap.Ap);
                    break;

                case EntityState.Modified:
                    edited.Add(ap.Ap);
                    break;
                }
            }

            foreach (var ap in ArgPointsOfOtherUser)
            {
                //if point is unnatached (removed in UI but preserved for UNDO),
                //for this method it's removed
                if (ap.Ap.Person == null || ap.Ap.Topic == null)
                {
                    deleted.Add(ap.Ap);
                    continue;
                }

                switch (ctx.ObjectStateManager.GetObjectStateEntry(ap.Ap).State)
                {
                case EntityState.Added:
                    created.Add(ap.Ap);
                    break;

                case EntityState.Deleted:
                    deleted.Add(ap.Ap);
                    break;

                case EntityState.Modified:
                    edited.Add(ap.Ap);
                    break;
                }
            }
        }
コード例 #13
0
        private static Person getFreshCurrentPerson()
        {
            var p = SessionInfo.Get().person;

            if (p == null)
            {
                return(null);
            }

            return(PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == p.Id));
        }
コード例 #14
0
        private void onStructChanged(int activeTopic, int initiaterId, DeviceType devType)
        {
            if (initiaterId == SessionInfo.Get().person.Id&& devType == DeviceType.Wpf)
            {
                return;
            }

            BusyWndSingleton.Show("Fetching changes...");
            try
            {
                //save selected topic
                int topicUnderSelectionId = -1;
                var sel = lstTopics.SelectedItem as Topic;
                if (sel != null)
                {
                    topicUnderSelectionId = sel.Id;
                }

                //save selected list of points
                var selectedAp = theBadge.DataContext as ArgPoint;

                ForgetDBDiscussionState();
                DiscussionSelectionChanged();

                //select previously selected topic
                if (topicUnderSelectionId != -1)
                {
                    lstTopics.SelectedItem = PrivateCenterCtx.Get().Topic.FirstOrDefault(t0 => t0.Id == topicUnderSelectionId);
                }

                //select previously selected point
                if (selectedAp != null)
                {
                    //own list
                    if (selectedAp.Person.Id == SessionInfo.Get().person.Id)
                    {
                        lstPoints.SelectedItem = null;
                        lstPoints.SelectedItem = OwnArgPoints.FirstOrDefault(ap0 => ap0.Ap.Id == selectedAp.Id);
                    }
                    else
                    {
                        lstOtherUsers.SelectedItem = OtherUsers.FirstOrDefault(u0 => u0.Pers.Id == selectedAp.Person.Id);

                        lstBadgesOfOtherUser.SelectedItem =
                            ArgPointsOfOtherUser.FirstOrDefault(ap0 => ap0.Ap.Id == selectedAp.Id);
                    }
                }
            }
            finally
            {
                BusyWndSingleton.Hide();
            }
        }
コード例 #15
0
ファイル: CopyDlg.xaml.cs プロジェクト: z-saffarpour/duscusys
        private void copyArgPointTo(ArgPoint ap, Topic t)
        {
            var pointCopy = DaoUtils.clonePoint(PrivateCenterCtx.Get(),
                                                ap,
                                                t,
                                                SessionInfo.Get().person,
                                                ap.Point + "_Copy");

            operationPerformed = true;

            Close();
        }
コード例 #16
0
        void HandleRecontext()
        {
            var ap = DataContext as ArgPoint;

            SetStyle();

            if (DataContext == null)
            {
                Opacity = 0;
            }
            else
            {
                Opacity = 1;
            }

            //Drawing.HandleRecontext();

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

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

            if (ap != null)
            {
                UpdateLocalReadCounts(PrivateCenterCtx.Get(), ap);
                UpdateRemoteReadCounts(PrivateCenterCtx.Get(), ap);
                new CommentNotificationDeferral(Dispatcher, PrivateCenterCtx.Get(), lstBxComments);
            }

            if (ap != null)
            {
                DaoUtils.RemoveDuplicateComments(ap);
            }

            if (CommentDismissalRecognizer != null)
            {
                CommentDismissalRecognizer.Reset(DataContext as ArgPoint);
                CommentDismissalRecognizer.CheckScrollState();
            }
        }
コード例 #17
0
        private void LogoutProcedures()
        {
            if (sharedClient.clienRt != null)
            {
                sharedClient.clienRt.SendLiveRequest();
            }

            SetListeners(sharedClient, false);

            _discWindows.CloseAndDispose();

            SessionInfo.Reset();
            PublicBoardCtx.DropContext();
            PrivateCenterCtx.DropContext();
        }
コード例 #18
0
        private void UpdateBadgesOfOtherUser(int personId, int topicId)
        {
            ArgPointsOfOtherUser.Clear();

            var q = from ap in PrivateCenterCtx.Get().ArgPoint
                    where ap.Person.Id == personId &&
                    ap.Topic.Id == topicId
                    select ap;

            foreach (var ap in q)
            {
                ArgPointsOfOtherUser.Add(new ArgPointExt(ap));
            }

            if (_otherUserSelectedManually && ArgPointsOfOtherUser.Count > 0)
            {
                theBadge.RemoveFocusFromInputControls();
                theBadge.DataContext = ArgPointsOfOtherUser.First().Ap;
            }

            UpdateLocalUnreadCountsOfOtherUser(TimingCtx.GetFresh());
        }
コード例 #19
0
        public void btnRemoveComment_Click(object sender, RoutedEventArgs e)
        {
            var c = DataContext as Comment;

            if (c == null)
            {
                return;
            }

            var ap = c.ArgPoint;

            c.ArgPoint        = null;
            c.Person          = null;
            ap.ChangesPending = true;
            //RaiseCommentEditLockChanged(false);
            RaiseCommentRemoved(c);

            try
            {
                foreach (var commentPersonReadEntry in c.ReadEntry.ToArray())
                {
                    PrivateCenterCtx.Get().DeleteObject(commentPersonReadEntry);
                }
                PrivateCenterCtx.Get().Comment.DeleteObject(c);
            }
            catch
            {
                //doesn't exist in content
            }

            ap.ChangesPending = true;
            UISharedRTClient.Instance.clienRt.SendStatsEvent(
                StEvent.CommentRemoved,
                ap.Person.Id,
                ap.Topic.Discussion.Id,
                ap.Topic.Id,
                DeviceType.Wpf);
        }
コード例 #20
0
        private void UpdateOtherUsers(int discussionId, int ownId)
        {
            OtherUsers.Clear();

            var q = from p in PrivateCenterCtx.Get().Person
                    where p.Topic.Any(t0 => t0.Discussion.Id == discussionId) && !p.Name.StartsWith(DaoUtils.MODER_SUBNAME) &&
                    p.Id != ownId
                    select p;

            foreach (var p in q)
            {
                OtherUsers.Add(new PersonExt(p));
            }

            if (OtherUsers.Count > 0)
            {
                _otherUserSelectedManually  = false;
                lstOtherUsers.SelectedIndex = 0;
                _otherUserSelectedManually  = true;

                UpdateOtherUsersDots(PrivateCenterCtx.Get());
            }
        }
コード例 #21
0
        //we can only process one deleted point at a time
        private void saveProcedure(ArgPoint deletedPt, int TopicOfDeletedPointId)
        {
            //extract modification lists
            List <ArgPoint> created = null;
            List <ArgPoint> edited  = null;
            List <ArgPoint> deleted = null;

            GetChangeLists(out created, out edited, out deleted);

            Topic    t;
            ArgPoint editedPoint;

            getPointAndTopic(out editedPoint, out t);

            //save changes
            PrivateCenterCtx.SaveChangesIgnoreConflicts();

            //first notify about deleted point!
            if (deletedPt != null)
            {
                _sharedClient.clienRt.SendArgPointDeleted(deletedPt.Id, TopicOfDeletedPointId,
                                                          SessionInfo.Get().person.Id);
            }

            //notify about changes
            foreach (var createdPt in created)
            {
                _sharedClient.clienRt.SendArgPointCreated(createdPt.Id, createdPt.Topic.Id,
                                                          SessionInfo.Get().person.Id);
            }

            foreach (var editedPt in edited)
            {
                _sharedClient.clienRt.SendArgPointChanged(editedPt.Id, editedPt.Topic.Id,
                                                          SessionInfo.Get().person.Id);
            }
        }
コード例 #22
0
        private Discussion selectedDiscussion()
        {
            int currentDiscId = SessionInfo.Get().discussion.Id;

            return(PrivateCenterCtx.Get().Discussion.FirstOrDefault(d0 => d0.Id == currentDiscId));
        }
コード例 #23
0
        void OnDismiss(ArgPoint ap)
        {
            //Console.Beep();

            CommentDismissalRecognizer.pushDismissal(ap, PrivateCenterCtx.Get());
        }
コード例 #24
0
        private void onStorageWndClosed(object sender, EventArgs e)
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (_storageWnd == null)
            {
                return;
            }

            if (_storageWnd.filesToAttach != null)
            {
                foreach (StorageSelectionEntry entry in _storageWnd.filesToAttach)
                {
                    try
                    {
                        var attach = AttachmentManager.AttachCloudEntry(ap, entry);
                        var seldId = SessionInfo.Get().person.Id;
                        attach.Person = PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == seldId);

                        ap.ChangesPending = true;

                        var ev = StEvent.ArgPointTopicChanged;
                        switch ((AttachmentFormat)attach.Format)
                        {
                        case AttachmentFormat.Bmp:
                        case AttachmentFormat.Jpg:
                        case AttachmentFormat.Png:
                            ev = StEvent.ImageAdded;
                            break;

                        case AttachmentFormat.Pdf:
                            ev = StEvent.PdfAdded;
                            break;
                        }
                        if (ev != StEvent.ArgPointTopicChanged)
                        {
                            UISharedRTClient.Instance.clienRt.SendStatsEvent(
                                ev,
                                ap.Person.Id,
                                ap.Topic.Discussion.Id,
                                ap.Topic.Id,
                                DeviceType.Wpf);
                        }
                    }
                    catch (Discussions.AttachmentManager.IncorrectAttachmentFormat)
                    {
                    }
                }

                UpdateOrderedMedia();
                BeginAttachmentNumberInjection();
            }

            _storageWnd.fileViewCallback -= onCloudViewerRequest;
            _storageWnd.Closed           -= onStorageWndClosed;
            _storageWnd = null;
        }
コード例 #25
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Main()
        {
            InitializeComponent();

            //special case of screenshot mode
            if (SessionInfo.Get().ScreenshotMode)
            {
                var discId = SessionInfo.Get().screenDiscId;
                PrivateCenterCtx.sharedClient = sharedClient;
                PublicBoardCtx.sharedClient   = sharedClient;
                SessionInfo.Get().discussion = PrivateCenterCtx.Get().Discussion.FirstOrDefault(d => d.Id == discId);
                SessionInfo.Get().setPerson(PrivateCenterCtx.Get().Person.FirstOrDefault(p => p.Name == "moderator"));
                var loginRes = new LoginResult();
                loginRes.devType    = DeviceType.Wpf;
                loginRes.discussion = SessionInfo.Get().discussion;
                loginRes.person     = SessionInfo.Get().person;
                sharedClient.start(loginRes, PrivateCenterCtx.Get().Connection.DataSource, DeviceType.Wpf);

                this.Hide();

                sharedClient.clienRt.onJoin += () =>
                {
                    PublicCenter pubCenter = new PublicCenter(UISharedRTClient.Instance,
                                                              () => { },
                                                              SessionInfo.Get().screenTopicId,
                                                              SessionInfo.Get().screenDiscId
                                                              );

                    pubCenter.Show();
                    pubCenter.Hide();

                    Task <PublicCenter.ScreenshoReports> t = pubCenter.FinalSceneScreenshots();
                    t.GetAwaiter().OnCompleted(() =>
                    {
                        pubCenter.Close();
                        pubCenter = null;

                        var reports = t.Result;
                        Utils.ScreenshotPackToMetaInfo(reports, SessionInfo.Get().screenMetaInfo);
                        Application.Current.Shutdown();
                    });
                };
                return;
            }

            lblVersion.Content = Utils2.VersionString();

            DataContext = this;

            PrivateCenterCtx.sharedClient = sharedClient;
            PublicBoardCtx.sharedClient   = sharedClient;

            avatar.pointDown = AvatarPointDown;

            foreach (EventViewModel evm in DaoUtils.GetRecentEvents())
            {
                RecentEvents.Insert(0, evm);
            }

            LoginProcedures();

            lstBxPlayers.ItemsSource = UsersStatus;
        }