本文整理汇总了C#中CmisSync.Lib.RepoInfo类的典型用法代码示例。如果您正苦于以下问题:C# RepoInfo类的具体用法?C# RepoInfo怎么用?C# RepoInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RepoInfo类属于CmisSync.Lib命名空间,在下文中一共展示了RepoInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fetcher
/// <summary>
/// Sets up a fetcher that can get remote CMIS folders.
/// </summary>
public Fetcher(RepoInfo repoInfo, IActivityListener activityListener)
{
string remote_path = repoInfo.RemotePath.Trim("/".ToCharArray());
string address = repoInfo.Address.ToString();
TargetFolder = repoInfo.TargetDirectory;
RemoteUrl = new Uri(address + remote_path);
Logger.Info("Fetcher | Cmis Fetcher constructor");
TargetFolder = repoInfo.TargetDirectory;
RemoteUrl = repoInfo.Address;
// Check that the CmisSync root folder exists.
if (!Directory.Exists(ConfigManager.CurrentConfig.FoldersPath))
{
Logger.Fatal(String.Format("Fetcher | ERROR - Cmis Default Folder {0} does not exist", ConfigManager.CurrentConfig.FoldersPath));
throw new DirectoryNotFoundException("Root folder don't exist !");
}
// Check that the folder is writable.
if (!Utils.HasWritePermissionOnDir(ConfigManager.CurrentConfig.FoldersPath))
{
Logger.Fatal(String.Format("Fetcher | ERROR - Cmis Default Folder {0} is not writable", ConfigManager.CurrentConfig.FoldersPath));
throw new UnauthorizedAccessException("Root folder is not writable!");
}
// Check that the folder exists.
if (Directory.Exists(repoInfo.TargetDirectory))
{
Logger.Fatal(String.Format("Fetcher | ERROR - Cmis Repository Folder {0} already exist", repoInfo.TargetDirectory));
throw new UnauthorizedAccessException("Repository folder already exists!");
}
// Create the local folder.
Directory.CreateDirectory(repoInfo.TargetDirectory);
// Use this folder configuration.
this.cmisRepo = new CmisRepo(repoInfo, activityListener);
}
示例2: CreateFromRemoteFolder
/// <summary>
/// Create sync item from the path of a remote folder.
/// </summary>
/// <param name="remoteFolderPath">Example: /sites/aproject/adir</param>
public static SyncItem CreateFromRemoteFolder(string remoteFolderPath, RepoInfo repoInfo, Database.Database database)
{
return new RemotePathSyncItem(remoteFolderPath, true, repoInfo, database);
}
示例3: IsFileWorthSyncing
/// <summary>
/// Check whether the file is worth syncing or not.
/// This optionally excludes blank files or files too large.
/// </summary>
private static bool IsFileWorthSyncing(string filepath, RepoInfo repoInfo)
{
if (File.Exists(filepath))
{
bool allowBlankFiles = true; //TODO: add a preference repoInfo.allowBlankFiles
bool limitFilesize = false; //TODO: add preference for filesize limiting
long filesizeLimit = 256 * 1024 * 1024; //TODO: add a preference for filesize limit
FileInfo fileInfo = new FileInfo(filepath);
//Check permissions
if (fileInfo.Attributes.HasFlag(FileAttributes.Hidden))
{
Logger.DebugFormat("Skipping {0}: hidden file", filepath);
return false;
}
if (fileInfo.Attributes.HasFlag(FileAttributes.System))
{
Logger.DebugFormat("Skipping {0}: system file", filepath);
return false;
}
//Check filesize
if (!allowBlankFiles && fileInfo.Length <= 0)
{
Logger.DebugFormat("Skipping {0}: blank file", filepath);
return false;
}
if (limitFilesize && fileInfo.Length > filesizeLimit)
{
Logger.DebugFormat("Skipping {0}: file too large {1}mb", filepath, fileInfo.Length / (1024f * 1024f));
return false;
}
}
else if (Directory.Exists(filepath))
{
return IsDirectoryWorthSyncing(filepath, repoInfo);
}
return true;
}
示例4: GetRepoInfo
/// <summary>
/// Get all the configured info about a synchronized folder.
/// </summary>
public RepoInfo GetRepoInfo(string folderName)
{
RepoInfo repoInfo = new RepoInfo(folderName, ConfigPath);
repoInfo.User = GetFolderAttribute(folderName, "user");
repoInfo.Password = GetFolderAttribute(folderName, "password");
repoInfo.Address = GetUrlForFolder(folderName);
repoInfo.RepoID = GetFolderAttribute(folderName, "repository");
repoInfo.RemotePath = GetFolderAttribute(folderName, "remoteFolder");
repoInfo.TargetDirectory = GetFolderAttribute(folderName, "path");
double pollinterval = 0;
double.TryParse(GetFolderAttribute(folderName, "pollinterval"), out pollinterval);
if (pollinterval < 1) pollinterval = 5000;
repoInfo.PollInterval = pollinterval;
if (String.IsNullOrEmpty(repoInfo.TargetDirectory))
{
repoInfo.TargetDirectory = Path.Combine(FoldersPath, folderName);
}
LinkedList<string> ignoredFolders = getIgnoredFolders(folderName);
foreach (string ignoredFolder in ignoredFolders)
{
repoInfo.addIgnorePath(ignoredFolder);
}
return repoInfo;
}
示例5: RepoBase
/// <summary>
/// Constructor.
/// </summary>
public RepoBase(RepoInfo repoInfo, IActivityListener activityListener)
{
EventManager = new SyncEventManager();
EventManager.AddEventHandler(new DebugLoggingHandler());
EventManager.AddEventHandler(new GenericSyncEventHandler<RepoConfigChangedEvent>(0, RepoInfoChanged));
Queue = new SyncEventQueue(EventManager);
RepoInfo = repoInfo;
LocalPath = repoInfo.TargetDirectory;
Name = repoInfo.Name;
RemoteUrl = repoInfo.Address;
this.activityListener = activityListener;
if (repoInfo.IsSuspended) Status = SyncStatus.Suspend;
// Folder lock.
// Disabled for now. Can be an interesting feature, but should be made opt-in, as
// most users would be surprised to see this file appear.
// folderLock = new FolderLock(LocalPath);
Watcher = new Watcher(LocalPath);
Watcher.EnableRaisingEvents = true;
// Main loop syncing every X seconds.
remote_timer.Elapsed += delegate
{
// Synchronize.
SyncInBackground();
};
remote_timer.AutoReset = true;
Logger.Info("Repo " + repoInfo.Name + " - Set poll interval to " + repoInfo.PollInterval + "ms");
remote_timer.Interval = repoInfo.PollInterval;
//Partial sync interval..
local_timer.Elapsed += delegate
{
// Run partial sync.
SyncInBackground(false);
};
local_timer.AutoReset = false;
local_timer.Interval = delay_interval;
}
示例6: AddRepository
/// <summary>
/// Initialize (in the GUI and syncing mechanism) an existing CmisSync synchronized folder.
/// </summary>
/// <param name="repositoryInfo">Synchronized folder path</param>
private void AddRepository(RepoInfo repositoryInfo)
{
RepoBase repo = null;
repo = new CmisSync.Lib.Sync.CmisRepo(repositoryInfo, activityListenerAggregator);
this.repositories.Add(repo);
repo.Initialize();
}
示例7: SyncWhileModifyingFolders
public void SyncWhileModifyingFolders(string canonical_name, string localPath, string remoteFolderPath,
string url, string user, string password, string repositoryId)
{
// Prepare checkout directory.
string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
CleanDirectory(localDirectory);
Console.WriteLine("Synced to clean state.");
// Mock.
IActivityListener activityListener = new Mock<IActivityListener>().Object;
// Sync.
RepoInfo repoInfo = new RepoInfo(
canonical_name,
CMISSYNCDIR,
remoteFolderPath,
url,
user,
password,
repositoryId,
5000);
using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
{
using (CmisRepo.SynchronizedFolder synchronizedFolder = new CmisRepo.SynchronizedFolder(
repoInfo,
activityListener,
cmis))
{
synchronizedFolder.Sync();
Console.WriteLine("Synced to clean state.");
// Sync a few times in a different thread.
bool syncing = true;
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(
delegate(Object o, DoWorkEventArgs args)
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Sync D" + i.ToString());
synchronizedFolder.Sync();
}
}
);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object o, RunWorkerCompletedEventArgs args)
{
syncing = false;
}
);
bw.RunWorkerAsync();
// Keep creating/removing a file as long as sync is going on.
while (syncing)
{
//Console.WriteLine("Create/remove.");
LocalFilesystemActivityGenerator.CreateDirectoriesAndFiles(localDirectory);
CleanAll(localDirectory);
}
// Clean.
Console.WriteLine("Clean all.");
Clean(localDirectory, synchronizedFolder);
}
}
}
示例8: ClientSideBigFileAddition
public void ClientSideBigFileAddition(string canonical_name, string localPath, string remoteFolderPath,
string url, string user, string password, string repositoryId)
{
// Prepare checkout directory.
string localDirectory = Path.Combine(CMISSYNCDIR, canonical_name);
CleanDirectory(localDirectory);
Console.WriteLine("Synced to clean state.");
IActivityListener activityListener = new Mock<IActivityListener>().Object;
RepoInfo repoInfo = new RepoInfo(
canonical_name,
".",
remoteFolderPath,
url,
user,
password,
repositoryId,
5000);
using (CmisRepo cmis = new CmisRepo(repoInfo, activityListener))
{
using (CmisRepo.SynchronizedFolder synchronizedFolder = new CmisRepo.SynchronizedFolder(
repoInfo,
activityListener,
cmis))
{
synchronizedFolder.Sync();
Console.WriteLine("Synced to clean state.");
// Create random big file.
LocalFilesystemActivityGenerator.CreateRandomFile(localDirectory, 1000); // 1 MB ... no that big to not load servers too much.
// Sync again.
synchronizedFolder.Sync();
Console.WriteLine("Second sync done.");
// Check that file is present server-side.
// TODO
// Clean.
Console.WriteLine("Clean all.");
Clean(localDirectory, synchronizedFolder);
}
}
}
示例9: CreateFromRemoteFolderAndLocalName
/// <summary></summary>
/// <param name="remoteFolder"></param>
/// <param name="LocalFileName"></param>
/// <param name="repoInfo"></param>
/// <returns></returns>
public static SyncItem CreateFromRemoteFolderAndLocalName(string remoteFolder, string LocalFileName, RepoInfo repoInfo)
{
return new RemotePathSyncItem(remoteFolder, LocalFileName, repoInfo);
}
示例10: CreateFromLocalFolderAndRemoteName
/// <summary></summary>
/// <param name="localFolder"></param>
/// <param name="remoteFileName"></param>
/// <param name="repoInfo"></param>
/// <returns></returns>
public static SyncItem CreateFromLocalFolderAndRemoteName(string localFolder, string remoteFileName, RepoInfo repoInfo)
{
return new LocalPathSyncItem(localFolder, remoteFileName, repoInfo);
}
示例11: CreateFromRemotePath
/// <summary></summary>
/// <param name="path"></param>
/// <param name="repoInfo"></param>
/// <returns></returns>
public static SyncItem CreateFromRemotePath(string path, RepoInfo repoInfo)
{
return new RemotePathSyncItem(path, repoInfo);
}
示例12: RepoBase
/// <summary>
/// Constructor.
/// </summary>
public RepoBase(RepoInfo repoInfo)
{
RepoInfo = repoInfo;
LocalPath = repoInfo.TargetDirectory;
Name = repoInfo.Name;
RemoteUrl = repoInfo.Address;
Logger.Info("Repo " + repoInfo.Name + " - Set poll interval to " + repoInfo.PollInterval + "ms");
this.remote_timer.Interval = repoInfo.PollInterval;
SyncStatusChanged += delegate(SyncStatus status)
{
Status = status;
};
this.Watcher = new Watcher(LocalPath);
// Main loop syncing every X seconds.
this.remote_timer.Elapsed += delegate
{
// Synchronize.
SyncInBackground();
};
ChangesDetected += delegate { };
}
示例13: RemotePathSyncItem
public RemotePathSyncItem(string remoteFolderPath, string remoteDocumentName, string localFilename, bool isFolder, RepoInfo repoInfo, Database.Database database)
{
this.isFolder = isFolder;
this.database = database;
this.localRoot = repoInfo.TargetDirectory;
this.remoteRoot = repoInfo.RemotePath;
this.remoteRelativePath = remoteFolderPath;
if (remoteRelativePath.StartsWith(this.remoteRoot))
{
this.remoteRelativePath = remoteRelativePath.Substring(this.remoteRoot.Length).TrimStart(CmisUtils.CMIS_FILE_SEPARATOR);
}
this.localRelativePath = localFilename;
}
示例14: LocalPathSyncItem
public LocalPathSyncItem(string localPath, bool isFolder, RepoInfo repoInfo, Database.Database database)
{
this.isFolder = isFolder;
this.database = database;
this.localRoot = repoInfo.TargetDirectory;
this.remoteRoot = repoInfo.RemotePath;
this.localRelativePath = localPath;
if (localPath.StartsWith(this.localRoot))
{
this.localRelativePath = localPath.Substring(localRoot.Length).TrimStart(Path.DirectorySeparatorChar);
}
}
示例15: GetRepoInfo
/// <summary>
/// Get all the configured info about a synchronized folder.
/// </summary>
public RepoInfo GetRepoInfo()
{
RepoInfo repoInfo = new RepoInfo(DisplayName, ConfigManager.CurrentConfig.ConfigPath);
repoInfo.User = UserName;
repoInfo.Password = new CmisSync.Auth.CmisPassword();
repoInfo.Password.ObfuscatedPassword = ObfuscatedPassword;
repoInfo.Address = RemoteUrl;
repoInfo.RepoID = RepositoryId;
repoInfo.RemotePath = RemotePath;
repoInfo.TargetDirectory = LocalPath;
if (PollInterval < 1) PollInterval = Config.DEFAULT_POLL_INTERVAL;
repoInfo.PollInterval = PollInterval;
foreach (IgnoredFolder ignoredFolder in IgnoredFolders)
{
repoInfo.addIgnorePath(ignoredFolder.Path);
}
return repoInfo;
}