Пример #1
0
 public FilesController(IFileClientService fileClientService,
                        ITicketClientService ticketClientService, IValidator <DownloadReferenceDto> downloadReferenceDtoValidator)
 {
     _fileClientService             = fileClientService;
     _ticketClientService           = ticketClientService;
     _downloadReferenceDtoValidator = downloadReferenceDtoValidator;
 }
Пример #2
0
        private static bool OnClientRequestError__(ByteArray byteArray, IFileClientService clientService)
        {
            int errorCode = byteArray.readDynamicsInt();

            if (ClientRequestErrorHandler__ != null)
            {
                ClientRequestErrorHandler__(errorCode);
            }
            return(true);
        }
Пример #3
0
        private static bool OnSetWorkingDirectoryResult(ByteArray byteArray, IFileClientService clientService)
        {
            int    result = byteArray.readDynamicsInt();
            String desc   = byteArray.readUTF();

            int crc = byteArray.readIntNCRC();

            if (crc == byteArray.CRC)
            {
                clientService.OnSetWorkingDirectoryResult(result, desc);
            }

            byteArray.Recycle();
            return(true);
        }
Пример #4
0
        private static bool OnFileBlockResponse(ByteArray byteArray, IFileClientService clientService)
        {
            int file    = byteArray.readDynamicsInt();
            int blockId = byteArray.readDynamicsInt();

            int crc = byteArray.readIntNCRC();

            if (crc == byteArray.CRC)
            {
                clientService.OnFileBlockResponse(file, blockId);
            }

            byteArray.Recycle();
            return(true);
        }
Пример #5
0
        private static bool OnFileSendResponse(ByteArray byteArray, IFileClientService clientService)
        {
            int file        = byteArray.readDynamicsInt();
            int uploadToken = byteArray.readDynamicsInt();

            int crc = byteArray.readIntNCRC();

            if (crc == byteArray.CRC)
            {
                clientService.OnFileSendResponse(file, uploadToken);
            }

            byteArray.Recycle();
            return(true);
        }
Пример #6
0
        private static bool OnRequestFileDownload(ByteArray byteArray, IFileClientService clientService)
        {
            String file       = byteArray.readUTF();
            String remoteFile = byteArray.readUTF();
            bool   isDir      = byteArray.readBoolean();

            int crc = byteArray.readIntNCRC();

            if (crc == byteArray.CRC)
            {
                clientService.OnRequestFileDownload(file, remoteFile, isDir);
            }

            byteArray.Recycle();
            return(true);
        }
Пример #7
0
        private static bool OnListDirectorysResult(ByteArray byteArray, IFileClientService clientService)
        {
            int            result      = byteArray.readDynamicsInt();
            StringSequence directories = new StringSequence();

            directories.ReadFromByteArray(byteArray);

            int crc = byteArray.readIntNCRC();

            if (crc == byteArray.CRC)
            {
                clientService.OnListDirectorysResult(result, ref directories);
            }

            byteArray.Recycle();
            return(true);
        }
Пример #8
0
        private static bool OnSendFinishResponse(ByteArray byteArray, IFileClientService clientService)
        {
            int    file       = byteArray.readDynamicsInt();
            int    totalSize  = byteArray.readDynamicsInt();
            int    expectSize = byteArray.readDynamicsInt();
            String md5        = byteArray.readUTF();

            int crc = byteArray.readIntNCRC();

            if (crc == byteArray.CRC)
            {
                clientService.OnSendFinishResponse(file, totalSize, expectSize, md5);
            }

            byteArray.Recycle();
            return(true);
        }
Пример #9
0
        public static bool IntepretMessage(ByteArray byteArray, IFileClientService clientService)
        {
            byteArray.BypassHeader();
            int  methodID = byteArray.readInt();
            bool mtdrst__ = false;

            switch (methodID)
            {
            case EnumFileMethods.CLIENT_REQUESTFILEDOWNLOAD_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_REQUESTFILEDOWNLOAD_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnRequestFileDownload(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_FILESENDRESPONSE_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_FILESENDRESPONSE_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnFileSendResponse(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_SENDFINISHRESPONSE_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_SENDFINISHRESPONSE_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnSendFinishResponse(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_FILEBLOCKRESPONSE_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_FILEBLOCKRESPONSE_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnFileBlockResponse(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_CREATEDIRECTORYRESULT_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_CREATEDIRECTORYRESULT_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnCreateDirectoryResult(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_LISTDIRECTORYSRESULT_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_LISTDIRECTORYSRESULT_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnListDirectorysResult(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_DELETEDIRECTORYRESULT_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_DELETEDIRECTORYRESULT_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnDeleteDirectoryResult(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_DELETEFILERESULT_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_DELETEFILERESULT_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnDeleteFileResult(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_SETWORKINGDIRECTORYRESULT_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_SETWORKINGDIRECTORYRESULT_HASH;
                byteArray.CRC        = 0;
                byteArray.readDynamicsInt();
                mtdrst__             = OnSetWorkingDirectoryResult(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(mtdrst__);

            case EnumFileMethods.CLIENT_REQUESTERROR_HASH:
                byteArray.EncryptKey = EnumFileMethods.CLIENT_REQUESTERROR_HASH;
                byteArray.readDynamicsInt();
                OnClientRequestError__(byteArray, clientService);
                byteArray.EncryptKey = 0;
                return(true);
            }

            if (methodID == EnumFileMethods.CLIENT_REQUESTERROR_HASH)
            {
                return(OnClientRequestError__(byteArray, clientService));
            }
            // recover the header
            byteArray.Rewind();
            return(false);
        }