本文整理汇总了C#中IDocument.DeleteAllVersions方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.DeleteAllVersions方法的具体用法?C# IDocument.DeleteAllVersions怎么用?C# IDocument.DeleteAllVersions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocument
的用法示例。
在下文中一共展示了IDocument.DeleteAllVersions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CrawlRemoteDocument
//.........这里部分代码省略.........
var paths = remoteDocument.Paths;
var pathsCount = paths.Count;
var syncItem = database.GetSyncItemFromRemotePath(remoteDocument.Paths[0]);
if (null == syncItem)
{
syncItem = SyncItemFactory.CreateFromRemotePath(remoteDocument.Paths[0], repoinfo);
}
if (syncItem.ExistsLocal())
{
// Check modification date stored in database and download if remote modification date if different.
DateTime? serverSideModificationDate = ((DateTime)remoteDocument.LastModificationDate).ToUniversalTime();
DateTime? lastDatabaseUpdate = database.GetServerSideModificationDate(syncItem);
if (lastDatabaseUpdate == null)
{
Logger.Info("Downloading file absent from database: " + syncItem.LocalPath);
activityListener.ActivityStarted();
DownloadFile(remoteDocument, localFolder);
activityListener.ActivityStopped();
}
else
{
// If the file has been modified since last time we downloaded it, then download again.
if (serverSideModificationDate > lastDatabaseUpdate)
{
activityListener.ActivityStarted();
if (database.LocalFileHasChanged(syncItem.LocalPath))
{
Logger.Info("Conflict with file: " + remoteDocumentFileName + ", backing up locally modified version and downloading server version");
Logger.Info("- serverSideModificationDate: " + serverSideModificationDate);
Logger.Info("- lastDatabaseUpdate: " + lastDatabaseUpdate);
Logger.Info("- Checksum in database: " + database.GetChecksum(syncItem.LocalPath));
Logger.Info("- Checksum of local file: " + Database.Database.Checksum(syncItem.LocalPath));
// Rename locally modified file.
String newFilePath = Utils.CreateConflictFilename(syncItem.LocalPath, repoinfo.User);
File.Move(syncItem.LocalPath, newFilePath);
// Download server version
DownloadFile(remoteDocument, localFolder);
Logger.Info("- Checksum of remote file: " + Database.Database.Checksum(syncItem.LocalPath));
repo.OnConflictResolved();
// Notify the user.
string lastModifiedBy = CmisUtils.GetProperty(remoteDocument, "cmis:lastModifiedBy");
string message = String.Format(
// Properties_Resources.ResourceManager.GetString("ModifiedSame", CultureInfo.CurrentCulture),
"User {0} modified file \"{1}\" at the same time as you.",
lastModifiedBy, syncItem.LocalPath)
+ "\n\n"
// + Properties_Resources.ResourceManager.GetString("YourVersion", CultureInfo.CurrentCulture);
+ "Your version has been saved as \"" + newFilePath + "\", please merge your important changes from it and then delete it.";
Logger.Info(message);
Utils.NotifyUser(message);
}
else
{
Logger.Info("Downloading modified file: " + remoteDocumentFileName);
DownloadFile(remoteDocument, localFolder);
}
activityListener.ActivityStopped();
}
}
}
else
{
if (database.ContainsFile(syncItem))
{
if (!(bool)remoteDocument.IsVersionSeriesCheckedOut)
{
// File has been recently removed locally, so remove it from server too.
activityListener.ActivityStarted();
Logger.Info("Removing locally deleted file on server: " + syncItem.RemotePath);
remoteDocument.DeleteAllVersions();
// Remove it from database.
database.RemoveFile(syncItem);
activityListener.ActivityStopped();
}
else
{
string message = String.Format("File {0} is checked out on the server by another user: {1}", syncItem.LocalPath, remoteDocument.CheckinComment);
// throw new IOException("File is checked out on the server");
Logger.Info(message);
Utils.NotifyUser(message);
}
}
else
{
// New remote file, download it.
Logger.Info("New remote file: " + syncItem.RemotePath);
activityListener.ActivityStarted();
DownloadFile(remoteDocument, localFolder);
activityListener.ActivityStopped();
}
}
}
}
示例2: SyncDownloadFile
/// <summary>
/// Download a single file from the CMIS server for sync.
/// </summary>
/// <returns>true if successful</returns>
private bool SyncDownloadFile(IDocument remoteDocument, string localFolder, IList<string> remoteFiles = null)
{
string remotePath = remoteDocument.Paths[0];
var syncItem = database.GetSyncItemFromRemotePath(remotePath);
if (null == syncItem)
{
syncItem = SyncItemFactory.CreateFromRemotePath(remotePath, repoinfo);
// syncItem = SyncItemFactory.CreateFromLocalFolderAndRemoteName(localFolder, remoteDocument.Name, repoinfo);
}
//var syncItem = SyncItemFactory.CreateFromRemotePath(localFolder, remoteDocument.Name);
string fileName = remoteDocument.Name;
string filePath = Path.Combine(localFolder, fileName);
// If this file does not have a filename, ignore it.
// It sometimes happen on IBM P8 CMIS server, not sure why.
if (remoteDocument.ContentStreamFileName == null)
{
//TODO Possibly the file content has been changed to 0, this case should be handled
Logger.Warn("Skipping download of '" + syncItem.RemoteFileName + "' with null content stream in " + localFolder);
return true;
}
if (null != remoteFiles)
{
remoteFiles.Add(syncItem.RemoteFileName);
}
// Check if file extension is allowed
if (!Utils.WorthSyncing(syncItem.RemoteFileName))
{
Logger.Info("Ignore the unworth syncing remote file: " + syncItem.RemoteFileName);
return true;
}
bool success = true;
try
{
if (syncItem.ExistsLocal())
{
// Check modification date stored in database and download if remote modification date if different.
DateTime? serverSideModificationDate = ((DateTime)remoteDocument.LastModificationDate).ToUniversalTime();
DateTime? lastDatabaseUpdate = database.GetServerSideModificationDate(syncItem);
if (lastDatabaseUpdate == null)
{
Logger.Info("Downloading file absent from database: " + syncItem.LocalPath);
success = DownloadFile(remoteDocument, localFolder);
}
else
{
// If the file has been modified since last time we downloaded it, then download again.
if (serverSideModificationDate > lastDatabaseUpdate)
{
Logger.Info("Downloading modified file: " + syncItem.RemoteFileName);
success = DownloadFile(remoteDocument, localFolder);
}
else if (serverSideModificationDate == lastDatabaseUpdate)
{
// check chunked upload
FileInfo fileInfo = new FileInfo(syncItem.LocalPath);
if (remoteDocument.ContentStreamLength < fileInfo.Length)
{
success = ResumeUploadFile(syncItem.LocalPath, remoteDocument);
}
}
}
}
else
{
if (database.ContainsFile(syncItem))
{
long retries = database.GetOperationRetryCounter(syncItem.LocalPath, Database.Database.OperationType.DELETE);
if (retries <= repoinfo.MaxDeletionRetries)
{
// File has been recently removed locally, so remove it from server too.
Logger.Info("Removing locally deleted file on server: " + syncItem.LocalPath); //?
try
{
remoteDocument.DeleteAllVersions();
// Remove it from database.
database.RemoveFile(syncItem);
database.SetOperationRetryCounter(syncItem, 0, Database.Database.OperationType.DELETE);
}
catch (CmisBaseException ex)
{
Logger.Warn("Could not delete remote file: ", ex);
database.SetOperationRetryCounter(syncItem, retries + 1, Database.Database.OperationType.DELETE);
throw;
}
}
else
{
Logger.Info(String.Format("Skipped deletion of remote file {0} because of too many failed retries ({1} max={2})", syncItem.RemotePath, retries, repoinfo.MaxDeletionRetries)); // ???
}
}
//.........这里部分代码省略.........
示例3: CrawlRemoteDocument
/// <summary>
/// Crawl remote document, syncing down if needed.
/// Meanwhile, cache remoteFiles, they are output parameters that are used in CrawlLocalFiles/CrawlLocalFolders
/// </summary>
private void CrawlRemoteDocument(IDocument remoteDocument, string localFolder, IList remoteFiles)
{
sleepWhileSuspended();
try
{
if (Utils.WorthSyncing(localFolder, remoteDocument.Name, repoinfo))
{
// We use the filename of the document's content stream.
// This can be different from the name of the document.
// For instance in FileNet it is not usual to have a document where
// document.Name is "foo" and document.ContentStreamFileName is "foo.jpg".
string remoteDocumentFileName = remoteDocument.ContentStreamFileName;
//Logger.Debug("CrawlRemote doc: " + localFolder + Path.DirectorySeparatorChar.ToString() + remoteDocumentFileName);
// If this file does not have a filename, ignore it.
// It sometimes happen on IBM P8 CMIS server, not sure why.
if (remoteDocumentFileName == null)
{
Logger.Warn("Skipping download of '" + remoteDocument.Name + "' with null content stream in " + localFolder);
return;
}
remoteFiles.Add(remoteDocumentFileName);
string filePath = Path.Combine(localFolder, remoteDocumentFileName);
if (File.Exists(filePath))
{
// Check modification date stored in database and download if remote modification date if different.
DateTime? serverSideModificationDate = ((DateTime)remoteDocument.LastModificationDate).ToUniversalTime();
DateTime? lastDatabaseUpdate = database.GetServerSideModificationDate(filePath);
if (lastDatabaseUpdate == null)
{
Logger.Info("Downloading file absent from database: " + filePath);
DownloadFile(remoteDocument, localFolder);
}
else
{
// If the file has been modified since last time we downloaded it, then download again.
if (serverSideModificationDate > lastDatabaseUpdate)
{
if (database.LocalFileHasChanged(filePath))
{
Logger.Info("Conflict with file: " + remoteDocumentFileName + ", backing up locally modified version and downloading server version");
// Rename locally modified file.
String newFilePath = Utils.ConflictPath(filePath);
File.Move(filePath, newFilePath);
// Download server version
DownloadFile(remoteDocument, localFolder);
repo.OnConflictResolved();
// TODO move to OS-dependant layer
//System.Windows.Forms.MessageBox.Show("Someone modified a file at the same time as you: " + filePath
// + "\n\nYour version has been saved with a '_your-version' suffix, please merge your important changes from it and then delete it.");
// TODO show CMIS property lastModifiedBy
}
else
{
Logger.Info("Downloading modified file: " + remoteDocumentFileName);
DownloadFile(remoteDocument, localFolder);
}
}
}
}
else
{
if (database.ContainsFile(filePath))
{
// File has been recently removed locally, so remove it from server too.
Logger.Info("Removing locally deleted file on server: " + filePath);
remoteDocument.DeleteAllVersions();
// Remove it from database.
database.RemoveFile(filePath);
}
else
{
// New remote file, download it.
Logger.Info("New remote file: " + filePath);
DownloadFile(remoteDocument, localFolder);
}
}
}
}
catch (Exception e)
{
ProcessRecoverableException("Could not crawl sync remote document: " + remoteDocument.Name, e);
}
}
示例4: DeleteRemoteDocument
public void DeleteRemoteDocument(IDocument document, SyncItem syncItem)
{
string message0 = "CmisSync Warning: You have deleted file " + syncItem.LocalPath + "\nCmisSync will now delete it from the server. If you actually did not delete this file, please report a bug at [email protected]";
Logger.Info(message0);
//Utils.NotifyUser(message0);
if (document.IsVersionSeriesCheckedOut != null
&& (bool)document.IsVersionSeriesCheckedOut)
{
string message = String.Format("File {0} is checked out on the server by another user: {1}", syncItem.LocalPath, document.CheckinComment);
Logger.Info(message);
Utils.NotifyUser(message);
}
else
{
// File has been recently removed locally, so remove it from server too.
activityListener.ActivityStarted();
Logger.Info("Removing locally deleted file on server: " + syncItem.RemotePath);
document.DeleteAllVersions();
// Remove it from database.
database.RemoveFile(syncItem);
activityListener.ActivityStopped();
}
}
示例5: DeleteRemoteDocument
public void DeleteRemoteDocument(IDocument remoteDocument, SyncItem syncItem)
{
string message0 = "CmisSync Warning: You have deleted file " + syncItem.LocalPath +
"\nCmisSync will now delete it from the server. If you actually did not delete this file, please report a bug at [email protected]";
Logger.Info(message0);
//Utils.NotifyUser(message0);
if (remoteDocument.IsVersionSeriesCheckedOut != null
&& (bool)remoteDocument.IsVersionSeriesCheckedOut
&& remoteDocument.VersionSeriesCheckedOutBy != null
&& !remoteDocument.VersionSeriesCheckedOutBy.Equals(repoInfo.User))
{
string message = String.Format("Restoring file \"{0}\" because it is checked out on the server by another user: {1}",
syncItem.LocalPath, remoteDocument.VersionSeriesCheckedOutBy);
Logger.Info(message);
Utils.NotifyUser(message);
// Restore the deleted file
activityListener.ActivityStarted();
DownloadFile(remoteDocument, syncItem.RemotePath, Path.GetDirectoryName(syncItem.LocalPath));
activityListener.ActivityStopped();
}
else
{
// File has been recently removed locally, so remove it from server too.
activityListener.ActivityStarted();
Logger.Info("Removing locally deleted file on server: " + syncItem.RemotePath);
remoteDocument.DeleteAllVersions();
// Remove it from database.
database.RemoveFile(syncItem);
activityListener.ActivityStopped();
}
}
示例6: CrawlRemoteDocument
/// <summary>
/// Crawl remote document, syncing down if needed.
/// Meanwhile, cache remoteFiles, they are output parameters that are used in CrawlLocalFiles/CrawlLocalFolders
/// </summary>
private void CrawlRemoteDocument(IDocument remoteDocument, string localFolder, IList<string> remoteFiles)
{
CheckPendingCancelation();
if (SyncUtils.IsWorthSyncing(localFolder, remoteDocument.Name, SyncFolderInfo))
{
// We use the filename of the document's content stream.
// This can be different from the name of the document.
// For instance in FileNet it is not unusual to have a document where
// document.Name is "foo" and document.ContentStreamFileName is "foo.jpg".
string remoteDocumentFileName = remoteDocument.ContentStreamFileName;
//Logger.Debug("CrawlRemote doc: " + localFolder + CmisPath.CMIS_FILE_SEPARATOR + remoteDocumentFileName);
// If this file does not have a filename, ignore it.
// It sometimes happen on IBM P8 CMIS server, not sure why.
if (remoteDocumentFileName == null)
{
Logger.Warn("Skipping download of '" + remoteDocument.Name + "' with null content stream in " + localFolder);
return;
}
remoteFiles.Add(remoteDocumentFileName);
var paths = remoteDocument.Paths;
var pathsCount = paths.Count;
SyncItem syncItem = getSyncItemFromRemotePath(remoteDocument.Paths[0]);
if (syncItem.ExistsLocal())
{
// Check modification date stored in database and download if remote modification date if different.
DateTime? serverSideModificationDate = getUtcLastModificationDate(remoteDocument);
DateTime? lastDatabaseUpdate = database.GetServerSideModificationDate(syncItem);
if (lastDatabaseUpdate == null)
{
Logger.Info("Downloading file absent from database: " + syncItem.LocalPath);
DownloadFile(remoteDocument, localFolder);
}
else
{
// If the file has been modified since last time we downloaded it, then download again.
if (serverSideModificationDate > lastDatabaseUpdate)
{
if (database.LocalFileHasChanged(syncItem.LocalPath))
{
Logger.Info("Conflict with file: " + remoteDocumentFileName + ", backing up locally modified version and downloading server version");
Logger.Info("- serverSideModificationDate: " + serverSideModificationDate);
Logger.Info("- lastDatabaseUpdate: " + lastDatabaseUpdate);
Logger.Info("- Checksum in database: " + database.GetChecksum(syncItem.LocalPath));
Logger.Info("- Checksum of local file: " + Database.Database.Checksum(syncItem.LocalPath));
// Rename locally modified file.
String newFilePath = SyncUtils.CreateConflictFilename(syncItem.LocalPath, SyncFolderInfo.Account.Credentials.UserName);
File.Move(syncItem.LocalPath, newFilePath);
// Download server version
DownloadFile(remoteDocument, localFolder);
Logger.Info("- Checksum of remote file: " + Database.Database.Checksum(syncItem.LocalPath));
// Notify the user.
string lastModifiedBy = CmisUtils.GetProperty(remoteDocument, "cmis:lastModifiedBy");
HandleException(new FileConflictException(syncItem.LocalPath, lastModifiedBy, newFilePath));
}
else
{
Logger.Info("Downloading modified file: " + remoteDocumentFileName);
DownloadFile(remoteDocument, localFolder);
}
}
}
}
else
{
if (database.ContainsFile(syncItem))
{
if (!(bool)remoteDocument.IsVersionSeriesCheckedOut)
{
// File has been recently removed locally, so remove it from server too.
Logger.Info("Removing locally deleted file on server: " + syncItem.RemotePath);
remoteDocument.DeleteAllVersions();
// Remove it from database.
database.RemoveFile(syncItem);
}
else
{
HandleException(new CheckOutFileException(syncItem.LocalPath, remoteDocument.CheckinComment));
}
}
else
{
// New remote file, download it.
Logger.Info("New remote file: " + syncItem.RemotePath);
//.........这里部分代码省略.........