public void fillServersTreeList() { try { DataTable DataServersTree = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetServersFromProcedure(); string PrimaryNode = ""; DataTable ServerNodes = Session["ServerNodes"] as DataTable; if (ServerNodes != null && ServerNodes.Rows.Count > 0) { PrimaryNode = ServerNodes.Rows[0][1].ToString(); } foreach (DataRow dr in DataServersTree.Rows) { if (dr["LocId"].ToString() != "") { if (dr["MonitoredBy"].ToString() == "") { if (PrimaryNode != "") { dr["MonitoredBy"] = "Unassigned(Monitored by " + PrimaryNode + ")"; } else { dr["MonitoredBy"] = "Unassigned"; } } } } Session["DataServers"] = DataServersTree; ServersTreeList.DataSource = (DataTable)Session["DataServers"]; ServersTreeList.DataBind(); ServersTreeList.ExpandAll(); ServersTreeList.UnselectAll(); } catch (Exception ex) { //Log.Entry.Ins.Write(Server.MapPath("~/LogFiles/"), "VSPlusLog.txt", DateTime.Now.ToString() + " Error in Page: " + // Request.Url.AbsolutePath + ", Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name + // ", Error: " + ex.ToString()); Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } }
//private UserProfileMaster CollectDataForUserProfiles(string Mode, int id) //{ // try // { // UserProfileMaster UserProfilesObject = new UserProfileMaster(); // UserProfilesObject.Name = ProfileTextBox.Text;// UserProfilesRow["Name"].ToString(); // if (Mode == "Update") // UserProfilesObject.ID = id;// int.Parse(UserProfilesRow["ID"].ToString()); // return UserProfilesObject; // } // catch (Exception ex) // { throw ex; } // finally { } //} //protected void CancelButton_Click(object sender, EventArgs e) //{ // Response.Redirect("UserProfilesGrid.aspx"); //} //public void fillServersTreeListfromSession() //{ // try // { // if (Session["DataServers"] != null) // { // DataTable ServersGridViewTable = new DataTable(); // if (Session["DataServers"] != null && Session["DataServers"] != "") // { // ServersGridViewTable = (DataTable)Session["DataServers"]; // } // if (ServersGridViewTable.Rows.Count > 0) // { // ServersGridView.DataSource = (DataTable)Session["DataServers"]; // ServersGridView.DataBind(); // } // } // // DataTable DataServersTree = VSWebBL.SecurityBL.ServersBL.Ins.GetAllDataByServerType(ServerTypeComboBox.SelectedItem.Text); // // Session["DataServers"] = DataServersTree; // //} // //ServersGridView.DataSource = (DataTable)Session["DataServers"]; // //ServersGridView.DataBind(); // //DataTable dtSel = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetSelectedServers(AlertKey); // //if (dtSel.Rows.Count > 0) // //{ // // TreeListNodeIterator iterator = ServersTreeList.CreateNodeIterator(); // // TreeListNode node; // // for (int i = 0; i < dtSel.Rows.Count; i++) // // { // // if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) == 0 && Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) == 0) // // { // // //select all // // while (true) // // { // // node = iterator.GetNext(); // // if (node == null) break; // // node.Selected = true; // // } // // } // // else if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) == 0 && (Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) != 0)) // // { // // //parent selected // // while (true) // // { // // node = iterator.GetNext(); // // if (node == null) break; // // if ((Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() == "UserProfiles") // // { // // node.Selected = true; // // } // // else if (node.GetValue("LocId").ToString() != "") // // { // // if ((Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) == Convert.ToInt32(node.GetValue("LocId"))) && node.GetValue("tbl").ToString() != "UserProfiles") // // { // // node.Selected = true; // // } // // } // // } // // } // // else if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) != 0 && (Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) != 0)) // // { // // //specific selected // // while (true) // // { // // node = iterator.GetNext(); // // if (node == null) break; // // if ((Convert.ToInt32(dtSel.Rows[i]["ServerID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() != "UserProfiles") // // { // // node.Selected = true; // // } // // } // // } // // iterator.Reset(); // // } // //} // } // catch (Exception ex) // { // } //} //public void fillServersTreeList() //{ // try // { // if (Session["DataServers"] == null) // { // DataTable DataServersTree = VSWebBL.SecurityBL.ServersBL.Ins.GetAllDataByServerType(ServerTypeComboBox.SelectedItem.Text); // Session["DataServers"] = DataServersTree; // } // ServersGridView.DataSource = (DataTable)Session["DataServers"]; // ServersGridView.DataBind(); // //DataTable dtSel = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetSelectedServers(AlertKey); // //if (dtSel.Rows.Count > 0) // //{ // // TreeListNodeIterator iterator = ServersTreeList.CreateNodeIterator(); // // TreeListNode node; // // for (int i = 0; i < dtSel.Rows.Count; i++) // // { // // if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) == 0 && Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) == 0) // // { // // //select all // // while (true) // // { // // node = iterator.GetNext(); // // if (node == null) break; // // node.Selected = true; // // } // // } // // else if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) == 0 && (Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) != 0)) // // { // // //parent selected // // while (true) // // { // // node = iterator.GetNext(); // // if (node == null) break; // // if ((Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() == "UserProfiles") // // { // // node.Selected = true; // // } // // else if (node.GetValue("LocId").ToString() != "") // // { // // if ((Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) == Convert.ToInt32(node.GetValue("LocId"))) && node.GetValue("tbl").ToString() != "UserProfiles") // // { // // node.Selected = true; // // } // // } // // } // // } // // else if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) != 0 && (Convert.ToInt32(dtSel.Rows[i]["UserProfileID"]) != 0)) // // { // // //specific selected // // while (true) // // { // // node = iterator.GetNext(); // // if (node == null) break; // // if ((Convert.ToInt32(dtSel.Rows[i]["ServerID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() != "UserProfiles") // // { // // node.Selected = true; // // } // // } // // } // // iterator.Reset(); // // } // //} // } // catch (Exception ex) // { // } //} public void ApplyToServers_Click(object sender, EventArgs e) { //12/12/2013 NS added errorDiv.Style.Value = "display: none;"; errorDiv2.Style.Value = "display: none"; List <object> fieldValues = ProfilesGridView.GetSelectedFieldValues(new string[] { "RelatedField", "DefaultValue", "RelatedTable" }); //List<object> serversSelected = ServersGridView.GetSelectedFieldValues(new string[] {"ID","ServerName" }); DataTable dt = GetSelectedServers(); List <DataRow> serversSelected = dt.AsEnumerable().ToList(); //List<DataRow> list = dt.AsEnumerable().ToList(); int Update = 0; string ServerErrors = ""; if (fieldValues.Count > 0 && serversSelected.Count > 0) { GridViewDataColumn column2 = ProfilesGridView.Columns["DefaultValue"] as GridViewDataColumn; List <ProfilesMaster> list = new List <ProfilesMaster>(); int startIndex = ProfilesGridView.PageIndex * ProfilesGridView.SettingsPager.PageSize; int endIndex = Math.Min(ProfilesGridView.VisibleRowCount, startIndex + ProfilesGridView.SettingsPager.PageSize); int ProfileMasterID = 0; for (int i = 0; i < ProfilesDataTable.Rows.Count; i++) { if (ProfilesDataTable.Rows[i]["isSelected"].ToString() == "true") { ProfileMasterID = Convert.ToInt32(ProfilesDataTable.Rows[i]["ID"]); list.Add(new ProfilesMaster(0, 0, "", ProfilesDataTable.Rows[i]["AttributeName"].ToString(), "", ProfilesDataTable.Rows[i]["DefaultValue"].ToString(), ProfilesDataTable.Rows[i]["RelatedTable"].ToString(), ProfilesDataTable.Rows[i]["RelatedField"].ToString())); //list.Add(new UserProfileDetailed(i, UserProfileMasterID, ProfileMasterID, ProfilesDataTable.Rows[i]["DefaultValue"].ToString())); } } //for (int i = 0; i < ProfilesGridView.VisibleRowCount; i++) //{ // if (ProfilesGridView.Selection.IsRowSelected(i)) // { // ASPxTextBox txtValue = (ASPxTextBox)ProfilesGridView.FindRowCellTemplateControl(i, column2, "txtValue"); // int ProfileMasterID = Convert.ToInt32(ProfilesGridView.GetRowValues(i, ProfilesGridView.KeyFieldName)); // list.Add(new ProfilesMaster(0, 0, "", "", "", txtValue.Text, ProfilesGridView.GetRowValues(i, "RelatedTable").ToString(), ProfilesGridView.GetRowValues(i, "RelatedField").ToString())); // //i, UserProfileMasterID, ProfileMasterID, txtValue.Text // } //} //foreach (object[] server in serversSelected) string AppliedServers = ""; foreach (DataRow server in serversSelected) { Update = VSWebBL.SecurityBL.UserProfileMasterBL.Ins.UpdateServerSettings(Convert.ToInt32(server[0]), list); if (Update == 0) { //12/12/2013 NS modified if (ServerErrors == "") { ServerErrors += server[1].ToString(); } else { ServerErrors += ", " + server[1].ToString(); } } else { //12/12/2013 NS modified if (AppliedServers == "") { AppliedServers += server[1].ToString(); } else { AppliedServers += ", " + server[1].ToString(); } } } if (ServerErrors != "") { //12/12/2013 NS modified //lblError.Text = "Settings for servers :" + ServerErrors + " are NOT updated"; errorDiv2.InnerHtml = "Settings for the server(s) " + ServerErrors + " were NOT updated."; errorDiv2.Style.Value = "display: block"; //lblMessage.ForeColor = } else { string parameters = ""; int count = 0; foreach (ProfilesMaster fieldValue in list) { if (count == 0) { parameters += fieldValue.AttributeName + " = " + fieldValue.DefaultValue; count++; } else { parameters += ", " + fieldValue.AttributeName + " = " + fieldValue.DefaultValue; } } ProfilesGridView.Selection.UnselectAll(); ServersTreeList.UnselectAll(); //12/12/2013 NS moved the code into the else block, otherwise on unsuccessful apply //the whole server list would get wiped out //Clearing the Data Grids ServerTypeComboBox.SelectedIndex = -1; ProfilesGridView.DataSource = null; ProfilesGridView.DataBind(); //ServersGridView.DataSource = null; //ServersGridView.DataBind(); ServersTreeList.ClearNodes(); ServersTreeList.DataSource = null; ServersTreeList.DataBind(); Session["DataServers"] = null; Session["Profiles"] = null; //12/12/2013 NS modified //lblMessage.Text = "Settings: " + parameters + " for the selected servers: " + AppliedServers + " are updated"; successDiv.InnerHtml = "The following settings for the server(s) " + AppliedServers + " were successfully updated: " + parameters; successDiv.Style.Value = "display: block"; ApplyServersButton.Style.Value = "visibility: hidden"; tblServer.Style.Value = "visibility: hidden"; } } else { //12/12/2013 NS modified //lblError.Text = "Please select required Attributes and Servers"; errorDiv.Style.Value = "display: block"; } }