Ejemplo n.º 1
0
        /*
        public int UseCount
        {
            get
            {
                return this.m_nUseCount;
            }
        }
         */

        // 初始化用户对象
        // 线程不安全。因为被调用时尚未进入集合,也没有必要线程安全
        // parameters:
        //      dom         用户记录dom
        //      strResPath  记录路径 全路径 库名/记录号
        //      db          所从属的数据库
        //      strError    out参数,返回出错信息
        // return:
        //      -1  出错
        //      0   成功
        internal int Initial(string strRecPath,
            XmlDocument dom,
            Database db,
            DatabaseCollection dbs,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            this.RecPath = strRecPath;
            this.m_dom = dom;
            // this.m_db = db;

            XmlNode root = this.m_dom.DocumentElement;
            XmlNode nodeName = root.SelectSingleNode("name");
            if (nodeName != null)
                this.Name = DomUtil.GetNodeText(nodeName).Trim();

            // 用户所拥有的数据库
            this.aOwnerDbName = null;

            if (String.IsNullOrEmpty(this.Name) == false)
            {
                List<string> aOwnerDbName = null;

                nRet = dbs.GetOwnerDbNames(this.Name,
                    out aOwnerDbName,
                    out strError);
                if (nRet == -1)
                    return -1;

                this.aOwnerDbName = aOwnerDbName;
            }




            XmlNode nodePassword = root.SelectSingleNode("password");
            if (nodePassword != null)
                SHA1Password = DomUtil.GetNodeText(nodePassword).Trim();

            XmlNode nodeRightsItem = root.SelectSingleNode("rightsItem");
            if (nodeRightsItem != null)
            {
                strError = "帐户记录为旧版本,根元素下已经不支持<rightsItem>元素。";
                return -1;
            }

            // 没有<server>元素是否按出错处理
            this.m_nodeServer = root.SelectSingleNode("server");
            if (this.m_nodeServer == null)
            {
                strError = "帐户记录未定义<server>元素。";
                return -1;
            }

            this.cfgRights = new CfgRights();
            // return:
            //      -1  出错
            //      0   成功
            nRet = this.cfgRights.Initial(this.m_nodeServer,
                out strError);
            if (nRet == -1)
                return -1;

            return 0;
        }