protected void btnRecom_Click(object sender, EventArgs e) { Variables oVariable = new Variables((int)CurrentEnvironment.PNCNT_DEV); string client = "WDCLV015A.pncbank.com"; string strError = ""; Avamar oAvamar = new Avamar(0, dsn); AvamarRegistration oAvamarRegistration = new AvamarRegistration(0, dsn); ClearViewWebServices oWebService = new ClearViewWebServices(); System.Net.NetworkCredential oCredentialsDNS = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain()); oWebService.Credentials = oCredentialsDNS; oWebService.Url = oVariable.WebServiceURL(); // First, query for groups. DataSet dsGroups = oAvamar.GetDecoms(client); if (dsGroups.Tables[0].Rows.Count > 0) { string grid = dsGroups.Tables[0].Rows[0]["grid"].ToString(); string domain = dsGroups.Tables[0].Rows[0]["domain"].ToString(); // Second, add the groups. foreach (DataRow drGroup in dsGroups.Tables[0].Rows) { if (String.IsNullOrEmpty(strError) == false) { break; } AvamarReturnType restore = oAvamarRegistration.API(oWebService.AddAvamarGroup(grid, domain, client, drGroup["group"].ToString())); if (restore.Error == false) { } else { strError = restore.Message; } } // Third, remove the /Decom group AvamarReturnType decom = oAvamarRegistration.API(oWebService.DeleteAvamarGroup(grid, domain, client, oAvamar.DecomGroup)); if (decom.Error == false) { // Fourth, recommission the saved decom groups. oAvamar.UpdateDecom(client); } else { strError = decom.Message; } } }
protected void btnSubmit_Click(Object Sender, EventArgs e) { int intUser = 0; string strAssets = ""; if (Int32.TryParse(Request.Form["hdnAJAXValue"], out intUser) == true && intUser > 0) { foreach (RepeaterItem ri in rptDevices.Items) { CheckBox chkDevice = (CheckBox)ri.FindControl("chkDevice"); Label lblName = (Label)ri.FindControl("lblName"); Label lblSerial = (Label)ri.FindControl("lblSerial"); Label lblStatus = (Label)ri.FindControl("lblStatus"); bool boolComplete = lblStatus.Text.ToUpper().Contains("COMPLETED"); oLog.AddEvent(lblName.Text, lblSerial.Text, "RECOMMISSION: Started by " + oUser.GetFullNameWithLanID(intProfile), LoggingType.Information); if (chkDevice.Checked == true) { if (chkDevice.ToolTip[0].ToString() == "S") { int intServer = Int32.Parse(chkDevice.ToolTip.Substring(1)); DataSet dsServers = oServer.GetAssetsServer(intServer); foreach (DataRow drServer in dsServers.Tables[0].Rows) { int intAsset = Int32.Parse(drServer["assetid"].ToString()); string strName = lblName.Text; if (drServer["dr"].ToString() == "1") { strName += "-DR"; } // Update Recommission Reason oAsset.UpdateDecommissionRecommission(intAsset, intUser, txtReason.Text); // Set status to InUse oAsset.AddStatus(intAsset, strName, (int)AssetStatus.InUse, intUser, DateTime.Now); // Clear cv_servers_assets DECOM field oServer.UpdateAssetDecom(intServer, intAsset, ""); if (boolComplete == true) { DataSet dsOrders = oAssetOrder.GetByAsset(intAsset, false); foreach (DataRow drOrders in dsOrders.Tables[0].Rows) { int intOrder = Int32.Parse(drOrders["orderid"].ToString()); // Cancel Resource Requests int intResource = 0; if (Int32.TryParse(drOrders["resourceid"].ToString(), out intResource) == true) { oResourceRequest.UpdateStatusOverallWorkflow(intResource, (int)ResourceRequestStatus.Cancelled); } // Delete Order oAssetOrder.DeleteOrder(intOrder); // Delete Asset Order Asset Selection oAssetOrder.DeleteAssetOrderAssetSelection(intOrder, intAsset); } // Set NewOrderID = 0 oAsset.updateNewOrderId(0, intAsset); } // Set strAssets to assets recommissioned (for status message on postback) if (strAssets != "") { strAssets += strSplit[0].ToString(); } strAssets += intAsset.ToString(); } // Remove previous decom records if (boolComplete == true) { bool boolPNC = (oServer.Get(intServer, "pnc") == "1"); // Update Server Name Record int intName = Int32.Parse(oServer.Get(intServer, "nameid")); if (boolPNC) { oServerName.UpdateFactory(intName, 0); } else { oServerName.Update(intName, 0); } } // Clear cv_servers DECOM field oServer.UpdateDecommissioned(intServer, ""); // Update IP Address(es) availability DataSet dsIP = oServer.GetIP(intServer, 0, 0, 0, 0); foreach (DataRow drIP in dsIP.Tables[0].Rows) { int intIP = Int32.Parse(drIP["ipaddressid"].ToString()); oIPAddresses.UpdateAvailable(intIP, 0); } // Restore Avamar Group(s) if (chkAvamar.Checked) { Avamar oAvamar = new Avamar(0, dsn); AvamarRegistration oAvamarRegistration = new AvamarRegistration(0, dsn); ClearViewWebServices oWebService = new ClearViewWebServices(); System.Net.NetworkCredential oCredentialsDNS = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain()); oWebService.Credentials = oCredentialsDNS; oWebService.Url = oVariable.WebServiceURL(); string strError = ""; // First, query for groups. DataSet dsGroups = oAvamar.GetDecoms(lblName.Text); if (dsGroups.Tables[0].Rows.Count > 0) { string client = dsGroups.Tables[0].Rows[0]["client"].ToString(); string grid = dsGroups.Tables[0].Rows[0]["grid"].ToString(); string domain = dsGroups.Tables[0].Rows[0]["domain"].ToString(); // Second, add the groups. foreach (DataRow drGroup in dsGroups.Tables[0].Rows) { if (String.IsNullOrEmpty(strError) == false) { break; } AvamarReturnType restore = oAvamarRegistration.API(oWebService.AddAvamarGroup(grid, domain, client, drGroup["group"].ToString())); if (restore.Error == true) { strError = restore.Message; } } // Third, remove the /Decom group AvamarReturnType decom = oAvamarRegistration.API(oWebService.DeleteAvamarGroup(grid, domain, client, oAvamar.DecomGroup)); if (decom.Error == false) { // Fourth, recommission the saved decom groups. oAvamar.UpdateDecom(client); } else { strError = decom.Message; } } if (String.IsNullOrEmpty(strError)) { oLog.AddEvent(lblName.Text, lblSerial.Text, "RECOMMISSION: Avamar completed.", LoggingType.Information); } else { oLog.AddEvent(lblName.Text, lblSerial.Text, "RECOMMISSION: Avamar encountered an error = " + strError, LoggingType.Error); } } // Add log entry oLog.AddEvent(lblName.Text, lblSerial.Text, "Asset Recommissioned (Client = " + oUser.GetFullName(intUser) + ")", LoggingType.Information); } else { // Manual recommission - just delete the resource request to get out of the person's queue int intResource = Int32.Parse(chkDevice.ToolTip.Substring(1)); oResourceRequest.UpdateStatusOverall(intResource, -2); } } } } Response.Redirect(Request.Path + "?assets=" + strAssets); }
protected void Page_Load(object sender, EventArgs e) { intProfile = Int32.Parse(Request.Cookies["profileid"].Value); oPage = new Pages(intProfile, dsn); oUser = new Users(intProfile, dsn); oServer = new Servers(intProfile, dsn); oAvamar = new Avamar(intProfile, dsn); oLocation = new Locations(intProfile, dsn); oClass = new Classes(intProfile, dsn); oResiliency = new Resiliency(intProfile, dsn); oOperatingSystem = new OperatingSystems(intProfile, dsn); oServerName = new ServerName(intProfile, dsn); oFunctions = new Functions(intProfile, dsn, intEnvironment); if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "") intApplication = Int32.Parse(Request.QueryString["applicationid"]); if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "") intPage = Int32.Parse(Request.QueryString["pageid"]); if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "") intApplication = Int32.Parse(Request.Cookies["application"].Value); if (Request.QueryString["saved"] != null) lblMessage.Text = oFunctions.BuildBox("/images/ico_check.gif", "Information Saved", "Your change has been saved successfully!", "box_green header"); if (Request.QueryString["deleted"] != null) lblMessage.Text = oFunctions.BuildBox("/images/ico_check.gif", "Record Deleted", "The record has been deleted successfully!", "box_green header"); int intMenuTab = 0; if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "") intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]); int intAddressID = 0; if (Request.QueryString["grid"] != null && Request.QueryString["grid"] != "") { intGrid = Int32.Parse(Request.QueryString["grid"]); lblCrumbs.Text += "<a href=\"" + oPage.GetFullLink(intPage) + FormURL("") + "\">Back to Home</a>"; if (Request.QueryString["domain"] != null && Request.QueryString["domain"] != "") { intDomain = Int32.Parse(Request.QueryString["domain"]); lblCrumbs.Text += strSpacer + "<a href=\"" + oPage.GetFullLink(intPage) + FormURL("grid=" + intGrid.ToString()) + "\">" + oAvamar.GetGrid(intGrid, "name") + "</a>"; panDomain.Visible = true; if (!IsPostBack) { chkDomainResiliency.DataValueField = "id"; chkDomainResiliency.DataTextField = "name"; chkDomainResiliency.DataSource = oResiliency.Gets(1); chkDomainResiliency.DataBind(); chkDomainApplication.DataValueField = "id"; chkDomainApplication.DataTextField = "name"; chkDomainApplication.DataSource = oServerName.GetComponents(1); chkDomainApplication.DataBind(); ddlDomainParent.DataValueField = "id"; ddlDomainParent.DataTextField = "FQDN"; ddlDomainParent.DataSource = oAvamar.GetDomainsGrid(intGrid, 0, 1); ddlDomainParent.DataBind(); DataSet ds = oAvamar.GetDomain(intDomain); if (ds.Tables[0].Rows.Count > 0) { txtDomainName.Text = ds.Tables[0].Rows[0]["name"].ToString(); if (ds.Tables[0].Rows[0]["root"].ToString() == "1") { txtDomainName.Enabled = false; txtDomainName.Text = "/ (ROOT)"; ddlDomainParent.Enabled = false; btnDomainUpdate.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); } else { foreach (ListItem domain in ddlDomainParent.Items) { if (domain.Value == ds.Tables[0].Rows[0]["id"].ToString()) { ddlDomainParent.Items.Remove(domain); break; } } btnDomainUpdate.Attributes.Add("onclick", "return ValidateText('" + txtDomainName.ClientID + "','Please enter a name for this domain')" + " && ProcessButton(this) && LoadWait()" + ";"); } lblCrumbs.Text += strSpacer + txtDomainName.Text; ddlDomainParent.SelectedValue = ds.Tables[0].Rows[0]["domainid"].ToString(); chkDomainCatchAll.Checked = (ds.Tables[0].Rows[0]["catchall"].ToString() == "1"); chkDomainEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1"); btnDomainUpdate.Visible = true; btnDomainDelete.Visible = true; btnDomainDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this domain')" + " && ProcessButton(this) && LoadWait()" + ";"); // Resiliencies DataSet dsResiliencies = oAvamar.GetDomainResiliencys(intDomain); foreach (DataRow drResiliency in dsResiliencies.Tables[0].Rows) { foreach (ListItem item in chkDomainResiliency.Items) { if (drResiliency["resiliencyid"].ToString() == item.Value) { item.Selected = true; break; } } } // Applications DataSet dsApplications = oAvamar.GetDomainApplications(intDomain); foreach (DataRow drApplication in dsApplications.Tables[0].Rows) { foreach (ListItem item in chkDomainApplication.Items) { if (drApplication["applicationid"].ToString() == item.Value) { item.Selected = true; break; } } } } else { btnDomainAdd.Visible = true; btnDomainAdd.Attributes.Add("onclick", "return ValidateText('" + txtDomainName.ClientID + "','Please enter a name for this domain')" + " && ProcessButton(this) && LoadWait()" + ";"); } btnDomainCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); } } else if (String.IsNullOrEmpty(Request.QueryString["group"]) == false) { intGroup = Int32.Parse(Request.QueryString["group"]); lblCrumbs.Text += strSpacer + "<a href=\"" + oPage.GetFullLink(intPage) + FormURL("grid=" + intGrid.ToString()) + "\">" + oAvamar.GetGrid(intGrid, "name") + "</a>"; panGroup.Visible = true; if (!IsPostBack) { ddlGroupDomain.DataValueField = "id"; ddlGroupDomain.DataTextField = "FQDN"; ddlGroupDomain.DataSource = oAvamar.GetDomainsGrid(intGrid, 1, 1); ddlGroupDomain.DataBind(); chkGroupOS.DataValueField = "id"; chkGroupOS.DataTextField = "name"; chkGroupOS.DataSource = oOperatingSystem.GetStandard(0); chkGroupOS.DataBind(); DataSet ds = oAvamar.GetGroup(intGroup); if (ds.Tables[0].Rows.Count > 0) { txtGroupName.Text = ds.Tables[0].Rows[0]["name"].ToString(); lblCrumbs.Text += strSpacer + txtGroupName.Text; chkGroupDaily.Checked = (ds.Tables[0].Rows[0]["daily"].ToString() == "1"); chkGroupWeekly.Checked = (ds.Tables[0].Rows[0]["weekly"].ToString() == "1"); if (chkGroupWeekly.Checked == true) divGroupWeekly.Style["display"] = "inline"; chkGroupWeeklySunday.Checked = (ds.Tables[0].Rows[0]["sunday"].ToString() == "1"); chkGroupWeeklyMonday.Checked = (ds.Tables[0].Rows[0]["monday"].ToString() == "1"); chkGroupWeeklyTuesday.Checked = (ds.Tables[0].Rows[0]["tuesday"].ToString() == "1"); chkGroupWeeklyWednesday.Checked = (ds.Tables[0].Rows[0]["wednesday"].ToString() == "1"); chkGroupWeeklyThursday.Checked = (ds.Tables[0].Rows[0]["thursday"].ToString() == "1"); chkGroupWeeklyFriday.Checked = (ds.Tables[0].Rows[0]["friday"].ToString() == "1"); chkGroupWeeklySaturday.Checked = (ds.Tables[0].Rows[0]["saturday"].ToString() == "1"); chkGroupMonthly.Checked = (ds.Tables[0].Rows[0]["monthly"].ToString() == "1"); if (chkGroupMonthly.Checked == true) divGroupMonthly.Style["display"] = "inline"; ddlGroupMonthly.SelectedValue = ds.Tables[0].Rows[0]["day"].ToString(); chk1200AM.Checked = (ds.Tables[0].Rows[0]["AM1200"].ToString() == "1"); chk100AM.Checked = (ds.Tables[0].Rows[0]["AM100"].ToString() == "1"); chk200AM.Checked = (ds.Tables[0].Rows[0]["AM200"].ToString() == "1"); chk300AM.Checked = (ds.Tables[0].Rows[0]["AM300"].ToString() == "1"); chk400AM.Checked = (ds.Tables[0].Rows[0]["AM400"].ToString() == "1"); chk500AM.Checked = (ds.Tables[0].Rows[0]["AM500"].ToString() == "1"); chk600AM.Checked = (ds.Tables[0].Rows[0]["AM600"].ToString() == "1"); chk700AM.Checked = (ds.Tables[0].Rows[0]["AM700"].ToString() == "1"); chk800AM.Checked = (ds.Tables[0].Rows[0]["AM800"].ToString() == "1"); chk900AM.Checked = (ds.Tables[0].Rows[0]["AM900"].ToString() == "1"); chk1000AM.Checked = (ds.Tables[0].Rows[0]["AM1000"].ToString() == "1"); chk1100AM.Checked = (ds.Tables[0].Rows[0]["AM1100"].ToString() == "1"); chk1200PM.Checked = (ds.Tables[0].Rows[0]["PM1200"].ToString() == "1"); chk100PM.Checked = (ds.Tables[0].Rows[0]["PM100"].ToString() == "1"); chk200PM.Checked = (ds.Tables[0].Rows[0]["PM200"].ToString() == "1"); chk300PM.Checked = (ds.Tables[0].Rows[0]["PM300"].ToString() == "1"); chk400PM.Checked = (ds.Tables[0].Rows[0]["PM400"].ToString() == "1"); chk500PM.Checked = (ds.Tables[0].Rows[0]["PM500"].ToString() == "1"); chk600PM.Checked = (ds.Tables[0].Rows[0]["PM600"].ToString() == "1"); chk700PM.Checked = (ds.Tables[0].Rows[0]["PM700"].ToString() == "1"); chk800PM.Checked = (ds.Tables[0].Rows[0]["PM800"].ToString() == "1"); chk900PM.Checked = (ds.Tables[0].Rows[0]["PM900"].ToString() == "1"); chk1000PM.Checked = (ds.Tables[0].Rows[0]["PM1000"].ToString() == "1"); chk1100PM.Checked = (ds.Tables[0].Rows[0]["PM1100"].ToString() == "1"); txtGroupThreshold.Text = ds.Tables[0].Rows[0]["threshold"].ToString(); txtGroupMaximum.Text = ds.Tables[0].Rows[0]["maximum"].ToString(); chkGroupClustering.Checked = (ds.Tables[0].Rows[0]["clustering"].ToString() == "1"); chkGroupEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1"); btnGroupUpdate.Visible = true; btnGroupUpdate.Attributes.Add("onclick", "return ValidateText('" + txtGroupName.ClientID + "','Please enter a name for this group')" + " && ProcessButton(this) && LoadWait()" + ";"); btnGroupDelete.Visible = true; btnGroupDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this group')" + " && ProcessButton(this) && LoadWait()" + ";"); // Operating Systems DataSet dsOperatingSystems = oAvamar.GetGroupOperatingSystems(intGroup); foreach (DataRow drOperatingSystem in dsOperatingSystems.Tables[0].Rows) { foreach (ListItem item in chkGroupOS.Items) { if (drOperatingSystem["osid"].ToString() == item.Value) { item.Selected = true; break; } } } } else { btnGroupAdd.Visible = true; btnGroupAdd.Attributes.Add("onclick", "return ValidateText('" + txtGroupName.ClientID + "','Please enter a name for this group')" + " && ProcessButton(this) && LoadWait()" + ";"); } btnGroupCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); chkGroupDaily.Attributes.Add("onclick", "ShowHideDiv('" + divGroupWeekly.ClientID + "','none');ShowHideDiv('" + divGroupMonthly.ClientID + "','none');"); chkGroupWeekly.Attributes.Add("onclick", "ShowHideDiv('" + divGroupWeekly.ClientID + "','inline');ShowHideDiv('" + divGroupMonthly.ClientID + "','none');"); chkGroupMonthly.Attributes.Add("onclick", "ShowHideDiv('" + divGroupWeekly.ClientID + "','none');ShowHideDiv('" + divGroupMonthly.ClientID + "','inline');"); } } else if (String.IsNullOrEmpty(Request.QueryString["location"]) == false) { intLocation = Int32.Parse(Request.QueryString["location"]); lblCrumbs.Text += strSpacer + "<a href=\"" + oPage.GetFullLink(intPage) + FormURL("grid=" + intGrid.ToString()) + "\">" + oAvamar.GetGrid(intGrid, "name") + "</a>"; panLocation.Visible = true; if (!IsPostBack) { DataSet ds = oAvamar.GetLocation(intLocation); if (ds.Tables[0].Rows.Count > 0) { intAddressID = Int32.Parse(ds.Tables[0].Rows[0]["addressid"].ToString()); lblCrumbs.Text += strSpacer + oLocation.GetFull(intAddressID); chkLocationEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1"); btnLocationUpdate.Visible = true; btnLocationUpdate.Attributes.Add("onclick", "return ValidateHidden0('" + hdnLocation.ClientID + "','ddlCommonLocation','Please select a location')" + " && ProcessButton(this) && LoadWait()" + ";"); btnLocationDelete.Visible = true; btnLocationDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this location')" + " && ProcessButton(this) && LoadWait()" + ";"); } else { btnLocationAdd.Visible = true; btnLocationAdd.Attributes.Add("onclick", "return ValidateHidden0('" + hdnLocation.ClientID + "','ddlCommonLocation','Please select a location')" + " && ProcessButton(this) && LoadWait()" + ";"); } btnLocationCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); strLocation = oLocation.LoadDDL("ddlStateLocation", "ddlCityLocation", "ddlAddressLocation", hdnLocation.ClientID, intAddressID, true, "ddlCommonLocation"); } } else if (String.IsNullOrEmpty(Request.QueryString["environment"]) == false) { intEnv = Int32.Parse(Request.QueryString["environment"]); lblCrumbs.Text += strSpacer + "<a href=\"" + oPage.GetFullLink(intPage) + FormURL("grid=" + intGrid.ToString()) + "\">" + oAvamar.GetGrid(intGrid, "name") + "</a>"; panEnvironment.Visible = true; if (!IsPostBack) { ddlClass.DataTextField = "name"; ddlClass.DataValueField = "id"; ddlClass.DataSource = oClass.GetForecasts(1); ddlClass.DataBind(); ddlClass.Items.Insert(0, new ListItem("-- SELECT --", "0")); DataSet ds = oAvamar.GetEnvironment(intEnv); if (ds.Tables[0].Rows.Count > 0) { int intClassID = Int32.Parse(ds.Tables[0].Rows[0]["classid"].ToString()); try { ddlClass.SelectedValue = intClassID.ToString(); } catch { } if (ddlClass.SelectedIndex == 0) { // Class is not available, add it. ddlClass.Items.Add(new ListItem(oClass.Get(intClassID, "name") + " *", intClassID.ToString())); ddlClass.SelectedValue = intClassID.ToString(); } int intEnvironmentID = Int32.Parse(ds.Tables[0].Rows[0]["environmentid"].ToString()); hdnEnvironment.Value = intEnvironmentID.ToString(); ddlEnvironment.DataTextField = "name"; ddlEnvironment.DataValueField = "id"; ddlEnvironment.DataSource = oClass.GetEnvironment(intClassID, 1); ddlEnvironment.DataBind(); ddlEnvironment.Items.Insert(0, new ListItem("-- SELECT --", "0")); ddlEnvironment.Enabled = true; ddlEnvironment.SelectedValue = intEnvironmentID.ToString(); chkEnvironmentEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1"); btnEnvironmentUpdate.Visible = true; btnEnvironmentUpdate.Attributes.Add("onclick", "return ValidateDropDown('" + ddlClass.ClientID + "','Please select a class')" + " && ValidateHidden0('" + hdnEnvironment.ClientID + "','" + ddlEnvironment.ClientID + "','Please select an environment')" + " && ProcessButton(this) && LoadWait()" + ";"); btnEnvironmentDelete.Visible = true; btnEnvironmentDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this location')" + " && ProcessButton(this) && LoadWait()" + ";"); } else { btnEnvironmentAdd.Visible = true; btnEnvironmentAdd.Attributes.Add("onclick", "return ValidateDropDown('" + ddlClass.ClientID + "','Please select a class')" + " && ValidateHidden0('" + hdnEnvironment.ClientID + "','" + ddlEnvironment.ClientID + "','Please select an environment')" + " && ProcessButton(this) && LoadWait()" + ";"); } btnEnvironmentCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); ddlClass.Attributes.Add("onchange", "PopulateEnvironments('" + ddlClass.ClientID + "','" + ddlEnvironment.ClientID + "',1);"); ddlEnvironment.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlEnvironment.ClientID + "','" + hdnEnvironment.ClientID + "');"); } } else { panGrid.Visible = true; if (!IsPostBack) { //Menus oTab = new Tab(hdnType.ClientID, intMenuTab, "divMenu1", true, false); oTab.AddTab("Domains", ""); DataSet dsDomains = oAvamar.GetDomainsGrid(intGrid, 0, 0); DataView dvDomains = dsDomains.Tables[0].DefaultView; if (Request.QueryString["sort"] != null) dvDomains.Sort = Request.QueryString["sort"]; else dvDomains.Sort = "name"; rptDomains.DataSource = dvDomains; rptDomains.DataBind(); lblDomains.Visible = (rptDomains.Items.Count == 0); oTab.AddTab("Groups", ""); DataSet dsGroups = oAvamar.GetGroupsGrid(intGrid, 0); DataView dvGroups = dsGroups.Tables[0].DefaultView; if (Request.QueryString["sort"] != null) dvGroups.Sort = Request.QueryString["sort"]; else dvGroups.Sort = "name"; rptGroups.DataSource = dvGroups; rptGroups.DataBind(); lblGroups.Visible = (rptGroups.Items.Count == 0); oTab.AddTab("Locations", ""); DataSet dsLocations = oAvamar.GetLocations(intGrid, 0); DataView dvLocations = dsLocations.Tables[0].DefaultView; if (Request.QueryString["sort"] != null) dvLocations.Sort = Request.QueryString["sort"]; else dvLocations.Sort = "addressid"; rptLocations.DataSource = dvLocations; rptLocations.DataBind(); lblLocations.Visible = (rptLocations.Items.Count == 0); oTab.AddTab("Environments", ""); DataSet dsEnvironments = oAvamar.GetEnvironments(intGrid, 0); DataView dvEnvironments = dsEnvironments.Tables[0].DefaultView; if (Request.QueryString["sort"] != null) dvEnvironments.Sort = Request.QueryString["sort"]; else dvEnvironments.Sort = "classid"; rptEnvironments.DataSource = dvEnvironments; rptEnvironments.DataBind(); lblEnvironments.Visible = (rptEnvironments.Items.Count == 0); strMenuTab1 = oTab.GetTabs(); DataSet ds = oAvamar.GetGrid(intGrid); if (ds.Tables[0].Rows.Count > 0) { txtGridName.Text = ds.Tables[0].Rows[0]["name"].ToString(); lblCrumbs.Text += strSpacer + txtGridName.Text; txtGridThreshold.Text = ds.Tables[0].Rows[0]["threshold"].ToString(); txtGridMaximum.Text = ds.Tables[0].Rows[0]["maximum"].ToString(); chkGridEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1"); btnGridUpdate.Visible = true; btnGridUpdate.Attributes.Add("onclick", "return ValidateText('" + txtGridName.ClientID + "','Please enter a name for this grid')" + " && ProcessButton(this) && LoadWait()" + ";"); btnGridDelete.Visible = true; btnGridDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this server')" + " && ProcessButton(this) && LoadWait()" + ";"); } else { btnGridAdd.Visible = true; btnGridAdd.Attributes.Add("onclick", "return ValidateText('" + txtGridName.ClientID + "','Please enter a name for this grid')" + " && ProcessButton(this) && LoadWait()" + ";"); btnAddDomain.Enabled = false; btnAddLocation.Enabled = false; btnAddEnvironment.Enabled = false; btnAddGroup.Enabled = false; } btnGridCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); strLocation = oLocation.LoadDDL("ddlStateServer", "ddlCityServer", "ddlAddressServer", hdnLocation.ClientID, intAddressID, true, "ddlCommonServer"); } } } else { panGrids.Visible = true; DataSet dsGrids = oAvamar.GetGrids(0); DataView dvGrids = dsGrids.Tables[0].DefaultView; if (Request.QueryString["sort"] != null) dvGrids.Sort = Request.QueryString["sort"]; else dvGrids.Sort = "name"; rptGrids.DataSource = dvGrids; rptGrids.DataBind(); lblGrids.Visible = (rptGrids.Items.Count == 0); } hdnLocation.Value = intAddressID.ToString(); btnAddDomain.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); btnAddLocation.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); btnAddEnvironment.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); btnAddGroup.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); btnAddGrid.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();"); }
protected void btnDecom_Click(object sender, EventArgs e) { Variables oVariable = new Variables((int)CurrentEnvironment.PNCNT_DEV); string grid = "yb19-avr01-01.test.pncbank.com"; string domain = "/BRII"; string client = "WDCLV015A.pncbank.com"; string strError = ""; Avamar oAvamar = new Avamar(0, dsn); AvamarRegistration oAvamarRegistration = new AvamarRegistration(0, dsn); ClearViewWebServices oWebService = new ClearViewWebServices(); System.Net.NetworkCredential oCredentialsDNS = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain()); oWebService.Credentials = oCredentialsDNS; oWebService.Url = oVariable.WebServiceURL(); // First, query for groups. AvamarReturnType groups = oAvamarRegistration.API(oWebService.GetAvamarClient(grid, domain, client)); if (groups.Error == false) { List <string> members = new List <string>(); foreach (XmlNode node in groups.Nodes) { if (node["Attribute"].InnerText == "Member of Group") { members.Add(node["Value"].InnerText); } } if (members.Count > 0) { // Second, add /Decom group (so there will always be at least one group) AvamarReturnType decom = oAvamarRegistration.API(oWebService.AddAvamarGroup(grid, domain, client, oAvamar.DecomGroup)); if (decom.Error == false) { oAvamar.DeleteDecom(client); foreach (string member in members) { if (String.IsNullOrEmpty(strError) == false) { break; } // Third, remove groups (one at a time) AvamarReturnType remove = oAvamarRegistration.API(oWebService.DeleteAvamarGroup(grid, domain, client, member)); if (remove.Error == false) { // Fourth, save groups. oAvamar.AddDecom(client, grid, domain, member); } else { strError = remove.Message; } } } else { strError = decom.Message; } } } else { strError = groups.Message; } }