Exemplo n.º 1
0
        /// <summary>
        /// Gets server graph from server and creates graph on screen.
        /// </summary>
        private void GetGraphFromServer()
        {
            try
            {
                //Send a message to MDS server to get list of client applications, get response and fill data grid.
                var message = _controller.SendMessageAndGetResponse(new GetServerGraphMessage());
                if (message.MessageTypeId != ControlMessageFactory.MessageTypeIdGetServerGraphResponseMessage)
                {
                    throw new MDSException("Response message to GetServerGraphMessage must be a GetServerGraphResponseMessage");
                }

                var serverGraphResponseMessage = message as GetServerGraphResponseMessage;
                if (serverGraphResponseMessage == null)
                {
                    throw new MDSException("Incorrect message type. MessageTypeId = " + message.MessageTypeId + ", but Type of object: " + message.GetType().Name);
                }

                _serverGraphInfo = serverGraphResponseMessage.ServerGraph;
                CreateGraph();
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                MDSGuiHelper.ShowErrorMessage("Application list can not received from MDS Server. Detail: " + ex.Message);
            }
        }
Exemplo n.º 2
0
        private void btnSaveGraph_Click(object sender, EventArgs e)
        {
            btnSaveGraph.Enabled = false;
            Application.DoEvents();

            try
            {
                CheckGraph();
                _serverGraphInfo = CreateServerGraphInfo();

                //Send message to the server and get response
                var message = _controller.SendMessageAndGetResponse(
                    new UpdateServerGraphMessage {
                    ServerGraph = _serverGraphInfo
                }
                    );

                //Check response message
                if (message.MessageTypeId != ControlMessageFactory.MessageTypeIdOperationResultMessage)
                {
                    throw new MDSException("Response message to UpdateServerGraphMessage must be a OperationResultMessage");
                }

                var updateResponseMessage = message as OperationResultMessage;
                if (updateResponseMessage == null)
                {
                    throw new MDSException("Incorrect message type. MessageTypeId = " + message.MessageTypeId + ", but Type of object: " + message.GetType().Name);
                }

                //Inform user about update result
                if (updateResponseMessage.Success)
                {
                    MDSGuiHelper.ShowInfoDialog("Server graph is successfully updated on server", "Success.");
                }
                else
                {
                    MDSGuiHelper.ShowErrorMessage(
                        "Server graph can not be updated on server. Reason: " + updateResponseMessage.ResultMessage,
                        "Failed!");
                }
            }
            catch (Exception ex)
            {
                MDSGuiHelper.ShowWarningMessage("Can not save graph. " + ex.Message);
            }
            finally
            {
                btnSaveGraph.Enabled = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prepares ServerGraphInfo object from graph on screen.
        /// </summary>
        /// <returns>ServerGraphInfo object</returns>
        private ServerGraphInfo CreateServerGraphInfo()
        {
            var graphInfo = new ServerGraphInfo
            {
                ThisServerName = _thisServer.ServerInfo.Name,
                Servers        = new ServerGraphInfo.ServerOnGraph[_servers.Count]
            };

            for (var i = 0; i < _servers.Count; i++)
            {
                graphInfo.Servers[i] =
                    new ServerGraphInfo.ServerOnGraph
                {
                    Name      = _servers[i].ServerInfo.Name,
                    IpAddress = _servers[i].ServerInfo.IpAddress,
                    Port      = _servers[i].ServerInfo.Port,
                    Location  = _servers[i].LabelOfServer.Left + "," + _servers[i].LabelOfServer.Top,
                    Adjacents = GetAdjacentListAsString(_servers[i])
                };
            }

            return(graphInfo);
        }