Example #1
0
        public TableTest Initialize(TableManager tableManager, string fileName)
        {
            m_dataArray.Clear();
            ScorpioReader reader = new ScorpioReader(TableUtil.GetBuffer(fileName));
            int           iRow   = TableUtil.ReadHead(reader, fileName, FILE_MD5_CODE);

            for (int i = 0; i < iRow; ++i)
            {
                DataTest pData = DataTest.Read(tableManager, fileName, reader);
                if (Contains(pData.ID()))
                {
                    throw new System.Exception("文件[" + fileName + "]有重复项 ID : " + pData.ID());
                }
                m_dataArray.Add(pData.ID(), pData);
            }
            m_count = m_dataArray.Count;
            reader.Close();
            return(this);
        }
Example #2
0
        //读取excel文件数据内容
        public static ScriptTable ReadDatas(Script script, ScriptTable tableManager, string fileName, string layoutTableName, string keyName, string MD5)
        {
            ScriptTable   ret    = script.CreateTable();
            ScorpioReader reader = new ScorpioReader(TableUtil.GetBuffer(fileName));
            int           iRow   = TableUtil.ReadHead(reader, fileName, MD5);
            ScriptTable   data   = null;
            double        key    = 0;

            for (int i = 0; i < iRow; ++i)
            {
                data = ScorpioSerializer.Read(script, reader, tableManager, fileName, layoutTableName, false);
                key  = ScorpioUtil.ToDouble(data.GetValue(keyName).ObjectValue);
                if (ret.HasValue(key))
                {
                    throw new System.Exception("文件[" + fileName + "]有重复项 ID : " + key);
                }
                ret.SetValue(key, data);
                data.SetValue("ID", script.CreateDouble(key));
            }
            return(ret);
        }