Ejemplo n.º 1
0
        private void dEditorReportResponse(DEditorStatsResponse stats)
        {
            //process
            var topic = _ctx.Topic.FirstOrDefault(t0 => t0.Id == stats.TopicId);

            int numSrc;
            int numComments;
            int numImages;
            int numScreenshots;
            int numPdfs;
            int numYoutubes;

            ArgPointTotalsOverTopic(_reportParams, topic, out numSrc, out numComments,
                                    out numImages, out numPdfs, out numScreenshots, out numYoutubes);

            _allTopicsReport.numClusters        += stats.NumClusters;
            _allTopicsReport.numClusteredBadges += stats.NumClusteredBadges;
            _allTopicsReport.numLinks           += stats.NumLinks;
            _allTopicsReport.numSources         += numSrc;
            _allTopicsReport.numComments        += numComments;
            _allTopicsReport.numImages          += numImages;
            _allTopicsReport.numPDFs            += numPdfs;
            _allTopicsReport.numYoutubes        += numYoutubes;
            _allTopicsReport.numScreenshots     += numScreenshots;
            _allTopicsReport.cumulativeDuration += topic.CumulativeDuration;
            var numArgPoints = topic.ArgPoint.Count();

            _allTopicsReport.numPoints += numArgPoints;
            var numPointsWithDescription = topic.ArgPoint.Where(ap0 => ap0.Description != null && ap0.Description.Text != "Description").Count();

            _allTopicsReport.numPointsWithDescription += numPointsWithDescription;
            //num media
            var nMedia = 0;

            foreach (var ap in topic.ArgPoint)
            {
                nMedia += ap.Attachment.Count();
            }
            _allTopicsReport.numMediaAttachments += nMedia;

            var report = new TopicReport(topic, stats.NumClusters, stats.NumClusteredBadges,
                                         stats.NumLinks, numSrc, numComments,
                                         topic.CumulativeDuration, stats.ListOfClusterIds,
                                         stats.ListOfLinkIds, numArgPoints,
                                         numPointsWithDescription, nMedia,
                                         numImages, numPdfs, numScreenshots, numYoutubes);

            _topicReports.Add(report);
            if (_topicReportReady != null)
            {
                _topicReportReady(report);
            }

            if (++_nProcessedTopics >= topics.Count())
            {
                _clientRT.dEditorReportResponse -= dEditorReportResponse;

                //all topics processed, request clusters
                bool hasClusters = false;
                bool hasLinks    = false;
                foreach (var topicReport in _topicReports)
                {
                    foreach (var clustId in topicReport.clusterIds)
                    {
                        _clientRT.SendClusterStatsRequest(clustId, topicReport.topic.Id);
                        hasClusters = true;
                    }
                    foreach (var linkId in topicReport.linkIds)
                    {
                        _clientRT.SendLinkStatsRequest(linkId, topicReport.topic.Id);
                        hasLinks = true;
                    }
                }
                if (!hasClusters && !hasLinks)
                {
                    finalizeReport();
                }
            }
            //else
            //{
            //    UISharedRTClient.Instance.clienRt.SendDEditorRequest(topics[nextTopicIdx++].Id);
            //}
        }
