Ejemplo n.º 1
0
        /// <summary>
        /// 获取用户可访问的站点
        /// </summary>
        /// <param name="userHandle"></param>
        /// <returns></returns>
        public List <LinkSiteInfo> GetLinkSites(string userHandle)
        {
            // 判断userHandle存不存在
            LibHandle handle = LibHandleCache.Default.GetCurrentHandle(userHandle);

            if (handle == null)
            {
                throw new Exception("用户句柄无效");
            }
            List <LinkSiteInfo> linkSiteInfoList = new List <LinkSiteInfo>();
            string        sql        = string.Format("select B.SITEID, B.SITENAME, B.SHORTNAME, B.SITEURL, B.SVCURL, B.ISSLAVE,B.ISSENDTO from AXPUSERSITE A join AXPLINKSITE B on A.SITEID = B.SITEID where A.USERID = {0}", LibStringBuilder.GetQuotString(handle.UserId));
            LibDataAccess dataAccess = new LibDataAccess();

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    var siteInfo = new LinkSiteInfo()
                    {
                        SiteId    = LibSysUtils.ToString(reader["SITEID"]),
                        SiteName  = LibSysUtils.ToString(reader["SITENAME"]),
                        ShortName = LibSysUtils.ToString(reader["SHORTNAME"]),
                        SiteUrl   = LibSysUtils.ToString(reader["SITEURL"]),
                        SvcUrl    = LibSysUtils.ToString(reader["SVCURL"]),
                        IsSlave   = LibSysUtils.ToBoolean(reader["ISSLAVE"]),
                        IsSendTo  = LibSysUtils.ToBoolean(reader["ISSENDTO"]),
                    };
                    linkSiteInfoList.Add(siteInfo);
                }
            }
            return(linkSiteInfoList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取用户可访问的下级站点代码列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns>站点代码与站点信息的字典</returns>
        public static Dictionary <string, LinkSiteInfo> GetCanLoginSlaveSites(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return(null);
            }
            Dictionary <string, LinkSiteInfo> siteIds = new Dictionary <string, LinkSiteInfo>();

            try
            {
                if (ExistLinkSiteTable == false || ExistUserLinkSiteTable == false)
                {
                    return(null);
                }

                string sql = string.Format("select distinct B.* from AXPUSERSITE A " +
                                           " left join AXPLINKSITE B on A.SITEID = B.SITEID" +
                                           " where A.USERID = {0} and ISSLAVE = 1", LibStringBuilder.GetQuotString(userId));
                LibDataAccess dataAccess = new LibDataAccess();
                string        name       = string.Empty;
                string        id         = string.Empty;
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        id   = LibSysUtils.ToString(reader["SITEID"]);
                        name = LibSysUtils.ToString(reader["SHORTNAME"]);
                        if (string.IsNullOrEmpty(id) == false)
                        {
                            siteIds[id] = new LinkSiteInfo()
                            {
                                SiteId    = id,
                                SiteName  = LibSysUtils.ToString(reader["SITENAME"]),
                                ShortName = LibSysUtils.ToString(reader["SHORTNAME"]),
                                SiteUrl   = LibSysUtils.ToString(reader["SITEURL"]),
                                SvcUrl    = LibSysUtils.ToString(reader["SVCURL"]),
                                IsSlave   = LibSysUtils.ToBoolean(reader["ISSLAVE"]),
                                IsSendTo  = LibSysUtils.ToBoolean(reader["ISSENDTO"]),
                            };
                        }
                    }
                }
            }
            catch
            {
                //to do log
            }
            return(siteIds);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取站点代码对应的子站点信息。如果站点代码为空则表示获取所有子站点信息
        /// </summary>
        /// <param name="siteIds">站点代码列表</param>
        /// <param name="checkNeedSendTo"></param>
        /// <returns>站点代码与站点信息的字典</returns>
        public static Dictionary <string, LinkSiteInfo> GetLinkSites(string[] siteIds = null, bool checkNeedSendTo = false)
        {
            string siteIdStr = string.Empty;

            if (siteIds != null && siteIds.Length > 0)
            {
                foreach (string siteId in siteIds)
                {
                    if (string.IsNullOrEmpty(siteId))
                    {
                        continue;
                    }
                    siteIdStr += LibStringBuilder.GetQuotString(siteId) + ",";
                }
                if (string.IsNullOrEmpty(siteIdStr) == false)
                {
                    siteIdStr = siteIdStr.Substring(0, siteIdStr.Length - 1);
                }
            }
            Dictionary <string, LinkSiteInfo> siteInfos = new Dictionary <string, LinkSiteInfo>();

            try
            {
                if (ExistLinkSiteTable == false || ExistUserLinkSiteTable == false)
                {
                    return(null);
                }
                string sql = string.Format("select * from AXPLINKSITE ");
                if (string.IsNullOrEmpty(siteIdStr) == false)
                {
                    sql += " where SITEID in (" + siteIdStr + ")";
                }
                LibDataAccess dataAccess = new LibDataAccess();
                string        name       = string.Empty;
                string        id         = string.Empty;
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        id   = LibSysUtils.ToString(reader["SITEID"]);
                        name = LibSysUtils.ToString(reader["SHORTNAME"]);
                        if (string.IsNullOrEmpty(id) == false)
                        {
                            siteInfos[id] = new LinkSiteInfo()
                            {
                                SiteId    = id,
                                SiteName  = LibSysUtils.ToString(reader["SITENAME"]),
                                ShortName = LibSysUtils.ToString(reader["SHORTNAME"]),
                                SiteUrl   = LibSysUtils.ToString(reader["SITEURL"]),
                                SvcUrl    = LibSysUtils.ToString(reader["SVCURL"]),
                                IsSlave   = LibSysUtils.ToBoolean(reader["ISSLAVE"]),
                                IsSendTo  = LibSysUtils.ToBoolean(reader["ISSENDTO"]),
                            };
                        }
                    }
                }
            }
            catch
            {
                //to do log
            }
            if (checkNeedSendTo)
            {
                if (siteInfos != null && siteInfos.Count > 0)
                {
                    siteInfos = (from item in siteInfos.Values
                                 where item.IsSendTo
                                 select item).ToDictionary(t => t.SiteId, t => t);//筛选需要同步到的站点
                }
            }
            return(siteInfos);
        }