Наследование: Aegis.Client.Response
Пример #1
0
        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);
                });
        }
Пример #2
0
        public static void Storage_Sheet_Refresh(string filename, APICallbackHandler<ResponseBase> callback)
        {
            _sheetFilename = filename;

            SecurePacket reqPacket = new SecurePacket(Protocol.GetID("CS_CloudSheet_GetSheetList_Req"));
            reqPacket.PutInt32(_userNo);
            reqPacket.PutStringAsUtf16(_sheetFilename);

            _request.SendPacket(reqPacket,
                (resPacket) =>
                {
                    ResponseBase response = new ResponseBase(resPacket);
                    if (response.ResultCodeNo != ResultCode.Ok)
                    {
                        callback(response);
                        return;
                    }

                    Workbook = new Workbook();
                    OnRecv_Storage_Sheet_GetSheetList(resPacket, callback);
                });
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
 private void OnResponse_SetValue(ResponseBase response)
 {
     if (response.ResultCodeNo == ResultCode.Ok)
         FormMain.SetMessageBlue("Ok");
     else
         FormMain.SetMessageRed(ResultCode.ToString(response.ResultCodeNo));
 }