Ejemplo n.º 2
0
        public void OnEvent(EventData eventData)
        {
            switch (eventData.Code)
            {
            case (byte)LiteEventCode.Join:
                int[] actNrs   = (int[])eventData.Parameters[(byte)ParameterKey.Actors];
                int   ActorNr  = (int)eventData.Parameters[(byte)ParameterKey.ActorNr];
                var   actProps = (Hashtable)eventData.Parameters[(byte)ParameterKey.ActorProperties];

                Console.WriteLine("Join event actors.len={0}", actNrs.Length);
                List <int> unknownPeersNrs = new List <int>();
                for (int i = 0; i < actNrs.Length; i++)
                {
                    if (!usersOnline.ContainsKey(actNrs[i]))
                    {
                        if (!unknownPeersNrs.Contains(actNrs[i]))
                        {
                            unknownPeersNrs.Add(actNrs[i]);
                        }
                    }
                }
                requestPeersInfo(unknownPeersNrs.ToArray());
                DbgPrintOnlineList();
                break;

            case (byte)EventCode.Leave:
                actNrs = (int[])eventData.Parameters[(byte)ParameterKey.Actors];
                int leftActNr = (int)eventData.Parameters[(byte)ParameterKey.ActorNr];
                Console.WriteLine("Leave event, actors.len={0}", actNrs.Length);
                if (usersOnline.ContainsKey(leftActNr))
                {
                    if (userLeaves != null)
                    {
                        DiscUser leaving = usersOnline[leftActNr];
                        userLeaves(leaving);
                    }
                    usersOnline.Remove(leftActNr);
                }
                DbgPrintOnlineList();
                break;

            case (byte)DiscussionEventCode.InstantUserPlusMinus:
                if (smbdLeaved != null)
                {
                    smbdLeaved();
                }
                break;

            case (byte)DiscussionEventCode.StructureChanged:
                int initiater = (int)eventData.Parameters[(byte)DiscussionParamKey.UserId];
                int devType   = (int)eventData.Parameters[(byte)DiscussionParamKey.DeviceType];
                if (eventData.Parameters.ContainsKey((byte)DiscussionParamKey.ForceSelfNotification))
                {
                    //topic updated
                    if (onStructChanged != null)
                    {
                        onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters),
                                        initiater, (DeviceType)devType);
                    }
                }
                else if (initiater != -1 && initiater != localUsr.ActNr)
                {
                    if (onStructChanged != null)
                    {
                        onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters),
                                        initiater, (DeviceType)devType);
                    }
                }
                break;

            case (byte)DiscussionEventCode.ArgPointChanged:
                var changeType = PointChangedType.Modified;
                int topicId;
                int personId;
                int argPointId = Serializers.ReadChangedArgPoint(eventData.Parameters, out changeType, out topicId, out personId);
                if (argPointChanged != null)
                {
                    argPointChanged(argPointId, topicId, changeType, personId);
                }
                break;

            case (byte)DiscussionEventCode.UserAccPlusMinus:
                if (userAccPlusMinus != null)
                {
                    userAccPlusMinus();
                }
                break;

            case (byte)DiscussionEventCode.StatsEvent:
                if (onStatsEvent != null)
                {
                    StEvent    e;
                    int        userId       = -1;
                    int        discussionId = -1;
                    int        statsTopicId = -1;
                    DeviceType devTyp;
                    Serializers.ReadStatEventParams(eventData.Parameters, out e, out userId, out discussionId,
                                                    out statsTopicId, out devTyp);
                    onStatsEvent(e, userId, discussionId, statsTopicId, devTyp);
                }
                break;

            case (byte)DiscussionEventCode.CursorEvent:
                if (cursorEvent != null)
                {
                    cursorEvent(CursorEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.CreateShapeEvent:
                if (createShapeEvent != null)
                {
                    createShapeEvent(CreateShape.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.UnselectAllEvent:
                if (unselectAll != null)
                {
                    unselectAll(UnselectAllEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.DeleteSingleShapeEvent:
                if (deleteSingleShape != null)
                {
                    deleteSingleShape(DeleteSingleShapeEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ApplyPointEvent:
                if (applyPoint != null)
                {
                    applyPoint(PointMove.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.StateSyncEvent:
                if (syncStateEvent != null)
                {
                    syncStateEvent(ShapeState.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.LinkCreateEvent:
                if (onLinkCreateEvent != null)
                {
                    onLinkCreateEvent(LinkCreateMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.UnclusterBadgeEvent:
                if (onUnclusterBadgeEvent != null)
                {
                    onUnclusterBadgeEvent(UnclusterBadgeMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ClusterBadgeEvent:
                if (onClusterBadgeEvent != null)
                {
                    onClusterBadgeEvent(ClusterBadgeMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.InkEvent:
                if (inkEvent != null)
                {
                    inkEvent(InkMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.SceneLoadingDone:
                if (loadingDoneEvent != null)
                {
                    loadingDoneEvent();
                }
                break;

            case (byte)DiscussionEventCode.DEditorReportEvent:
                if (dEditorReportResponse != null)
                {
                    dEditorReportResponse(DEditorStatsResponse.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ClusterStatsEvent:
                if (clusterStatsResponse != null)
                {
                    if (eventData.Parameters == null || eventData.Parameters.Count() == 0)
                    {
                        clusterStatsResponse(default(ClusterStatsResponse), false);
                    }
                    else
                    {
                        clusterStatsResponse(ClusterStatsResponse.Read(eventData.Parameters), true);
                    }
                }
                break;

            case (byte)DiscussionEventCode.LinkStatsEvent:
                if (linkStatsResponseEvent != null)
                {
                    if (eventData.Parameters == null || eventData.Parameters.Count() == 0)
                    {
                        linkStatsResponseEvent(default(LinkReportResponse), false);
                    }
                    else
                    {
                        linkStatsResponseEvent(LinkReportResponse.Read(eventData.Parameters), true);
                    }
                }
                break;

            case (byte)DiscussionEventCode.BadgeViewEvent:
                if (onBadgeViewRequest != null)
                {
                    onBadgeViewRequest(BadgeViewMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.SourceViewEvent:
                if (onSourceViewRequest != null)
                {
                    onSourceViewRequest(ExplanationModeSyncMsg.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.CommentReadEvent:
                if (onCommentRead != null)
                {
                    onCommentRead(CommentsReadEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.AttachLaserPointerEvent:
                if (onAttachLaserPointer != null)
                {
                    onAttachLaserPointer(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.DetachLaserPointerEvent:
                if (onDetachLaserPointer != null)
                {
                    onDetachLaserPointer(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.LaserPointerMovedEvent:
                if (onLaserPointerMoved != null)
                {
                    onLaserPointerMoved(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ImageViewerManipulatedEvent:
                if (onImageViewerManipulated != null)
                {
                    onImageViewerManipulated(ImageViewerMatrix.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.BrowserScrollChangedEvent:
                if (onBrowserScroll != null)
                {
                    onBrowserScroll(BrowserScrollPosition.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.PdfScrollChangedEvent:
                if (onPdfScroll != null)
                {
                    onPdfScroll(PdfScrollPosition.Read(eventData.Parameters));
                }
                break;

            default:
                Console.WriteLine("Unhandled event " + eventData.Code);
                break;
            }
        }