Ejemplo n.º 1
0
 void _messageCommunication_ConnectionStateChangedEvent(object sender, EventArgs e)
 {
     if (IsHandleCreated && !IsDisposed)
     {
         this.BeginInvoke(new MethodInvoker(delegate()
         {
             if (_messageCommunication.IsConnected)
             {
                 labelConnected.Text = "Connected";
                 try
                 {
                     // Ask for current state of all Items
                     _messageCommunication.TransmitMessage(
                         new VideoOS.Platform.Messaging.Message(MessageCommunication.ProvideCurrentStateRequest), null, null, null);
                 }
                 catch (MIPException)
                 {
                     MessageBox.Show(
                         "Unable to connect to EventServer's MessageCommunication service (default port 22333) - will retry every 5 seconds",
                         "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
             else
             {
                 labelConnected.Text = "Not Connected, retrying ...";
             }
         }));
     }
 }
Ejemplo n.º 2
0
        public MapSelectForm()
        {
            InitializeComponent();

            treeView1.Nodes.Clear();
            _selectedNode = treeView1.Nodes.Add("", "Top");

            try
            {
                MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
                _client = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);

                //System.Threading.Thread.Sleep(500);
                bool x = _client.IsConnected;
                _msgObject = _client.RegisterCommunicationFilter(MapResponseHandler,
                                                                 new CommunicationIdFilter(MessageId.Server.GetMapResponse));

                MapRequestData data = new MapRequestData()
                {
                    MapGuid = "",
                };
                _client.TransmitMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.GetMapRequest, data),
                                        null, null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Map Select issue:" + ex.Message);
            }
        }
        public override void Init()
        {
            try
            {
                MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
                _messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);

                _messageCommunication.ConnectionStateChangedEvent += new EventHandler(_messageCommunication_ConnectionStateChangedEvent);
                _obj1 = _messageCommunication.RegisterCommunicationFilter(WhoAreOnlineResponseHandler, new VideoOS.Platform.Messaging.CommunicationIdFilter(MessageCommunication.WhoAreOnlineResponse));
                _obj2 = _messageCommunication.RegisterCommunicationFilter(NewEndPointHandler, new VideoOS.Platform.Messaging.CommunicationIdFilter(MessageCommunication.NewEndPointIndication));
                _obj3 = _messageCommunication.RegisterCommunicationFilter(EndPointTableChangedHandler, new VideoOS.Platform.Messaging.CommunicationIdFilter(MessageCommunication.EndPointTableChangedIndication));
                _obj4 = _messageCommunication.RegisterCommunicationFilter(ChatLineHandler, new VideoOS.Platform.Messaging.CommunicationIdFilter(MessageIdChatLine));

                LoginSettings ls = LoginSettingsCache.GetLoginSettings(EnvironmentManager.Instance.MasterSite);
                _myName = ls.UserName;
                if (_myName.Contains("\\"))
                {
                    _myName = _myName.Split('\\')[1];
                }
                if (_messageCommunication.IsConnected)
                {
                    _messageCommunication.TransmitMessage(
                        new VideoOS.Platform.Messaging.Message(MessageCommunication.WhoAreOnlineRequest), null, null,
                        null);
                }
            } catch (Exception ex)
            {
                EnvironmentManager.Instance.ExceptionDialog("Chat.Init", ex);
            }
        }
 void _messageCommunication_ConnectionStateChangedEvent(object sender, EventArgs e)
 {
     if (_messageCommunication.IsConnected)
     {
         try
         {
             _messageCommunication.TransmitMessage(
                 new VideoOS.Platform.Messaging.Message(MessageCommunication.WhoAreOnlineRequest), null, null,
                 null);
         } catch (Exception ex)
         {
             MessageBox.Show("Chat: " + ex.Message);
             //TODO: Retry later?
         }
     }
     else
     {
         BeginInvoke(new MethodInvoker(delegate() { this.Enabled = false; }));
     }
 }
