public bool AddSiteMapNode(MDMSVC.DC_SiteMap AF) { object result = null; ServiceConnection.MDMSvcProxy.PostData(ConfigurationManager.AppSettings["SiteMap_Add"], AF, typeof(DC_SiteMap), typeof(bool), out result); return((bool)result); }
private SiteMapNode GetParentNode(MDMSVC.DC_SiteMap SM) { // Make sure the parent ID is present if (SM.ParentID == null) { throw new ProviderException(_errmsg3); } // Get the parent ID from the DataReader int pid = int.Parse(SM.ParentID.ToString()); // Make sure the parent ID is valid if ((!_nodes.ContainsKey(pid))) { throw new ProviderException(_errmsg4); } // Return the parent SiteMapNode return(_nodes[pid]); }
private MenuItem CreateSiteMapNode(MDMSVC.DC_SiteMap SM, string currentPage) { // Get the node ID from the DataReader int id = SM.ID; // Make sure the node ID is unique //if (_nodes.ContainsKey(SM.ID)) //{ // throw new ProviderException(_errmsg2); //} // Get title, URL, description, and roles from the DataReader string title = null; if (SM.Title == null) { title = null; } else { if (SM.ParentID != 1) { title = SM.Title.Trim(); } else { title = SM.Title.Trim() + "<b class='caret'></b>"; } } string url = null; if (SM.Url == null) { url = null; } else { url = SM.Url.Trim(); } string description = null; if (SM.Description == null) { description = null; } else { description = SM.Description.Trim(); } string roles = null; if (SM.Roles == null) { roles = null; } else { roles = SM.Roles.Trim(); } // If roles were specified, turn the list into a string array string[] rolelist = null; if ((!string.IsNullOrEmpty(roles))) { rolelist = roles.Split(new char[] { ',', ';' }, 512); } // Create a SiteMapNode // SiteMapNode node = new SiteMapNode(this, id.ToString(), url, title, description, rolelist, null, null, null); MenuItem menuItem = new MenuItem { Value = id.ToString(), Text = title.ToString(), NavigateUrl = url.ToString(), Selected = url.ToString().EndsWith(currentPage, StringComparison.CurrentCultureIgnoreCase) }; // Record the node in the _nodes dictionary //_nodes.Add(id, node); // Return the node return(menuItem); }
protected void frmSiteNode_ItemCommand(object sender, FormViewCommandEventArgs e) { DropDownList ddlParent = (DropDownList)frmSiteNode.FindControl("ddlParent"); CheckBoxList chkListRoles = (CheckBoxList)frmSiteNode.FindControl("chkListRoles"); TextBox txtTitle = (TextBox)frmSiteNode.FindControl("txtTitle"); TextBox txtUrl = (TextBox)frmSiteNode.FindControl("txtUrl"); TextBox txtDescription = (TextBox)frmSiteNode.FindControl("txtDescription"); CheckBox chkbIsSiteMapNode = (CheckBox)frmSiteNode.FindControl("chkbIsSiteMapNode"); HiddenField hdnSiteMapID = (HiddenField)frmSiteNode.FindControl("hdnSiteMapID"); if (e.CommandName.ToString() == "Add") { TLGX_Consumer.MDMSVC.DC_SiteMap newObj = new MDMSVC.DC_SiteMap(); newObj.SiteMap_ID = Guid.NewGuid(); newObj.ID = 0; newObj.Create_Date = DateTime.Now; newObj.Create_User = System.Web.HttpContext.Current.User.Identity.Name; newObj.Description = txtDescription.Text; newObj.IsActive = true; newObj.IsSiteMapNode = chkbIsSiteMapNode.Checked; newObj.ApplicationID = Guid.Parse(ddlApplilcation.SelectedValue); if (ddlParent.SelectedIndex != 0) { newObj.ParentID = int.Parse(ddlParent.SelectedValue.ToString()); } else { newObj.ParentID = 1; } string Roles = string.Empty; foreach (ListItem item in chkListRoles.Items) { if (item.Selected) { Roles = Roles + item.Text + ","; } } Roles = Roles.Trim(',').Trim(); if (!string.IsNullOrWhiteSpace(Roles)) { newObj.Roles = Roles; } newObj.Title = txtTitle.Text; newObj.Url = txtUrl.Text; AccSvc.AddSiteMapNode(newObj); newObj = null; BootstrapAlert.BootstrapAlertMessage(dvMsg, "SiteMap Created Successfully.", BootstrapAlertType.Success); } else if (e.CommandName.ToString() == "Modify") { Guid mySiteMap_Id = Guid.Parse(grdSiteMap.SelectedDataKey.Value.ToString()); TLGX_Consumer.MDMSVC.DC_SiteMap newObj = new MDMSVC.DC_SiteMap(); newObj.ID = Convert.ToInt32(hdnSiteMapID.Value); newObj.SiteMap_ID = mySiteMap_Id; newObj.Edit_Date = DateTime.Now; newObj.Edit_User = System.Web.HttpContext.Current.User.Identity.Name; newObj.Description = txtDescription.Text; newObj.ApplicationID = Guid.Parse(ddlApplilcation.SelectedValue); newObj.IsActive = true; newObj.IsSiteMapNode = chkbIsSiteMapNode.Checked; if (ddlParent.SelectedIndex != 0) { newObj.ParentID = int.Parse(ddlParent.SelectedValue.ToString()); } string Roles = string.Empty; foreach (ListItem item in chkListRoles.Items) { if (item.Selected) { Roles = Roles + item.Text + ","; } } Roles = Roles.Trim(',').Trim(); if (!string.IsNullOrWhiteSpace(Roles)) { newObj.Roles = Roles; } newObj.Title = txtTitle.Text; newObj.Url = txtUrl.Text; AccSvc.UpdateSiteMapNode(newObj); newObj = null; } hdnFlag.Value = "true"; frmSiteNode.ChangeMode(FormViewMode.Insert); frmSiteNode.DataBind(); BootstrapAlert.BootstrapAlertMessage(dvMsg, "SiteMap Edited Successfully.", BootstrapAlertType.Success); GetSiteMapMaster(); //BindParent(); //BindRoles(); }
protected void grdSiteMap_RowCommand(object sender, GridViewCommandEventArgs e) { int ID = int.Parse(e.CommandArgument.ToString()); GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); int index = row.RowIndex; if (e.CommandName == "Select") { List <MDMSVC.DC_SiteMap> objDS = new List <MDMSVC.DC_SiteMap>(); objDS.Add(new MDMSVC.DC_SiteMap { ID = ID }); frmSiteNode.ChangeMode(FormViewMode.Edit); frmSiteNode.DataSource = objDS; frmSiteNode.DataBind(); BindParent(); BindRoles(); DropDownList ddlParent = (DropDownList)frmSiteNode.FindControl("ddlParent"); CheckBoxList chkListRoles = (CheckBoxList)frmSiteNode.FindControl("chkListRoles"); TextBox txtTitle = (TextBox)frmSiteNode.FindControl("txtTitle"); TextBox txtUrl = (TextBox)frmSiteNode.FindControl("txtUrl"); TextBox txtDescription = (TextBox)frmSiteNode.FindControl("txtDescription"); CheckBox chkbIsSiteMapNode = (CheckBox)frmSiteNode.FindControl("chkbIsSiteMapNode"); HiddenField hdnSiteMapID = (HiddenField)frmSiteNode.FindControl("hdnSiteMapID"); hdnSiteMapID.Value = System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[0].Text); txtTitle.Text = System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[1].Text); txtDescription.Text = System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[2].Text); txtUrl.Text = System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[3].Text); chkbIsSiteMapNode.Checked = Convert.ToBoolean(grdSiteMap.Rows[index].Cells[6].Text); ddlParent.ClearSelection(); //Disable parent dropdown and isSiteMap var ApplicationName = Convert.ToString(ConfigurationManager.AppSettings["ApplicationName"]); var SelectedApplication = Convert.ToString(ddlApplilcation.SelectedItem); if (SelectedApplication == "MDM") { ddlParent.Enabled = true; chkbIsSiteMapNode.Enabled = true; if (ddlParent.Items.FindByText(System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[4].Text)) != null) { ddlParent.Items.FindByText(System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[4].Text)).Selected = true; } } else { ddlParent.Enabled = false; chkbIsSiteMapNode.Enabled = false; } chkListRoles.ClearSelection(); string[] rolelist = null; if (!string.IsNullOrWhiteSpace(System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[5].Text))) { rolelist = System.Web.HttpUtility.HtmlDecode(grdSiteMap.Rows[index].Cells[5].Text).Split(new char[] { ',', ';' }, 512); if (rolelist.Length > 0) { foreach (string role in rolelist) { if (chkListRoles.Items.FindByText(role) != null) { chkListRoles.Items.FindByText(role).Selected = true; } } } } } else if (e.CommandName.ToString() == "SoftDelete") { TLGX_Consumer.MDMSVC.DC_SiteMap newObj = new MDMSVC.DC_SiteMap { ID = ID, IsActive = false, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name }; if (AccSvc.UpdateSiteMapNode(newObj)) { GetSiteMapMaster(); } ; } else if (e.CommandName.ToString() == "UnDelete") { TLGX_Consumer.MDMSVC.DC_SiteMap newObj = new MDMSVC.DC_SiteMap { ID = ID, IsActive = true, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name }; if (AccSvc.UpdateSiteMapNode(newObj)) { GetSiteMapMaster(); } ; } }
// Helper methods private SiteMapNode CreateSiteMapNode(MDMSVC.DC_SiteMap SM) { //// Make sure the node ID is present //if (SM.ID == null) //{ // throw new ProviderException(_errmsg1); //} // Get the node ID from the DataReader int id = SM.ID; // Make sure the node ID is unique if (_nodes.ContainsKey(SM.ID)) { throw new ProviderException(_errmsg2); } // Get title, URL, description, and roles from the DataReader string title = null; if (SM.Title == null) { title = null; } else { title = SM.Title.Trim(); } string url = null; if (SM.Url == null) { url = null; } else { url = SM.Url.Trim(); } string description = null; if (SM.Description == null) { description = null; } else { description = SM.Description.Trim(); } string roles = null; if (SM.Roles == null) { roles = null; } else { roles = SM.Roles.Trim(); } // If roles were specified, turn the list into a string array string[] rolelist = null; if ((!string.IsNullOrEmpty(roles))) { rolelist = roles.Split(new char[] { ',', ';' }, 512); } // Create a SiteMapNode SiteMapNode node = new SiteMapNode(this, id.ToString(), url, title, description, rolelist, null, null, null); // Record the node in the _nodes dictionary _nodes.Add(id, node); // Return the node return(node); }