public int IsMemberOf(string path, uint attributes) { SyncTableManager.Reload(); var item = SyncTableManager.GetByPath(path); if (item == null) { unchecked { return((int)HRESULT.S_FALSE); } } try { unchecked { return(item.State == ItemState ? (int)HRESULT.S_OK : (int)HRESULT.S_FALSE); } } catch { unchecked { return((int)HRESULT.E_FAIL); } } }
protected override async Task <bool> DoExecuteAsync() { var item = SyncTableManager.GetByPath(_oldFullPath); if (item != null) { var syncItems = SyncTableManager.GetAllByPath(_oldFullPath); if (syncItems != null) { foreach (var syncItem in syncItems) { if (syncItem.Type == "F" && String.Compare(syncItem.FolderId, item.FolderId) == 0) { syncItem.Name = _newName; } syncItem.Path = syncItem.Path.Replace(_oldFullPath, _fullPath); } } else { item.Name = _newName; item.Path = item.Path.Replace(_oldFullPath, _fullPath); } try { return(await DokuFlexService.RenameFileFolderAsync(_ticket, item.GroupId, item.FolderId, _newName)); } catch (Exception ex) { var newMsg = string.Format("Rename directory, raise an exception with: {0}, Exception: {1}", item.Path, ex.Message); throw new Exception(newMsg); } } return(false); }
protected override async Task <bool> DoExecuteAsync() { var item = SyncTableManager.GetByPath(_oldFullPath); if (item != null) { item.Name = _newName; item.Path = item.Path.Replace(_oldFullPath, _fullPath); } else { return(false); } try { return(await DokuFlexService.RenameFileFolderAsync(_ticket, item.GroupId, item.FileId, _newName)); } catch (Exception ex) { var newMsg = string.Format("Rename file, raise an exception with: {0}, Exception: {1}", item.Path, ex.Message); throw new Exception(newMsg); } }
protected override async Task <bool> DoExecuteAsync() { try { //Create the target file to download File.Create(_filePath).Close(); var item = SyncTableManager.GetByPath(_filePath); if (item == null) { //Add to file sync table item = new SyncTableItem() { Name = string.Empty, Path = _filePath, LastWriteTime = 0, Type = _fileFolder.type, GroupId = _groupId, FolderId = _folderId, FileId = _fileFolder.id, ModifiedTime = _fileFolder.modifiedTime, SyncFolder = false }; SyncTableManager.Add(item); } else { item.FileId = _fileFolder.id; item.ModifiedTime = _fileFolder.modifiedTime; item.SyncStatus = SyncTableItemStatus.SyncInProgress; } var result = await DokuFlexService.DownloadFileAsync(_ticket, _fileFolder.id, _filePath); var fileInfo = new FileInfo(_filePath); item.Name = fileInfo.Name; item.LastWriteTime = fileInfo.LastWriteTime.ToFileTime(); item.SyncStatus = SyncTableItemStatus.InSync; SyncTableManager.Save(); return(result); } catch (Exception ex) { if (File.Exists(_filePath)) { var fileInfo = new FileInfo(_filePath); var item = SyncTableManager.GetByPath(_filePath); item.Name = fileInfo.Name; item.LastWriteTime = fileInfo.LastWriteTime.ToFileTime(); item.SyncStatus = SyncTableItemStatus.ErrorConflict; SyncTableManager.Save(); } else { var newMsg = string.Format("Download file, raise an exception with: {0}, Exception: {1}", _filePath, ex.Message); throw new Exception(newMsg); } } return(false); }
protected override async Task <bool> DoExecuteAsync() { var sourcePath = Command.SourcePath; var targetPath = _fileInfo.FullName; //remove this code when possible. if (string.Equals(sourcePath, targetPath)) { var newMsg = string.Format("The source file was already processed in a previous call. File: {0}", sourcePath); throw new Exception(newMsg); } var item = SyncTableManager.GetByPath(_fileInfo.FullName); if (item == null) { item = new SyncTableItem() { Name = _fileInfo.Name, Path = _fileInfo.FullName, LastWriteTime = 0, Type = "C", GroupId = _groupId, FolderId = _folderId, FileId = _fileId, ModifiedTime = 0, SyncFolder = false }; SyncTableManager.Add(item); } else { item.SyncStatus = SyncTableItemStatus.SyncInProgress; } try { var uploadInfo = await DokuFlexService.UploadFileAsync(_ticket, _groupId, _folderId, _fileId, _fileInfo, true); //Set additional attributes item.LastWriteTime = _fileInfo.LastWriteTime.ToFileTimeUtc(); item.FileId = uploadInfo.nodeId; item.ModifiedTime = uploadInfo.modifiedTime; item.SyncStatus = SyncTableItemStatus.InSync; SyncTableManager.Save(); //This too! Command.SourcePath = _fileInfo.FullName; return(uploadInfo != null); } catch (Exception ex) { var newMsg = string.Format("File: {0}, Exception: {1}", _fileInfo.FullName, ex.Message); item.LastWriteTime = 0; //Enable this file to by uploaded again in some point of the time item.SyncStatus = SyncTableItemStatus.ErrorConflict; throw new Exception(newMsg); } }