Example #1
0
        public UI.Controls.Menu.SiteMapNode CreateMenuForCustomReport(HRM.Presentation.UI.Controls.Menu.XmlSiteMap sitemap, List <Rep_MasterModel> ListMaster, ModuleName module, string alias)
        {
            List <Rep_MasterModel> item = ListMaster.Where(m => m.ReportStoreModule == module.ToString()).ToList();

            if (item != null && item.Count > 0)
            {
                //Add menu cha
                HRM.Presentation.UI.Controls.Menu.SiteMapNode node = new UI.Controls.Menu.SiteMapNode();
                node.ControllerName = "Sys_CustomReport";
                node.ActionName     = "GeneralCustomReport";
                node.HrmWebSite     = "Hrm_Sys_Web";
                //node.Alias = ConstantPathWeb.Hrm_Main_Web;
                node.RouteValues = sitemap.RootNode.ChildNodes.LastOrDefault().RouteValues;
                node.ImageUrl    = "/Content/images/icons/submenu/menu/Att_ShiftTimeSheet.png";
                node.Title       = "Báo Cáo Động";
                node.Visible     = true;
                node.ChildNodes  = new List <UI.Controls.Menu.SiteMapNode>();

                foreach (var t in item)
                {
                    HRM.Presentation.UI.Controls.Menu.SiteMapNode nodeitem = new UI.Controls.Menu.SiteMapNode();
                    nodeitem.ControllerName = "Sys_CustomReport";
                    nodeitem.ActionName     = "GeneralCustomReport?id=" + t.ID;
                    nodeitem.HrmWebSite     = "Hrm_Sys_Web";
                    nodeitem.Alias          = alias;
                    //nodeitem.Alias = ConstantPathWeb.Hrm_Main_Web;
                    nodeitem.Url         = "#" + nodeitem.HrmWebSite + "/" + nodeitem.ControllerName + "/" + nodeitem.ActionName;
                    nodeitem.RouteValues = sitemap.RootNode.ChildNodes.LastOrDefault().RouteValues;
                    nodeitem.ImageUrl    = "/Content/images/icons/submenu/menu/Att_ShiftTimeSheet.png";
                    nodeitem.Title       = t.ReportName;
                    nodeitem.Visible     = true;
                    node.ChildNodes.Add(nodeitem);
                }
                return(node);
            }
            return(null);
        }
Example #2
0
        public UI.Controls.Menu.SiteMapNode CreateMenuForCustomReport(HRM.Presentation.UI.Controls.Menu.XmlSiteMap sitemap, List<Rep_MasterModel> ListMaster, ModuleName module, string alias)
        {
            List<Rep_MasterModel> item = ListMaster.Where(m => m.ReportStoreModule == module.ToString()).ToList();
            if (item != null && item.Count > 0)
            {
                //Add menu cha
                HRM.Presentation.UI.Controls.Menu.SiteMapNode node = new UI.Controls.Menu.SiteMapNode();
                node.ControllerName = "Sys_CustomReport";
                node.ActionName = "GeneralCustomReport";
                node.HrmWebSite = "Hrm_Sys_Web";
                //node.Alias = ConstantPathWeb.Hrm_Main_Web;
                node.RouteValues = sitemap.RootNode.ChildNodes.LastOrDefault().RouteValues;
                node.ImageUrl = "/Content/images/icons/submenu/menu/Att_ShiftTimeSheet.png";
                node.Title = "Báo Cáo Động";
                node.Visible = true;
                node.ChildNodes = new List<UI.Controls.Menu.SiteMapNode>();

                foreach (var t in item)
                {
                    HRM.Presentation.UI.Controls.Menu.SiteMapNode nodeitem = new UI.Controls.Menu.SiteMapNode();
                    nodeitem.ControllerName = "Sys_CustomReport";
                    nodeitem.ActionName = "GeneralCustomReport?id=" + t.ID;
                    nodeitem.HrmWebSite = "Hrm_Sys_Web";
                    nodeitem.Alias = alias;
                    //nodeitem.Alias = ConstantPathWeb.Hrm_Main_Web;
                    nodeitem.Url = "#" + nodeitem.HrmWebSite + "/" + nodeitem.ControllerName + "/" + nodeitem.ActionName;
                    nodeitem.RouteValues = sitemap.RootNode.ChildNodes.LastOrDefault().RouteValues;
                    nodeitem.ImageUrl = "/Content/images/icons/submenu/menu/Att_ShiftTimeSheet.png";
                    nodeitem.Title = t.ReportName;
                    nodeitem.Visible = true;
                    node.ChildNodes.Add(nodeitem);
                }
                return node;
            }
            return null;
        }
