Esempio n. 1
0
        public string GetMenuTreeTableHtml(string orgID, Guid?userId = default(Guid?))
        {
            DataTable allDataTable = new Menu().GetAllDataTable();
            List <RoadFlow.Data.Model.MenuUser> all = new MenuUser().GetAll();
            StringBuilder stringBuilder             = new StringBuilder();

            getMenuTreeTableHtml(stringBuilder, allDataTable, Guid.Empty, all, orgID, userId);
            return(stringBuilder.ToString());
        }
Esempio n. 2
0
        public static bool CheckApp(out string msg, string appid = "")
        {
            msg = "";
            Guid userID = RoadFlow.Platform.Users.CurrentUserID;

            if (userID.IsEmptyGuid())
            {
                msg = "<script>top.login();</script>";
                return(false);
            }
            appid = (appid.IsNullOrEmpty() ? HttpContext.Current.Request["appid"] : appid);
            Guid appGuid;

            if (!appid.IsGuid(out appGuid))
            {
                return(false);
            }
            List <RoadFlow.Data.Model.MenuUser> all = new RoadFlow.Platform.MenuUser().GetAll();
            string source;
            string @params;
            bool   flag = new RoadFlow.Platform.Menu().HasUse(appGuid, userID, all, out source, out @params);

            if (!flag)
            {
                return(false);
            }
            string url = HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"].ToString();

            if (!url.IsNullOrEmpty())
            {
                url = url.TrimStart('/');
                if (!url.IsNullOrEmpty())
                {
                    List <RoadFlow.Data.Model.AppLibrarySubPages> list = new RoadFlow.Platform.AppLibrarySubPages().GetAll().FindAll((RoadFlow.Data.Model.AppLibrarySubPages p) => p.Address.Contains(url, StringComparison.CurrentCultureIgnoreCase));
                    if (list.Count > 0)
                    {
                        foreach (RoadFlow.Data.Model.AppLibrarySubPages item in list)
                        {
                            if (all.Find(delegate(RoadFlow.Data.Model.MenuUser p)
                            {
                                if (p.MenuID == appGuid && p.SubPageID == item.ID)
                                {
                                    return(p.Users.Contains(userID.ToString(), StringComparison.CurrentCultureIgnoreCase));
                                }
                                return(false);
                            }) != null)
                            {
                                return(true);
                            }
                        }
                        return(false);
                    }
                }
            }
            return(flag);
        }
Esempio n. 3
0
        public void RefreshUsers()
        {
            MenuUser menuUser = new MenuUser();
            Organize organize = new Organize();

            foreach (RoadFlow.Data.Model.MenuUser model in menuUser.GetAll(false))
            {
                model.Users = organize.GetAllUsersIdList(model.Organizes).ToArray().Join1 <Guid>(",");
                menuUser.Update(model);
            }
            this.ClearCache();
        }
Esempio n. 4
0
        public void RefreshUsers()
        {
            MenuUser menuUser = new MenuUser();
            Organize organize = new Organize();

            foreach (RoadFlow.Data.Model.MenuUser item in menuUser.GetAll(false))
            {
                item.Users = organize.GetAllUsersIdList(item.Organizes).ToArray().Join1();
                menuUser.Update(item);
            }
            ClearCache();
        }
