Beispiel #1
0
        private void GetSelectedServers()
        {
            DataTable dtSel   = new DataTable();
            DataTable dtUnSel = new DataTable();

            try
            {
                dtSel.Columns.Add("ServerID");
                dtSel.Columns.Add("Name");
                dtSel.Columns.Add("ServerType");

                dtUnSel.Columns.Add("ServerID");
                dtUnSel.Columns.Add("Name");
                dtUnSel.Columns.Add("ServerType");

                //string selValues = "";
                TreeListNodeIterator iterator = ServersTreeList.CreateNodeIterator();
                TreeListNode         node;

                while (true)
                {
                    node = iterator.GetNext();

                    if (node == null)
                    {
                        break;
                    }
                    if (node.Level == 2) //(node.ParentNode.Selected==false)
                    {
                        if (node.Selected)
                        {
                            DataRow dr = dtSel.NewRow();
                            dr["ServerID"]   = node.GetValue("actid");
                            dr["Name"]       = node.GetValue("Name");
                            dr["ServerType"] = node.GetValue("ServerType");
                            dtSel.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dtUnSel.NewRow();
                            dr["ServerID"]   = node.GetValue("actid");
                            dr["Name"]       = node.GetValue("Name");
                            dr["ServerType"] = node.GetValue("ServerType");
                            dtUnSel.Rows.Add(dr);
                        }
                    }
                }
                Session["SelectedServers"]   = dtSel;
                Session["UnSelectedServers"] = dtUnSel;
            }
            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;
            }
        }
Beispiel #2
0
        public void fillServersTreeList()
        {
            try
            {
                ServersTreeList.CollapseAll();
                CollapseAllSrvButton.Image.Url = "~/images/icons/add.png";
                CollapseAllSrvButton.Text      = "Expand All";
                if (Session["DataServers"] == null)
                {
                    DataTable DataServersTree = VSWebBL.ConfiguratorBL.ELSBL.Ins.GetServersFromProcedure();
                    Session["DataServers"] = DataServersTree;
                }
                ServersTreeList.DataSource = (DataTable)Session["DataServers"];
                ServersTreeList.DataBind();

                DataTable dtSel = VSWebBL.ConfiguratorBL.ELSBL.Ins.GetSelectedServers(EventKey);
                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]["LocationID"]) == 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]["LocationID"]) != 0))
                        {
                            //parent selected
                            while (true)
                            {
                                node = iterator.GetNext();
                                if (node == null)
                                {
                                    break;
                                }
                                if ((Convert.ToInt32(dtSel.Rows[i]["LocationID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() == "Locations")
                                {
                                    node.Selected = true;
                                }
                                else if (node.GetValue("LocId").ToString() != "")
                                {
                                    if ((Convert.ToInt32(dtSel.Rows[i]["LocationID"]) == Convert.ToInt32(node.GetValue("LocId"))) && node.GetValue("tbl").ToString() != "Locations")
                                    {
                                        node.Selected = true;
                                    }
                                }
                            }
                        }
                        else if (Convert.ToInt32(dtSel.Rows[i]["ServerID"]) != 0 && (Convert.ToInt32(dtSel.Rows[i]["LocationID"]) != 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() != "Locations")
                                {
                                    node.Selected = true;
                                }
                            }
                        }
                        iterator.Reset();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
            }
        }
Beispiel #3
0
        private DataTable GetSelectedServers(int EventKey)
        {
            DataTable dtSel = new DataTable();

            try
            {
                dtSel.Columns.Add("EventKey");
                dtSel.Columns.Add("ServerID");
                dtSel.Columns.Add("LocationID");
                dtSel.Columns.Add("ServerTypeID");

                TreeListNodeIterator iterator = ServersTreeList.CreateNodeIterator();
                TreeListNode         node;

                TreeListColumn columnActid     = ServersTreeList.Columns["actid"];
                TreeListColumn columnSrvId     = ServersTreeList.Columns["LocId"];
                TreeListColumn columnTbl       = ServersTreeList.Columns["tbl"];
                TreeListColumn columnSrvTypeId = ServersTreeList.Columns["srvtypeid"];
                while (true)
                {
                    node = iterator.GetNext();

                    if (node == null)
                    {
                        break;
                    }
                    //if (node.Level == 1 && node.ParentNode.Selected)
                    //{
                    //    // root node selected ie All Servers selected
                    //    DataRow dr = dtSel.NewRow();
                    //    dr["EventKey"] = EventKey;
                    //    dr["ServerID"] =  node.GetValue("actid");
                    //    dr["LocationID"] = node.GetValue("LocId");
                    //    dr["ServerTypeID"] = node.GetValue("srvtypeid");
                    //    dtSel.Rows.Add(dr);
                    //    break;
                    //}
                    //else if (node.Level == 1 && node.ParentNode.Selected == false && node.Selected)
                    //{

                    //    DataRow dr = dtSel.NewRow();
                    //    dr["EventKey"] = EventKey;
                    //    dr["ServerID"] = node.GetValue("actid");
                    //    dr["LocationID"] = ((System.Data.DataRowView)(node.DataItem)).Row.ItemArray[3];// node.GetValue("LocId");
                    //    dr["ServerTypeID"] = node.GetValue("srvtypeid");
                    //    dtSel.Rows.Add(dr);
                    //}
                    //else
                    if (node.Level == 2)                     //(node.ParentNode.Selected==false)
                    {
                        if (node.Selected)
                        {
                            DataRow dr = dtSel.NewRow();
                            dr["EventKey"]     = EventKey;
                            dr["ServerID"]     = node.GetValue("actid");
                            dr["LocationID"]   = node.GetValue("LocId");
                            dr["ServerTypeID"] = node.GetValue("srvtypeid");
                            dtSel.Rows.Add(dr);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
            }

            return(dtSel);
        }