protected void ResetServerAccessButton_Click(object sender, EventArgs e)
 {
     ServerAccessTreeList.DataSource = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetServersFromProcedure();
     ServerAccessTreeList.DataBind();
     ServerAccessTreeList.SelectAll();
     ServerAccessTreeList.ExpandAll();
 }
        private void RemoveRestricted()
        {
            string    uname        = "";
            DataTable dt           = new DataTable();
            DataTable AllServersDT = new DataTable();
            DataTable ServerRestrictedDataTable = new DataTable();

            if (Request.QueryString["FullName"] != null && Request.QueryString["FullName"] != "")
            {
                uname = Request.QueryString["FullName"].ToString();
            }
            if (Session["AllServerAccessList"] != null && Session["AllServerAccessList"] != "")
            {
                AllServersDT = (DataTable)Session["AllServerAccessList"];
            }
            ServerRestrictedDataTable = VSWebBL.SecurityBL.AdminTabBL.Ins.GetAllServersNotVisible(uname);
            if (AllServersDT.Rows.Count > 0)
            {
                dt = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetServersFromProcedure();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        if (row.ItemArray[5].ToString() == "7")
                        {
                            row.Delete();
                        }
                    }
                    dt.AcceptChanges();
                }
                ServerAccessTreeList.DataSource = dt;
                ServerAccessTreeList.DataBind();
                if (ServerRestrictedDataTable.Rows.Count > 0)
                {
                    List <int> ServerID   = new List <int>();
                    List <int> LocationID = new List <int>();
                    foreach (DataRow resser in ServerRestrictedDataTable.Rows)
                    {
                        foreach (DataRow allrow in AllServersDT.Rows)
                        {
                            if (resser["ID"].ToString() == allrow["actid"].ToString())
                            {
                                if (allrow["locid"] != null && allrow["locid"].ToString() != "" && resser["LocId"].ToString() == allrow["locid"].ToString())
                                {
                                    ServerID.Add(AllServersDT.Rows.IndexOf(allrow));
                                }
                            }
                        }
                    }
                    foreach (int Id in ServerID)
                    {
                        AllServersDT.Rows[Id].Delete();
                    }
                    AllServersDT.AcceptChanges();
                    try
                    {
                        TreeListNodeIterator iterator = ServerAccessTreeList.CreateNodeIterator();
                        TreeListNode         node;
                        string locid     = "";
                        string actid     = "";
                        string srvtypeid = "";
                        while (true)
                        {
                            node = iterator.GetNext();
                            if (node == null)
                            {
                                break;
                            }
                            if (node.Level == 2)
                            {
                                if (node.GetValue("LocId") != null)
                                {
                                    locid     = node.GetValue("LocId").ToString();
                                    actid     = node.GetValue("actid").ToString();
                                    srvtypeid = node.GetValue("srvtypeid").ToString();
                                    DataRow[] foundrows = AllServersDT.Select("LocId=" + locid + " AND actid=" + actid + " AND srvtypeid=" + srvtypeid);
                                    if (foundrows.Length > 0)
                                    {
                                        node.Selected = true;
                                    }
                                }
                            }
                        }
                        ServerAccessTreeList.ExpandAll();
                        Session["ServerAccessList"] = AllServersDT;
                    }
                    catch (Exception ex)
                    {
                        Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                        throw ex;
                    }
                }
                else
                {
                    ServerAccessTreeList.SelectAll();
                }
            }
        }