public int UpdateVirtualGroups(int serverId, VirtualGroupInfo[] groups)
 {
     return ServerController.UpdateVirtualGroups(serverId, groups);
 }
        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();
        }
        public static int UpdateVirtualGroups(int serverId, VirtualGroupInfo[] groups)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin
                | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            /*
            XML Format:

            <groups>
	            <group id="16" distributionType="1" bindDistributionToPrimary="1"/>
            </groups>

            */

            // build XML
            XmlDocument doc = new XmlDocument();
            XmlElement nodeGroups = doc.CreateElement("groups");
            // groups
            if (groups != null)
            {
                foreach (VirtualGroupInfo group in groups)
                {
                    XmlElement nodeGroup = doc.CreateElement("group");
                    nodeGroups.AppendChild(nodeGroup);
                    nodeGroup.SetAttribute("id", group.GroupId.ToString());
                    nodeGroup.SetAttribute("distributionType", group.DistributionType.ToString());
                    nodeGroup.SetAttribute("bindDistributionToPrimary", group.BindDistributionToPrimary ? "1" : "0");
                }
            }

            string xml = nodeGroups.OuterXml;

            // update server
            DataProvider.UpdateVirtualGroups(serverId, xml);

            return 0;
        }
Example #4
0
 /// <remarks/>
 public void UpdateVirtualGroupsAsync(int serverId, VirtualGroupInfo[] groups, object userState) {
     if ((this.UpdateVirtualGroupsOperationCompleted == null)) {
         this.UpdateVirtualGroupsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateVirtualGroupsOperationCompleted);
     }
     this.InvokeAsync("UpdateVirtualGroups", new object[] {
                 serverId,
                 groups}, this.UpdateVirtualGroupsOperationCompleted, userState);
 }
Example #5
0
 /// <remarks/>
 public void UpdateVirtualGroupsAsync(int serverId, VirtualGroupInfo[] groups) {
     this.UpdateVirtualGroupsAsync(serverId, groups, null);
 }
Example #6
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateVirtualGroups(int serverId, VirtualGroupInfo[] groups, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("UpdateVirtualGroups", new object[] {
                 serverId,
                 groups}, callback, asyncState);
 }
Example #7
0
 public int UpdateVirtualGroups(int serverId, VirtualGroupInfo[] groups) {
     object[] results = this.Invoke("UpdateVirtualGroups", new object[] {
                 serverId,
                 groups});
     return ((int)(results[0]));
 }