Exemplo n.º 1
0
        // 获得一条记录的 XML 字符串
        // return:
        //		-1  出错
        //		-4  未找到记录
        //      -10 记录局部未找到
        //		0   成功
        long GetXmlBody(
            Database db,
            string strID,
            bool bXml,
            bool bTimestamp,
            bool bMetadata,
            bool bWithResMetadata,
            out string strXml,
            out string strMetadata,
            out byte[] baTimestamp,
            out string strError)
        {
            strError = "";
            strXml = "";
            strMetadata = "";
            baTimestamp = null;

            string strGetStyle = "";   //"data,timestamp"; // ,outputpath, metadata

            if (bTimestamp == true)
                StringUtil.SetInList(ref strGetStyle, "timestamp", true);

            if (bXml == true)
                StringUtil.SetInList(ref strGetStyle, "data", true);

            if (bMetadata == true)
                StringUtil.SetInList(ref strGetStyle, "metadata", true);

            if (bWithResMetadata == true)
                StringUtil.SetInList(ref strGetStyle, "withresmetadata", true);

            int nStart0 = 0;
            int nLength0 = -1;
            int nMaxLength = 300 * 1024;    // 每次最多获取300K
            int nTotalLength = 0;

            string strOutputID = "";

            byte[] baTotal = null;

            int nAdditionError = 0;

            for (; ; )
            {
                byte[] baData = null;

                long lRet = db.GetXml(strID,
                    "", // strXPath,
                    nStart0,
                    nLength0,
                    nMaxLength,
                    strGetStyle,
                    out baData,
                    out strMetadata,
                    out strOutputID,
                    out baTimestamp,
                    true,
                    out nAdditionError,
                    out strError);
                if (lRet <= -1)
                    return lRet;

                nTotalLength = (int)lRet;

                // 如果数据体太大
                if (nTotalLength > QUOTA_SIZE)
                {
                    strError = "数据尺寸超过 " + QUOTA_SIZE.ToString();
                    return -1;
                }

                // 2012/11/28
                // 如果不想获得数据, baData就是null
                if (baData == null)
                    break;

                baTotal = ByteArray.Add(baTotal, baData);

                nStart0 += baData.Length;

                if (nStart0 >= nTotalLength)
                    break;
            }

            // 记录体
            // 转换成字符串
            if (bXml == true && baTotal != null)
            {
                strXml = ByteArray.ToString(baTotal);
            }

            return 0;
        }
Exemplo n.º 2
0
 // 检查其它的库所有语言版本中是否存在相同的逻辑名
 internal bool IsExistLogicName(string strLogicName,
     Database exceptDb)
 {
     for (int i = 0; i < this.Count; i++)
     {
         Database db = (Database)this[i];
         if (exceptDb != null)
         {
             if (db == exceptDb)
                 continue;
         }
         string strDbAllLogicName = db.GetAllCaption();
         if (StringUtil.IsInList(strLogicName, strDbAllLogicName, true) == true)
             return true;
     }
     return false;
 }
Exemplo n.º 3
0
        // 检索数据库对应的配置目录是否重复
        // parameters:
        //      strCfgsDir  目录名,相对目录
        //      exceptDb    不参考比较的数据库对象
        // return:
        //      true    有重复
        //      false   无重复
        internal bool IsExistCfgsDir(string strCfgsDir,
            Database exceptDb)
        {
            for (int i = 0; i < this.Count; i++)
            {
                Database db = (Database)this[i];
                if (exceptDb != null)
                {
                    if (db == exceptDb)
                        continue;
                }
                string strDbCfgsDir = DatabaseUtil.GetLocalDir(this.NodeDbs,
                    db.m_selfNode);

                if (String.Compare(strCfgsDir, strDbCfgsDir, true) == 0)
                    return true;
            }
            return false;
        }
Exemplo n.º 4
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;
        }