Beispiel #1
0
 private static bool WriteField(ScorpioWriter write, string type, object value)
 {
     if (type == BoolType)
     {
         write.WriteBool((bool)value);
     }
     else if (type == Int8Type)
     {
         write.WriteInt8(ScorpioUtil.ToInt8(value));
     }
     else if (type == Int16Type)
     {
         write.WriteInt16(ScorpioUtil.ToInt16(value));
     }
     else if (type == Int32Type || type == IntType)
     {
         write.WriteInt32(ScorpioUtil.ToInt32(value));
     }
     else if (type == Int64Type)
     {
         write.WriteInt64(ScorpioUtil.ToInt64(value));
     }
     else if (type == FloatType)
     {
         write.WriteFloat(ScorpioUtil.ToFloat(value));
     }
     else if (type == DoubleType)
     {
         write.WriteDouble(ScorpioUtil.ToDouble(value));
     }
     else if (type == StringType)
     {
         write.WriteString((string)value);
     }
     else if (type == BytesType)
     {
         write.WriteBytes((byte[])value);
     }
     else
     {
         return(false);
     }
     return(true);
 }
Beispiel #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);
        }