Example #1
0
 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);
 }
Example #3
0
 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));
        }
Example #8
0
 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);
     }
 }
Example #9
0
 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);
     }
 }
Example #10
0
        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));
            }
        }
Example #11
0
 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}");
     }
 }
Example #12
0
 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);
 }
Example #13
0
        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();
        }
Example #14
0
        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);
        }
Example #17
0
        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));
            }
        }
Example #18
0
        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}");
            }
        }
Example #19
0
        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);
         }
     }
 }
Example #21
0
        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;
            }
        }
Example #22
0
 public void Logout(OperationFinished<LogoutResponse> logoutCompleted, object userState);
Example #23
0
 public void Logout(OperationFinished<LogoutResponse> logoutCompleted);
Example #24
0
 public void MoveObject(long targetObjectID, ObjectType targetObjectType, long destinationFolderID, OperationFinished<MoveObjectResponse> moveObjectCompleted, object userState);
Example #25
0
 public void OverwriteFile(string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify, OperationFinished<OverwriteFileResponse> overwriteFileCompleted, object userState);
Example #26
0
 public void PrivateShare(long targetObjectID, ObjectType targetObjectType, string password, string notificationMessage, string[] emailList, bool sendNotification, OperationFinished<PrivateShareResponse> privateShareCompleted, object userState);
Example #27
0
 public void PublicShare(long targetObjectID, ObjectType targetObjectType, string password, string message, string[] emailList, bool sendNotification, OperationFinished<PublicShareResponse> publicShareCompleted);
Example #28
0
 public void AddToMyBox(long targetFileID, long destinationFolderID, TagPrimitiveCollection tagList, OperationFinished<AddToMyBoxResponse> addToMyBoxCompleted);
Example #29
0
        /// <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);
                }
            });
        }
Example #30
0
 void ICondaEnvironmentManagerUI.OnOperationFinished(ICondaEnvironmentManager mgr, string operation, bool success)
 {
     OperationFinished?.Invoke(this, new OperationFinishedEventArgs(operation, success));
 }
Example #31
0
        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();
        }
Example #32
0
        public void NotifyOperationFinished(string installPath, PackageOperationType operationType, IPackageDetails packageDetails)
        {
            Argument.IsNotNull(() => packageDetails);

            OperationFinished?.Invoke(this, new PackageOperationEventArgs(packageDetails, installPath, operationType));
        }
Example #33
0
 public void RegisterNewUser(string login, string password, OperationFinished<RegisterNewUserResponse> registerNewUserCompleted, object userState);
 protected void OnOperationFinished()
 {
     OperationFinished?.Invoke(this, EventArgs.Empty);
 }
Example #35
0
 public void VerifyRegistrationEmail(string login, OperationFinished<VerifyRegistrationEmailResponse> verifyRegistrationEmailCompleted, object userState);
Example #36
0
 public void ExportTags(OperationFinished<ExportTagsResponse> exportTagsCompleted, object userState);
Example #37
0
 public void AddToMyBox(string targetFileName, long destinationFolderID, TagPrimitiveCollection tagList, OperationFinished<AddToMyBoxResponse> addToMyBoxCompleted, object userState);
Example #38
0
 public void SetDescription(long objectID, ObjectType objectType, string description, OperationFinished<SetDescriptionResponse> setDescriptionCompleted, object userState);
Example #39
0
 public void PublicUnshare(long targetObjectID, ObjectType targetObjectType, OperationFinished<PublicUnshareResponse> publicUnshareCompleted, object userState);
Example #40
0
 public void RenameObject(long objectID, ObjectType objectType, string newName, OperationFinished<RenameObjectResponse> renameObjectCompleted, object userState);
Example #41
0
 public void FileNewCopy(string filePath, long fileID, OperationFinished<FileNewCopyResponse> fileNewCopyCompleted);
Example #42
0
 public void OnOperationFinished(string operation, bool success)
 {
     OperationFinished?.Invoke(this, new OperationFinishedEventArgs(operation, success));
 }
Example #43
0
 /// <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);
 }
Example #44
0
 public void FileNewCopy(string filePath, long fileID, bool isFileShared, string message, string[] emailsToNotify, OperationFinished<FileNewCopyResponse> fileNewCopyCompleted, object userState);
Example #45
0
 protected void FireOperationFinishedEvent()
 {
     OperationFinished.Raise(this, System.EventArgs.Empty);
 }
Example #46
0
 public void CreateFolder(string folderName, long parentFolderID, bool isShared, OperationFinished<CreateFolderResponse> createFolderCompleted, object userState);
Example #47
0
 public void DeleteObject(long objectID, ObjectType objectType, OperationFinished<DeleteObjectResponse> deleteObjectCompleted, object userState);
Example #48
0
 public void GetRootFolderStructure(RetrieveFolderStructureOptions retrieveOptions, OperationFinished<GetFolderStructureResponse> getFolderStructureCompleted);
Example #49
0
 /// <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);
 }
Example #50
0
 public void GetFolderStructure(long folderID, RetrieveFolderStructureOptions retrieveOptions, OperationFinished<GetFolderStructureResponse> getFolderStructureCompleted, object userState);
Example #51
0
 public UploadFileThreadParams(string filePath, long folderID, bool encrypted, OperationFinished<UploadFileResponse> operationFinished)
 {
     this.FilePath = filePath;
     this.FolderID = folderID;
     this.Encrypted = encrypted;
     this.OperationFinished = operationFinished;
 }
Example #52
0
 public void ExportTags(OperationFinished<ExportTagsResponse> exportTagsCompleted);
Example #53
0
 public void OnOperationFinished(IPackageManager sender, string operation, bool success)
 {
     OperationFinished?.Invoke(this, new OperationFinishedEventArgs(operation, success));
 }
Example #54
0
 public void DoWork(Dispatcher mainThreadDispatcher)
 {
     mainThreadDispatcher.InvokeAsync(() => OperationStarted?.Invoke(this, new OperationEventArgs()));
     DoWorkInternal();
     mainThreadDispatcher.InvokeAsync(() => OperationFinished?.Invoke(this, new OperationEventArgs()));
 }