private void removeWebServiceToolStripMenuItem_Click(object sender, EventArgs e) { //Check if user selected any web service to remove if (gwWebServices.SelectedRows.Count <= 0) { return; } var selectedIndex = gwWebServices.SelectedRows[0].Index; if ((selectedIndex < 0) || (selectedIndex >= _webServicesList.Count)) { return; } //Get selected web service item var selectedItem = _webServicesList[selectedIndex]; //Confirm removing var dialogResult = MDSGuiHelper.ShowQuestionDialog( "Are you sure to remove web service: " + selectedItem.Url, "Comfirm removing?"); if (dialogResult != DialogResult.Yes) { return; } _webServicesList.RemoveAt(selectedIndex); }
/// <summary> /// Gets all applications from server and fills into list. /// </summary> private void GetApplicationsFromServer() { try { //Send a message to MDS server to get list of client applications, get response and fill data grid. var message = _controller.SendMessageAndGetResponse(new GetApplicationListMessage()); if (message.MessageTypeId != ControlMessageFactory.MessageTypeIdGetApplicationListResponseMessage) { throw new MDSException("Response message to GetApplicationListMessage must be a GetApplicationListResponseMessage"); } var applicationListMessage = message as GetApplicationListResponseMessage; if (applicationListMessage == null) { throw new MDSException("Incorrect message type. MessageTypeId = " + message.MessageTypeId + ", but Type of object: " + message.GetType().Name); } FillApplicationList(applicationListMessage.ClientApplications); } catch (Exception ex) { Logger.Error(ex.Message, ex); MDSGuiHelper.ShowErrorMessage("Application list can not received from MDS Server. Detail: " + ex.Message); } }
/// <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); } }
private void MainForm_Load(object sender, EventArgs e) { try { _controller.Connect(); } catch (Exception ex) { Logger.Error(ex.Message, ex); MDSGuiHelper.ShowErrorMessage("Can not connected to MDS Server. Detail: " + ex.Message); Close(); } }
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(); }
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(); }
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; } }
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; }
private void btnConnect_Click(object sender, EventArgs e) { try { var port = Convert.ToInt32(txtPort.Text); MDSController = new MDSController(txtIPAddress.Text, port); _settings.SetStringValue("LastConnectedIPAddress", txtIPAddress.Text); _settings.SetIntegerValue("LastConnectedTCPPort", port); Close(); } catch { MDSGuiHelper.ShowErrorMessage("Please check IP address and TCP Port. TCP port must be numeric."); } }
private void btnGenerateCode_Click(object sender, EventArgs e) { btnGenerateCode.Enabled = false; Application.DoEvents(); try { GenerateCode(); MDSGuiHelper.ShowInfoDialog("Proxy classes are generated.", "Success."); } catch (Exception ex) { MDSGuiHelper.ShowErrorMessage(ex.Message); } finally { btnGenerateCode.Enabled = true; } }
/// <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); } }
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); } }
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 btnAddApplication_Click(object sender, EventArgs e) { var addApplicationForm = new AddNewApplicationForm(); addApplicationForm.ShowDialog(); if (string.IsNullOrEmpty(addApplicationForm.ApplicationName)) { return; } try { _controller.SendMessage( new AddNewApplicationMessage { ApplicationName = addApplicationForm.ApplicationName }); } catch (Exception ex) { Logger.Error(ex.Message, ex); MDSGuiHelper.ShowErrorMessage("Application can not be added. Detail: " + ex.Message); } }
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); } } }