/// <summary> /// create or edit a host /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveHostButtonClick( object sender, EventArgs e) { if (_enterpriseClient == null || _enterpriseSession == null || string.IsNullOrEmpty(hostName.Value)) { return; } try { if (!_hostId.HasValue) { _enterpriseClient.AddHost(new EnterpriseHostEdit { HostID = 0, HostName = hostName.Value, HostAddress = hostAddress.Value, DirectoryGroups = groupsAccess.Value, Protocol = (SecurityProtocolEnum)securityProtocol.SelectedIndex }, _enterpriseSession.SessionID); } else { _enterpriseClient.UpdateHost(new EnterpriseHostEdit { HostID = _hostId.Value, HostName = hostName.Value, HostAddress = hostAddress.Value, DirectoryGroups = groupsAccess.Value, Protocol = (SecurityProtocolEnum)securityProtocol.SelectedIndex }, _enterpriseSession.SessionID); } // refresh the hosts list Response.Redirect(Request.RawUrl + (Request.RawUrl.Contains("?") ? "&" : "?") + "edit=success"); } catch (ThreadAbortException) { // occurs because the response is ended after redirect } catch (Exception exc) { System.Diagnostics.Trace.TraceError("Failed to save host ({0})", exc); } }
/// <summary> /// create or edit a host /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveHostButtonClick( object sender, EventArgs e) { if (_enterpriseClient == null || _enterpriseSession == null || string.IsNullOrEmpty(hostName.Value)) { return; } try { var enterpriseHost = new EnterpriseHostEdit { HostID = _hostId ?? 0, HostType = _hostType, HostName = hostName.Value, HostAddress = hostAddress.Value, VMGuid = vmGuid.Value, VMEnhancedMode = vmEnhancedMode.Checked, DirectoryGroups = groupsAccess.Value, Protocol = (SecurityProtocolEnum)securityProtocol.SelectedIndex, StartRemoteProgram = startProgram.Value, PromptForCredentials = promptCredentials.Checked }; if (_hostId != null) { _enterpriseClient.UpdateHost(enterpriseHost, _enterpriseSession.SessionID); } else { _enterpriseClient.AddHost(enterpriseHost, _enterpriseSession.SessionID); } // refresh the hosts list Response.Redirect(Request.RawUrl + (Request.RawUrl.Contains("?") ? "&" : "?") + "edit=success" + (_hostId != null ? string.Format("&hostType={0}", _hostType) : string.Empty)); } catch (ThreadAbortException) { // occurs because the response is ended after redirect } catch (Exception exc) { System.Diagnostics.Trace.TraceError("Failed to save host ({0})", exc); } }