Esempio n. 5
0
        public string GetUserMenuRefreshJsonString(Guid userID, Guid refreshID, string rootDir = "", bool showSource = false)
        {
            DataTable allDataTable = GetAllDataTable();
            DataView  defaultView  = allDataTable.DefaultView;

            defaultView.RowFilter = string.Format("ParentID='{0}'", refreshID);
            defaultView.Sort      = "Sort";
            DataTable dataTable = defaultView.ToTable();

            if (dataTable.Rows.Count == 0)
            {
                return("[]");
            }
            int           count                     = dataTable.Rows.Count;
            StringBuilder stringBuilder             = new StringBuilder("[", count * 100);
            List <RoadFlow.Data.Model.MenuUser> all = new MenuUser().GetAll();
            string source = string.Empty;

            foreach (DataRow row in dataTable.Rows)
            {
                string @params = string.Empty;
                if (HasUse(row["ID"].ToString().ToGuid(), userID, all, out source, out @params, showSource))
                {
                    DataRow[] array  = allDataTable.Select(string.Format("ParentID='{0}'", row["id"].ToString()));
                    bool      flag   = false;
                    DataRow[] array2 = array;
                    foreach (DataRow dataRow2 in array2)
                    {
                        if (HasUse(dataRow2["ID"].ToString().ToGuid(), userID, all, out source, out @params, showSource))
                        {
                            flag = true;
                            break;
                        }
                    }
                    stringBuilder.Append("{");
                    stringBuilder.AppendFormat("\"id\":\"{0}\",", row["ID"].ToString());
                    stringBuilder.AppendFormat("\"title\":\"{0}{1}\",", row["Title"].ToString().Trim1(), showSource ? ("<span style='margin-left:4px;color:#666;'>[" + source + "]</span>") : "");
                    stringBuilder.AppendFormat("\"ico\":\"{0}\",", row["AppIco"].ToString());
                    stringBuilder.AppendFormat("\"color\":\"{0}\",", row["IcoColor"].ToString());
                    stringBuilder.AppendFormat("\"link\":\"{0}\",", getAddress(row, @params));
                    stringBuilder.AppendFormat("\"model\":\"{0}\",", row["OpenMode"].ToString());
                    stringBuilder.AppendFormat("\"width\":\"{0}\",", row["Width"].ToString());
                    stringBuilder.AppendFormat("\"height\":\"{0}\",", row["Height"].ToString());
                    stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", flag ? "1" : "0");
                    stringBuilder.AppendFormat("\"childs\":[");
                    stringBuilder.Append("]");
                    stringBuilder.Append("}");
                    stringBuilder.Append(",");
                }
            }
            return(stringBuilder.ToString().TrimEnd(',') + "]");
        }
