/// <summary> /// Processes UpdateServerGraphMessage. /// </summary> /// <param name="communicator">Communicator that sent message</param> /// <param name="controlMessage">The message to be processed</param> /// <param name="controllerMessage">NGRIDControllerMessage object that includes controlMessage</param> private void ProcessUpdateServerGraphMessage(ICommunicator communicator, UpdateServerGraphMessage controlMessage, NGRIDControllerMessage controllerMessage) { try { var newSettings = new NGRIDSettings(Path.Combine(GeneralHelper.GetCurrentDirectory(), "NGRIDSettings.xml")); //var newDesignSettings = new NGRIDDesignSettings(Path.Combine(GeneralHelper.GetCurrentDirectory(), "NGRIDSettings.design.xml")); //Clear existing server lists newSettings.Servers.Clear(); //newDesignSettings.Servers.Clear(); //Add servers from UpdateServerGraphMessage newSettings.ThisServerName = controlMessage.ServerGraph.ThisServerName; foreach (var server in controlMessage.ServerGraph.Servers) { //Settings newSettings.Servers.Add( new ServerInfoItem { Name = server.Name, IpAddress = server.IpAddress, Port = server.Port, Adjacents = server.Adjacents }); /*Design settings * newDesignSettings.Servers.Add( * new ServerDesignItem * { * Name = server.Name, * Location = server.Location * });*/ } //Save settings newSettings.SaveToXml(); //newDesignSettings.SaveToXml(); } catch (Exception ex) { //Send fail message ReplyMessageToCommunicator( communicator, new OperationResultMessage { Success = false, ResultMessage = ex.Message }, controllerMessage ); return; } //Send success message ReplyMessageToCommunicator( communicator, new OperationResultMessage { Success = true, ResultMessage = "Success" }, controllerMessage ); }
private void ProcessUpdateApplicationWebServicesMessage(ICommunicator communicator, UpdateApplicationWebServicesMessage message, NGRIDControllerMessage controllerMessage) { try { //Find application ApplicationInfoItem application = null; foreach (var applicationInfoItem in _settings.Applications) { if (applicationInfoItem.Name == message.ApplicationName) { application = applicationInfoItem; } } if (application == null) { //Send message ReplyMessageToCommunicator( communicator, new OperationResultMessage() { Success = false, ResultMessage = "No application found with name '" + message.ApplicationName + "'." }, controllerMessage ); return; } //Delete old service list application.CommunicationChannels.Clear(); //Add new services if (message.WebServices != null && message.WebServices.Length > 0) { foreach (var webServiceInfo in message.WebServices) { var channelInfo = new ApplicationInfoItem.CommunicationChannelInfoItem { CommunicationType = "WebService" }; channelInfo.CommunicationSettings["Url"] = webServiceInfo.Url; application.CommunicationChannels.Add(channelInfo); } } try { //Save settings _settings.SaveToXml(); } catch (Exception ex) { Logger.Error(ex.Message, ex); ReplyMessageToCommunicator( communicator, new OperationResultMessage() { Success = false, ResultMessage = "Can not save XML configuration file (NGRIDSettings.xml)." }, controllerMessage ); return; } //Send success message ReplyMessageToCommunicator( communicator, new OperationResultMessage() { Success = true, ResultMessage = "Success." }, controllerMessage ); } catch (Exception ex) { Logger.Error(ex.Message, ex); ReplyMessageToCommunicator( communicator, new OperationResultMessage() { Success = false, ResultMessage = ex.Message }, controllerMessage ); return; } }