CmisSync.Lib.Database.Database.RemoteToLocal C# (CSharp) Метод

RemoteToLocal() публичный Метод

Return the remote path of an item identified by its local path. If no such item exist yet in database (ex: new local file), returns the remote path it should be written to.
public RemoteToLocal ( string remotePath, bool isFolder ) : string
remotePath string
isFolder bool
Результат string
        public string RemoteToLocal(string remotePath, bool isFolder)
        {
            string normalizedRemotePath = RemoveLocalPrefix(remotePath);
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("remotePath", normalizedRemotePath);
            string table = isFolder ? "folders" : "files";
            string localPath = (string)ExecuteSQLFunction("SELECT localPath FROM " + table + " WHERE path=@remotePath", parameters);
            if (string.IsNullOrEmpty(localPath))
            {
                return PathRepresentationConverter.RemoteToLocal(remotePath);
            }
            return localPath;
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Create from the path of a remote file, and the local filename to use.
        /// </summary>
        /// <param name="remoteRelativePath">Example: adir/a<file</param>
        /// <param name="localFilename">Example: afile.txt</param>
        public RemotePathSyncItem(string remoteRelativePath, string localFilename, RepoInfo repoInfo, Database.Database database)
        {
            this.isFolder   = false;
            this.database   = database;
            this.localRoot  = repoInfo.TargetDirectory;
            this.remoteRoot = repoInfo.RemotePath;

            this.remoteRelativePath = remoteRelativePath;
            if (remoteRelativePath.StartsWith(this.remoteRoot))
            {
                this.remoteRelativePath = this.remoteRelativePath.Substring(localRoot.Length).TrimStart(CmisUtils.CMIS_FILE_SEPARATOR);
            }

            int    lastSeparator        = remoteRelativePath.LastIndexOf(CmisUtils.CMIS_FILE_SEPARATOR);
            string remoteRelativeFolder = lastSeparator >= 0 ?
                                          remoteRelativePath.Substring(0, lastSeparator)
                : String.Empty;
            string remoteRelativePathWithCorrectLeafname = CmisUtils.PathCombine(remoteRelativeFolder, localFilename);

            localRelativePath = database.RemoteToLocal(remoteRelativePathWithCorrectLeafname, isFolder);
        }
All Usage Examples Of CmisSync.Lib.Database.Database::RemoteToLocal