Esempio n. 6
0
        public string GetUserMenuJsonString(Guid userID, string rootDir = "", bool showSource = false)
        {
            Menu menu = new Menu();

            new AppLibrary();
            DataTable allDataTable = menu.GetAllDataTable();

            if (allDataTable.Rows.Count == 0)
            {
                return("[]");
            }
            DataRow[] array = allDataTable.Select(string.Format("ParentID='{0}'", Guid.Empty.ToString()));
            if (array.Length == 0)
            {
                return("[]");
            }
            List <RoadFlow.Data.Model.MenuUser> all = new MenuUser().GetAll();

            DataRow[]     array2        = allDataTable.Select(string.Format("ParentID='{0}'", array[0]["ID"].ToString()));
            StringBuilder stringBuilder = new StringBuilder("", 1000);
            DataRow       dataRow       = array[0];
            string        empty         = string.Empty;

            stringBuilder.Append("{");
            stringBuilder.AppendFormat("\"id\":\"{0}\",", dataRow["ID"].ToString());
            stringBuilder.AppendFormat("\"title\":\"{0}\",", dataRow["Title"].ToString().Trim());
            stringBuilder.AppendFormat("\"ico\":\"{0}\",", dataRow["AppIco"].ToString());
            stringBuilder.AppendFormat("\"color\":\"{0}\",", dataRow["IcoColor"].ToString());
            stringBuilder.AppendFormat("\"link\":\"{0}\",", getAddress(dataRow).ToString(), empty);
            stringBuilder.AppendFormat("\"model\":\"{0}\",", dataRow["OpenMode"].ToString());
            stringBuilder.AppendFormat("\"width\":\"{0}\",", dataRow["Width"].ToString());
            stringBuilder.AppendFormat("\"height\":\"{0}\",", dataRow["Height"].ToString());
            stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", (array2.Length != 0) ? "1" : "0");
            stringBuilder.AppendFormat("\"childs\":[");
            StringBuilder stringBuilder2 = new StringBuilder(array2.Length * 100);
            string        source         = string.Empty;

            if (!showSource)
            {
                List <RoadFlow.Data.Model.UserShortcut> allByUserID = new UserShortcut().GetAllByUserID(userID, true);
                if (allByUserID.Count > 0)
                {
                    stringBuilder2.Append("{");
                    stringBuilder2.AppendFormat("\"id\":\"{0}\",", Guid.NewGuid());
                    stringBuilder2.AppendFormat("\"title\":\"{0}\",", "快捷菜单");
                    stringBuilder2.AppendFormat("\"ico\":\"{0}\",", "");
                    stringBuilder2.AppendFormat("\"color\":\"{0}\",", "");
                    stringBuilder2.AppendFormat("\"link\":\"{0}\",", "");
                    stringBuilder2.AppendFormat("\"model\":\"{0}\",", "");
                    stringBuilder2.AppendFormat("\"width\":\"{0}\",", "");
                    stringBuilder2.AppendFormat("\"height\":\"{0}\",", "");
                    stringBuilder2.AppendFormat("\"hasChilds\":\"1\",");
                    stringBuilder2.AppendFormat("\"childs\":[");
                    StringBuilder stringBuilder3 = new StringBuilder();
                    foreach (RoadFlow.Data.Model.UserShortcut item in allByUserID)
                    {
                        string @params = string.Empty;
                        List <RoadFlow.Data.Model.MenuUser> list = all.FindAll(delegate(RoadFlow.Data.Model.MenuUser p)
                        {
                            if (p.MenuID == item.MenuID && p.SubPageID == Guid.Empty)
                            {
                                return(p.Users.Contains(userID.ToString(), StringComparison.CurrentCultureIgnoreCase));
                            }
                            return(false);
                        });
                        if (list.Count > 0)
                        {
                            StringBuilder stringBuilder4 = new StringBuilder();
                            foreach (IGrouping <string, RoadFlow.Data.Model.MenuUser> item2 in from p in list.FindAll((RoadFlow.Data.Model.MenuUser p) => !p.Params.IsNullOrEmpty())
                                     group p by p.Params)
                            {
                                stringBuilder4.Append(item2.Key.Trim1());
                                stringBuilder4.Append("&");
                            }
                            @params = stringBuilder4.ToString().TrimEnd('&');
                        }
                        if (HasUse(item.MenuID, userID, all, out source, out @params, showSource))
                        {
                            DataRow[] array3 = allDataTable.Select(string.Format("ID='{0}'", item.MenuID.ToString()));
                            if (array3.Length != 0)
                            {
                                DataRow   dataRow2 = array3[0];
                                DataRow[] array4   = allDataTable.Select("ParentID='" + dataRow2["ID"].ToString() + "'");
                                stringBuilder3.Append("{");
                                stringBuilder3.AppendFormat("\"id\":\"{0}\",", dataRow2["ID"].ToString());
                                stringBuilder3.AppendFormat("\"title\":\"{0}\",", dataRow2["Title"].ToString().Trim1());
                                stringBuilder3.AppendFormat("\"ico\":\"{0}\",", dataRow2["AppIco"].ToString());
                                stringBuilder3.AppendFormat("\"color\":\"{0}\",", dataRow2["IcoColor"].ToString());
                                stringBuilder3.AppendFormat("\"link\":\"{0}\",", getAddress(dataRow2, @params));
                                stringBuilder3.AppendFormat("\"model\":\"{0}\",", dataRow2["OpenMode"].ToString());
                                stringBuilder3.AppendFormat("\"width\":\"{0}\",", dataRow2["Width"].ToString());
                                stringBuilder3.AppendFormat("\"height\":\"{0}\",", dataRow2["Height"].ToString());
                                stringBuilder3.AppendFormat("\"hasChilds\":\"{0}\",", (array4.Length != 0) ? "1" : "0");
                                stringBuilder3.AppendFormat("\"childs\":[]");
                                stringBuilder3.Append("},");
                            }
                        }
                    }
                    stringBuilder2.Append((stringBuilder3.Length > 0) ? stringBuilder3.ToString().TrimEnd(',') : "");
                    stringBuilder2.Append("]");
                    stringBuilder2.Append("}");
                    if (array2.Length != 0)
                    {
                        stringBuilder2.Append(",");
                    }
                }
            }
            for (int i = 0; i < array2.Length; i++)
            {
                string  params2  = string.Empty;
                DataRow dataRow3 = array2[i];
                if (HasUse(dataRow3["ID"].ToString().ToGuid(), userID, all, out source, out params2, showSource))
                {
                    DataRow[] array5 = allDataTable.Select("ParentID='" + dataRow3["ID"].ToString() + "'");
                    bool      flag   = false;
                    DataRow[] array6 = array5;
                    foreach (DataRow dataRow4 in array6)
                    {
                        if (HasUse(dataRow4["ID"].ToString().ToGuid(), userID, all, out source, out params2, showSource))
                        {
                            flag = true;
                            break;
                        }
                    }
                    stringBuilder2.Append("{");
                    stringBuilder2.AppendFormat("\"id\":\"{0}\",", dataRow3["ID"].ToString());
                    stringBuilder2.AppendFormat("\"title\":\"{0}{1}\",", dataRow3["Title"].ToString().Trim1(), showSource ? ("<span style='margin-left:4px;color:#666;'>[" + source + "]</span>") : "");
                    stringBuilder2.AppendFormat("\"ico\":\"{0}\",", dataRow3["AppIco"].ToString());
                    stringBuilder2.AppendFormat("\"color\":\"{0}\",", dataRow3["IcoColor"].ToString());
                    stringBuilder2.AppendFormat("\"link\":\"{0}\",", getAddress(dataRow3, params2));
                    stringBuilder2.AppendFormat("\"model\":\"{0}\",", dataRow3["OpenMode"].ToString());
                    stringBuilder2.AppendFormat("\"width\":\"{0}\",", dataRow3["Width"].ToString());
                    stringBuilder2.AppendFormat("\"height\":\"{0}\",", dataRow3["Height"].ToString());
                    stringBuilder2.AppendFormat("\"hasChilds\":\"{0}\",", flag ? "1" : "0");
                    stringBuilder2.AppendFormat("\"childs\":[");
                    stringBuilder2.Append("]");
                    stringBuilder2.Append("}");
                    stringBuilder2.Append(",");
                }
            }
            stringBuilder.Append(stringBuilder2.ToString().TrimEnd(','));
            stringBuilder.Append("]");
            stringBuilder.Append("}");
            return(stringBuilder.ToString());
        }
