/// <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 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 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 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); } } }