Example #3
0
        public ActionResult GetDataTreeview()
        {
            if (Session != null && Session[NodeParent] != null)
            {
                //Key của node cha đang được chọn
                var strParent = Session[NodeParent].ToString();
                //Tất cả dữ liệu của menu đang được chọn
                var menus = (XmlSiteMap)HttpContext.Cache["SiteMap"];
                if (menus != null && menus.RootNode != null && menus.RootNode.ChildNodes != null && !string.IsNullOrEmpty(strParent))
                {
                    //Load tất cả node con theo node cha strParent
                    var nodeParent = menus.RootNode.ChildNodes.FirstOrDefault(d => d.NopResource == strParent);
                    //Danh sách node con sẽ trả về
                    if (nodeParent != null)
                    {
                        var nodes = nodeParent.ChildNodes;
                        //Biến lưu tat cả các node con
                        var smNodes = new UI.Controls.Menu.SiteMapNode();
                        if (nodes != null)
                        {
                            object listChildNodes = null;
                            //Duyệt qua 4 cấp và lưu tat cả các node con
                            foreach (var node in nodes)
                            {
                                if (node.ChildNodes != null)
                                {
                                    var nodes1 = node.ChildNodes;
                                    if (nodes1.Count == 0)
                                    {
                                        smNodes.ChildNodes.Add(node);
                                    }
                                    foreach (var node1 in nodes1)
                                    {
                                        if (node1.ChildNodes != null)
                                        {
                                            var nodes2 = node1.ChildNodes;
                                            if (nodes2.Count == 0)
                                            {
                                                smNodes.ChildNodes.Add(node1);
                                            }
                                            foreach (var node2 in nodes2)
                                            {
                                                smNodes.ChildNodes.Add(node2);
                                            }
                                        }
                                    }
                                }
                            }
                            //Xử lý ghi nhớ các menu đã chọn trong config
                            var listChildCheck = new List<string>();
                            //Sesion này lưu tất cả các node đang chọn ở thời điểm hiện tại
                            if (Session[ChildCheck] != null && (string)Session[ChildCheck] != "")
                            {
                                listChildCheck = Session[ChildCheck].ToString().Split(',').ToList();
                            }
                            //Nếu hiện tài không có check thì xuống db để lấy config và kiểm tra
                            else
                            {
                                var sessionConfig = Session[Constant.HRM_CONFIG_MENU_OPTION];
                                Sys_AllSettingModel getConfig = null;
                                //Xử lý lưu config vào session đe không xuống db nhiều lần
                                if (sessionConfig != null)
                                {
                                    var modelConfig = (Sys_AllSettingModel)sessionConfig;
                                    if (!string.IsNullOrEmpty(modelConfig.Value1) && !string.IsNullOrEmpty(modelConfig.Value2))
                                    {
                                        getConfig = modelConfig;
                                    }
                                }
                                else
                                {
                                    getConfig = GetConfig(Constant.HRM_CONFIG_MENU_OPTION);
                                    Session[Constant.HRM_CONFIG_MENU_OPTION] = getConfig;
                                }
                                if (getConfig != null)
                                {
                                    var strValue1 = getConfig.Value1;
                                    var strValue2 = getConfig.Value2;
                                    if (!string.IsNullOrEmpty(strValue1))
                                    {
                                        var indexParent = strValue1.IndexOf(strParent, System.StringComparison.Ordinal);
                                        if (!string.IsNullOrEmpty(strValue2) && indexParent >= 0)
                                        {
                                            var splitValue2 = strValue2.Split('|');
                                            if (splitValue2.Length > indexParent)
                                            {
                                                listChildCheck = splitValue2[indexParent].Split(',').ToList();
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Session[Constant.HRM_CONFIG_MENU_OPTION] = null;
                                }
                                Session[ChildCheck] = string.Join(",", listChildCheck);
                            }
                            //Lấy danh sách dữ liệu cần để trả về
                            listChildNodes = from e in smNodes.ChildNodes
                                             where !string.IsNullOrWhiteSpace(e.NopResource)
                                             select new
                                             {
                                                 id = e.NopResource,
                                                 Name = e.NopResource.TranslateString(),
                                                 hasChildren = false,
                                                 @checked = listChildCheck.Contains(e.NopResource)
                                             };
                            //Làm trống session sau mỗi lần xử lý
                            Session[NodeParent] = null;

                            return Json(listChildNodes, JsonRequestBehavior.AllowGet);
                        }
                    }
                }
            }
            return null;
        }
Example #4
0
        public ActionResult GetDataTreeview()
        {
            if (Session != null && Session[NodeParent] != null)
            {
                //Key của node cha đang được chọn
                var strParent = Session[NodeParent].ToString();
                //Tất cả dữ liệu của menu đang được chọn
                var menus = (XmlSiteMap)HttpContext.Cache["SiteMap"];
                if (menus != null && menus.RootNode != null && menus.RootNode.ChildNodes != null && !string.IsNullOrEmpty(strParent))
                {
                    //Load tất cả node con theo node cha strParent
                    var nodeParent = menus.RootNode.ChildNodes.FirstOrDefault(d => d.NopResource == strParent);
                    //Danh sách node con sẽ trả về
                    if (nodeParent != null)
                    {
                        var nodes = nodeParent.ChildNodes;
                        //Biến lưu tat cả các node con
                        var smNodes = new UI.Controls.Menu.SiteMapNode();
                        if (nodes != null)
                        {
                            object listChildNodes = null;
                            //Duyệt qua 4 cấp và lưu tat cả các node con
                            foreach (var node in nodes)
                            {
                                if (node.ChildNodes != null)
                                {
                                    var nodes1 = node.ChildNodes;
                                    if (nodes1.Count == 0)
                                    {
                                        smNodes.ChildNodes.Add(node);
                                    }
                                    foreach (var node1 in nodes1)
                                    {
                                        if (node1.ChildNodes != null)
                                        {
                                            var nodes2 = node1.ChildNodes;
                                            if (nodes2.Count == 0)
                                            {
                                                smNodes.ChildNodes.Add(node1);
                                            }
                                            foreach (var node2 in nodes2)
                                            {
                                                smNodes.ChildNodes.Add(node2);
                                            }
                                        }
                                    }
                                }
                            }
                            //Xử lý ghi nhớ các menu đã chọn trong config
                            var listChildCheck = new List <string>();
                            //Sesion này lưu tất cả các node đang chọn ở thời điểm hiện tại
                            if (Session[ChildCheck] != null && (string)Session[ChildCheck] != "")
                            {
                                listChildCheck = Session[ChildCheck].ToString().Split(',').ToList();
                            }
                            //Nếu hiện tài không có check thì xuống db để lấy config và kiểm tra
                            else
                            {
                                var sessionConfig             = Session[Constant.HRM_CONFIG_MENU_OPTION];
                                Sys_AllSettingModel getConfig = null;
                                //Xử lý lưu config vào session đe không xuống db nhiều lần
                                if (sessionConfig != null)
                                {
                                    var modelConfig = (Sys_AllSettingModel)sessionConfig;
                                    if (!string.IsNullOrEmpty(modelConfig.Value1) && !string.IsNullOrEmpty(modelConfig.Value2))
                                    {
                                        getConfig = modelConfig;
                                    }
                                }
                                else
                                {
                                    getConfig = GetConfig(Constant.HRM_CONFIG_MENU_OPTION);
                                    Session[Constant.HRM_CONFIG_MENU_OPTION] = getConfig;
                                }
                                if (getConfig != null)
                                {
                                    var strValue1 = getConfig.Value1;
                                    var strValue2 = getConfig.Value2;
                                    if (!string.IsNullOrEmpty(strValue1))
                                    {
                                        var indexParent = strValue1.IndexOf(strParent, System.StringComparison.Ordinal);
                                        if (!string.IsNullOrEmpty(strValue2) && indexParent >= 0)
                                        {
                                            var splitValue2 = strValue2.Split('|');
                                            if (splitValue2.Length > indexParent)
                                            {
                                                listChildCheck = splitValue2[indexParent].Split(',').ToList();
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    Session[Constant.HRM_CONFIG_MENU_OPTION] = null;
                                }
                                Session[ChildCheck] = string.Join(",", listChildCheck);
                            }
                            //Lấy danh sách dữ liệu cần để trả về
                            listChildNodes = from e in smNodes.ChildNodes
                                             where !string.IsNullOrWhiteSpace(e.NopResource)
                                             select new
                            {
                                id          = e.NopResource,
                                Name        = e.NopResource.TranslateString(),
                                hasChildren = false,
                                @checked    = listChildCheck.Contains(e.NopResource)
                            };
                            //Làm trống session sau mỗi lần xử lý
                            Session[NodeParent] = null;

                            return(Json(listChildNodes, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
            }
            return(null);
        }