Esempio n. 7
0
        public string GetUserMenu1(Guid userID)
        {
            Menu menu = new Menu();

            new AppLibrary();
            DataTable allDataTable = menu.GetAllDataTable();

            if (allDataTable.Rows.Count == 0)
            {
                return("");
            }
            StringBuilder stringBuilder             = new StringBuilder();
            string        source                    = string.Empty;
            List <RoadFlow.Data.Model.MenuUser> all = new MenuUser().GetAll();

            foreach (RoadFlow.Data.Model.UserShortcut item in new UserShortcut().GetAllByUserID(userID, true))
            {
                string @params = string.Empty;
                List <RoadFlow.Data.Model.MenuUser> list = all.FindAll(delegate(RoadFlow.Data.Model.MenuUser p)
                {
                    if (p.MenuID == item.MenuID && p.SubPageID == Guid.Empty)
                    {
                        return(p.Users.Contains(userID.ToString(), StringComparison.CurrentCultureIgnoreCase));
                    }
                    return(false);
                });
                if (list.Count > 0)
                {
                    StringBuilder stringBuilder2 = new StringBuilder();
                    foreach (IGrouping <string, RoadFlow.Data.Model.MenuUser> item2 in from p in list.FindAll((RoadFlow.Data.Model.MenuUser p) => !p.Params.IsNullOrEmpty())
                             group p by p.Params)
                    {
                        stringBuilder2.Append(item2.Key.Trim1());
                        stringBuilder2.Append("&");
                    }
                    @params = stringBuilder2.ToString().TrimEnd('&');
                }
                if (HasUse(item.MenuID, userID, all, out source, out @params))
                {
                    DataRow[] array = allDataTable.Select(string.Format("ID='{0}'", item.MenuID.ToString()));
                    if (array.Length != 0)
                    {
                        DataRow dataRow = array[0];
                        string  str     = dataRow["IcoColor"].ToString();
                        if (str.IsNullOrEmpty())
                        {
                            str = dataRow["IcoColor1"].ToString();
                        }
                        DataRow[] array2 = allDataTable.Select("ParentID='" + dataRow["ID"].ToString() + "'");
                        stringBuilder.Append("<div class=\"menulistdiv11\" title=\"" + dataRow["Title"].ToString().Trim1() + "\" onclick=\"menuClick1(this);\" data-id=\"" + dataRow["ID"].ToString() + "\" data-title=\"" + dataRow["Title"].ToString().Trim() + "\" data-model=\"" + dataRow["OpenMode"].ToString() + "\" data-width=\"" + dataRow["Width"].ToString() + "\" data-height=\"" + dataRow["Height"].ToString() + "\" data-childs=\"" + ((array2.Length != 0) ? "1" : "0") + "\" data-url=\"" + getAddress(dataRow, @params) + "\" data-parent=\"" + Guid.Empty.ToString() + "\" style=\"" + (str.IsNullOrEmpty() ? "" : ("color:" + str.Trim1() + ";")) + "\">");
                        stringBuilder.Append("<div class=\"menulistdiv1\">");
                        string text = dataRow["Ico"].ToString();
                        if (text.IsNullOrEmpty())
                        {
                            text = dataRow["AppIco"].ToString();
                        }
                        if (text.IsNullOrEmpty())
                        {
                            stringBuilder.Append("<i class=\"fa fa-list-ul\" style=\"margin-right:3px;vertical-align:middle\"></i>");
                        }
                        else if (text.IsFontIco())
                        {
                            stringBuilder.Append("<i class=\"fa " + text + "\" style=\"margin-right:3px;vertical-align:middle\"></i>");
                        }
                        else
                        {
                            stringBuilder.Append("<img src=\"" + Config.BaseUrl + text + "\" style=\"vertical-align:middle\" alt=\"\"/>");
                        }
                        stringBuilder.Append("</div>");
                        stringBuilder.Append("</div>");
                    }
                }
            }
            DataRow[] array3 = allDataTable.Select(string.Format("ParentID='{0}'", Guid.Empty.ToString()));
            if (array3.Length == 0)
            {
                return(stringBuilder.ToString());
            }
            DataRow[] array4 = allDataTable.Select(string.Format("ParentID='{0}'", array3[0]["ID"].ToString()));
            for (int i = 0; i < array4.Length; i++)
            {
                string  params2  = string.Empty;
                DataRow dataRow2 = array4[i];
                if (HasUse(dataRow2["ID"].ToString().ToGuid(), userID, all, out source, out params2))
                {
                    DataRow[] array5 = allDataTable.Select("ParentID='" + dataRow2["ID"].ToString() + "'");
                    bool      flag   = false;
                    DataRow[] array6 = array5;
                    foreach (DataRow dataRow3 in array6)
                    {
                        if (HasUse(dataRow3["ID"].ToString().ToGuid(), userID, all, out source, out params2))
                        {
                            flag = true;
                            break;
                        }
                    }
                    string str2 = dataRow2["IcoColor"].ToString();
                    if (str2.IsNullOrEmpty())
                    {
                        str2 = dataRow2["IcoColor1"].ToString();
                    }
                    stringBuilder.Append("<div class=\"menulistdiv11\" title=\"" + dataRow2["Title"].ToString().Trim1() + "\" onclick=\"menuClick1(this);\" data-id=\"" + dataRow2["ID"].ToString() + "\" data-title=\"" + dataRow2["Title"].ToString().Trim() + "\" data-model=\"" + dataRow2["OpenMode"].ToString() + "\" data-width=\"" + dataRow2["Width"].ToString() + "\" data-height=\"" + dataRow2["Height"].ToString() + "\" data-childs=\"" + (flag ? "1" : "0") + "\" data-url=\"" + getAddress(dataRow2, params2) + "\" data-parent=\"" + Guid.Empty.ToString() + "\" style=\"" + (str2.IsNullOrEmpty() ? "" : ("color:" + str2.Trim1() + ";")) + "\">");
                    stringBuilder.Append("<div class=\"menulistdiv1\">");
                    string text2 = dataRow2["Ico"].ToString();
                    if (text2.IsNullOrEmpty())
                    {
                        text2 = dataRow2["AppIco"].ToString();
                    }
                    if (text2.IsNullOrEmpty())
                    {
                        stringBuilder.Append("<i class=\"fa fa-th-list\" style=\"margin-right:3px;vertical-align:middle\"></i>");
                    }
                    else if (text2.IsFontIco())
                    {
                        stringBuilder.Append("<i class=\"fa " + text2 + "\" style=\"margin-right:3px;vertical-align:middle\"></i>");
                    }
                    else
                    {
                        stringBuilder.Append("<img src=\"" + Config.BaseUrl + text2 + "\" style=\"vertical-align:middle\" alt=\"\"/>");
                    }
                    stringBuilder.Append("</div>");
                    stringBuilder.Append("</div>");
                }
            }
            return(stringBuilder.ToString());
        }
