Beispiel #1
0
        private static List <Common.Menu> GetSubMenu(List <DataRow> lstItems, Guid parentGuid)
        {
            List <Common.Menu> subMenu      = new List <Common.Menu>();
            List <DataRow>     childrenlist = lstItems.Where(item => Helper.GetGuid(item["ParentGuid"]) == parentGuid).ToList();

            try
            {
                foreach (DataRow row in childrenlist)
                {
                    var menu = new Common.Menu
                    {
                        ID           = Helper.GetInt(row["ID"]),
                        Title        = row["Title"].ToString(),
                        Order        = Helper.GetInt(row["Priority"]),
                        SubMenuCount = lstItems.Where(item => Helper.GetGuid(item["ParentGuid"]) == Helper.GetGuid(row["Guid"])).Count(),

                        Children = new List <Common.Menu>(),
                    };

                    menu.Children = GetSubMenu(lstItems, Helper.GetGuid(row["Guid"]));
                    subMenu.Add(menu);
                }
                return(subMenu);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public static List <Common.Menu> GetDomainMenu(Guid domainGuid, DataLocation location, Desktop desktop)
        {
            domainMenu.Clear();
            int subMenuCount = 0;

            try
            {
                Business.DataCenter dataCenterController = new Business.DataCenter();
                List <DataRow>      lstItems             = dataCenterController.GetDomainMenu(domainGuid, location, desktop).AsEnumerable().ToList();
                subMenuCount = lstItems.Where(item => Helper.GetGuid(item["ParentGuid"]) == Helper.GetGuid(item["Guid"])).Count();

                foreach (DataRow row in lstItems.Where(item => Helper.GetGuid(item["ParentGuid"]) == Guid.Empty))
                {
                    var menu = new Common.Menu
                    {
                        ID           = Helper.GetInt(row["ID"]),
                        Title        = row["Title"].ToString(),
                        Order        = Helper.GetInt(row["Priority"]),
                        SubMenuCount = subMenuCount,

                        Children = new List <Common.Menu>(),
                    };

                    menu.Children = GetSubMenu(lstItems, Helper.GetGuid(row["Guid"]));
                    domainMenu.Add(menu);
                }
                return(domainMenu);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public static List <Common.Menu> GetMenusOfDesktop(string domainName, Business.Desktop desktop)
        {
            try
            {
                lstMenu.Clear();
                Business.DomainMenu     domainMenuController = new Business.DomainMenu();
                Business.DomainMenuType menuType;

                DataTable domainInfo     = Facade.Domain.GetDomainInfo(domainName);
                DataTable dataTableMenus = domainMenuController.GetMenusOfDesktop(Helper.GetGuid(domainInfo.Rows[0]["Guid"]), desktop);

                foreach (DataRow row in dataTableMenus.Rows)
                {
                    var menu = new Common.Menu();

                    menuType = (Business.DomainMenuType)Helper.GetInt(row["Type"]);
                    switch (menuType)
                    {
                    case Business.DomainMenuType.ExternalUrl:
                        menu.Type     = (int)menuType;
                        menu.Path     = row["Link"].ToString();
                        menu.Title    = row["Title"].ToString();
                        menu.Target   = Helper.GetInt(row["TargetType"]) == (int)Business.DomainNameTargetType.BlankPage ? "_blank" : "_self";
                        menu.Children = new List <Common.Menu>();
                        menu.Location = Helper.GetInt(row["Location"]);
                        lstMenu.Add(menu);
                        break;

                    case Business.DomainMenuType.DataCenter:
                        DataTable dataTableDataMenu = Facade.Data.GetMenusOfDataCenter(Helper.GetGuid(row["DataCenterGuid"]));
                        DataView  dataViewMenu      = dataTableDataMenu.DefaultView;
                        dataViewMenu.RowFilter = string.Format("ParentGuid='{0}'", Guid.Empty);
                        DataTable dataTableParent = dataViewMenu.ToTable();

                        foreach (DataRow rowData in dataTableParent.Rows)
                        {
                            var menu1 = new Common.Menu();
                            menu1.Path   = Helper.GetString(rowData["Content"]).Length > 0 ? string.Format("/{0}{1}/{2}", (int)Business.ContentType.Menu, rowData["ID"].ToString(), rowData["Title"]) : "#";
                            menu1.Title  = rowData["Title"].ToString();
                            menu1.Type   = (int)menuType;
                            menu1.Target = "_self";

                            menu1.Children = GenerateDataMenu(dataTableDataMenu, Helper.GetGuid(row["Guid"]), (Business.DefaultPages)Helper.GetInt(domainInfo.Rows[0]["DefaultPage"]));
                            menu1.Location = Helper.GetInt(row["Location"]);
                            lstMenu.Add(menu1);
                        }
                        break;
                    }
                }

                return(lstMenu);
            }
            catch { return(lstMenu); }
        }
Beispiel #4
0
        public static List <Menu> GetUserShortcut(Guid userGuid)
        {
            UserShortcuts.Clear();
            Business.UserSetting userSettingController = new Business.UserSetting();
            DataTable            dtServiceInfo         = userSettingController.GetUserShortcutForLoad(userGuid);

            foreach (DataRow row in dtServiceInfo.Rows)
            {
                var menu = new Common.Menu
                {
                    Title     = row["Title"].ToString(),
                    Path      = "/PageLoader.aspx?c=" + Helper.Encrypt(row["ReferencePageKey"], HttpContext.Current.Session),
                    SmallIcon = row["IconAddress"].ToString(),
                    LargeIcon = row["LargeIcon"].ToString(),
                };

                UserShortcuts.Add(menu);
            }
            return(UserShortcuts);
        }
Beispiel #5
0
        private static List <Common.Menu> GenerateDataMenu(DataTable dataTableDataMenu, Guid root, Business.DefaultPages defaultPage)
        {
            DataView dataViewMenu = dataTableDataMenu.DefaultView;

            dataViewMenu.RowFilter = string.Format("ParentGuid='{0}'", root);
            DataTable dataTableChildren = dataViewMenu.ToTable();

            List <Common.Menu> lstDataMenu = new List <Common.Menu>();
            var menu = new Common.Menu();

            foreach (DataRow row in dataTableChildren.Rows)
            {
                menu.Path   = Helper.GetString(row["Content"]).Length > 0 ? string.Format("/{0}{1}/{2}", (int)Business.ContentType.Menu, row["ID"], row["Title"]) : "#";
                menu.Title  = row["Title"].ToString();
                menu.Type   = (int)Business.DomainMenuType.DataCenter;
                menu.Target = "_self";

                menu.Children = GenerateDataMenu(dataTableDataMenu, Helper.GetGuid(row["Guid"]), defaultPage);
                lstDataMenu.Add(menu);
            }

            return(lstDataMenu);
        }
Beispiel #6
0
        public static List <Menu> GenerateUserServiceMenu(Guid userGuid, string lang)
        {
            userMenus.Clear();

            DataTable      parentServiceGroup = Facade.ServiceGroup.GetParentGroups();
            List <DataRow> serviceList        = Facade.ServiceGroup.GetUserGroupsWithServices(userGuid).AsEnumerable().ToList();
            int            subMenuCount       = 0;
            bool           parentHasService   = false;

            try
            {
                foreach (DataRow row in parentServiceGroup.Rows)
                {
                    subMenuCount     = serviceList.Where(service => Helper.GetGuid(service["ParentGuid"]) == Helper.GetGuid(row["GroupGuid"])).Count();
                    parentHasService = serviceList.Where(service => Helper.GetGuid(service["ParentGuid"]) == Helper.GetGuid(row["GroupGuid"]) ||
                                                         Helper.GetGuid(service["GroupGuid"]) == Helper.GetGuid(row["GroupGuid"])).Any();

                    if (parentHasService)
                    {
                        if (lang == "fa")
                        {
                            var menu = new Common.Menu
                            {
                                Title        = row["GroupTitleFa"].ToString(),
                                SmallIcon    = row["GroupIcon"].ToString(),
                                LargeIcon    = row["GroupLargeIcon"].ToString(),
                                Order        = Helper.GetInt(row["Order"]),
                                Path         = string.Empty,
                                ActiveLink   = false,
                                SubMenuCount = subMenuCount,

                                Children = new List <Common.Menu>(),
                            };
                            menu.Children = GenerateSubMenu(serviceList, Helper.GetGuid(row["GroupGuid"]), false, lang);
                            userMenus.Add(menu);
                        }
                        else
                        {
                            var menu = new Common.Menu
                            {
                                Title        = row["GroupTitle"].ToString(),
                                SmallIcon    = row["GroupIcon"].ToString(),
                                LargeIcon    = row["GroupLargeIcon"].ToString(),
                                Order        = Helper.GetInt(row["Order"]),
                                Path         = string.Empty,
                                ActiveLink   = false,
                                SubMenuCount = subMenuCount,

                                Children = new List <Common.Menu>(),
                            };
                            menu.Children = GenerateSubMenu(serviceList, Helper.GetGuid(row["GroupGuid"]), false, lang);
                            userMenus.Add(menu);
                        }
                    }
                }
                return(userMenus);
            }
            catch
            {
                return(userMenus);
            }
        }
Beispiel #7
0
        private static List <Common.Menu> GenerateSubMenu(List <DataRow> serviceList, Guid parentGuid, bool isHelp, string lang)
        {
            List <Common.Menu> subMenu  = new List <Common.Menu>();
            List <string>      groups   = new List <string>();
            int            subMenuCount = 0;
            List <DataRow> childrenlist = serviceList.Where(service => Helper.GetGuid(service["ServiceGroupGuid"]) == parentGuid ||
                                                            Helper.GetGuid(service["ParentGuid"]) == parentGuid).ToList();

            foreach (DataRow service in childrenlist)
            {
                if (Helper.GetGuid(service["ServiceGroupGuid"]) == parentGuid)
                {
                    groups.Add(Helper.GetString(service["GroupGuid"]));
                    if (lang == "fa")
                    {
                        var menu1 = new Common.Menu
                        {
                            Title        = service["ServiceTitleFa"].ToString(),
                            SmallIcon    = service["IconAddress"].ToString(),
                            Order        = Helper.GetInt(service["ServiceOrder"]),
                            Path         = "/PageLoader.aspx?c=" + Helper.Encrypt(service["ReferencePageKey"], HttpContext.Current.Session),
                            ActiveLink   = true,
                            SubMenuCount = subMenuCount,

                            Children = new List <Common.Menu>(),
                        };

                        subMenu.Add(menu1);
                    }
                    else
                    {
                        var menu1 = new Common.Menu
                        {
                            Title        = service["ServiceTitle"].ToString(),
                            SmallIcon    = service["IconAddress"].ToString(),
                            Order        = Helper.GetInt(service["ServiceOrder"]),
                            Path         = "/PageLoader.aspx?c=" + Helper.Encrypt(service["ReferencePageKey"], HttpContext.Current.Session),
                            ActiveLink   = true,
                            SubMenuCount = subMenuCount,

                            Children = new List <Common.Menu>(),
                        };

                        subMenu.Add(menu1);
                    }
                }

                if (Helper.GetGuid(service["ParentGuid"]) == parentGuid &&
                    !groups.Contains(service["GroupGuid"].ToString()))
                {
                    groups.Add(service["GroupGuid"].ToString());

                    subMenuCount = serviceList.Where(serviceInfo => Helper.GetGuid(serviceInfo["ParentGuid"]) == Helper.GetGuid(service["GroupGuid"])).Count();
                    if (lang == "fa")
                    {
                        var menu = new Common.Menu
                        {
                            Title        = service["GroupTitleFa"].ToString(),
                            SmallIcon    = service["GroupIcon"].ToString(),
                            LargeIcon    = service["GroupLargeIcon"].ToString(),
                            Order        = Helper.GetInt(service["GroupOrder"]),
                            Path         = string.Empty,
                            ActiveLink   = false,
                            SubMenuCount = subMenuCount,

                            Children = new List <Common.Menu>(),
                        };

                        menu.Children = GenerateSubMenu(serviceList, Helper.GetGuid(service["GroupGuid"]), isHelp, lang);
                        subMenu.Add(menu);
                    }
                    else
                    {
                        var menu = new Common.Menu
                        {
                            Title        = service["GroupTitle"].ToString(),
                            SmallIcon    = service["GroupIcon"].ToString(),
                            LargeIcon    = service["GroupLargeIcon"].ToString(),
                            Order        = Helper.GetInt(service["GroupOrder"]),
                            Path         = string.Empty,
                            ActiveLink   = false,
                            SubMenuCount = subMenuCount,

                            Children = new List <Common.Menu>(),
                        };

                        menu.Children = GenerateSubMenu(serviceList, Helper.GetGuid(service["GroupGuid"]), isHelp, lang);
                        subMenu.Add(menu);
                    }
                }
            }
            return(subMenu);
        }