protected void btnAddCluster_OnClick(object sender, EventArgs e) { RequiresAuthorization(AuthorizationStrings.UpdateAdmin); var clusterGroup = new ClusterGroupEntity { Name = txtClusterName.Text, Default = chkDefault.Checked ? 1 : 0 }; var result = Call.ClusterGroupApi.Post(clusterGroup); if (result.Success) { var listOfServers = new List <ClusterGroupServerEntity>(); foreach (GridViewRow row in gvServers.Rows) { var cb = (CheckBox)row.FindControl("chkSelector"); if (!cb.Checked) { continue; } var cbTftp = (CheckBox)row.FindControl("chkTftp"); var cbMulticast = (CheckBox)row.FindControl("chkMulticast"); var dataKey = gvServers.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var clusterGroupServer = new ClusterGroupServerEntity(); clusterGroupServer.ClusterGroupId = result.Id; clusterGroupServer.ServerId = Convert.ToInt32(dataKey.Value); if (cbTftp.Checked) { clusterGroupServer.TftpRole = 1; } if (cbMulticast.Checked) { clusterGroupServer.MulticastRole = 1; } listOfServers.Add(clusterGroupServer); } Call.ClusterGroupServerApi.Post(listOfServers); var listOfDps = new List <ClusterGroupDistributionPointEntity>(); foreach (GridViewRow row in gvDps.Rows) { var cb = (CheckBox)row.FindControl("chkSelector"); if (!cb.Checked) { continue; } var dataKey = gvDps.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var clusterGroupDistributionPoint = new ClusterGroupDistributionPointEntity(); clusterGroupDistributionPoint.ClusterGroupId = result.Id; clusterGroupDistributionPoint.DistributionPointId = Convert.ToInt32(dataKey.Value); listOfDps.Add(clusterGroupDistributionPoint); } Call.ClusterGroupDistributionPointApi.Post(listOfDps); EndUserMessage = "Successfully Created Cluster Group"; Response.Redirect("~/views/admin/cluster/editcluster.aspx?cat=sub1&clusterid=" + result.Id); } else { EndUserMessage = result.ErrorMessage; } }
protected void btnUpdateCluster_OnClick(object sender, EventArgs e) { RequiresAuthorization(AuthorizationStrings.UpdateAdmin); var clusterGroup = new ClusterGroupEntity { Id = ClusterGroup.Id, Name = txtClusterName.Text, Default = chkDefault.Checked ? 1 : 0 }; var result = Call.ClusterGroupApi.Put(clusterGroup.Id, clusterGroup); if (result.Success) { var listOfServers = new List <ClusterGroupServerEntity>(); foreach (GridViewRow row in gvServers.Rows) { var cb = (CheckBox)row.FindControl("chkSelector"); if (!cb.Checked) { continue; } var cbImage = (CheckBox)row.FindControl("chkImage"); var cbTftp = (CheckBox)row.FindControl("chkTftp"); var cbMulticast = (CheckBox)row.FindControl("chkMulticast"); var dataKey = gvServers.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var clusterGroupServer = new ClusterGroupServerEntity(); clusterGroupServer.ClusterGroupId = result.Id; clusterGroupServer.ServerId = Convert.ToInt32(dataKey.Value); if (cbTftp.Checked) { clusterGroupServer.TftpRole = 1; } if (!cbTftp.Visible) { clusterGroupServer.TftpRole = 0; } if (cbMulticast.Checked) { clusterGroupServer.MulticastRole = 1; } if (!cbMulticast.Visible) { clusterGroupServer.MulticastRole = 0; } listOfServers.Add(clusterGroupServer); } if (listOfServers.Count == 0) { listOfServers.Add(new ClusterGroupServerEntity { ClusterGroupId = ClusterGroup.Id, ServerId = -2 }); } Call.ClusterGroupServerApi.Post(listOfServers); var listOfDps = new List <ClusterGroupDistributionPointEntity>(); foreach (GridViewRow row in gvDps.Rows) { var cb = (CheckBox)row.FindControl("chkSelector"); if (!cb.Checked) { continue; } var dataKey = gvDps.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } var clusterGroupDistributionPoint = new ClusterGroupDistributionPointEntity(); clusterGroupDistributionPoint.ClusterGroupId = result.Id; clusterGroupDistributionPoint.DistributionPointId = Convert.ToInt32(dataKey.Value); listOfDps.Add(clusterGroupDistributionPoint); } if (listOfDps.Count == 0) { listOfDps.Add(new ClusterGroupDistributionPointEntity { ClusterGroupId = ClusterGroup.Id, DistributionPointId = -2 }); } Call.ClusterGroupDistributionPointApi.Post(listOfDps); EndUserMessage = "Successfully Updated Cluster Group"; } else { EndUserMessage = result.ErrorMessage; } }