Ejemplo n.º 1
0
        /// <summary>
        /// 得到角色应用刷新JSON
        /// </summary>
        /// <returns></returns>
        public string GetRoleAppRefreshJsonString(Guid roleID, Guid userID, Guid refreshID, string rootDir = "")
        {
            RoleApp    roleApp   = new BizProcess.Platform.RoleApp();
            UsersApp   UsersApp  = new Platform.UsersApp();
            AppLibrary Applibary = new AppLibrary();
            DataTable  roleAppDt = roleApp.GetAllDataTableFromCache();
            DataTable  appDt1    = CloneDataTable(roleAppDt);

            UsersApp.AppendUserApps(userID, appDt1);
            var dv = appDt1.DefaultView;

            dv.RowFilter = string.Format("ParentID='{0}'", refreshID);
            dv.Sort      = "Sort";
            var appDt = dv.ToTable();

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

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", count * 100);

            foreach (DataRow dr in appDt.Rows)
            {
                if (!dr["UseMember"].ToString().IsNullOrEmpty() && dr["AppID"].ToString().IsGuid() &&
                    !Applibary.GetUseMemberCache(dr["AppID"].ToString().ToGuid()).Contains(userID))
                {
                    continue;
                }
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", dr["ID"].ToString());
                json.AppendFormat("\"title\":\"{0}\",", dr["Title"].ToString().Trim());
                json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr["Ico"].ToString());
                json.AppendFormat("\"link\":\"{0}\",", getAddress(dr));
                json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"].ToString());
                json.AppendFormat("\"width\":\"{0}\",", dr["Width"].ToString());
                json.AppendFormat("\"height\":\"{0}\",", dr["Height"].ToString());
                json.AppendFormat("\"hasChilds\":\"{0}\",", appDt1.Select(string.Format("ParentID='{0}'", dr["id"].ToString())).Length > 0 ? "1" : "0");
                json.AppendFormat("\"childs\":[");

                json.Append("]");
                json.Append("}");
                if (dr["ID"].ToString() != appDt.Rows[appDt.Rows.Count - 1]["ID"].ToString())
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            return(json.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新应用程序库使用人员缓存
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="userIdString"></param>
        public List <Guid> UpdateUseMemberCache(Guid appid)
        {
            string key = BizProcess.Utility.Keys.CacheKeys.AppLibraryUseMember.ToString();
            var    obj = BizProcess.Cache.IO.Opation.Get(key);
            Dictionary <Guid, List <Guid> > dict;

            if (obj != null && obj is Dictionary <Guid, List <Guid> > )
            {
                dict = obj as Dictionary <Guid, List <Guid> >;
            }
            else
            {
                dict = new Dictionary <Guid, List <Guid> >();
            }
            var app = new AppLibrary().Get(appid);

            if (app == null)
            {
                return(new List <Guid>());
            }
            if (dict.ContainsKey(appid))
            {
                if (app.UseMember.IsNullOrEmpty())
                {
                    dict.Remove(appid);
                    return(new List <Guid>());
                }
                else
                {
                    var userIDs = new Organize().GetAllUsersIdList(app.UseMember);
                    dict[appid] = userIDs;
                    return(userIDs);
                }
            }
            else if (!app.UseMember.IsNullOrEmpty())
            {
                var userIDs = new Organize().GetAllUsersIdList(app.UseMember);
                dict.Add(appid, userIDs);
                return(userIDs);
            }
            return(new List <Guid>());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个应用程序库的使用人员
        /// </summary>
        /// <param name="appid"></param>
        /// <returns></returns>
        public List <Guid> GetUseMemberCache(Guid appid)
        {
            string key = BizProcess.Utility.Keys.CacheKeys.AppLibraryUseMember.ToString();
            var    obj = BizProcess.Cache.IO.Opation.Get(key);

            if (obj != null && obj is Dictionary <Guid, List <Guid> > )
            {
                var dict = obj as Dictionary <Guid, List <Guid> >;
                if (dict.ContainsKey(appid))
                {
                    return(dict[appid]);
                }
            }
            var app = new AppLibrary().Get(appid);

            if (app == null || app.UseMember.IsNullOrEmpty())
            {
                return(new List <Guid>());
            }
            return(UpdateUseMemberCache(appid));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到角色应用JSON
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public string GetRoleAppJsonString(Guid roleID, Guid userID, string rootDir = "")
        {
            RoleApp    RoleApp   = new BizProcess.Platform.RoleApp();
            UsersApp   UsersApp  = new Platform.UsersApp();
            AppLibrary Applibary = new AppLibrary();

            System.Data.DataTable roleAppDt = RoleApp.GetAllDataTableFromCache();
            System.Data.DataTable appDt     = CloneDataTable(roleAppDt);
            UsersApp.AppendUserApps(userID, appDt);
            if (appDt.Rows.Count == 0)
            {
                return("[]");
            }
            var root = appDt.Select(string.Format("ParentID='{0}' AND RoleID='{1}'", Guid.Empty.ToString(), roleID));

            if (root.Length == 0)
            {
                return("[]");
            }

            var apps = appDt.Select(string.Format("ParentID='{0}'", root[0]["ID"].ToString()));

            System.Text.StringBuilder json   = new System.Text.StringBuilder("[", 1000);
            System.Data.DataRow       rootDr = root[0];
            json.Append("{");
            json.AppendFormat("\"id\":\"{0}\",", rootDr["ID"].ToString());
            json.AppendFormat("\"title\":\"{0}\",", rootDr["Title"].ToString().Trim());
            json.AppendFormat("\"ico\":\"{0}\",", rootDr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + rootDr["Ico"].ToString());
            json.AppendFormat("\"link\":\"{0}\",", getAddress(rootDr).ToString());
            json.AppendFormat("\"model\":\"{0}\",", rootDr["OpenMode"].ToString());
            json.AppendFormat("\"width\":\"{0}\",", rootDr["Width"].ToString());
            json.AppendFormat("\"height\":\"{0}\",", rootDr["Height"].ToString());
            json.AppendFormat("\"hasChilds\":\"{0}\",", apps.Length > 0 ? "1" : "0");
            json.AppendFormat("\"childs\":[");

            for (int i = 0; i < apps.Length; i++)
            {
                DataRow dr = apps[i];
                if (!dr["UseMember"].ToString().IsNullOrEmpty() && dr["AppID"].ToString().IsGuid() &&
                    !Applibary.GetUseMemberCache(dr["AppID"].ToString().ToGuid()).Contains(userID))
                {
                    continue;
                }
                var childs = appDt.Select("ParentID='" + dr["ID"].ToString() + "'");
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", dr["ID"].ToString());
                json.AppendFormat("\"title\":\"{0}\",", dr["Title"].ToString());
                json.AppendFormat("\"ico\":\"{0}\",", dr["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr["Ico"].ToString());
                json.AppendFormat("\"link\":\"{0}\",", getAddress(dr));
                json.AppendFormat("\"model\":\"{0}\",", dr["OpenMode"].ToString());
                json.AppendFormat("\"width\":\"{0}\",", dr["Width"].ToString());
                json.AppendFormat("\"height\":\"{0}\",", dr["Height"].ToString());
                json.AppendFormat("\"hasChilds\":\"{0}\",", childs.Length > 0 ? "1" : "0");
                json.AppendFormat("\"childs\":[");

                /* DataRow[] apps1 = appDt.Select(string.Format("ParentID='{0}'", dr["ID"].ToString()));
                 * for (int j = 0; j < apps1.Length; j++)
                 * {
                 *  DataRow dr1 = apps1[j];
                 *  var childs1 = appDt.Select("ParentID='" + dr1["ID"].ToString() + "'");
                 *  json.Append("{");
                 *  json.AppendFormat("\"id\":\"{0}\",", dr1["ID"]);
                 *  json.AppendFormat("\"title\":\"{0}\",", dr1["Title"]);
                 *  json.AppendFormat("\"ico\":\"{0}\",", dr1["Ico"].ToString().IsNullOrEmpty() ? "" : rootDir + dr1["Ico"]);
                 *  json.AppendFormat("\"link\":\"{0}\",", getAddress(dr1));
                 *  json.AppendFormat("\"model\":\"{0}\",", dr1["OpenMode"]);
                 *  json.AppendFormat("\"width\":\"{0}\",", dr1["Width"]);
                 *  json.AppendFormat("\"height\":\"{0}\",", dr1["Height"]);
                 *  json.AppendFormat("\"hasChilds\":\"{0}\",", childs1.Length > 0 ? "1" : "0");
                 *  json.AppendFormat("\"childs\":[");
                 *  json.Append("]");
                 *  json.Append("}");
                 *  if (j < apps1.Length - 1)
                 *  {
                 *      json.Append(",");
                 *  }
                 * }*/

                json.Append("]");
                json.Append("}");
                if (dr["ID"].ToString() != apps[apps.Length - 1]["ID"].ToString())
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            json.Append("}");
            json.Append("]");
            return(json.ToString());
        }