private void PopRequester(string itemId, ITurnContext turnContext) { OperationFinished?.Invoke(turnContext, $"Parece que {queuedItems[itemId].CurrentOwner} ha liberado {itemId}."); queuedItems[itemId].SetNextOwner(); queuedItems[itemId].PopRequester(); NotifyNextRequester(itemId, turnContext); }
public void FileNewCopy( string filePath, long fileID, OperationFinished<FileNewCopyResponse> fileNewCopyCompleted) { FileNewCopy(filePath, fileID, false, null, null, fileNewCopyCompleted, null); }
private void NotifyNextRequester(string itemId, ITurnContext turnContext) { if (queuedItems[itemId].IsAnyUserWaiting()) { OperationFinished?.Invoke(turnContext, $"{queuedItems[itemId].CurrentOwner} es tu turno en {itemId}."); } }
/// <summary> /// Copies file into specific folder /// </summary> /// <param name="targetFileID">ID of the file to copy</param> /// <param name="destinationFolderID">Destination folder ID</param> /// <param name="copyFileCompleted">Callback method which will be invoked after operation completes</param> /// <exception cref="ArgumentException">Thrown if <paramref name="copyFileCompleted"/> is null</exception> public void CopyFile( long targetFileID, long destinationFolderID, OperationFinished<CopyFileResponse> copyFileCompleted) { CopyFile(targetFileID, destinationFolderID, copyFileCompleted, null); }
/// <summary> /// Asynchronously deletes specified object /// </summary> /// <param name="objectID">ID of the object to delete</param> /// <param name="objectType">Type of the object</param> /// <param name="deleteObjectCompleted">Callback method which will be invoked after delete operation completes</param> /// <exception cref="ArgumentException">Thrown if <paramref name="deleteObjectCompleted"/> is null</exception> public void DeleteObject( long objectID, ObjectType objectType, OperationFinished<DeleteObjectResponse> deleteObjectCompleted) { DeleteObject(objectID, objectType, deleteObjectCompleted, null); }
/// <summary> /// Asynchronously creates folder /// </summary> /// <param name="folderName">Folder name</param> /// <param name="parentFolderID">ID of the parent folder where new folder needs to be created or '0'</param> /// <param name="isShared">Indicates if new folder will be publicly shared</param> /// <param name="createFolderCompleted">Callback method which will be invoked after operation completes</param> /// <exception cref="ArgumentException">Thrown if <paramref name="createFolderCompleted"/> is null</exception> public void CreateFolder( string folderName, long parentFolderID, bool isShared, OperationFinished<CreateFolderResponse> createFolderCompleted) { CreateFolder(folderName, parentFolderID, isShared, createFolderCompleted, null); }
public void NotifyOperationFinished(string installPath, PackageOperationType operationType, IPackageDetails packageDetails) { Argument.IsNotNull(() => packageDetails); //UnsubscribeFromDownloadProgress(packageDetails); OperationFinished.SafeInvoke(this, new PackageOperationEventArgs(packageDetails, installPath, operationType)); }
void IChatService.ProcessMessage(ITurnContext turnContext) { try { List <string> texts = turnContext.Activity.Text.Split(' ').ToList(); ProcessAction(QueuedItemsActions.GetActionService(texts), turnContext); } catch (Exception e) { OperationFinished?.Invoke(turnContext, ConversationWords.errorParsingMessage); } }
private void RemoveOwnerFromService(QueuedItem item, ITurnContext turnContext) { if (!item.IsAnyUserWaiting()) { RemoveService(item.Id); OperationFinished?.Invoke(turnContext, $"el recurso {item.Id} ha sido liberado y no hay nadie a la cola."); } else { PopRequester(item.Id, turnContext); } }
private void ShowServiceState(string itemId, ITurnContext turnContext) { QueuedItem item = GetQueuedService(itemId); if (item != null) { OperationFinished?.Invoke(turnContext, item.GetCurrentState()); } else { OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases)); } }
private void NotifyRequester(QueuedItem item, ITurnContext turnContext, string requesterNames) { if (string.IsNullOrEmpty(requesterNames)) { OperationFinished?.Invoke(turnContext, $"Actualmente {item.Id} está siendo utilizado por @{item.CurrentOwner}"); OperationFinished?.Invoke(turnContext, $"Eres la siguiente en la lista"); } else { OperationFinished?.Invoke(turnContext, $"Actualmente {item.Id} está siendo utilizado por @{item.CurrentOwner}"); OperationFinished?.Invoke(turnContext, $"Estas personas están por delante tuyo: {requesterNames}"); } }
private bool IsServiceAvailableForUser(string userId, QueuedItem item, ITurnContext turnContext) { if (item.IsCurrentOwner(userId)) { OperationFinished?.Invoke(turnContext, $"El recurso ya está reservado por ti."); return(false); } if (item.IsUserWaiting(userId)) { OperationFinished?.Invoke(turnContext, $"Ya estás en la lista."); return(false); } return(true); }
public override void BeginVerifyImageAndDevice(ulong numBytesToVerify) { cancelPending = false; currentDiskOperation = DiskOperation.Verify; numSectors = numBytesToVerify / sectorSize; workingThread = new Thread(async() => { bool result = false; OperationFinishedState state = OperationFinishedState.Error; Exception exception = null; try { if (useEncryption) { result = await VerifyImageAndDeviceCryptoWorkerAsync(fileHandle, sectorSize, numSectors); } else { result = await VerifyImageAndDeviceWorkerAsync(fileHandle, sectorSize, numSectors); } Dispose(); state = OperationFinishedState.Success; } catch (Exception e) { result = false; state = OperationFinishedState.Error; exception = e; } finally { if (cancelPending) { state = OperationFinishedState.Canceled; } if (!result && !cancelPending) { state = OperationFinishedState.Error; } Dispose(); OperationFinished?.Invoke(this, new OperationFinishedEventArgs(true, result && !cancelPending, state, currentDiskOperation, exception)); } }); workingThread.Start(); }
private void EndOperationImpl() { lock (syncRoot) { FocusCheckTimer?.Stop(); if (IsShown) { helperWindow.Close(); LongOpView.Close(); } HasEnded = true; OperationFinished?.Invoke(); } }
/// <summary> /// Asynchronously deletes specified object /// </summary> /// <param name="objectID">ID of the object to delete</param> /// <param name="objectType">Type of the object</param> /// <param name="deleteObjectCompleted">Callback method which will be invoked after delete operation completes</param> /// <param name="userState">A user-defined object containing state information. /// This object is passed to the <paramref name="deleteObjectCompleted"/> delegate as a part of response when the operation is completed</param> /// <exception cref="ArgumentException">Thrown if <paramref name="deleteObjectCompleted"/> is null</exception> public void DeleteObject( long objectID, ObjectType objectType, OperationFinished<DeleteObjectResponse> deleteObjectCompleted, object userState) { ThrowIfParameterIsNull(deleteObjectCompleted, "deleteObjectCompleted"); string type = ObjectType2String(objectType); _service.deleteCompleted += DeleteObjectFinished; object[] state = { deleteObjectCompleted, userState }; _service.deleteAsync(_apiKey, _token, type, objectID, state); }
/// <summary> /// Copies file into specific folder /// </summary> /// <param name="targetFileID">ID of the file to copy</param> /// <param name="destinationFolderID">Destination folder ID</param> /// <param name="copyFileCompleted">Callback method which will be invoked after operation completes</param> /// <param name="userState">A user-defined object containing state information. /// This object is passed to the <paramref name="copyFileCompleted"/> delegate as a part of response when the operation is completed</param> /// <exception cref="ArgumentException">Thrown if <paramref name="copyFileCompleted"/> is null</exception> public void CopyFile( long targetFileID, long destinationFolderID, OperationFinished<CopyFileResponse> copyFileCompleted, object userState) { ThrowIfParameterIsNull(copyFileCompleted, "copyFileCompleted"); string type = ObjectType2String(ObjectType.File); _service.copyCompleted += CopyFileFinished; object[] state = { copyFileCompleted, userState }; _service.copyAsync(_apiKey, _token, type, targetFileID, destinationFolderID, state); }
private void AskForServiceState(ActionOnItem actionOnItem, ITurnContext turnContext) { if (!IsValidServiceId(actionOnItem.itemName)) { OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases)); return; } QueuedItem item = GetQueuedService(actionOnItem.itemName); if (item != null) { ShowServiceState(item.Id, turnContext); } else { OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases)); } }
private void RequestService(ActionOnItem actionOnItem, ITurnContext turnContext) { if (!IsValidServiceId(actionOnItem.itemName)) { OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases)); return; } QueuedItem item = GetQueuedService(actionOnItem.itemName); if (item != null) { AddUserToServiceQueue(turnContext.Activity.From.Name, item, turnContext); } else { CreateQueuedService(turnContext.Activity.From.Name, actionOnItem.itemName); OperationFinished?.Invoke(turnContext, $"{actionOnItem.itemName} ha sido reservado por {turnContext.Activity.From.Name}"); } }
private void SetServiceFree(ActionOnItem actionOnItem, ITurnContext turnContext) { if (!IsValidServiceId(actionOnItem.itemName)) { OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases)); return; } QueuedItem item = GetQueuedService(actionOnItem.itemName); if (item == null) { OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.emptyServicePhrases)); return; } if (item.IsCurrentOwner(turnContext.Activity.From.Name)) { RemoveOwnerFromService(item, turnContext); return; } OperationFinished?.Invoke(turnContext, ConversationWords.GetRandomValueFromList(ConversationWords.authorizationErrors)); }
protected void OnOperationFinished(MessageEventArg e) { //##### Method1 - Event raised on the same thread ##### //EventHandler<MessageEventArg> handler = OperationFinished; //if (handler != null) //{ // handler(this, e); //} //##### Method2 - Event raised on (the same) separate thread for all listener ##### //EventHandler<MessageEventArg> handler = OperationFinished; //if (handler != null) //{ // Task.Factory.StartNew(() => handler(this, e)); //} //##### Method3 - Event raised on different threads for each listener ##### if (OperationFinished != null) { foreach (EventHandler<MessageEventArg> handler in OperationFinished.GetInvocationList()) { Task.Factory.FromAsync((asyncCallback, @object) => handler.BeginInvoke(this, e, asyncCallback, @object), handler.EndInvoke, null); } } }
private void ProcessAction(ActionOnItem actionOnItem, ITurnContext turnContext) { switch (actionOnItem.actionType) { case ActionType.NoAction: OperationFinished?.Invoke(turnContext, ConversationWords.errorParsingMessage); return; case ActionType.RequestItem: RequestService(actionOnItem, turnContext); break; case ActionType.AskForItemState: AskForServiceState(actionOnItem, turnContext); break; case ActionType.SetItemFree: SetServiceFree(actionOnItem, turnContext); break; default: break; } }
public void Logout(OperationFinished<LogoutResponse> logoutCompleted, object userState);
public void Logout(OperationFinished<LogoutResponse> logoutCompleted);
public void MoveObject(long targetObjectID, ObjectType targetObjectType, long destinationFolderID, OperationFinished<MoveObjectResponse> moveObjectCompleted, object userState);
public void OverwriteFile(string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify, OperationFinished<OverwriteFileResponse> overwriteFileCompleted, object userState);
public void PrivateShare(long targetObjectID, ObjectType targetObjectType, string password, string notificationMessage, string[] emailList, bool sendNotification, OperationFinished<PrivateShareResponse> privateShareCompleted, object userState);
public void PublicShare(long targetObjectID, ObjectType targetObjectType, string password, string message, string[] emailList, bool sendNotification, OperationFinished<PublicShareResponse> publicShareCompleted);
public void AddToMyBox(long targetFileID, long destinationFolderID, TagPrimitiveCollection tagList, OperationFinished<AddToMyBoxResponse> addToMyBoxCompleted);
/// <summary> /// Upload a file and sets a tag value Encrypted if the file is sent encrypted /// </summary> /// <param name="filePath"></param> /// <param name="folderID"></param> /// <param name="operationFinished"></param> public void UploadFile(string filePath, long folderID, bool encrypted, OperationFinished<UploadFileResponse> operationFinished) { //Thread thread = new Thread(new ParameterizedThreadStart(UploadFileThreadMethod)); //thread.Start(new UploadFileThreadParams(filePath, folderID, encrypted, operationFinished)); _manager.AddFile(filePath, folderID, delegate(UploadFileResponse fileResponse) { // Try to add the Tag (Encrypted) if (encrypted) { Folder folder = GetFolderStructure(folderID, RetrieveFolderStructureOptions.Simple); BoxSync.Core.Primitives.File file = folder.Files.Where(f => f.Name == Path.GetFileName(filePath)).FirstOrDefault(); if (file != null) { SetFileTags(file.ID, new string[] { ENCRYPTED }); } } if (operationFinished != null) { operationFinished(fileResponse); } }); }
void ICondaEnvironmentManagerUI.OnOperationFinished(ICondaEnvironmentManager mgr, string operation, bool success) { OperationFinished?.Invoke(this, new OperationFinishedEventArgs(operation, success)); }
public override void BeginWriteImageToDevice(bool verify, bool cropData = false) { cancelPending = false; currentDiskOperation = DiskOperation.Write; if (verify) { currentDiskOperation |= DiskOperation.Verify; } if (cropData) { numSectors = availibleSectors; } workingThread = new Thread(async() => { bool result = false; OperationFinishedState state = OperationFinishedState.Error; Exception exception = null; try { if (useEncryption) { result = await WriteImageToDeviceCryptoWorker(sectorSize, numSectors); } else { result = await WriteImageToDeviceWorker(sectorSize, numSectors); } if (verify && !cancelPending) { OperationFinished?.Invoke(this, new OperationFinishedEventArgs(false, result && !cancelPending, state, currentDiskOperation, null)); if (useEncryption) { result = await VerifyImageAndDeviceCryptoWorkerAsync(fileHandle, sectorSize, numSectors); } else { result = await VerifyImageAndDeviceWorkerAsync(fileHandle, sectorSize, numSectors); } } Dispose(); state = OperationFinishedState.Success; } catch (Exception e) { result = false; state = OperationFinishedState.Error; exception = e; } finally { if (cancelPending) { state = OperationFinishedState.Canceled; } if (!result && !cancelPending) { state = OperationFinishedState.Error; } Dispose(); OperationFinished?.Invoke(this, new OperationFinishedEventArgs(true, result && !cancelPending, state, currentDiskOperation, exception)); } }); workingThread.Start(); }
public void NotifyOperationFinished(string installPath, PackageOperationType operationType, IPackageDetails packageDetails) { Argument.IsNotNull(() => packageDetails); OperationFinished?.Invoke(this, new PackageOperationEventArgs(packageDetails, installPath, operationType)); }
public void RegisterNewUser(string login, string password, OperationFinished<RegisterNewUserResponse> registerNewUserCompleted, object userState);
protected void OnOperationFinished() { OperationFinished?.Invoke(this, EventArgs.Empty); }
public void VerifyRegistrationEmail(string login, OperationFinished<VerifyRegistrationEmailResponse> verifyRegistrationEmailCompleted, object userState);
public void ExportTags(OperationFinished<ExportTagsResponse> exportTagsCompleted, object userState);
public void AddToMyBox(string targetFileName, long destinationFolderID, TagPrimitiveCollection tagList, OperationFinished<AddToMyBoxResponse> addToMyBoxCompleted, object userState);
public void SetDescription(long objectID, ObjectType objectType, string description, OperationFinished<SetDescriptionResponse> setDescriptionCompleted, object userState);
public void PublicUnshare(long targetObjectID, ObjectType targetObjectType, OperationFinished<PublicUnshareResponse> publicUnshareCompleted, object userState);
public void RenameObject(long objectID, ObjectType objectType, string newName, OperationFinished<RenameObjectResponse> renameObjectCompleted, object userState);
public void FileNewCopy(string filePath, long fileID, OperationFinished<FileNewCopyResponse> fileNewCopyCompleted);
public void OnOperationFinished(string operation, bool success) { OperationFinished?.Invoke(this, new OperationFinishedEventArgs(operation, success)); }
/// <summary> Invokes the event OperationFinished. </summary> /// <param name="args"> Any details about the finished operation. </param> public static void OnOperationFinished(params object[] args) { OperationFinished?.Invoke(args); }
public void FileNewCopy(string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify, OperationFinished<FileNewCopyResponse> fileNewCopyCompleted, object userState);
protected void FireOperationFinishedEvent() { OperationFinished.Raise(this, System.EventArgs.Empty); }
public void CreateFolder(string folderName, long parentFolderID, bool isShared, OperationFinished<CreateFolderResponse> createFolderCompleted, object userState);
public void DeleteObject(long objectID, ObjectType objectType, OperationFinished<DeleteObjectResponse> deleteObjectCompleted, object userState);
public void GetRootFolderStructure(RetrieveFolderStructureOptions retrieveOptions, OperationFinished<GetFolderStructureResponse> getFolderStructureCompleted);
/// <summary> /// Get files information for a given folder asynchronously /// </summary> /// <param name="folderID"></param> /// <param name="operationFinished"></param> /// <param name="options"></param> public void GetFilesAsync(long folderID, OperationFinished<GetFolderStructureResponse> operationFinished, RetrieveFolderStructureOptions options = RetrieveFolderStructureOptions.OneLevel) { _manager.GetFolderStructure(folderID, options, operationFinished); }
public void GetFolderStructure(long folderID, RetrieveFolderStructureOptions retrieveOptions, OperationFinished<GetFolderStructureResponse> getFolderStructureCompleted, object userState);
public UploadFileThreadParams(string filePath, long folderID, bool encrypted, OperationFinished<UploadFileResponse> operationFinished) { this.FilePath = filePath; this.FolderID = folderID; this.Encrypted = encrypted; this.OperationFinished = operationFinished; }
public void ExportTags(OperationFinished<ExportTagsResponse> exportTagsCompleted);
public void OnOperationFinished(IPackageManager sender, string operation, bool success) { OperationFinished?.Invoke(this, new OperationFinishedEventArgs(operation, success)); }
public void DoWork(Dispatcher mainThreadDispatcher) { mainThreadDispatcher.InvokeAsync(() => OperationStarted?.Invoke(this, new OperationEventArgs())); DoWorkInternal(); mainThreadDispatcher.InvokeAsync(() => OperationFinished?.Invoke(this, new OperationEventArgs())); }