protected void btnAdd_Click(object sender, EventArgs e) { // add server if (!Page.IsValid) return; ServerInfo server = new ServerInfo(); server.ServerName = Server.HtmlEncode(txtName.Text.Trim()); server.Comments = Server.HtmlEncode(txtComments.Text); server.VirtualServer = true; int serverId = 0; try { serverId = ES.Services.Servers.AddServer(server, false); if (serverId < 0) { ShowResultMessage(serverId); return; } } catch (Exception ex) { ShowErrorMessage("VSERVER_ADD_SERVER", ex); return; } Response.Redirect(EditUrl("ServerID", serverId.ToString(), "edit_server")); }
private void BindServer() { server = ES.Services.Servers.GetServerById(PanelRequest.ServerId); if (server == null) RedirectToBrowsePage(); // header txtName.Text = PortalAntiXSS.DecodeOld(server.ServerName); txtComments.Text = PortalAntiXSS.DecodeOld(server.Comments); Utils.SelectListItem(ddlPrimaryGroup, server.PrimaryGroupId); // instant alias txtInstantAlias.Text = server.InstantDomainAlias; }
protected void btnAdd_Click(object sender, EventArgs e) { // add server if (!Page.IsValid) return; ServerInfo server = new ServerInfo(); server.ServerName = txtName.Text.Trim(); server.ServerUrl = txtUrl.Text.Trim(); server.Password = serverPassword.Password; server.Comments = ""; server.VirtualServer = false; int serverId = 0; try { // add a server serverId = ES.Services.Servers.AddServer(server, cbAutoDiscovery.Checked); if (serverId < 0) { ShowResultMessage(serverId); return; } } catch (Exception ex) { if (ex.Message.Contains("Invalid URI")) { ShowErrorMessage("SERVER_INVALID_URL"); return; } ShowErrorMessage("SERVER_ADD_SERVER", ex); return; } Response.Redirect(EditUrl("ServerID", serverId.ToString(), "edit_server")); }
/// <remarks/> public void UpdateServerAsync(ServerInfo server, object userState) { if ((this.UpdateServerOperationCompleted == null)) { this.UpdateServerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateServerOperationCompleted); } this.InvokeAsync("UpdateServer", new object[] { server}, this.UpdateServerOperationCompleted, userState); }
private int AddServer(string url, string name, string password) { try { Log.WriteStart("Adding server"); ServerInfo serverInfo = new ServerInfo() { ADAuthenticationType = null, ADPassword = null, ADEnabled = false, ADRootDomain = null, ADUsername = null, Comments = string.Empty, Password = password, ServerName = name, ServerUrl = url, VirtualServer = false }; int serverId = ES.Services.Servers.AddServer(serverInfo, false); if (serverId > 0) { Log.WriteEnd("Added server"); } else { Log.WriteError(string.Format("Enterprise Server error: {0}", serverId)); } return serverId; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Server configuration error", ex); return -1; } }
private int AddVirtualServer(string name, int serverId, int[] services) { Log.WriteStart("Adding virtual server"); ServerInfo serverInfo = new ServerInfo() { Comments = string.Empty, ServerName = name, VirtualServer = true }; int virtualServerId = ES.Services.Servers.AddServer(serverInfo, false); if (virtualServerId > 0) { List<int> allServices = new List<int>(services); List<int> validServices = new List<int>(); foreach (int serviceId in allServices) { if (serviceId > 0) validServices.Add(serviceId); } ES.Services.Servers.AddVirtualServices(virtualServerId, validServices.ToArray()); Log.WriteEnd("Added virtual server"); } else { Log.WriteError(string.Format("Enterprise Server error: {0}", virtualServerId)); } return virtualServerId; }
public int AddServer(ServerInfo server, bool autoDiscovery) { return ServerController.AddServer(server, autoDiscovery); }
public int UpdateServer(ServerInfo server) { return ServerController.UpdateServer(server); }
public static int AddServer(ServerInfo server, bool autoDiscovery) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsAdmin); if (accountCheck < 0) return accountCheck; // init passwords if (server.Password == null) server.Password = ""; if (server.ADPassword == null) server.ADPassword = ""; // check server availability if (!server.VirtualServer) { int availResult = CheckServerAvailable(server.ServerUrl, server.Password); if (availResult < 0) return availResult; } TaskManager.StartTask("SERVER", "ADD", server.ServerName); int serverId = DataProvider.AddServer(server.ServerName, server.ServerUrl, CryptoUtils.Encrypt(server.Password), server.Comments, server.VirtualServer, server.InstantDomainAlias, server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword), server.ADAuthenticationType); if (autoDiscovery) { server.ServerId = serverId; try { FindServices(server); } catch (Exception ex) { TaskManager.WriteError(ex); } } TaskManager.ItemId = serverId; TaskManager.CompleteTask(); return serverId; }
public static int UpdateServer(ServerInfo server) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive | DemandAccount.IsAdmin); if (accountCheck < 0) return accountCheck; TaskManager.StartTask("SERVER", "UPDATE"); TaskManager.ItemId = server.ServerId; // get original server ServerInfo origServer = GetServerByIdInternal(server.ServerId); TaskManager.ItemName = origServer.ServerName; // preserve passwords server.Password = origServer.Password; server.ADPassword = origServer.ADPassword; // check server availability if (!origServer.VirtualServer) { int availResult = CheckServerAvailable(server.ServerUrl, server.Password); if (availResult < 0) return availResult; } DataProvider.UpdateServer(server.ServerId, server.ServerName, server.ServerUrl, CryptoUtils.Encrypt(server.Password), server.Comments, server.InstantDomainAlias, server.PrimaryGroupId, server.ADEnabled, server.ADRootDomain, server.ADUsername, CryptoUtils.Encrypt(server.ADPassword), server.ADAuthenticationType); TaskManager.CompleteTask(); return 0; }
public int AddServer(ServerInfo server, bool autoDiscovery) { object[] results = this.Invoke("AddServer", new object[] { server, autoDiscovery}); return ((int)(results[0])); }
public int UpdateServer(ServerInfo server) { return(ServerController.UpdateServer(server)); }
/// <remarks/> public void UpdateServerAsync(ServerInfo server) { this.UpdateServerAsync(server, null); }
private void UpdateServer() { if (!Page.IsValid) return; ServerInfo server = new ServerInfo(); // header server.ServerId = PanelRequest.ServerId; server.ServerName = txtName.Text; server.Comments = txtComments.Text; // connection server.ServerUrl = txtUrl.Text; // AD server.ADEnabled = (rbUsersCreationMode.SelectedIndex == 1); server.ADAuthenticationType = ddlAdAuthType.SelectedValue; server.ADRootDomain = txtDomainName.Text; server.ADUsername = txtAdUsername.Text; // instant alias server.InstantDomainAlias = txtInstantAlias.Text; try { int result = ES.Services.Servers.UpdateServer(server); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("SERVER_UPDATE_SERVER", ex); return; } // return to browse page RedirectToBrowsePage(); }
/// <remarks/> public System.IAsyncResult BeginUpdateServer(ServerInfo server, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UpdateServer", new object[] { server}, callback, asyncState); }
public int UpdateServer(ServerInfo server) { object[] results = this.Invoke("UpdateServer", new object[] { server}); return ((int)(results[0])); }
/// <remarks/> public void AddServerAsync(ServerInfo server, bool autoDiscovery, object userState) { if ((this.AddServerOperationCompleted == null)) { this.AddServerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddServerOperationCompleted); } this.InvokeAsync("AddServer", new object[] { server, autoDiscovery}, this.AddServerOperationCompleted, userState); }
/// <remarks/> public void AddServerAsync(ServerInfo server, bool autoDiscovery) { this.AddServerAsync(server, autoDiscovery, null); }
/// <remarks/> public System.IAsyncResult BeginAddServer(ServerInfo server, bool autoDiscovery, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("AddServer", new object[] { server, autoDiscovery}, callback, asyncState); }
private void UpdateServer() { if (!Page.IsValid) return; ServerInfo server = new ServerInfo(); // header server.ServerId = PanelRequest.ServerId; server.ServerName = txtName.Text; server.Comments = txtComments.Text; server.PrimaryGroupId = Utils.ParseInt(ddlPrimaryGroup.SelectedValue, 0); // instant alias server.InstantDomainAlias = txtInstantAlias.Text; // gather groups info List<VirtualGroupInfo> groups = new List<VirtualGroupInfo>(); for (int i = 0; i < dlServiceGroups.Items.Count; i++) { int groupId = (int)dlServiceGroups.DataKeys[i]; DataListItem item = dlServiceGroups.Items[i]; CheckBox chkBind = (CheckBox)item.FindControl("chkBind"); DropDownList ddlDistType = (DropDownList)item.FindControl("ddlDistType"); Control rowBound = item.FindControl("rowBound"); VirtualGroupInfo group = new VirtualGroupInfo(); group.GroupId = groupId; group.DistributionType = Utils.ParseInt(ddlDistType.SelectedValue, 0); group.BindDistributionToPrimary = chkBind.Checked && rowBound.Visible; groups.Add(group); } try { // update server int result = ES.Services.Servers.UpdateServer(server); if (result < 0) { ShowResultMessage(result); return; } // update groups result = ES.Services.Servers.UpdateVirtualGroups(PanelRequest.ServerId, groups.ToArray()); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("VSERVER_UPDATE_SERVER", ex); return; } // return to browse page RedirectToBrowsePage(); }
private static void FindServices(ServerInfo server) { try { List<ProviderInfo> providers; try { providers = GetProviders(); } catch (Exception ex) { TaskManager.WriteError(ex); throw new ApplicationException("Could not get providers list."); } foreach (ProviderInfo provider in providers) { if (!provider.DisableAutoDiscovery) { BoolResult isInstalled = IsInstalled(server.ServerId, provider.ProviderId); if (isInstalled.IsSuccess) { if (isInstalled.Value) { try { ServiceInfo service = new ServiceInfo(); service.ServerId = server.ServerId; service.ProviderId = provider.ProviderId; service.ServiceName = provider.DisplayName; AddService(service); } catch (Exception ex) { TaskManager.WriteError(ex); } } } else { string errors = string.Join("\n", isInstalled.ErrorCodes.ToArray()); string str = string.Format( "Could not check if specific software intalled for {0}. Following errors have been occured:\n{1}", provider.ProviderName, errors); TaskManager.WriteError(str); } } } } catch (Exception ex) { throw new ApplicationException("Could not find services. General error was occued.", ex); } }
private void BindServices() { // load services dsServices = ES.Services.Servers.GetVirtualServices(PanelRequest.ServerId); // bind primary groups ddlPrimaryGroup.Items.Clear(); ddlPrimaryGroup.Items.Add(new ListItem("<Select Group>", "")); DataView dvGroups = dsServices.Tables[0].DefaultView; foreach (DataRowView dr in dvGroups) { int groupId = (int)dr["GroupID"]; DataView dvServices = GetGroupServices(groupId); if (dvServices.Count > 1) { ddlPrimaryGroup.Items.Add(new ListItem(dr["GroupName"].ToString(), groupId.ToString())); } } // select primary group if (server == null) server = ES.Services.Servers.GetServerById(PanelRequest.ServerId); bool showBindToPrimary = (ddlPrimaryGroup.Items.Count > 2); ddlPrimaryGroup.SelectedIndex = -1; if (showBindToPrimary) Utils.SelectListItem(ddlPrimaryGroup, server.PrimaryGroupId); rowPrimaryGroup.Visible = showBindToPrimary; // bind services try { dlServiceGroups.DataSource = dsServices.Tables[0]; dlServiceGroups.DataBind(); } catch (Exception ex) { ShowErrorMessage("INIT_SERVICE_ITEM_FORM", ex); } }
public int AddServer(ServerInfo server, bool autoDiscovery) { return(ServerController.AddServer(server, autoDiscovery)); }