示例#1
0
        /// <summary>
        /// Gets web service list of application from web service.
        /// </summary>
        private void GetWebServiceList()
        {
            try
            {
                //Send a message to MDS server to get list of web services of application, get response and fill data grid.
                var responseMessage = _controller.SendMessageAndGetResponse(new GetApplicationWebServicesMessage {
                    ApplicationName = txtAppName.Text
                });
                if (responseMessage.MessageTypeId != ControlMessageFactory.MessageTypeIdGetApplicationWebServicesResponseMessage)
                {
                    throw new MDSException("Response message to GetApplicationWebServicesMessage must be a GetApplicationWebServicesResponseMessage");
                }

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

                //Check result
                if (!webServicesResponseMessage.Success)
                {
                    MDSGuiHelper.ShowWarningMessage(webServicesResponseMessage.ResultText);
                    return;
                }

                //Fill data grid
                FillWebServiceList(webServicesResponseMessage.WebServices);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                MDSGuiHelper.ShowErrorMessage("Error occured while getting web service list from server. Error detail: " + ex.Message);
            }
        }
示例#2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var appName = txtName.Text.Trim();

            if (string.IsNullOrEmpty(appName))
            {
                MDSGuiHelper.ShowWarningMessage("Application name can not be empty!");
                return;
            }

            ApplicationName = appName;
            Close();
        }
示例#3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var name      = txtName.Text;
            var ipAddress = txtIPAddress.Text;
            var port      = txtPort.Text;

            if (string.IsNullOrEmpty(name))
            {
                MDSGuiHelper.ShowWarningMessage("Server name can not be empty.", "Server name is invalid!");
                return;
            }

            if (string.IsNullOrEmpty(ipAddress))
            {
                MDSGuiHelper.ShowWarningMessage("IP address can not be empty.", "IP address is invalid!");
                return;
            }

            if (string.IsNullOrEmpty(port))
            {
                MDSGuiHelper.ShowWarningMessage("TCP Port can not be empty.", "TCP Port is invalid!");
                return;
            }

            int portNo;

            try
            {
                portNo = Convert.ToInt32(port);
            }
            catch
            {
                MDSGuiHelper.ShowWarningMessage("TCP Port must be numeric.", "TCP Port is invalid!");
                return;
            }

            if (portNo <= 0)
            {
                MDSGuiHelper.ShowWarningMessage("TCP Port must be a positive number.", "TCP Port is invalid!");
                return;
            }

            _server.Name      = name;
            _server.IpAddress = ipAddress;
            _server.Port      = portNo;

            Updated = true;

            Close();
        }
示例#4
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;
            }
        }
示例#5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var webServiceUrl = txtServiceUrl.Text.Trim();

            if (string.IsNullOrEmpty(webServiceUrl))
            {
                MDSGuiHelper.ShowWarningMessage("Web Service URL can not be empty!");
                return;
            }

            _webServicesList.Add(new WebServiceListItem {
                Url = webServiceUrl
            });
            gwWebServices.DataSource = _webServicesList;
        }
示例#6
0
        /// <summary>
        /// Sends new web service list to server.
        /// </summary>
        private void SendChangesToServer()
        {
            try
            {
                var wsList = new ApplicationWebServiceInfo[_webServicesList.Count];
                for (var i = 0; i < _webServicesList.Count; i++)
                {
                    wsList[i] = new ApplicationWebServiceInfo {
                        Url = _webServicesList[i].Url
                    };
                }

                var responseMessage = _controller.SendMessageAndGetResponse(new UpdateApplicationWebServicesMessage {
                    ApplicationName = txtAppName.Text, WebServices = wsList
                });
                if (responseMessage.MessageTypeId != ControlMessageFactory.MessageTypeIdOperationResultMessage)
                {
                    throw new MDSException("Response message to UpdateApplicationWebServicesMessage must be a OperationResultMessage");
                }

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

                //Check result
                if (!operationResultMessage.Success)
                {
                    MDSGuiHelper.ShowWarningMessage(operationResultMessage.ResultMessage);
                    return;
                }

                //Success
                MDSGuiHelper.ShowInfoDialog("Updated web services for application '" + txtAppName.Text + "'.", "Success");
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                MDSGuiHelper.ShowErrorMessage("Error occured while sending web service list to server. Error detail: " + ex.Message);
            }
        }
