本文整理汇总了C#中VersionManager类的典型用法代码示例。如果您正苦于以下问题:C# VersionManager类的具体用法?C# VersionManager怎么用?C# VersionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VersionManager类属于命名空间,在下文中一共展示了VersionManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
engine = new Fakes.FakeEngine(new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart), typeof(Fakes.FakeNodeAdapter) });
//engine.Resolve<Fakes.FakeNodeAdapter>().Engine = engine;
handler = new ContentHandler(engine);
context = new Fakes.FakeWebContextWrapper();
context.HttpContext.User = SecurityUtilities.CreatePrincipal("Admin");
startPage = new ContentHandlerTestsPage { Title = "Start page" };
engine.Persister.Save(startPage);
page = new ContentHandlerTestsPage { Title = "Page in question" };
page.AddTo(startPage);
engine.Persister.Save(page);
engine.AddComponentInstance<IWebContext>(context);
engine.AddComponentInstance<IUrlParser>(new Fakes.FakeUrlParser(startPage: startPage));
var persister = engine.Persister;
var activator = engine.Resolve<ContentActivator>();
var versionRepository = TestSupport.CreateVersionRepository(ref persister, ref activator, new Type[] { typeof(ContentHandlerTestsPage), typeof(ContentHandlerTestsPart) });
engine.AddComponentInstance<ContentVersionRepository>(versionRepository);
engine.AddComponentInstance<VersionManager>(versionManager = TestSupport.SetupVersionManager(engine.Persister, versionRepository));
(engine.Resolve<IContentAdapterProvider>() as N2.Plugin.IAutoStart).Start();
engine.Resolve<IContentAdapterProvider>().ResolveAdapter<N2.Edit.NodeAdapter>(typeof(ContentItem)).Engine = engine;
engine.AddComponentInstance(new HtmlSanitizer(new N2.Configuration.HostSection()));
engine.AddComponentInstance<IEditUrlManager>(new FakeEditUrlManager());
engine.AddComponentInstance(new ConfigurationManagerWrapper());
engine.AddComponentInstance<ILanguageGateway>(new FakeLanguageGateway());
engine.AddComponentInstance(new DraftRepository(versionRepository, new FakeCacheWrapper()));
}
开发者ID:n2cms,项目名称:n2cms,代码行数:30,代码来源:ContentHandlerTests.cs
示例2: TestFixtureSetUp
public override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
persister = (ContentPersister) engine.Resolve<IPersister>();
versioner = (VersionManager) engine.Resolve<IVersionManager>();
engine.SecurityManager.ScopeEnabled = false;
}
开发者ID:andy4711,项目名称:n2cms,代码行数:8,代码来源:VersionManagerTests.cs
示例3: SetUp
public override void SetUp()
{
base.SetUp();
var types = new[] { typeof(Items.PageItem), typeof(Items.DataItem) };
versionRepository = TestSupport.CreateVersionRepository(ref persister, ref activator, types);
versions = TestSupport.SetupVersionManager(persister, versionRepository);
copyer = new ItemCopyer(
// persister,
new Navigator(persister, TestSupport.SetupHost(), new VirtualNodeFactory(), TestSupport.SetupContentSource()),
new FakeIntegrityManager(),
versions,
versionRepository);
request = new NameValueCollection();
root = CreateOneItem<Items.PageItem>(0, "root", null);
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:17,代码来源:ItemCopyerTests.cs
示例4: SetUp
public void SetUp()
{
engine = new Fakes.FakeEngine(new Type[] { typeof(ContentHandlerTestsPage) });
handler = new ContentHandler(engine);
context = new Fakes.FakeWebContextWrapper();
context.HttpContext.User = SecurityUtilities.CreatePrincipal("Admin");
startPage = new ContentHandlerTestsPage { Title = "Start page" };
engine.Persister.Save(startPage);
page = new ContentHandlerTestsPage { Title = "Page in question" };
page.AddTo(startPage);
engine.Persister.Save(page);
engine.AddComponentInstance<IWebContext>(context);
engine.AddComponentInstance<IUrlParser>(new Fakes.FakeUrlParser(startPage: startPage));
var versionRepository = TestSupport.CreateVersionRepository(new Type[] { typeof(ContentHandlerTestsPage) });
engine.AddComponentInstance<ContentVersionRepository>(versionRepository);
engine.AddComponentInstance<VersionManager>(versionManager = TestSupport.SetupVersionManager(engine.Persister, versionRepository));
}
开发者ID:rukmareddy,项目名称:n2cms,代码行数:19,代码来源:ContentHandlerTests.cs
示例5: UndoCheckout
/// <summary>
/// Reverts back the changes made in the latest version if check-in/check-out is used. Called when the "Undo check-out" button is pressed.
/// Expects the "CreateExampleObjects" and "CheckOut" methods to be run first.
/// </summary>
private bool UndoCheckout()
{
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Prepare parameters
string siteName = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = TreeProvider.ALL_CLASSNAMES;
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
string columns = null;
// Get the document
TreeNode node = DocumentHelper.GetDocument(siteName, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, columns, tree);
if (node != null)
{
WorkflowManager workflowmanager = new WorkflowManager(tree);
// Make sure the document uses workflow
WorkflowInfo workflow = workflowmanager.GetNodeWorkflow(node);
if (workflow != null)
{
if (node.IsCheckedOut)
{
VersionManager versionmanager = new VersionManager(tree);
// Undo the checkout
versionmanager.UndoCheckOut(node);
return true;
}
else
{
apiUndoCheckout.ErrorMessage = "The document hasn't been checked out.";
}
}
else
{
apiUndoCheckout.ErrorMessage = "The document doesn't use workflow.";
}
}
return false;
}
开发者ID:KuduApps,项目名称:Kentico,代码行数:54,代码来源:Default.aspx.cs
示例6: Publish
/// <summary>
/// Publishes document.
/// </summary>
/// <param name="node">Node to publish</param>
/// <param name="wm">Workflow manager</param>
/// <returns>Whether node is already published</returns>
private static bool Publish(TreeNode node, WorkflowManager wm)
{
WorkflowStepInfo currentStep = wm.GetStepInfo(node);
bool toReturn = true;
if (currentStep != null)
{
// For archive step start new version
if (currentStep.StepName.ToLower() == "archived")
{
VersionManager vm = new VersionManager(node.TreeProvider);
currentStep = vm.CheckOut(node, node.IsPublished, true);
vm.CheckIn(node, null, null);
}
// Remove possible checkout
if (node.GetIntegerValue("DocumentCheckedOutByUserID") > 0)
{
TreeProvider.ClearCheckoutInformation(node);
node.Update();
}
// Approve until the document is published
while ((currentStep != null) && (currentStep.StepName.ToLower() != "published"))
{
currentStep = wm.MoveToNextStep(node, string.Empty);
toReturn = false;
}
}
return toReturn;
}
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:36,代码来源:Workflow_Documents.aspx.cs
示例7: HandleAttachmentEdit
/// <summary>
/// Handles attachment edit action.
/// </summary>
/// <param name="argument">Attachment GUID coming from view control</param>
private void HandleAttachmentEdit(string argument)
{
IsEditImage = true;
if (!string.IsNullOrEmpty(argument))
{
string[] argArr = argument.Split('|');
Guid attachmentGuid = ValidationHelper.GetGuid(argArr[1], Guid.Empty);
AttachmentInfo ai = null;
int versionHistoryId = 0;
if (TreeNodeObj != null)
{
versionHistoryId = TreeNodeObj.DocumentCheckedOutVersionHistoryID;
}
if (versionHistoryId == 0)
{
ai = AttachmentManager.GetAttachmentInfo(attachmentGuid, CMSContext.CurrentSiteName);
}
else
{
VersionManager vm = new VersionManager(TreeNodeObj.TreeProvider);
if (vm != null)
{
// Get the attachment version data
AttachmentHistoryInfo attachmentVersion = vm.GetAttachmentVersion(versionHistoryId, attachmentGuid, false);
if (attachmentVersion == null)
{
ai = null;
}
else
{
// Create the attachment info from given data
ai = new AttachmentInfo(attachmentVersion.Generalized.DataClass);
ai.AttachmentID = attachmentVersion.AttachmentHistoryID;
}
if (ai != null)
{
ai.AttachmentLastHistoryID = versionHistoryId;
}
}
}
if (ai != null)
{
string nodeAliasPath = "";
if (TreeNodeObj != null)
{
nodeAliasPath = TreeNodeObj.NodeAliasPath;
}
string url = mediaView.GetAttachmentItemUrl(ai.AttachmentGUID, ai.AttachmentName, nodeAliasPath, ai.AttachmentImageHeight, ai.AttachmentImageWidth, 0);
if (LastAttachmentGuid == attachmentGuid)
{
SelectMediaItem(ai.AttachmentName, ai.AttachmentExtension, ai.AttachmentImageWidth, ai.AttachmentImageHeight, ai.AttachmentSize, url);
}
// Update select action to reflect changes made during editing
LoadDataSource();
mediaView.Reload();
pnlUpdateView.Update();
}
}
ClearActionElems();
}
开发者ID:KuduApps,项目名称:Kentico,代码行数:74,代码来源:LinkMediaSelector.ascx.cs
示例8: RestoreDataSet
/// <summary>
/// Restores set of given version histories.
/// </summary>
/// <param name="currentUserInfo">Current user info</param>
/// <param name="recycleBin">DataSet with nodes to restore</param>
private void RestoreDataSet(CurrentUserInfo currentUserInfo, DataSet recycleBin)
{
// Result flags
bool resultOK = true;
bool permissionsOK = true;
if (!DataHelper.DataSourceIsEmpty(recycleBin))
{
TreeProvider tree = new TreeProvider(currentUserInfo);
tree.AllowAsyncActions = false;
VersionManager verMan = new VersionManager(tree);
// Restore all documents
foreach (DataRow dataRow in recycleBin.Tables[0].Rows)
{
int versionId = ValidationHelper.GetInteger(dataRow["VersionHistoryID"], 0);
// Log actual event
string taskTitle = HTMLHelper.HTMLEncode(ValidationHelper.GetString(dataRow["DocumentNamePath"], string.Empty));
// Restore document
if (versionId > 0)
{
// Check permissions
TreeNode tn = null;
if (!IsAuthorizedPerDocument(versionId, "Create", currentUser, out tn, verMan))
{
CurrentError = String.Format(ResHelper.GetString("Recyclebin.RestorationFailedPermissions", currentCulture), taskTitle);
AddLog(CurrentError);
permissionsOK = false;
}
else
{
tn = verMan.RestoreDocument(versionId, tn);
if (tn != null)
{
AddLog(ResHelper.GetString("general.document", currentCulture) + "'" + taskTitle + "'");
}
else
{
// Set result flag
if (resultOK)
{
resultOK = false;
}
}
}
}
}
}
if (resultOK && permissionsOK)
{
CurrentInfo = ResHelper.GetString("Recyclebin.RestorationOK", currentCulture);
AddLog(CurrentInfo);
}
else
{
CurrentError = ResHelper.GetString("Recyclebin.RestorationFailed", currentCulture);
if (!permissionsOK)
{
CurrentError += "<br />" + ResHelper.GetString("recyclebin.errorsomenotrestored", currentCulture);
}
AddLog(CurrentError);
}
}
开发者ID:v-jli,项目名称:jean0407large,代码行数:70,代码来源:RecycleBin.ascx.cs
示例9: ugRecycleBin_OnAction
/// <summary>
/// Handles the UniGrid's OnAction event.
/// </summary>
/// <param name="actionName">Name of item (button) that throws event</param>
/// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
protected void ugRecycleBin_OnAction(string actionName, object actionArgument)
{
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
VersionManager verMan = new VersionManager(tree);
int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0);
TreeNode doc = null;
if (actionName == "restore")
{
try
{
if (IsAuthorizedPerDocument(versionHistoryId, "Create", currentUser, out doc, verMan))
{
verMan.RestoreDocument(versionHistoryId, doc);
lblInfo.Visible = true;
lblInfo.Text = GetString("Recyclebin.RestorationOK");
}
else
{
lblError.Visible = true;
lblError.Text = String.Format(ResHelper.GetString("Recyclebin.RestorationFailedPermissions", currentCulture), doc.DocumentNamePath);
}
}
catch (Exception ex)
{
lblError.Visible = true;
lblError.Text = GetString("recyclebin.errorrestoringdocument") + " " + ex.Message;
}
}
else if (actionName == "destroy")
{
if (IsAuthorizedPerDocument(versionHistoryId, "Destroy", currentUser, out doc, verMan))
{
verMan.DestroyDocumentHistory(doc.DocumentID);
lblInfo.Visible = true;
lblInfo.Text = GetString("recyclebin.destroyok");
}
else
{
lblError.Visible = true;
lblError.Text = String.Format(ResHelper.GetString("recyclebin.destructionfailedpermissions", currentCulture), doc.DocumentNamePath);
}
}
ugRecycleBin.ResetSelection();
}
开发者ID:v-jli,项目名称:jean0407large,代码行数:51,代码来源:RecycleBin.ascx.cs
示例10: HandleAttachmentUpload
/// <summary>
/// Provides operations necessary to create and store new attachment.
/// </summary>
private void HandleAttachmentUpload(bool fieldAttachment)
{
TreeProvider tree = null;
TreeNode node = null;
// New attachment
AttachmentInfo newAttachment = null;
string message = string.Empty;
bool fullRefresh = false;
try
{
// Get the existing document
if (DocumentID != 0)
{
// Get document
tree = new TreeProvider(CMSContext.CurrentUser);
node = DocumentHelper.GetDocument(DocumentID, tree);
if (node == null)
{
throw new Exception("Given document doesn't exist!");
}
}
#region "Check permissions"
if (this.CheckPermissions)
{
CheckNodePermissions(node);
}
#endregion
// Check the allowed extensions
CheckAllowedExtensions();
// Standard attachments
if (DocumentID != 0)
{
// Ensure automatic check-in/check-out
bool useWorkflow = false;
bool autoCheck = false;
WorkflowManager workflowMan = new WorkflowManager(tree);
VersionManager vm = null;
// Get workflow info
WorkflowInfo wi = workflowMan.GetNodeWorkflow(node);
// Check if the document uses workflow
if (wi != null)
{
useWorkflow = true;
autoCheck = !wi.UseCheckInCheckOut(CMSContext.CurrentSiteName);
}
// Check out the document
if (autoCheck)
{
// Get original step Id
int originalStepId = node.DocumentWorkflowStepID;
// Get current step info
WorkflowStepInfo si = workflowMan.GetStepInfo(node);
if (si != null)
{
// Decide if full refresh is needed
bool automaticPublish = wi.WorkflowAutoPublishChanges;
string stepName = si.StepName.ToLower();
// Document is published or archived or uses automatic publish or step is different than original (document was updated)
fullRefresh = (stepName == "published") || (stepName == "archived") || (automaticPublish && (stepName != "published")) || (originalStepId != node.DocumentWorkflowStepID);
}
vm = new VersionManager(tree);
vm.CheckOut(node, node.IsPublished, true);
}
// Handle field attachment
if (fieldAttachment)
{
newAttachment = DocumentHelper.AddAttachment(node, AttachmentGUIDColumnName, Guid.Empty, Guid.Empty, ucFileUpload.PostedFile, tree, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize);
// Update attachment field
DocumentHelper.UpdateDocument(node, tree);
}
// Handle grouped and unsorted attachments
else
{
// Grouped attachment
if (AttachmentGroupGUID != Guid.Empty)
{
newAttachment = DocumentHelper.AddGroupedAttachment(node, AttachmentGUID, AttachmentGroupGUID, ucFileUpload.PostedFile, tree, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize);
}
// Unsorted attachment
else
{
newAttachment = DocumentHelper.AddUnsortedAttachment(node, AttachmentGUID, ucFileUpload.PostedFile, tree, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize);
}
//.........这里部分代码省略.........
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:101,代码来源:FileUpload.ascx.cs
示例11: gridAttachments_OnDataReload
protected DataSet gridAttachments_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
{
string where = null;
Guid attachmentFormGUID = Guid.Empty;
string whereCondition = GetWhereConditionInternal();
int documentVersionHistoryID = UsesWorkflow ? VersionHistoryID : 0;
// Grouped attachments
if (GroupGUID != Guid.Empty)
{
// Combine where conditions
where = String.Format("(AttachmentGroupGUID='{0}')", GroupGUID);
}
// Unsorted attachments
else
{
where = "(AttachmentIsUnsorted = 1)";
}
// Temporary attachments
if ((attachmentFormGUID != Guid.Empty) && (documentVersionHistoryID == 0))
{
where += String.Format(" AND (AttachmentFormGUID='{0}')", FormGUID);
}
// Else document attachments
else
{
if (documentVersionHistoryID == 0)
{
// Ensure current site name
if (string.IsNullOrEmpty(SiteName))
{
SiteName = CMSContext.CurrentSiteName;
}
if (Node != null)
{
where += String.Format(" AND (AttachmentDocumentID = {0})", Node.DocumentID);
// Get attachments for latest version if not live site
if (!IsLiveSite)
{
WorkflowManager wm = new WorkflowManager(TreeProvider);
WorkflowInfo wi = wm.GetNodeWorkflow(Node);
if (wi != null)
{
documentVersionHistoryID = Node.DocumentCheckedOutVersionHistoryID;
}
}
}
else
{
return null;
}
}
}
// Ensure additional where condition
whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, where);
// Ensure [AttachmentID] column
List<String> cols = new List<string>(columns.Split(new char[] { ',', ';' }));
if (!cols.Contains("AttachmentID") && !cols.Contains("[AttachmentID]"))
{
columns = SqlHelperClass.MergeColumns("AttachmentID", columns);
}
DataSet ds = null;
// Get attachments for published document
if (documentVersionHistoryID == 0)
{
currentOrder = "AttachmentOrder, AttachmentName, AttachmentID";
ds = AttachmentManager.GetAttachments(whereCondition, currentOrder, true, currentTopN, columns);
}
else
{
currentOrder = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
VersionManager vm = new VersionManager(TreeProvider);
ds = vm.GetVersionAttachments(documentVersionHistoryID, whereCondition, currentOrder, true, currentTopN, columns.Replace("AttachmentID", "AttachmentHistoryID"));
}
// Ensure consistent ID column name
if (!DataHelper.DataSourceIsEmpty(ds))
{
ds.Tables[0].Columns[0].ColumnName = "AttachmentID";
}
return ds;
}
开发者ID:KuduApps,项目名称:Kentico,代码行数:91,代码来源:DocumentAttachmentsList.ascx.cs
示例12: Publish
/// <summary>
/// Publishes document.
/// </summary>
/// <param name="node">Node to publish</param>
/// <param name="wm">Workflow manager</param>
/// <param name="currentStep">Current workflow step</param>
/// <returns>Whether node is already published</returns>
private static bool Publish(TreeNode node, WorkflowManager wm, WorkflowStepInfo currentStep)
{
bool toReturn = true;
if (currentStep != null)
{
// For archive step start new version
if (currentStep.StepName.ToLower() == "archived")
{
VersionManager vm = new VersionManager(node.TreeProvider);
currentStep = vm.CheckOut(node, node.IsPublished, true);
vm.CheckIn(node, null, null);
}
// Approve until the step is publish
while ((currentStep != null) && (currentStep.StepName.ToLower() != "published"))
{
currentStep = wm.MoveToNextStep(node, string.Empty);
toReturn = false;
}
// Document is already published, check if still under workflow
if (toReturn && (currentStep.StepName.ToLower() == "published"))
{
WorkflowScopeInfo wsi = wm.GetNodeWorkflowScope(node);
if (wsi == null)
{
DocumentHelper.ClearWorkflowInformation(node);
VersionManager vm = new VersionManager(node.TreeProvider);
vm.RemoveWorkflow(node);
}
}
}
return toReturn;
}
开发者ID:KuduApps,项目名称:Kentico,代码行数:42,代码来源:PublishArchive.aspx.cs
示例13: RestoreFromRecycleBin
/// <summary>
/// Restores the document from the recycle bin. Called when the "Restore document" button is pressed.
/// Expects the "CreateDocumentStructure" and "MoveDocumentToRecycleBin" methods to be run first.
/// </summary>
private bool RestoreFromRecycleBin()
{
// Prepare the where condition
string where = "VersionNodeAliasPath LIKE N'/API-Example/Document-1'";
// Get the recycled document
DataSet recycleBin = VersionHistoryInfoProvider.GetRecycleBin(CMSContext.CurrentSiteID, where, null, 0, "VersionHistoryID");
if (!DataHelper.DataSourceIsEmpty(recycleBin))
{
// Create a new version history info object from the data row
VersionHistoryInfo version = new VersionHistoryInfo(recycleBin.Tables[0].Rows[0]);
// Create a new version manager instance and restore the document
VersionManager manager = new VersionManager(new TreeProvider(CMSContext.CurrentUser));
manager.RestoreDocument(version.VersionHistoryID);
return true;
}
return false;
}
开发者ID:KuduApps,项目名称:Kentico,代码行数:26,代码来源:Default.aspx.cs
示例14: VersionManager
static VersionManager()
{
Instance = new VersionManager();
}
开发者ID:lbddk,项目名称:ahzs-client,代码行数:4,代码来源:VersionManager.cs
示例15: GetAndUpdateDocuments
/// <summary>
/// Gets a dataset of documents in the example section and updates them. Called when the "Get and update documents" button is pressed.
/// Expects the "CreateExampleObjects" and "CreateDocument" methods to be run first.
/// </summary>
private bool GetAndUpdateDocuments()
{
// Create an instance of the Tree provider first
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Prepare parameters
string siteName = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example/%";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = "CMS.MenuItem";
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
// Fill dataset with documents
DataSet documents = DocumentHelper.GetDocuments(siteName, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, tree);
if (!DataHelper.DataSourceIsEmpty(documents))
{
// Create a new Version manager instance
VersionManager manager = new VersionManager(tree);
// Loop through all documents
foreach (DataRow documentRow in documents.Tables[0].Rows)
{
// Create a new Tree node from the data row
TreeNode editDocument = TreeNode.New(documentRow, "CMS.MenuItem", tree);
// Check out the document
manager.CheckOut(editDocument);
string newName = editDocument.DocumentName.ToLower();
// Change document data
editDocument.DocumentName = newName;
// Change coupled data
editDocument.SetValue("MenuItemName", newName);
// Save the changes
DocumentHelper.UpdateDocument(editDocument, tree);
// Check in the document
manager.CheckIn(editDocument, null, null);
}
return true;
}
return false;
}
开发者ID:v-jli,项目名称:jean0407large,代码行数:57,代码来源:Default.aspx.cs
示例16: AncestralTrail_IsUpdated_WhenUsing_VersioningManager
public void AncestralTrail_IsUpdated_WhenUsing_VersioningManager()
{
PersistableItem root = CreateOneItem<PersistableItem>(0, "root", null);
PersistableItem one = CreateOneItem<PersistableItem>(0, "one", root);
persister.Repository.SaveOrUpdate(root, one);
VersionManager vm = new VersionManager(TestSupport.CreateVersionRepository(typeof(PersistableItem)), persister.Repository, new N2.Edit.Workflow.StateChanger(), new N2.Configuration.EditSection());
var version = vm.AddVersion(one);
one.Name += "2";
persister.Save(one);
Assert.That(version.AncestralTrail, Is.EqualTo("/"));
Assert.That(one.AncestralTrail, Is.EqualTo("/" + root.ID + "/"));
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:15,代码来源:TrailTrackerTests.cs
示例17: btnCheckIn_Click
protected void btnCheckIn_Click(object sender, EventArgs e)
{
try
{
// Check in the document
if (node != null)
{
// Check modify permissions
if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
{
formElem.Enabled = false;
lblWorkflowInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath);
return;
}
// Validate the form first
if (formElem.BasicForm.ValidateData())
{
// Save the document first
if (SaveChanges)
{
SaveDocument(true);
}
else
{
formElem.BasicForm.LoadControlValues();
PassiveRefresh(nodeId, node.NodeParentID, node.DocumentName);
}
VersionManager verMan = new VersionManager(TreeProvider);
// Check in the document
verMan.CheckIn(node, null, null);
formElem.lblInfo.Text += " " + GetString("ContentEdit.WasCheckedIn");
}
}
}
catch (WorkflowException)
{
formElem.lblError.Text += GetString("EditContent.DocumentCannotCheckIn");
}
catch (Exception ex)
{
formElem.lblError.Text += ex.Message;
}
ReloadForm();
}
开发者ID:KuduApps,项目名称:Kentico,代码行数:49,代码来源:Edit.aspx.cs
示例18: SavedAsPrevious_IsNotFoundAsDraft
public void SavedAsPrevious_IsNotFoundAsDraft()
{
var master = CreateOneItem<Items.NormalPage>(0, "pageX", null);
persister.Save(master);
var manager = new VersionManager(repository, persister.Repository, new StateChanger(), new N2.Configuration.EditSection());
manager.AddVersion(master, asPreviousVersion: true);
drafts.FindDrafts().Any().ShouldBe(false);
}
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:10,代码来源:ContentVersionRepositoryTests.cs
示例19: IsAuthorizedPerDocument
/// <summary>
/// Check user permissions for document version.
/// </summary>
/// <param name="versionId">Document version</param>
/// <param name="permission">Permission</param>
/// <param name="user">User</param>
/// <param name="checkedNode">Checked node</param>
/// <param name="versionManager">Version manager</param>
/// <returns>True if authorized, false otherwise</returns>
public bool IsAuthorizedPerDocument(int versionId, string permission, CurrentUserInfo user, out TreeNode checkedNode, VersionManager versionManager)
{
if (versionManager == null)
{
TreeProvider tree = new TreeProvider(user);
tree.AllowAsyncActions = false;
versionManager = new VersionManager(tree);
}
// Get the values form deleted node
checkedNode = versionManager.GetVersion(versionId);
return IsAuthorizedPerDocument(checkedNode, permission, user);
}
开发者ID:v-jli,项目名称:jean0407large,代码行数:22,代码来源:RecycleBin.ascx.cs
示例20: DraftsCanBeFound_ForSingleItem
public void DraftsCanBeFound_ForSingleItem()
{
var master = CreateOneItem<Items.NormalPage>(0, "pageX", null);
persister.Save(master);
var manager = new VersionManager(repository, persister.Repository, new StateChanger(), new N2.Configuration.EditSection());
manager.AddVersion(master, asPreviousVersion: false);
drafts.FindDrafts().Single().Master.ID.ShouldBe(master.ID);
}
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:10,代码来源:ContentVersionRepositoryTests.cs
注:本文中的VersionManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论