protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["DataEvents"] = null; Session["DataServers"] = null; if (Request.QueryString["Mode"] != null) { string Mode = Request.QueryString["Mode"].ToString(); } if (Request.QueryString["Key"] != null) { Mode = "update"; ID = Convert.ToInt32(Request.QueryString["Key"].ToString()); Session["id"] = ID; filldata(Convert.ToInt32(Session["id"].ToString())); } else { Mode = "insert"; } if (Session["UserPreferences"] != null) { DataTable UserPreferences = (DataTable)Session["UserPreferences"]; foreach (DataRow dr in UserPreferences.Rows) { if (dr[1].ToString() == "AlertEventTemplate_Edit|EventsTreeList") { EventsTreeList.SettingsPager.PageSize = Convert.ToInt32(dr[2]); } } } //fillEventsTreeList(); } else { fillEventsTreefromSession(); } if (!IsPostBack) { fillEventsTreeList(); EventsTreeList.CollapseAll(); } else { //fillEventsTreeList(); fillEventsTreefromSession(); EventsTreeList.CollapseAll(); } }
//private DataTable GetSelectedEvents(int AlertKey) //{ // DataTable dtSel = new DataTable(); // try // { // dtSel.Columns.Add("AlertKey"); // dtSel.Columns.Add("EventID"); // dtSel.Columns.Add("ServerTypeID"); // //10/16/2014 NS added // dtSel.Columns.Add("ConsecutiveFailures"); // //string selValues = ""; // TreeListNodeIterator iterator = EventsTreeList.CreateNodeIterator(); // TreeListNode node; // //TreeListColumn columnActid = EventsTreeList.Columns["actid"]; // TreeListColumn columnActid = EventsTreeList.Columns["actid"]; // TreeListColumn columnSrvId = EventsTreeList.Columns["SrvId"]; // TreeListColumn columnTbl = EventsTreeList.Columns["tbl"]; // while (true) // { // node = iterator.GetNext(); // if (node == null) break; // if (node.Level == 1 && node.ParentNode.Selected) // { // // root node selected ie All Events selected // DataRow dr = dtSel.NewRow(); // dr["AlertKey"] = AlertKey; // dr["EventID"] = 0;// node.GetValue("actid"); // dr["ServerTypeID"] = 0;//node.GetValue("SrvId"); // dtSel.Rows.Add(dr); // break; // } // else if (node.Level == 1 && node.ParentNode.Selected == false && node.Selected) // { // // level 1 node selected ie One Servertype selected and all events under it // DataRow dr = dtSel.NewRow(); // dr["AlertKey"] = AlertKey; // dr["EventID"] = 0;//node.GetValue("actid"); // dr["ServerTypeID"] = ((System.Data.DataRowView)(node.DataItem)).Row.ItemArray[3];//node.GetValue("SrvId"); // dtSel.Rows.Add(dr); // } // else if (node.Level == 2 && node.ParentNode.Selected == false) // { // if (node.Selected) // { // DataRow dr = dtSel.NewRow(); // dr["AlertKey"] = AlertKey; // dr["EventID"] = node.GetValue("actid"); // dr["ServerTypeID"] = node.GetValue("SrvId"); // //10/16/2014 NS added // dr["ConsecutiveFailures"] = node.GetValue("ConsecutiveFailures"); // dtSel.Rows.Add(dr); // } // } // } // } // 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()); // //6/27/2014 NS added for VSPLUS-634 // Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); // } // return dtSel; //} private DataTable GetSelectedEvents(int AlertKey) { DataTable dtSel = new DataTable(); try { dtSel.Columns.Add("AlertKey"); dtSel.Columns.Add("EventID"); dtSel.Columns.Add("ServerTypeID"); //10/16/2014 NS added dtSel.Columns.Add("ConsecutiveFailures"); //string selValues = ""; TreeListNodeIterator iterator = EventsTreeList.CreateNodeIterator(); TreeListNode node; //TreeListColumn columnActid = EventsTreeList.Columns["actid"]; TreeListColumn columnActid = EventsTreeList.Columns["actid"]; TreeListColumn columnSrvId = EventsTreeList.Columns["SrvId"]; TreeListColumn columnTbl = EventsTreeList.Columns["tbl"]; while (true) { node = iterator.GetNext(); if (node == null) { break; } //if (node.Level == 1 && node.ParentNode.Selected) //{ // // root node selected ie All Events selected // DataRow dr = dtSel.NewRow(); // dr["AlertKey"] = AlertKey; // dr["EventID"] = 0;// node.GetValue("actid"); // dr["ServerTypeID"] = 0;//node.GetValue("SrvId"); // dtSel.Rows.Add(dr); // break; //} //else if (node.Level == 1 && node.ParentNode.Selected == false && node.Selected) //{ // // level 1 node selected ie One Servertype selected and all events under it // DataRow dr = dtSel.NewRow(); // dr["AlertKey"] = AlertKey; // dr["EventID"] = node.GetValue("actid"); // dr["ServerTypeID"] = ((System.Data.DataRowView)(node.DataItem)).Row.ItemArray[3];//node.GetValue("SrvId"); // dtSel.Rows.Add(dr); //} //else if (node.Level == 2) // && node.ParentNode.Selected == false) { if (node.Selected) { DataRow dr = dtSel.NewRow(); dr["AlertKey"] = AlertKey; dr["EventID"] = node.GetValue("actid"); dr["ServerTypeID"] = node.GetValue("SrvId"); //10/16/2014 NS added dr["ConsecutiveFailures"] = node.GetValue("ConsecutiveFailures"); dtSel.Rows.Add(dr); } } } } 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()); //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } return(dtSel); }
//public void fillEventsTreeList() //{ // try // { // EventsTreeList.CollapseAll(); // CollapseAllButton.Image.Url = "~/images/icons/add.png"; // CollapseAllButton.Text = "Expand All"; // if (Session["DataEvents"] == null) // { // DataTable DataEventsTree = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetEventsFromProcedure(); // Session["DataEvents"] = DataEventsTree; // } // EventsTreeList.DataSource = (DataTable)Session["DataEvents"]; // EventsTreeList.DataBind(); // DataTable dtSel = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetSelectedEventsfortemplate(Convert.ToInt32(Session["id"].ToString())); // string s = dtSel.Rows[0]["EventID"].ToString(); // string[] words = s.Split(','); // DataTable dt = new DataTable(); // dt.Columns.Add("EventID"); // foreach (string str in words) // { // DataRow drow = dt.NewRow(); // Here you will get an actual instance of a DataRow // drow["EventID"] = str; // Assign values // dt.Rows.Add(drow); // Don't forget to add the row to the DataTable. // } // if (dtSel.Rows.Count > 0) // { // TreeListNodeIterator iterator = EventsTreeList.CreateNodeIterator(); // TreeListNode node; // for (int i = 0; i < dtSel.Rows.Count; i++) // { // if (Convert.ToInt32(dtSel.Rows[i]["EventID"]) == 0 && Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) == 0) // { // //select all // while (true) // { // node = iterator.GetNext(); // if (node == null) break; // node.Selected = true; // } // } // else if (Convert.ToInt32(dtSel.Rows[i]["EventID"]) == 0 && (Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) != 0)) // { // //parent selected // while (true) // { // node = iterator.GetNext(); // if (node == null) break; // if ((Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() == "ServerTypes") // { // node.Selected = true; // } // else if (node.GetValue("SrvId").ToString() != "") // { // if ((Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) == Convert.ToInt32(node.GetValue("SrvId"))) && node.GetValue("tbl").ToString() != "ServerTypes") // { // node.Selected = true; // } // } // } // } // else if (Convert.ToInt32(dtSel.Rows[i]["EventID"]) != 0 && (Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) != 0)) // { // //specific selected // while (true) // { // node = iterator.GetNext(); // if (node == null) break; // if ((Convert.ToInt32(dtSel.Rows[i]["EventID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() != "ServerTypes") // { // node.Selected = true; // } // } // } // iterator.Reset(); // } // } // } // 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()); // //6/27/2014 NS added for VSPLUS-634 // Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); // } //} public void fillEventsTreeList() { int j; try { Session["DataEvents"] = null; EventsTreeList.ClearNodes(); EventsTreeList.RefreshVirtualTree(); EventsTreeList.CollapseAll(); CollapseAllButton.Image.Url = "~/images/icons/add.png"; CollapseAllButton.Text = "Expand All"; if (Session["DataEvents"] == null) { DataTable DataEventsTree = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetEventsFromProcedure(); Session["DataEvents"] = DataEventsTree; } EventsTreeList.DataSource = (DataTable)Session["DataEvents"]; EventsTreeList.DataBind(); if (Request.QueryString["Key"] != null) { dtSel = VSWebBL.ConfiguratorBL.AlertsBL.Ins.GetSelectedEventsfortemplate(Convert.ToInt32(Session["id"].ToString())); //for (j = 0; j < dtSel.Rows.Count; j++) // { // string eventsid = dtSel.Rows[j]["ServerTypeID"].ToString(); // lastid += eventsid + ","; // } // while (lastid.EndsWith(",")) // lastid = lastid.Substring(0, lastid.Length - 1); // Session["lastid2"] = lastid; if (dtSel.Rows.Count > 0) { TreeListNodeIterator iterator = EventsTreeList.CreateNodeIterator(); TreeListNode node; for (int i = 0; i < dtSel.Rows.Count; i++) { if (Convert.ToInt32(dtSel.Rows[i]["EventID"]) == 0 && Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) == 0) { //select all while (true) { node = iterator.GetNext(); if (node == null) { break; } node.Selected = true; } } else if (Convert.ToInt32(dtSel.Rows[i]["EventID"]) == 0 && (Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) != 0)) { //parent selected while (true) { node = iterator.GetNext(); if (node == null) { break; } if ((Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() == "ServerTypes") { node.Selected = true; } else if (node.GetValue("SrvId").ToString() != "") { if ((Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) == Convert.ToInt32(node.GetValue("SrvId"))) && node.GetValue("tbl").ToString() != "ServerTypes") { node.Selected = true; } } } } else if (Convert.ToInt32(dtSel.Rows[i]["EventID"]) != 0 && (Convert.ToInt32(dtSel.Rows[i]["ServerTypeID"]) != 0)) { //specific selected while (true) { node = iterator.GetNext(); if (node == null) { break; } if ((Convert.ToInt32(dtSel.Rows[i]["EventID"]) == Convert.ToInt32(node.GetValue("actid"))) && node.GetValue("tbl").ToString() != "ServerTypes") { node.Selected = true; } } } iterator.Reset(); } } } } 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()); //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } }