private bool StartUpload(XferUploadHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) { uploader.UploadDone += uploadCompleteCallback; uploader.UploadDone += RemoveXferUploadHandler; if (abortCallback != null) { uploader.UploadAborted += abortCallback; } lock (m_uploadHandlersLock) { if (!m_uploadHandlers.ContainsKey(uploader.XferID)) { m_uploadHandlers.Add(uploader.XferID, uploader); uploader.RequestStartXfer(m_clientAPI); return(true); } else { // something went wrong with the xferID allocation uploader.UploadDone -= uploadCompleteCallback; uploader.UploadDone -= RemoveXferUploadHandler; if (abortCallback != null) { uploader.UploadAborted -= abortCallback; } return(false); } } }
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { return; } string szKey = FileObjectSessionKey(e.FileId); PendingIDs.Add(szKey); Session[szKey] = new MFBPendingImage(new MFBPostedFile(e), szKey); e.DeleteTemporaryData(); RefreshPreviewList(); if (Mode == UploadMode.Legacy) { Mode = UploadMode.Ajax; } UploadComplete?.Invoke(this, e); }
internal bool PublishBundleAndCleanUp(string resourceFolder, UploadComplete complete, UploadProgress progress, Stack <RequestHandle> requests) { if (string.IsNullOrEmpty(m_Guid)) { return(false); } m_UploadCompleteCallback = complete; m_UploadProgressCallback = progress; switch (m_Resource.type) { case ResourceType.Scene: requests.Push(m_StorageUser.UploadSceneAssetBundle(resourceFolder, m_Platform.ToString(), m_Guid, OnComplete, OnUploadProgress)); break; case ResourceType.Prefab: requests.Push(m_StorageUser.UploadPrefabAssetBundle(resourceFolder, m_Platform.ToString(), m_Guid, OnComplete, OnUploadProgress)); break; default: Debug.LogWarning($"Trying to upload asset bundle {m_Resource.name} which is of type {m_Resource.type} which is not a Scene or a Prefab"); break; } return(true); }
protected void SendCompleteMessage(IClientAPI remoteClient) { m_complete = true; handlerUploadDone = UploadDone; if (handlerUploadDone != null) { handlerUploadDone(m_asset.Name, m_asset.FullID, mXferID, m_asset.Data, remoteClient); } }
public bool RequestUpload(string clientFileName, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) { if ((String.IsNullOrEmpty(clientFileName)) || (uploadCompleteCallback == null)) { return false; } XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, clientFileName); return StartUpload(uploader, uploadCompleteCallback, abortCallback); }
public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) { if ((fileID == UUID.Zero) || (uploadCompleteCallback == null)) { return(false); } XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, fileID); return(StartUpload(uploader, uploadCompleteCallback, abortCallback)); }
public bool RequestUpload(string clientFileName, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) { if ((String.IsNullOrEmpty(clientFileName)) || (uploadCompleteCallback == null)) { return(false); } XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, clientFileName); return(StartUpload(uploader, uploadCompleteCallback, abortCallback)); }
public async Task <UploadStatus> Upload(string[] logLines, UploadMetaData data) { var result = LogValidator.Validate(logLines); if (!result.IsValid) { UploadError?.Invoke(new UploadErrorEventArgs(0, data, result.Reason)); return(new UploadStatus(new InvalidLogException(result.Reason))); } var log = string.Join(Environment.NewLine, logLines); var item = new UploaderItem(log.GetHashCode()); if (_inProgress.Contains(item)) { Log.Debug($"{item.Hash} already in progress. Waiting for it to complete..."); _inProgress.Add(item); return(await item.Status); } _inProgress.Add(item); Log.Debug($"Uploading {item.Hash}..."); UploadStatus status; UploadInitiated?.Invoke(new UploadStatusChangedEventArgs(item.Hash, data)); try { status = await TryUpload(logLines, data); } catch (Exception ex) { Log.Error(ex); status = new UploadStatus(ex); } Log.Debug($"{item.Hash} complete. Success={status.Success}"); UploadComplete?.Invoke(new UploadCompleteEventArgs(item.Hash, data, status)); foreach (var waiting in _inProgress.Where(x => x.Hash == item.Hash)) { waiting.Complete(status); } _inProgress.RemoveAll(x => x.Hash == item.Hash); return(status); }
protected MFBPendingImage AddPostedFile(MFBPostedFile pf, LatLong ll) { if (pf == null) { throw new ArgumentNullException(nameof(pf)); } string szKey = FileObjectSessionKey(pf.FileID); PendingIDs.Add(szKey); MFBPendingImage result = new MFBPendingImage(pf, szKey); if (ll != null) { result.Location = ll; } Session[szKey] = result; UploadComplete?.Invoke(this, new EventArgs()); RefreshPreviewList(); return(result); }
protected void ProcessClipboardImage() { // Regardless of mode, see if there's a clipboard image if (!String.IsNullOrEmpty(hImg.Value)) { try { MFBPostedFile pf = new MFBPostedFile(hImg.Value); if (ValidateFileType(MFBImageInfo.ImageTypeFromFile(pf))) { // create a pending file. string szKey = FileObjectSessionKey(pf.FileName); PendingIDs.Add(szKey); Session[szKey] = new MFBPendingImage(pf, szKey); RefreshPreviewList(); UploadComplete?.Invoke(this, new EventArgs()); } } catch (FormatException) { } // if it's bad data, just don't do anything. hImg.Value = string.Empty; // don't send it back down the wire!!! } }
public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) { if ((fileID == UUID.Zero) || (uploadCompleteCallback == null)) { return false; } XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, fileID); return StartUpload(uploader, uploadCompleteCallback, abortCallback); }
private bool StartUpload(XferUploadHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) { uploader.UploadDone += uploadCompleteCallback; uploader.UploadDone += RemoveXferUploadHandler; if (abortCallback != null) { uploader.UploadAborted += abortCallback; } lock (m_uploadHandlersLock) { if (!m_uploadHandlers.ContainsKey(uploader.XferID)) { m_uploadHandlers.Add(uploader.XferID, uploader); uploader.RequestStartXfer(m_clientAPI); return true; } else { // something went wrong with the xferID allocation uploader.UploadDone -= uploadCompleteCallback; uploader.UploadDone -= RemoveXferUploadHandler; if (abortCallback != null) { uploader.UploadAborted -= abortCallback; } return false; } } }