Ejemplo n.º 5
0
        private void OnLoad(object sender, EventArgs e)
        {
            treeViewItems.ImageList        = VideoOS.Platform.UI.Util.ImageListClone;
            treeViewItems.ShowNodeToolTips = true;

            MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
            _messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);

            // Register to retrieve all NewEventIndication's from the Event Server
            _obj = _messageCommunication.RegisterCommunicationFilter(MessageHandler,
                                                                     new VideoOS.Platform.Messaging.CommunicationIdFilter(VideoOS.Platform.Messaging.MessageId.Server.NewEventIndication));
            _obj = _messageCommunication.RegisterCommunicationFilter(MessageHandler,
                                                                     new VideoOS.Platform.Messaging.CommunicationIdFilter(VideoOS.Platform.Messaging.MessageId.System.SystemConfigurationChangedIndication));

            // Register to receive the response from the ProvideCurrentStateRequest - issued later in this method.
            _obj3 = _messageCommunication.RegisterCommunicationFilter(ProvideCurrentStateResponseHandler,
                                                                      new VideoOS.Platform.Messaging.CommunicationIdFilter(MessageCommunication.ProvideCurrentStateResponse));

            _messageCommunication.ConnectionStateChangedEvent += new EventHandler(_messageCommunication_ConnectionStateChangedEvent);
            // Build Top TreeNode
            // GetItems will always return the Management Server as the single top-node - we are using System-defined hierarchy so that in XPCO you can see recording servers
            Item     server = Configuration.Instance.GetItems(ItemHierarchy.SystemDefined)[0];
            TreeNode tn     = new TreeNode(server.Name)
            {
                ImageIndex         = VideoOS.Platform.UI.Util.ServerIconIx,
                SelectedImageIndex = VideoOS.Platform.UI.Util.ServerIconIx,
                Tag = server.FQID.ServerId.Id
            };

            treeViewItems.Nodes.Add(tn);

            // Add all children
            tn.Nodes.AddRange(AddChildren(server));

            try
            {
                // Ask for current state of all Items
                _messageCommunication.TransmitMessage(
                    new VideoOS.Platform.Messaging.Message(MessageCommunication.ProvideCurrentStateRequest), null, null, null);
            } catch (MIPException)
            {
                MessageBox.Show(
                    "Unable to connect to EventServer's MessageCommunication service (default port 22333) - will retry every 5 seconds",
                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            treeViewItems.ExpandAll();
        }
        private void SearchData_aButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SearchData data = new SearchData
            {
                Camera     = _selectItem.Name as string,
                ItemFQID   = _selectItem.FQID.ToString(),
                Initial    = initial.SelectedDate,
                End        = end.SelectedDate,
                ObjectID   = _selectItem.FQID.ObjectId.ToString(),
                ObjectKind = _selectItem.FQID.Kind.ToString()
            };

            try
            {
                _messageCommunication.TransmitMessage(new VideoOS.Platform.Messaging.Message(AnalyticsDefinition.analyticsHeatMapSearchFilterID, data), null, null, null);
                MessageBox.Show(data.Camera + " has been sent to service.");
            }
            catch (Exception)
            {
                MessageBox.Show("error");
            }
        }
Ejemplo n.º 7
0
 private void OnBeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     _selectedNode = e.Node;
     if (_selectedNode != null)
     {
         if (_selectedNode.Nodes.Count == 1 && _selectedNode.Nodes[0].Text == "Empty")
         {
             try
             {
                 MapRequestData data = new MapRequestData()
                 {
                     MapGuid = SelectedMapId,
                 };
                 _client.TransmitMessage(
                     new VideoOS.Platform.Messaging.Message(MessageId.Server.GetMapRequest, data), null, null,
                     null);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Map Select issue:" + ex.Message);
             }
         }
     }
 }
Ejemplo n.º 8
0
 private void _IpButton_Click(object sender, RoutedEventArgs e)
 {
     EnsureMessageCommunicationInitialized();
     _mc.TransmitMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.GetIPAddressRequest, _selectItem.FQID), null, null, null);
 }
Ejemplo n.º 9
0
        private void StartMessaging(ServerObject smo)
        {
            if (smo.MessCommunication == null)
            {
                //VideoOS.Platform.SDK.Environment.AddServer(smo.SiteItem, _credentialCache);
                Item site = smo.SiteItem;

                MessageCommunicationManager.Start(site.FQID.ServerId);
                MessageCommunication messageCommunication = MessageCommunicationManager.Get(site.FQID.ServerId);
                object newEventIndicationHandler          = messageCommunication.RegisterCommunicationFilter(
                    MessageHandler,
                    new VideoOS.Platform.Messaging.CommunicationIdFilter(
                        VideoOS.Platform.Messaging.MessageId.Server.NewEventIndication));
                object provideCurrentStateResponseHandler =
                    messageCommunication.RegisterCommunicationFilter(ProvideCurrentStateResponseHandler,
                                                                     new VideoOS.Platform.Messaging.
                                                                     CommunicationIdFilter(
                                                                         MessageCommunication
                                                                         .ProvideCurrentStateResponse));
                TreeNode treeNode = BuildTree(site.FQID);
                if (treeNode != null)
                {
                    smo.MessCommunication                  = messageCommunication;
                    smo.NewEventIndicationHandler          = newEventIndicationHandler;
                    smo.ProvideCurrentStateResponseHandler = provideCurrentStateResponseHandler;
                }

                try
                {
                    messageCommunication.TransmitMessage(
                        new VideoOS.Platform.Messaging.Message(MessageCommunication.ProvideCurrentStateRequest),
                        null, null, null);
                }
                catch (Exception ex)
                {
                    toolStripStatusLabel1.Text = "TransmitMessage Exception: " + ex.Message +
                                                 " -Happens on server: " + smo.SiteItem.Name;
                    // todo

                    {
                        if (IsHandleCreated && !IsDisposed)
                        {
                            this.BeginInvoke(new MethodInvoker(delegate()
                            {
                                TreeNode tn = smo.SitesTreeNode;
                                if (smo.MessCommunication != null)
                                {
                                    if (smo.MessCommunication.IsConnected)
                                    {
                                        tn.ToolTipText = "connected";
                                        tn.ForeColor   = Color.Black;
                                    }
                                    else
                                    {
                                        tn.ToolTipText = "not connected";
                                        tn.ForeColor   = Color.Gray;
                                    }
                                }
                            }));
                        }
                    }
                }

                messageCommunication.ConnectionStateChangedEvent +=
                    new EventHandler(MessageConnectionStateChangedEvent);
            }
        }