コード例 #1
0
 protected virtual void OnFileUploadRequest(EventArguments.FileUploadRequestEventArguments args)
 {
     if (FileUploadRequest != null)
     {
         FileUploadRequest(this, args);
     }
 }
コード例 #2
0
        private void FileUploadRequestHandler(FileUploadRequest request)
        {
            FileUploadResponse response = new FileUploadResponse(request);

            if (request.CurrentPosition == 0)
            {
                EventArguments.FileUploadRequestEventArguments args = new EventArguments.FileUploadRequestEventArguments(() =>
                {
                    //Confirm File Upload
                    response.DestinationFilePath = request.DestinationFilePath;
                    SendMessage(response);
                },
                                                                                                                         () =>
                {
                    //Refuse File Upload
                    response.HasError  = true;
                    response.Exception = new Exception("The file upload request was refused by the user!");
                    SendMessage(response);
                });

                args.Request = request;
                OnFileUploadRequest(args);
            }
            else
            {
                lock (fileUploadRequests)
                {
                    fileUploadRequests.Add(request);
                }

                //SendMessage(response);
                //OnUploadFileProgress(new EventArguments.FileUploadProgressEventArguments() { CurrentPosition = request.CurrentPosition, FileName = request.FileName, TotalBytes = request.TotalBytes, DestinationPath = request.DestinationFilePath });
            }
        }