public bool InitFileUploadOnServerExt() { var uploadFileName = Path.GetFileName(_file); StartFileUploadResponse startFileUploadResponse = (StartFileUploadResponse)DBFileUploader.StartFileUpload(_file, _userId, "", _uploadMethod); bool rtn = true; if (startFileUploadResponse.UploadedCompleted) { MessageBox.Show("Already Copyed File: " + Path.GetFileName(_file) + " using " + startFileUploadResponse.UploadMethod.ToString()); return(false); } if (startFileUploadResponse.AlredayUploded) { _startingIndex = startFileUploadResponse.StartingIndex; var uploadedSoFarMsg = string.Format("{0} MB of {1} MB", ConvertBytesToMegabytes(_startingIndex).ToString(), fileSizeInMB.ToString()); worker.ReportProgress((int)(_startingIndex / _bufferLength), uploadedSoFarMsg); } else { startFileUploadResponse.UploadMethod = _uploadMethod; } fileUploadId = startFileUploadResponse.FileUploadID; fileUploadGUID = startFileUploadResponse.FileUploadGUID; var uploadMethod = startFileUploadResponse.UploadMethod; _fileCopyer = GetFileCopyer(uploadMethod); return(rtn); }
public static StartFileUploadResponse StartFileUpload(string file, int userId, string fileHash, string uploadMethod) { var result = GetUploadedFileInfo(file, userId, fileHash); var alreadyUploaded = true; if (result == null) { alreadyUploaded = false; result = new UploadedFileInfo(); result.ID = Guid.NewGuid(); result.UserId = userId; result.FileName = Path.GetFileName(file); result.ClientFilePath = file; result.LastUpdate = DateTime.Now; result.SavedBytes = 0; result.UploadedCompleted = false; result.UploadMethod = uploadMethod; lock (objlock) { uploadFiles.Add(result); } Save(); } StartFileUploadResponse response = new StartFileUploadResponse() { ClientFilePath = result.ClientFilePath, FileHash = result.FileHash, FileName = result.FileName, FileUploadGUID = result.ID, UserId = result.UserId, StartingIndex = result.SavedBytes, AlredayUploded = alreadyUploaded, UploadMethod = result.UploadMethod, UploadedCompleted = result.UploadedCompleted }; return(response); }