Ejemplo n.º 1
0
        protected override async Task <bool> DoExecuteAsync()
        {
            try
            {
                var result = await DokuFlexService.DeleteFileAsync(_ticket, _item.GroupId, _item.FileId);

                SyncTableManager.Remove(_item);
                SyncTableManager.Save();

                return(result);
            }
            catch (Exception ex)
            {
                var newMsg = string.Format("Delete online file, raise an exception with: {0}, Exception: {1}", _item.Path, ex.Message);
                throw new Exception(newMsg);
            }
        }
        protected override async Task <bool> DoExecuteAsync()
        {
            var directory = new DirectoryInfo(_path);

            //Add item to SyncTable and set the SyncProgress state
            var item = new SyncTableItem()
            {
                Name          = directory.Name,
                Path          = _path,
                LastWriteTime = directory.LastWriteTimeUtc.ToFileTimeUtc(),
                Type          = "F",
                GroupId       = _groupId,
                FolderId      = String.Empty,
                FileId        = String.Empty,
                ModifiedTime  = 0,
                SyncFolder    = false,
            };

            SyncTableManager.Add(item);
            SyncTableManager.Save();

            try
            {
                var nodeId = await DokuFlexService.CreateFolderAsync(_ticket, _groupId, _parentFolderId, directory.Name);

                //Set nodeId property
                item.FolderId = nodeId;
                SyncTableManager.Save();

                return(!String.IsNullOrWhiteSpace(nodeId));
            }
            catch (Exception ex)
            {
                //Rollback the Add item action
                SyncTableManager.Remove(item);
                SyncTableManager.Save();

                var newMsg = string.Format("Create online directory, raise an exception with: {0}, Exception: {1}", _path, ex.Message);
                throw new Exception(newMsg);
            }
        }