private static void OnRecv_Storage_Sheet_GetSheetList(SecurePacket packet, APICallbackHandler<ResponseBase> callback) { int sheetCount = packet.GetInt32(); while (sheetCount-- > 0) { string sheetName = packet.GetStringFromUtf16(); int recordCount = packet.GetInt32(); int columnCount = packet.GetInt32(); Sheet sheet = Workbook.AddSheet(sheetName, recordCount, columnCount); while (columnCount-- > 0) { FieldDataType type = (FieldDataType)packet.GetInt32(); string fieldname = packet.GetStringFromUtf16(); sheet.AddField(type, fieldname); } } if (Workbook.Sheets.Count() == 0) { callback(new ResponseBase(ResultCode.Ok)); return; } _sheetRequestedNo = 0; _sheetName = Workbook.Sheets[_sheetRequestedNo].Name; SecurePacket reqPacket = new SecurePacket(Protocol.GetID("CS_CloudSheet_GetRecords_Req")); reqPacket.PutInt32(_userNo); reqPacket.PutStringAsUtf16(_sheetFilename); reqPacket.PutStringAsUtf16(_sheetName); reqPacket.PutUInt32(0); _request.SendPacket(reqPacket, (resPacket) => { ResponseBase response = new ResponseBase(resPacket); if (response.ResultCodeNo != ResultCode.Ok) { callback(response); return; } OnRecv_Storage_Sheet_GetRecords(resPacket, callback); }); }
private static void OnRecv_Storage_Sheet_GetRecords(SecurePacket packet, APICallbackHandler<ResponseBase> callback) { try { Boolean hasMore = (packet.GetByte() == 1); int rowCount = packet.GetInt32(); UInt32 rowNo = 0; Sheet table = Workbook.GetSheet(_sheetName); while (rowCount-- > 0) { string[] values = new string[table.Fields.Count()]; rowNo = packet.GetUInt32(); for (int i = 0; i < table.Fields.Count(); ++i) values[i] = packet.GetStringFromUtf16(); table.AddRowData(rowNo, values); } if (hasMore) { SecurePacket reqPacket = new SecurePacket(Protocol.GetID("CS_CloudSheet_GetRecords_Req")); reqPacket.PutInt32(_userNo); reqPacket.PutStringAsUtf16(_sheetFilename); reqPacket.PutStringAsUtf16(_sheetName); reqPacket.PutUInt32(rowNo + 1); _request.SendPacket(reqPacket, (resPacket) => { ResponseBase response = new ResponseBase(resPacket); if (response.ResultCodeNo != ResultCode.Ok) { callback(response); return; } OnRecv_Storage_Sheet_GetRecords(resPacket, callback); }); } else { ++_sheetRequestedNo; if (Workbook.Sheets.Count() > _sheetRequestedNo) { table = Workbook.Sheets[_sheetRequestedNo]; _sheetName = table.Name; SecurePacket reqPacket = new SecurePacket(Protocol.GetID("CS_CloudSheet_GetRecords_Req")); reqPacket.PutInt32(_userNo); reqPacket.PutStringAsUtf16(_sheetFilename); reqPacket.PutStringAsUtf16(_sheetName); reqPacket.PutUInt32(0); _request.SendPacket(reqPacket, (resPacket) => { ResponseBase response = new ResponseBase(resPacket); if (response.ResultCodeNo != ResultCode.Ok) { callback(response); return; } OnRecv_Storage_Sheet_GetRecords(resPacket, callback); }); } else { callback(new ResponseBase(packet)); } } } catch (Exception) { callback(new ResponseBase(ResultCode.UnknownError)); } }