示例#7
0
        private void GenerateCode()
        {
            if (cmbClasses.Items.Count < 2)
            {
                MDSGuiHelper.ShowWarningMessage("There is no class to generate.");
                return;
            }

            var namespaceName = txtNamespace.Text;

            if (string.IsNullOrEmpty(namespaceName))
            {
                MDSGuiHelper.ShowWarningMessage("Please enter a namespace.");
                return;
            }

            var targetFolder = txtTargetFolder.Text;

            if (string.IsNullOrEmpty(targetFolder))
            {
                MDSGuiHelper.ShowWarningMessage("Please enter a target folder to generate code files.");
                return;
            }

            if (!Directory.Exists(targetFolder))
            {
                Directory.CreateDirectory(targetFolder);
            }

            if (cmbClasses.SelectedIndex == 0)
            {
                for (var i = 1; i < cmbClasses.Items.Count; i++)
                {
                    GenerateProxyClass(_selectedAssembly, namespaceName, cmbClasses.Items[i].ToString(), targetFolder);
                }
            }
            else
            {
                GenerateProxyClass(_selectedAssembly, namespaceName, cmbClasses.Items[cmbClasses.SelectedIndex].ToString(), targetFolder);
            }
        }
示例#8
0
        private void ServerRightMenu_RemoveServer_Click(object sender, EventArgs e)
        {
            var removingServer = GetSelectedServer();

            if (removingServer == null)
            {
                return;
            }

            if (removingServer.ServerInfo.Name == _thisServer.ServerInfo.Name)
            {
                MDSGuiHelper.ShowWarningMessage("You can not remove this server from graph!", "Attention!");
                return;
            }

            var dialogResult = MDSGuiHelper.ShowQuestionDialog(
                "Are you sure to remove MDS Server " + removingServer.ServerInfo.Name + " (" +
                removingServer.ServerInfo.IpAddress + ") from graph.", "Confirm removing server!");

            if (dialogResult != DialogResult.Yes)
            {
                return;
            }

            foreach (var adjacent in removingServer.Adjacents)
            {
                if (adjacent.Adjacents.Contains(removingServer))
                {
                    adjacent.Adjacents.Remove(removingServer);
                }
            }

            _servers.Remove(removingServer);
            pnlDesign.Controls.Remove(removingServer.LabelOfServer);
            _selectedLabel = null;

            pnlDesign.Invalidate();
        }
        private void btnRemoveApplication_Click(object sender, EventArgs e)
        {
            lock (_applicationList)
            {
                //Check if user selected any application to remove
                if (gwApplicationList.SelectedRows.Count <= 0)
                {
                    return;
                }

                var selectedIndex = gwApplicationList.SelectedRows[0].Index;
                if ((selectedIndex < 0) || (selectedIndex >= _applicationList.Count))
                {
                    return;
                }

                //Get confirmation from user to remove application.
                var applicationName = _applicationList[selectedIndex].ApplicationName;
                var dialogResult    =
                    MDSGuiHelper.ShowQuestionDialog("Are you sure to remove '" + applicationName + "' application from MDS",
                                                    "Attention! You are removing an application",
                                                    MessageBoxDefaultButton.Button2);
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }

                try
                {
                    //Send RemoveApplicationMessage to MDS server
                    var message = _controller.SendMessageAndGetResponse(
                        new RemoveApplicationMessage
                    {
                        ApplicationName = applicationName
                    });

                    //Check response message
                    if (message.MessageTypeId != ControlMessageFactory.MessageTypeIdRemoveApplicationResponseMessage)
                    {
                        throw new MDSException("Response message to RemoveApplicationMessage must be as RemoveApplicationResponseMessage");
                    }

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

                    //Evaluate response message
                    if (responseMessage.Removed)
                    {
                        RemoveApplicationFromList(responseMessage.ApplicationName);
                    }
                    else
                    {
                        MDSGuiHelper.ShowWarningMessage(responseMessage.ResultMessage, applicationName + " application can not be removed!");
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex.Message, ex);
                    MDSGuiHelper.ShowErrorMessage(applicationName + " application can not be removed. Detail: " + ex.Message);
                }
            }
        }