Esempio n. 8
0
        public string GetUserMenuChilds(Guid userID, Guid refreshID, string rootDir = "", string isrefresh1 = "0")
        {
            StringBuilder stringBuilder = new StringBuilder();
            DataTable     allDataTable  = GetAllDataTable();
            DataView      defaultView   = allDataTable.DefaultView;

            defaultView.RowFilter = string.Format("ParentID='{0}'", refreshID);
            defaultView.Sort      = "Sort";
            DataTable dataTable = defaultView.ToTable();

            if (dataTable.Rows.Count == 0)
            {
                return("[]");
            }
            int count = dataTable.Rows.Count;

            new StringBuilder("[", count * 100);
            List <RoadFlow.Data.Model.MenuUser> all = new MenuUser().GetAll();
            string source = string.Empty;

            foreach (DataRow row in dataTable.Rows)
            {
                string @params = string.Empty;
                if (HasUse(row["ID"].ToString().ToGuid(), userID, all, out source, out @params))
                {
                    DataRow[] array  = allDataTable.Select(string.Format("ParentID='{0}'", row["id"].ToString()));
                    bool      flag   = false;
                    DataRow[] array2 = array;
                    foreach (DataRow dataRow2 in array2)
                    {
                        if (HasUse(dataRow2["ID"].ToString().ToGuid(), userID, all, out source, out @params))
                        {
                            flag = true;
                            break;
                        }
                    }
                    string str = row["IcoColor"].ToString();
                    if (str.IsNullOrEmpty())
                    {
                        str = row["IcoColor1"].ToString();
                    }
                    stringBuilder.Append("<div class=\"menulistdiv\" " + (("1" == isrefresh1) ? "data-isrefresh1=\"1\"" : "") + " onclick=\"" + (("1" == isrefresh1) ? "menuClick(this, 1);" : "menuClick(this, 0);") + "\" data-id=\"" + row["ID"].ToString() + "\" data-title=\"" + row["Title"].ToString().Trim() + "\" data-model=\"" + row["OpenMode"].ToString() + "\" data-width=\"" + row["Width"].ToString() + "\" data-height=\"" + row["Height"].ToString() + "\" data-childs=\"" + (flag ? "1" : "0") + "\" data-url=\"" + getAddress(row, @params) + "\" data-parent=\"" + refreshID.ToString() + "\" style=\"" + (str.IsNullOrEmpty() ? "" : ("color:" + str.Trim1() + ";")) + "\">");
                    stringBuilder.Append("<div class=\"menulistdiv1\">");
                    string text = row["Ico"].ToString();
                    if (text.IsNullOrEmpty())
                    {
                        text = row["AppIco"].ToString();
                    }
                    if (text.IsNullOrEmpty())
                    {
                        stringBuilder.Append("<i class=\"fa fa-file-text-o\" style=\"font-size:14px;margin-right:3px;vertical-align:middle\"></i>");
                    }
                    else if (text.IsFontIco())
                    {
                        stringBuilder.Append("<i class=\"fa " + text + "\" style=\"font-size:14px;margin-right:3px;vertical-align:middle\"></i>");
                    }
                    else
                    {
                        stringBuilder.Append("<img src=\"" + Config.BaseUrl + text + "\" style=\"vertical-align:middle\" alt=\"\"/>");
                    }
                    stringBuilder.Append("<span style=\"vertical-align:middle\">" + row["Title"].ToString().Trim1() + "</span>");
                    stringBuilder.Append("</div>");
                    if (flag)
                    {
                        stringBuilder.Append("<div class=\"menulistdiv2\"><i class=\"fa fa-angle-left\"></i></div>");
                    }
                    stringBuilder.Append("</div>");
                }
            }
            return(stringBuilder.ToString());
        }