();
- var webModel = SPMeta2Model
- .NewWebModel(web =>
- {
- web.AddRandomWeb(rndWeb =>
- {
- rndWeb.AddRandomList(rndList =>
- {
- rndList.AddRandomListItem(rndListItem =>
- {
- rndListItem.AddSecurityGroupLink(new SecurityGroupLinkDefinition
- {
- IsAssociatedMemberGroup = true
- });
- });
- });
- });
- });
+ var webModel = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddRandomWeb(rndWeb =>
+ {
+ rndWeb.AddRandomList(rndList =>
+ {
+ rndList.AddRandomListItem(rndListItem =>
+ {
+ rndListItem.AddSecurityGroupLink(new SecurityGroupLinkDefinition
+ {
+ IsAssociatedMemberGroup = true
+ });
+ });
+ });
+ });
+ });
TestModels(new ModelNode[] { webModel });
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/TaxonomyScenariousTest.cs b/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/TaxonomyScenariousTest.cs
index 6d80d61d2..71691627a 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/TaxonomyScenariousTest.cs
+++ b/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/TaxonomyScenariousTest.cs
@@ -46,7 +46,7 @@ protected void GenerateTermsTree(ModelNode termSetOrTermNode, int deep, bool cle
(termSetOrTermNode as TaxonomyTermModelNode).AddRandomTerm(term =>
{
var termDef = term.Value as TaxonomyTermDefinition;
- termDef.Name = string.Format("InvertedLevel_{0}_{1}", deep, termDef.Name);
+ termDef.Name = string.Format("il{0}_{1}", deep, termDef.Name);
if (cleanGuid)
termDef.Id = null;
@@ -59,7 +59,7 @@ protected void GenerateTermsTree(ModelNode termSetOrTermNode, int deep, bool cle
(termSetOrTermNode as TaxonomyTermSetModelNode).AddRandomTerm(term =>
{
var termDef = term.Value as TaxonomyTermDefinition;
- termDef.Name = string.Format("InvertedLevel_{0}_{1}", deep, termDef.Name);
+ termDef.Name = string.Format("il{0}_{1}", deep, termDef.Name);
if (cleanGuid)
termDef.Id = null;
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WebpartScenariosTest.cs b/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WebpartScenariosTest.cs
index 0a1288e2d..b9b1a1a66 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WebpartScenariosTest.cs
+++ b/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WebpartScenariosTest.cs
@@ -418,18 +418,22 @@ public void CanDeploy_Webpart_With_AuthorizationFilter()
var webModel = SPMeta2Model.NewWebModel(web =>
{
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
+
+ web.AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list.AddRandomWebPartPage(page =>
{
- list.AddRandomWebPartPage(page =>
+ page.AddRandomWebpart(webPart =>
{
- page.AddRandomWebpart(webPart =>
- {
- var wpDef = webPart.Value as WebPartDefinition;
- wpDef.AuthorizationFilter = string.Format(";;;;{0}", securityGroupDef.Name);
- });
+ var wpDef = webPart.Value as WebPartDefinition;
+ wpDef.AuthorizationFilter = string.Format(";;;;{0}", securityGroupDef.Name);
});
});
+ });
});
@@ -441,29 +445,32 @@ public void CanDeploy_Webpart_With_AuthorizationFilter()
[TestCategory("Regression.Scenarios.Webparts.Hosts")]
public void CanDeploy_WebpartTo_WebpartPage()
{
- var model = SPMeta2Model
- .NewWebModel(web =>
+ var model = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
{
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
+ def.Enable = true;
+ }));
+
+ web.AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list
+ .AddRandomWebPartPage(page =>
{
- list
- .AddRandomWebPartPage(page =>
- {
- page
- .AddRandomWebpart()
- .AddRandomWebpart();
- })
- .AddRandomWebPartPage(page =>
- {
- page
- .AddRandomWebpart()
- .AddRandomWebpart();
- });
+ page
+ .AddRandomWebpart()
+ .AddRandomWebpart();
+ })
+ .AddRandomWebPartPage(page =>
+ {
+ page
+ .AddRandomWebpart()
+ .AddRandomWebpart();
});
-
});
+ });
+
TestModel(model);
}
@@ -484,6 +491,11 @@ public void CanDeploy_WebpartTo_WebpartPage_WithCustomPageLayout()
var model = SPMeta2Model.NewWebModel(web =>
{
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
+
web.AddHostList(BuiltInListDefinitions.SitePages, list =>
{
list
@@ -516,32 +528,35 @@ public void CanDeploy_WebpartTo_WebpartPage_WithCustomPageLayout()
[TestCategory("Regression.Scenarios.Webparts")]
public void CanDeploy_Webpart_WithTitleUrl_WithTokens()
{
- var model = SPMeta2Model
- .NewWebModel(web =>
+ var model = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
{
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
+ def.Enable = true;
+ }));
+
+ web.AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list
+ .AddRandomWebPartPage(page =>
{
- list
- .AddRandomWebPartPage(page =>
+ page
+ .AddRandomWebpart(w =>
{
- page
- .AddRandomWebpart(w =>
- {
- (w.Value as WebPartDefinition).TitleUrl =
- string.Format("~sitecollection/{0}.html", Rnd.String());
- })
- .AddRandomWebpart(w =>
- {
- (w.Value as WebPartDefinition).TitleUrl =
- string.Format("~site/{0}.html", Rnd.String());
-
- });
+ (w.Value as WebPartDefinition).TitleUrl =
+ string.Format("~sitecollection/{0}.html", Rnd.String());
+ })
+ .AddRandomWebpart(w =>
+ {
+ (w.Value as WebPartDefinition).TitleUrl =
+ string.Format("~site/{0}.html", Rnd.String());
+
});
});
-
});
+ });
+
TestModel(model);
}
@@ -621,24 +636,27 @@ public void CanDeploy_WebpartTo_PublishingPageWebPartZone()
var webModel = SPMeta2Model.NewWebModel(web =>
{
- web
- .AddWebFeature(RegWebFeatures.Publishing)
- .AddHostList(BuiltInListDefinitions.Pages, list =>
- {
- list
- .AddRandomPublishingPage(page =>
- {
- page
- .AddRandomWebpart()
- .AddRandomWebpart();
- })
- .AddRandomPublishingPage(page =>
- {
- page
- .AddRandomWebpart()
- .AddRandomWebpart();
- });
- });
+ web.AddWebFeature(BuiltInWebFeatures.SharePointServerPublishing.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
+
+ web.AddHostList(BuiltInListDefinitions.Pages, list =>
+ {
+ list
+ .AddRandomPublishingPage(page =>
+ {
+ page
+ .AddRandomWebpart()
+ .AddRandomWebpart();
+ })
+ .AddRandomPublishingPage(page =>
+ {
+ page
+ .AddRandomWebpart()
+ .AddRandomWebpart();
+ });
+ });
});
@@ -651,77 +669,89 @@ public void CanDeploy_WebpartTo_PublishingPageWebPartZone()
[TestCategory("Regression.Scenarios.Webparts.Hosts")]
public void CanDeploy_WebpartTo_PublishingPageContent()
{
- var webModel = SPMeta2Model
- .NewWebModel(web =>
- {
- web
- .AddHostList(BuiltInListDefinitions.Pages, list =>
- {
- list
- .AddRandomPublishingPage(page =>
- {
- var id_1 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- var id_2 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ var siteModel = SPMeta2Model.NewSiteModel(site =>
+ {
+ site.AddSiteFeature(BuiltInSiteFeatures.SharePointServerPublishingInfrastructure.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
+ });
- var id_3 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ var webModel = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.SharePointServerPublishing.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
- var wpId11 = id_1
- .Replace("g_", string.Empty)
- .Replace("_", "-");
+ web
+ .AddHostList(BuiltInListDefinitions.Pages, list =>
+ {
+ list
+ .AddRandomPublishingPage(page =>
+ {
+ var id_1 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ var id_2 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- var wpId22 = id_2
- .Replace("g_", string.Empty)
- .Replace("_", "-");
+ var id_3 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- var pageTemplate = new StringBuilder();
+ var wpId11 = id_1
+ .Replace("g_", string.Empty)
+ .Replace("_", "-");
- pageTemplate.AppendFormat("");
- pageTemplate.AppendFormat("
", wpId11);
- pageTemplate.AppendFormat("
");
- pageTemplate.AppendFormat("
");
+ var wpId22 = id_2
+ .Replace("g_", string.Empty)
+ .Replace("_", "-");
- pageTemplate.AppendFormat("");
- pageTemplate.AppendFormat(" SPMeta2 publishing page.");
- pageTemplate.AppendFormat("
");
+ var pageTemplate = new StringBuilder();
- pageTemplate.AppendFormat("");
- pageTemplate.AppendFormat("
", wpId22);
- pageTemplate.AppendFormat("
");
- pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("");
+ pageTemplate.AppendFormat("
", wpId11);
+ pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("
");
- (page.Value as PublishingPageDefinition).Content = pageTemplate.ToString();
+ pageTemplate.AppendFormat("");
+ pageTemplate.AppendFormat(" SPMeta2 publishing page.");
+ pageTemplate.AppendFormat("
");
- page
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.ZoneId = "wpz";
- wp.Id = id_1;
- wp.AddToPageContent = true;
- })
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.ZoneId = "wpz";
- wp.Id = id_2;
- wp.AddToPageContent = true;
- })
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.ZoneId = "wpz";
- wp.Id = id_3;
- wp.AddToPageContent = true;
- });
- });
- });
+ pageTemplate.AppendFormat("");
+ pageTemplate.AppendFormat("
", wpId22);
+ pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("
");
- });
+ (page.Value as PublishingPageDefinition).Content = pageTemplate.ToString();
- TestModel(webModel);
+ page
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.ZoneId = "wpz";
+ wp.Id = id_1;
+ wp.AddToPageContent = true;
+ })
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.ZoneId = "wpz";
+ wp.Id = id_2;
+ wp.AddToPageContent = true;
+ })
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.ZoneId = "wpz";
+ wp.Id = id_3;
+ wp.AddToPageContent = true;
+ });
+ });
+ });
+
+ });
+
+ TestModel(siteModel, webModel);
}
[TestMethod]
@@ -732,22 +762,25 @@ public void CanDeploy_WebpartTo_WikiPageContent_AsItIs()
// Some web part provision on wiki page give empty markup
// https://github.com/SubPointSolutions/spmeta2/issues/693
- var webModel = SPMeta2Model
- .NewWebModel(web =>
- {
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
- {
- list
- .AddRandomWikiPage(page =>
- {
- page
- .AddRandomWebpart()
- .AddRandomWebpart()
- .AddRandomWebpart();
- });
- });
- });
+ var webModel = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
+
+ web.AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list
+ .AddRandomWikiPage(page =>
+ {
+ page
+ .AddRandomWebpart()
+ .AddRandomWebpart()
+ .AddRandomWebpart();
+ });
+ });
+ });
TestModel(webModel);
}
@@ -784,22 +817,26 @@ public void CanDeploy_ScriptEditorTo_WikiPageContent_As_AddToPageContent()
Rnd.String())
};
- var webModel = SPMeta2Model
- .NewWebModel(web =>
- {
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
- {
- list
- .AddRandomWikiPage(page =>
- {
- page.RegExcludeFromValidation();
+ var webModel = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
- page.AddScriptEditorWebPart(scriptEditor1);
- page.AddScriptEditorWebPart(scriptEditor2);
- });
- });
- });
+ web
+ .AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list
+ .AddRandomWikiPage(page =>
+ {
+ page.RegExcludeFromValidation();
+
+ page.AddScriptEditorWebPart(scriptEditor1);
+ page.AddScriptEditorWebPart(scriptEditor2);
+ });
+ });
+ });
TestModel(webModel);
}
@@ -825,47 +862,50 @@ public void CanDeploy_WebpartTo_WikiPageContent_As_AddToPageContent()
ListUrl = BuiltInListDefinitions.SitePages.CustomUrl
};
- var webModel = SPMeta2Model
- .NewWebModel(web =>
- {
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
- {
- list
- .AddRandomWikiPage(page =>
- {
- page.RegExcludeFromValidation();
+ var webModel = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
- page
- .AddListViewWebPart(listViewWebPartDef)
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.Id = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- wp.ZoneId = "wpz";
- wp.AddToPageContent = true;
- })
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.Id = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- wp.ZoneId = "wpz";
- wp.AddToPageContent = true;
- })
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.Id = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- wp.ZoneId = "wpz";
- wp.AddToPageContent = true;
- })
- ;
- });
- });
- });
+ web.AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list
+ .AddRandomWikiPage(page =>
+ {
+ page.RegExcludeFromValidation();
+
+ page
+ .AddListViewWebPart(listViewWebPartDef)
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.Id = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ wp.ZoneId = "wpz";
+ wp.AddToPageContent = true;
+ })
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.Id = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ wp.ZoneId = "wpz";
+ wp.AddToPageContent = true;
+ })
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.Id = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ wp.ZoneId = "wpz";
+ wp.AddToPageContent = true;
+ })
+ ;
+ });
+ });
+ });
TestModel(webModel);
}
@@ -875,77 +915,80 @@ public void CanDeploy_WebpartTo_WikiPageContent_As_AddToPageContent()
[TestCategory("Regression.Scenarios.Webparts.Hosts")]
public void CanDeploy_WebpartTo_WikiPageContent()
{
- var webModel = SPMeta2Model
- .NewWebModel(web =>
- {
- web
- .AddHostList(BuiltInListDefinitions.SitePages, list =>
- {
- list
- .AddRandomWikiPage(page =>
- {
- page.RegExcludeFromValidation();
+ var webModel = SPMeta2Model.NewWebModel(web =>
+ {
+ web.AddWebFeature(BuiltInWebFeatures.WikiPageHomePage.Inherit(def =>
+ {
+ def.Enable = true;
+ }));
- var id_1 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- var id_2 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ web.AddHostList(BuiltInListDefinitions.SitePages, list =>
+ {
+ list
+ .AddRandomWikiPage(page =>
+ {
+ page.RegExcludeFromValidation();
- var id_3 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ var id_1 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
+ var id_2 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- var wpId11 = id_1
- .Replace("g_", string.Empty)
- .Replace("_", "-");
+ var id_3 = "g_" + Guid.NewGuid().ToString("D").Replace('-', '_');
- var wpId22 = id_2
- .Replace("g_", string.Empty)
- .Replace("_", "-");
+ var wpId11 = id_1
+ .Replace("g_", string.Empty)
+ .Replace("_", "-");
- var pageTemplate = new StringBuilder();
+ var wpId22 = id_2
+ .Replace("g_", string.Empty)
+ .Replace("_", "-");
- pageTemplate.AppendFormat("");
- pageTemplate.AppendFormat("
", wpId11);
- pageTemplate.AppendFormat("
");
- pageTemplate.AppendFormat("
");
+ var pageTemplate = new StringBuilder();
- pageTemplate.AppendFormat("");
- pageTemplate.AppendFormat(" SPMeta2 wiki page.");
- pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("");
+ pageTemplate.AppendFormat("
", wpId11);
+ pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("
");
- pageTemplate.AppendFormat("");
- pageTemplate.AppendFormat("
", wpId22);
- pageTemplate.AppendFormat("
");
- pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("");
+ pageTemplate.AppendFormat(" SPMeta2 wiki page.");
+ pageTemplate.AppendFormat("
");
- (page.Value as WikiPageDefinition).Content = pageTemplate.ToString();
+ pageTemplate.AppendFormat("");
+ pageTemplate.AppendFormat("
", wpId22);
+ pageTemplate.AppendFormat("
");
+ pageTemplate.AppendFormat("
");
- page
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.ZoneId = "wpz";
- wp.Id = id_1;
- wp.AddToPageContent = true;
- })
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.ZoneId = "wpz";
- wp.Id = id_2;
- wp.AddToPageContent = true;
- })
- .AddRandomWebpart(wpNode =>
- {
- var wp = wpNode.Value as WebPartDefinition;
-
- wp.ZoneId = "wpz";
- wp.Id = id_3;
- wp.AddToPageContent = true;
- });
- });
- });
+ (page.Value as WikiPageDefinition).Content = pageTemplate.ToString();
- });
+ page
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.ZoneId = "wpz";
+ wp.Id = id_1;
+ wp.AddToPageContent = true;
+ })
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.ZoneId = "wpz";
+ wp.Id = id_2;
+ wp.AddToPageContent = true;
+ })
+ .AddRandomWebpart(wpNode =>
+ {
+ var wp = wpNode.Value as WebPartDefinition;
+
+ wp.ZoneId = "wpz";
+ wp.Id = id_3;
+ wp.AddToPageContent = true;
+ });
+ });
+ });
+
+ });
TestModel(webModel);
}
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WorkflowAssociationScenariosTest.cs b/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WorkflowAssociationScenariosTest.cs
index 25f0464b0..1355996e4 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WorkflowAssociationScenariosTest.cs
+++ b/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/WorkflowAssociationScenariosTest.cs
@@ -97,6 +97,11 @@ public void CanDeploy_WorkflowAssociation_UnderWeb()
def.AssociationData = Rnd.String();
});
+ var siteModel = SPMeta2Model.NewSiteModel(site =>
+ {
+ AddDefaultWorkflowFeatures(site);
+ });
+
var model = SPMeta2Model.NewWebModel(web =>
{
web.AddList(taskList);
@@ -106,7 +111,7 @@ public void CanDeploy_WorkflowAssociation_UnderWeb()
web.AddWorkflowAssociation(workflowDefChanges);
});
- TestModel(model);
+ TestModel(siteModel, model);
}
[TestMethod]
@@ -144,6 +149,11 @@ public void CanDeploy_WorkflowAssociation_UnderList()
def.AssociationData = Rnd.String();
});
+ var siteModel = SPMeta2Model.NewSiteModel(site =>
+ {
+ AddDefaultWorkflowFeatures(site);
+ });
+
var model = SPMeta2Model.NewWebModel(web =>
{
web.AddList(taskList);
@@ -156,7 +166,7 @@ public void CanDeploy_WorkflowAssociation_UnderList()
});
});
- TestModel(model);
+ TestModel(siteModel, model);
}
[TestMethod]
@@ -203,6 +213,7 @@ public void CanDeploy_WorkflowAssociation_UnderContentTypeLink()
var siteModel = SPMeta2Model.NewSiteModel(site =>
{
site.AddContentType(contentTypeDef);
+ AddDefaultWorkflowFeatures(site);
});
var model = SPMeta2Model.NewWebModel(web =>
@@ -223,6 +234,35 @@ public void CanDeploy_WorkflowAssociation_UnderContentTypeLink()
TestModel(siteModel, model);
}
+ private void AddDefaultWorkflowFeatures(SiteModelNode site)
+ {
+ site.AddSiteFeature(BuiltInSiteFeatures.Workflows.Inherit(f =>
+ {
+ f.Enable = true;
+ }));
+
+ site.AddSiteFeature(BuiltInSiteFeatures.SharePoint2007Workflows.Inherit(f =>
+ {
+ f.Enable = true;
+ }));
+
+ //site.AddSiteFeature(BuiltInSiteFeatures.DispositionApprovalWorkflow.Inherit(f =>
+ //{
+ // f.Enable = true;
+ //}));
+
+ //site.AddSiteFeature(BuiltInSiteFeatures.PublishingApprovalWorkflow.Inherit(f =>
+ //{
+ // f.Enable = true;
+ //}));
+
+ //site.AddSiteFeature(BuiltInSiteFeatures.ThreeStateWorkflow.Inherit(f =>
+ //{
+ // f.Enable = true;
+ //}));
+ }
+
+
[TestMethod]
[TestCategory("Regression.Scenarios.WorkflowAssociation")]
@@ -249,6 +289,11 @@ public void CanDeploy_WorkflowAssociation_UnderContentType()
def.HistoryListTitle = historyList.Title;
});
+ var initialSiteModel = SPMeta2Model.NewSiteModel(site =>
+ {
+ AddDefaultWorkflowFeatures(site);
+ });
+
// changability
// deploy the same association with different props
var workflowDefChanges = workflowDef.Inherit(def =>
@@ -279,7 +324,10 @@ public void CanDeploy_WorkflowAssociation_UnderContentType()
});
});
- TestModel(webModel, siteModel);
+ TestModels(new ModelNode[] {
+ initialSiteModel,
+ webModel,
+ siteModel });
}
}
}
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/DefaultTryRetryServiceTests.cs b/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/DefaultTryRetryServiceTests.cs
new file mode 100644
index 000000000..ed5438414
--- /dev/null
+++ b/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/DefaultTryRetryServiceTests.cs
@@ -0,0 +1,185 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SPMeta2.Containers.Services;
+using SPMeta2.Containers.Services.Rnd;
+using SPMeta2.Definitions;
+using SPMeta2.Exceptions;
+using SPMeta2.Services.Impl;
+using System;
+
+namespace SPMeta2.Regression.Tests.Impl.Services
+{
+ [TestClass]
+ public class DefaultTryRetryServiceTests
+ {
+ #region constructors
+
+ public DefaultTryRetryServiceTests()
+ {
+ Rnd = new DefaultRandomService();
+ }
+
+ #endregion
+
+ #region properties
+
+ public RandomService Rnd { get; set; }
+
+ #endregion
+
+ #region tests
+
+ [TestMethod]
+ [TestCategory("Regression.Services.DefaultTryRetryService")]
+ [TestCategory("CI.Core")]
+ public void CanCreate_DefaultTryRetryService()
+ {
+ var service = new DefaultTryRetryService();
+
+ Assert.IsNotNull(service);
+ }
+
+ [TestMethod]
+ [TestCategory("Regression.Services.DefaultTryRetryService")]
+ [TestCategory("CI.Core")]
+ public void ShouldFail_OnMoreAttempts()
+ {
+ var service = new DefaultTryRetryService();
+ var currentTryCount = 0;
+
+ ExpectException(() =>
+ {
+ service.TryWithRetry(() =>
+ {
+ currentTryCount++;
+ return false;
+ });
+ });
+
+ Assert.AreEqual(service.MaxRetryCount, currentTryCount);
+ }
+
+ [TestMethod]
+ [TestCategory("Regression.Services.DefaultTryRetryService")]
+ [TestCategory("CI.Core")]
+ public void ShouldWork_On_FirstAttempt()
+ {
+ var service = new DefaultTryRetryService();
+
+ var currentTryCount = 0;
+ var maxTryCount = Rnd.Int(5) + 1;
+
+ service.TryWithRetry(() =>
+ {
+ currentTryCount++;
+ return true;
+ }, maxTryCount, 50);
+
+ Assert.AreEqual(1, currentTryCount);
+ }
+
+ [TestMethod]
+ [TestCategory("Regression.Services.DefaultTryRetryService")]
+ [TestCategory("CI.Core")]
+ public void ShouldWork_On_RandomAttempt()
+ {
+ var service = new DefaultTryRetryService();
+
+ var currentTryCount = 0;
+
+ var maxTryCount = Rnd.Int(5) + 2;
+ var positiveTryCount = maxTryCount / 2 + 1;
+
+ service.TryWithRetry(() =>
+ {
+ currentTryCount++;
+
+ if (positiveTryCount == currentTryCount)
+ return true;
+
+ return false;
+
+ }, maxTryCount, 50);
+
+ Assert.AreEqual(positiveTryCount, currentTryCount);
+ }
+
+ [TestMethod]
+ [TestCategory("Regression.Services.DefaultTryRetryService")]
+ [TestCategory("CI.Core")]
+ public void CanOverride_MaxTryAttempts()
+ {
+ var service = new DefaultTryRetryService();
+
+ var currentTryCount = 0;
+ var maxTryCount = Rnd.Int(5) + 1;
+
+ ExpectException(() =>
+ {
+ service.TryWithRetry(() =>
+ {
+ currentTryCount++;
+ return false;
+ }, maxTryCount, 50);
+ });
+
+ Assert.AreEqual(maxTryCount, currentTryCount);
+ }
+
+ [TestMethod]
+ [TestCategory("Regression.Services.DefaultTryRetryService")]
+ [TestCategory("CI.Core")]
+ public void ShouldFail_OnWrongParameters()
+ {
+ var service = new DefaultTryRetryService();
+
+ ExpectException(() =>
+ {
+ service.TryWithRetry(null, 1, 50);
+ });
+
+ ExpectException(() =>
+ {
+ service.TryWithRetry(() =>
+ {
+ return true;
+ }, 1, 50, null);
+ });
+
+ ExpectException(() =>
+ {
+ service.TryWithRetry(() =>
+ {
+ return false;
+ }, -1, 50);
+ });
+
+ ExpectException(() =>
+ {
+ service.TryWithRetry(() =>
+ {
+ return false;
+ }, 1, -50);
+ });
+ }
+
+ protected void ExpectException(Action action)
+ where TException : Exception
+ {
+ var hasValidException = false;
+ var expectedExceptionType = typeof(TException);
+
+ try
+ {
+ action();
+ }
+ catch (Exception e)
+ {
+ hasValidException = e.GetType() == expectedExceptionType;
+ }
+
+ Assert.IsTrue(hasValidException);
+ }
+
+ #endregion
+ }
+}
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/ServiceContainerTests.cs b/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/ServiceContainerTests.cs
index ed28551c9..3b234b6e7 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/ServiceContainerTests.cs
+++ b/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/ServiceContainerTests.cs
@@ -38,7 +38,9 @@ public void ServiceContainer_Should_Have_DefaultServices()
typeof(DefaultDiagnosticInfoService),
typeof(ModelPrettyPrintServiceBase),
- typeof(ModelDotGraphPrintServiceBase)
+ typeof(ModelDotGraphPrintServiceBase),
+
+ typeof(TryRetryServiceBase)
};
foreach (var serviceType in serviceTypes)
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/TokenReplacementServiceTests.cs b/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/TokenReplacementServiceTests.cs
index 7bbfee9b6..1ad53d901 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/TokenReplacementServiceTests.cs
+++ b/SPMeta2/SPMeta2.Regression.Tests/Impl/Services/TokenReplacementServiceTests.cs
@@ -197,10 +197,14 @@ protected void TestModelAndUrl(ModelNode model, string expectedEndWithUrl)
{
hasHit = true;
- if (e.Result.Value == expectedEndWithUrl)
+ if (e.Result.Value.EndsWith(expectedEndWithUrl))
{
hasCorrectUrl = true;
}
+ else
+ {
+ hasCorrectUrl = false;
+ }
};
TestModel(model);
diff --git a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/100 - Ensure M2 Web Application.ps1 b/SPMeta2/SPMeta2.Regression.Tests/PSScripts/100 - Ensure M2 Web Application.ps1
deleted file mode 100644
index 68c65af02..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/100 - Ensure M2 Web Application.ps1
+++ /dev/null
@@ -1,13 +0,0 @@
-cls
cd "$PSScriptRoot"
. "$PSScriptRoot\_config.ps1"
-. "$PSScriptRoot\_sys.common.ps1"
-
-Write-Host "Ensuring M2 test web application with the following settings:" -fore Green
-M2ShowSettings $g_M2WebAppSettings
-
-Write-Host "Ensuring M2 test web application with the following settings:" -fore Green
-
-$g_M2WebAppSettings.ShouldRecreateWebApplicaiton = $true
-$g_M2WebAppSettings.ShouldRecreateSiteCollection = $true
-
-EnsureSPMeta2SandboxWebApplication $g_M2WebAppSettings.ShouldRecreateWebApplicaiton
-EnsureSPMeta2SandboxSiteCollections $g_M2WebAppSettings.ShouldRecreateSiteCollection
\ No newline at end of file
diff --git a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/1000 - Internal.CheckContentTypeSetup.ps1 b/SPMeta2/SPMeta2.Regression.Tests/PSScripts/1000 - Internal.CheckContentTypeSetup.ps1
deleted file mode 100644
index fcac18fd2..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/1000 - Internal.CheckContentTypeSetup.ps1
+++ /dev/null
@@ -1,129 +0,0 @@
-cls
-
-Write-Host "Loading SharePoint API"
-
-$ver = $host | select version
-if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"}
-if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
- Add-PSSnapin "Microsoft.SharePoint.PowerShell"
-}
-
-# checks that Pages and Docs are configured correctly
-
-$rootWebUrl = "http://dev42:9299/sites/parliament-web-3"
-$web = Get-SPWeb $rootWebUrl
-
-if($web -eq $null) {
- return
-}
-
-function isContentTypeHidden($list, $name) {
-
- $result = $true
-
- $cts = $list.RootFolder.ContentTypeOrder
- foreach($ct in $cts) {
-
- if($ct.Name -eq $name) {
- $result = $false
- }
- }
-
- return $result
-
-}
-
-function hasContentType($list, $name) {
-
- $result = $false
-
- $cts = $list.ContentTypes
-
- foreach($ct in $cts) {
-
- if($ct.Name -eq $name) {
- $result = $true
- }
- }
-
- return $result
-
-}
-
-function CheckPagesLibraryContentTypes($web) {
-
- $isValid = $true
-
- $pages = $web.Lists["Pages"]
- # should have 'Welcome Page' hidden
-
-
- $isValid = $true
-
- $isValid = $isValid -and ((isContentTypeHidden $pages "Welcome Page") -eq $true)
- $isValid = $isValid -and ((hasContentType $pages "Welcome Page") -eq $true)
- $isValid = $isValid -and ((hasContentType $pages "Article Page") -eq $false)
- $isValid = $isValid -and ((hasContentType $pages "Page") -eq $false)
-
-
-
- if($isValid -eq $true) {
- Write-Host "`t`t[+] Page content types" -fore green
- } else {
- Write-Host "`t`t[-] Page content types " -fore red
- }
- #RETURN $isValid
-}
-
-
-function CheckDocumentaLibraryContentTypes($web) {
-
- $isValid = $true
-
- $pages = $web.Lists["Pages"]
- # should have 'Welcome Page' hidden
-
-
- $isValid = $true
-
- $isValid = $isValid -and ((hasContentType $pages "Document") -eq $false)
-
-
- if($isValid -eq $true) {
- Write-Host "`t`t[+] Document content types" -fore green
- } else {
- Write-Host "`t`t[-] Document content types" -fore red
- $errors++
- #exit
- }
-
- #RETURN $isValid
-}
-
-function ProcessWeb($web) {
- # Write-Host $web.ServerRelativeUrl
-
-
- CheckPagesLibraryContentTypes $web
- CheckDocumentaLibraryContentTypes $web
-}
-
-function ProcessSPWebRecursively([Microsoft.SharePoint.SPWeb] $web)
-{
- Write-Host "Processing web: [$($web.Url)]" -fore Gray
-
- ProcessWeb($web)
-
- $subwebs = $web.GetSubwebsForCurrentUser()
-
- foreach($subweb in $subwebs)
- {
- ProcessSPWebRecursively($subweb)
- $subweb.Dispose()
- }
-}
-
-Write-Host "Processing web: [$webUrl] with all subwebs" -fore Green
-ProcessSPWebRecursively $web
-
-Write-Host "Done"
\ No newline at end of file
diff --git a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/200 - Configure M2 Test Environment.ps1 b/SPMeta2/SPMeta2.Regression.Tests/PSScripts/200 - Configure M2 Test Environment.ps1
deleted file mode 100644
index bfb0d0bc5..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/200 - Configure M2 Test Environment.ps1
+++ /dev/null
@@ -1,17 +0,0 @@
-cls
-
-cd "$PSScriptRoot"
-
-$PSScriptRoot
-
-. "$PSScriptRoot\_config.ps1"
-. "$PSScriptRoot\_sys.common.ps1"
-
-Write-Host "Configuring M2 test environment with the following settings:" -fore Green
-M2ShowSettings $g_M2TestEnvironment
-
-# CSOM, SSOM, O365
-#SetupSPMeta2RegressionTestEnvironment "SSOM"
-#SetupSPMeta2RegressionTestEnvironment "CSOM"
-#SetupSPMeta2RegressionTestEnvironment "O365"
-SetupSPMeta2RegressionTestEnvironment "O365v16"
\ No newline at end of file
diff --git a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/300 - Configure M2 Grid.ps1 b/SPMeta2/SPMeta2.Regression.Tests/PSScripts/300 - Configure M2 Grid.ps1
deleted file mode 100644
index 11ebbb607..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/300 - Configure M2 Grid.ps1
+++ /dev/null
@@ -1,97 +0,0 @@
-cls
-
-$s_runnerLibrary = "SPMeta2.Containers.CSOM.dll"
-#$s_runnerLibrary = "SPMeta2.Containers.SSOM.dll"
-
-$s_username = [System.Environment]::GetEnvironmentVariable("SPMeta2_Grid_UserName", "Machine")
-$s_password = [System.Environment]::GetEnvironmentVariable("SPMeta2_Grid_UserPassword", "Machine")
-$s_nodeList = [System.Environment]::GetEnvironmentVariable("SPMeta2_Grid_Nodes", "Machine")
-
-$s_passwordSecure = $s_password | convertto-securestring -Force -AsPlainText
-
-$s_cred = new-object -typename System.Management.Automation.PSCredential `
- -argumentlist $s_username, $s_passwordSecure
-
-$s_nodes = $s_nodeList.Split(',')
-
-Configuration M2GridRunnerLibrariesClean {
-
- param(
- $nodeName,
- $runnerLibraries
- )
-
- Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
-
- Node $nodeName {
-
- Environment RunnerLibraryRemove {
- Name = "SPMeta2_RunnerLibraries"
- Ensure = 'Absent'
- }
- }
-
- Node $nodeName {
-
- Environment SPMeta2_SSOM_WebApplicationUrlsRemove {
- Name = "SPMeta2_SSOM_WebApplicationUrls"
- Ensure = 'Absent'
- }
- }
-}
-
-Configuration M2GridRunnerLibraries {
-
- param(
- $nodeName,
- $runnerLibraries,
- $webAppUrls
- )
-
- Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
-
- Node $nodeName {
-
- Environment RunnerLibrary {
- Name = "SPMeta2_RunnerLibraries"
- Ensure = 'Present'
- Value = $runnerLibraries
- }
- }
-
- Node $nodeName {
-
- Environment SPMeta2_SSOM_WebApplicationUrls {
- Name = "SPMeta2_SSOM_WebApplicationUrls"
- Ensure = 'Present'
- Value = $webAppUrls
- }
- }
-}
-
-Remove-item M2GridRunnerLibrariesClean -Force -Recurse -Confirm:$false
-Remove-item M2GridRunnerLibraries -Force -Recurse -Confirm:$false
-
-foreach($node in $s_nodes) {
-
- Write-Host "Compiling DSC for node [$node] and library:[$s_runnerLibrary]" -fore green
-
- M2GridRunnerLibrariesClean -nodeName $node `
- -runnerLibraries $s_runnerLibrary | out-null
-
- M2GridRunnerLibraries -nodeName $node `
- -webAppUrls ("http://" + $node + ":31417") `
- -runnerLibraries $s_runnerLibrary | out-null
-}
-
-Write-Host "Applying DSC with library:[$s_runnerLibrary ]" -fore green
-
-Start-DscConfiguration M2GridRunnerLibrariesClean -Credential $s_cred `
- -Wait `
- -Verbose
-
-Start-DscConfiguration M2GridRunnerLibraries -Credential $s_cred `
- -Wait `
- -Verbose
-
-
diff --git a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/_config.ps1 b/SPMeta2/SPMeta2.Regression.Tests/PSScripts/_config.ps1
deleted file mode 100644
index 1b6b77efc..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/_config.ps1
+++ /dev/null
@@ -1,120 +0,0 @@
-Add-Type -TypeDefinition @"
- public enum EnvironmentType
- {
- SSOM,
- CSOM,
- O365,
- O365v16
- }
-"@
-
-# defines configs for new 'sandbox' web application
-$g_M2WebAppSettings = New-Object PSObject -Property @{
-
- # -- GLOBAL SETTINGS --
- # current machine/domain name
- MachineName = [Environment]::MachineName
- DomainName = [Environment]::UserDomainName
-
- # sql server address
- SqlServerMachineName = [Environment]::MachineName
-
- # -- WEB APP SETTINGS --
- # should web app or site be recreated
-
- ShouldRecreateWebApplicaiton = $true
-
- # port and ap account for the web app
- WebApplicationPort = 31415
- WebApplicationPoolAccountName = "$([Environment]::UserDomainName)\sp_farm"
-
-
- # -- SITE COLLECTION SETTINGS --
- # should site colleciton be recreated
-
- ShouldRecreateSiteCollection = $true
- SiteCollectionTemplate = "BLANKINTERNET#0"
- SiteCollectionLCID = 1033
- SiteCollectionOwner = "$([Environment]::UserDomainName)\$([Environment]::UserName)"
- SiteCollectionAdministrators = @(
- "$([Environment]::UserDomainName)\administrator",
- "$([Environment]::UserDomainName)\sp_admin",
- "$([Environment]::UserDomainName)\sp_farm"
- )
-}
-
-# defines config for the regression test
-$g_M2TestEnvironment = New-Object PSObject -Property @{
-
- # -- GLOBAL SETTINGS --
- # current environment type
- # CSOM, SSOM or O365
- EnvironmentType = "SSOM"
-
- #O365 specific settings
- O365UserName = "support@subpointsolutions.com"
- O365UserPassword = "su1sbhsbhu8wxvKQ"
-
- O365SiteUrls = @(
- "https://subpointsolutions.sharepoint.com/sites/calc-col"
- )
-
- O365WebUrls = @(
- "https://subpointsolutions.sharepoint.com/sites/calc-col"
- )
-
- RandomBalancedUrls = @(
-
-)
-
- O365DefaultTestUserLogins = @(
- ""
- )
-
-
- # CSOM specific settings
- CSOMWebApplicationUrls = @(
- "http://$([Environment]::MachineName):$($g_M2WebAppSettings.WebApplicationPort)"
- #"http://$([Environment]::MachineName)"
- #"http://portal"
- )
-
- CSOMSiteUrls = @(
- "http://$([Environment]::MachineName):$($g_M2WebAppSettings.WebApplicationPort)"
- #"http://$([Environment]::MachineName)"
- #"http://portal"
- )
-
- CSOMWebUrls = @(
- "http://$([Environment]::MachineName):$($g_M2WebAppSettings.WebApplicationPort)"
- #"http://$([Environment]::MachineName)"
- #"http://portal"
- )
-
- # SSOM specific settings
- SSOMWebApplicationUrls = @(
- "http://$([Environment]::MachineName):$($g_M2WebAppSettings.WebApplicationPort)"
- )
-
- SSOMSiteUrls = @(
- "http://$([Environment]::MachineName):$($g_M2WebAppSettings.WebApplicationPort)"
- )
-
- SSOMWebUrls = @(
- "http://$([Environment]::MachineName):$($g_M2WebAppSettings.WebApplicationPort)"
- )
-
- OO365TestLogins = @(
- ""
- )
-
- OnPremTestActiveDirectoryLogins = @(
- "$([Environment]::UserDomainName)\administrator",
- "$([Environment]::UserDomainName)\sp_admin",
- "$([Environment]::UserDomainName)\sp_farm"
- )
-
- OnPremTestActiveDirectoryGroups = @(
- "$([Environment]::UserDomainName)\test-g1"
- )
-}
\ No newline at end of file
diff --git a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/_sys.common.ps1 b/SPMeta2/SPMeta2.Regression.Tests/PSScripts/_sys.common.ps1
deleted file mode 100644
index ae5897948..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/PSScripts/_sys.common.ps1
+++ /dev/null
@@ -1,535 +0,0 @@
-. "$PSScriptRoot\_config.ps1"
-
-Write-Host "Loading SharePoint API" -fore Green
-$ver = $host | select version
-if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"}
-if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
- Add-PSSnapin "Microsoft.SharePoint.PowerShell"
-}
-
-
-function M2ShowSettings($obj) {
-
- $props = $obj | Get-Member -type NoteProperty
-
- foreach($prop in $props) {
- $value=$obj."$($prop.Name)"
- Write-Host "`t[$($prop.Name)]:`t[$value]" -fore Gray
- }
-}
-
-#script setting
-$g_script_RecreateWebApp = $g_M2WebAppSettings.ShouldRecreateWebApplicaiton
-$g_script_RecreateSiteCollections = $g_M2WebAppSettings.ShouldRecreateSiteCollection
-
-#global settings
-$g_port = $g_M2WebAppSettings.WebApplicationPort
-
-$g_machineName = $g_M2WebAppSettings.MachineName
-$g_DomainName = $g_M2WebAppSettings.DomainName
-$g_webAppDatabaseServerName = $g_M2WebAppSettings.SqlServerMachineName
-
-# web app settings
-
- $g_webAppUrl = $g_machineName + ":" + $g_port;
-
- $g_webAppName = "SPMeta2 Sandbox - $g_port"
- $g_webAppPool = "$g_machineName - $g_port"
- $g_webAppHostHeader = $g_machineName
- $g_webAppPort = $g_port
-
- # should be managed account
- $g_webAppAppPoolAccount = $g_M2WebAppSettings.WebApplicationPoolAccountName
-
- #$g_webAppDatabaseServerName = $g_machineName
- $g_webAppDatabaseName = "WSS_Content_$g_port"
-
-# site settings
-
- $g_siteCollectionOwner = $g_M2WebAppSettings.SiteCollectionOwner
-
- $g_siteCollectionTemplate = $g_M2WebAppSettings.SiteCollectionTemplate
- $g_siteCollectionLanguage = $g_M2WebAppSettings.SiteCollectionLCID
-
- $g_siteUrls = @()
- $g_siteUrls += ("http://" + $g_machineName + ":" + $g_port);
- $g_siteUrls += ("http://" + $g_machineName + ":" + $g_port + "/sites/m2");
-
-# subweb settings
-
- $g_webTemplate = "STS#0"
-
-
- $g_siteRelativeWebUrls = @()
- $g_siteRelativeWebUrls += "/first"
- $g_siteRelativeWebUrls += "/first/second"
- $g_siteRelativeWebUrls += "/first/second/third"
-
-
-# creates a new web app
-function CreateWebApplication()
-{
- $WebAppName = $g_webAppName
- $WebAppAppPool = $g_webAppPool
-
- $WebAppHostHeader = $g_webAppHostHeader
- $WebAppPort = $g_webAppPort
-
- $WebAppAppPoolAccount = $g_webAppAppPoolAccount
- $WebAppDatabaseName = $g_webAppDatabaseName
- $WebAppDatabaseServer = $g_webAppDatabaseServerName
-
- $WebAppName
- $WebAppPort
- $WebAppHostHeader
- $WebAppAppPool
- (Get-SPManagedAccount $WebAppAppPoolAccount)
- $WebAppDatabaseName
- $WebAppDatabaseServer
-
- New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL $WebAppHostHeader -ApplicationPool $WebAppAppPool -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -DatabaseName $WebAppDatabaseName -DatabaseServer $WebAppDatabaseServer
-}
-
-# ensures security groups on the site
-function EnsureSecurityGroup($web, $groupName) {
-
- $group = $web.SiteGroups[$groupName];
-
- if($group -eq $null) {
- $web.SiteGroups.Add($groupName, $web.Site.Owner, $web.Site.Owner, $groupName)
- $group = $web.SiteGroups[$groupName];
- }
-
- return $group
-}
-
-# ensures a web app
-function EnsureSPMeta2SandboxWebApplication($recreate) {
-
- $webApp = GetSPMeta2SandboxWebApp $g_webAppUrl
-
- if($webApp -eq $null) {
-
- Write-Host "Cannot find web application. at URL:[$g_webAppUrl]. Creating one." -fore yellow
-
- CreateWebApplication
-
- } else {
-
- Write-Host "Web application at URL:[$g_webAppUrl] exists." -fore green
-
- if($recreate -eq $true) {
- if($webApp -ne $null) {
-
- Write-Host "Deleting web application at URL:[$g_webAppUrl]." -fore yellow
- Remove-SPWebApplication $webApp -Confirm:$false
-
- CreateWebApplication
- }
- }
-
- }
-}
-
-function GetSPMeta2SandboxWebApp($url) {
- return Get-SPWebApplication | Where-Object { $_.Url.ToUpper().Contains($url.ToUpper()) -eq $true }
-}
-
-function LookupWebSite($url)
-{
- $webApp = GetSPMeta2SandboxWebApp $g_webAppUrl
-
- return $webApp.Sites | Where-Object { $_.Url.ToUpper().EndsWith($url.ToUpper()) -eq $true }
-}
-
-function LookupWeb($site, $url) {
-
- $web = $site.AllWebs | Where-Object { $_.Url.ToUpper().EndsWith($url.ToUpper()) -eq $true }
-
- return $web
-}
-
-function CreateWeb( $url) {
-
- $web = New-SPWeb $url -Template $g_webTemplate
- return $web
-}
-
-function CreateSiteCollection($url) {
-
- $SiteCollectionName = "Root"
- $SiteCollectionURL = $url
- $SiteCollectionTemplate = $g_siteCollectionTemplate
- $SiteCollectionLanguage = $g_siteCollectionLanguage
- $SiteCollectionOwner = $g_siteCollectionOwner
-
- $site = New-SPSite -URL $SiteCollectionURL -OwnerAlias $SiteCollectionOwner -Language $SiteCollectionLanguage -Template $SiteCollectionTemplate -Name $SiteCollectionName
-
- return $site;
-}
-
-function EnableFeature($web, $id) {
-
- $f = $web.Features[[guid]$id]
-
- if($f -eq $null) {
- Enable-SPFeature -Identity $id -url $web.Url -Confirm:$false -force
- }
-}
-
-function DisableFeature($web, $id) {
-
- $f = $web.Features[[guid]$id]
-
- if($f -ne $null) {
- Disable-SPFeature -Identity $id -url $web.Url -Confirm:$false -force
- }
-}
-
-function EnsureSiteCollectionAdministrators($site, $logins) {
-
- foreach($login in $logins) {
-
- Write-Host "`tEnsuring site admin: $login" -ForegroundColor Gray;
-
- $user = $site.RootWeb.EnsureUser($login);
- if($user.IsSiteAdmin -ne $true)
- {
- $user.IsSiteAdmin = $true;
- $user.Update();
- #Write-Host "User is now site collection admin for $site" -ForegroundColor Green;
- }
- else
- {
- #Write-Host "User is already site collection admin for $site" -ForegroundColor DarkYellow;
- }
-
- #Write-Host "Current Site Collection Admins for site: " $site.Url " " $site.RootWeb.SiteAdministrators;
- }
-
-}
-
-function EnsureSPMeta2SandboxSiteCollections($recreate) {
-
- Write-Host ""
- Write-Host "Ensuring sandbox site collections" -fore Green
-
- $siteUrls = $g_siteUrls
-
- foreach($url in $siteUrls) {
-
- $site = LookupWebSite $url
-
- if($recreate -eq $true) {
-
- if( $site -ne $null) {
-
- Write-Host "Deleting site collection [$url]" -fore DarkYellow
-
- $siteId = $site.ID
-
- Remove-spsite $siteId -Confirm:$false
-
- $site = $null
- }
- }
-
- if($site -eq $null) {
-
- Write-Host "Site [$url] does not exist." -fore Gray
- Write-Host "Creating site: [$url]" -fore DarkYellow
-
- $site = CreateSiteCollection $url
- } else {
-
- Write-Host "Site [$url] exists." -fore Gray
-
- }
-
- EnsureSiteCollectionAdministrators $site $g_M2WebAppSettings.SiteCollectionAdministrators
- EnsureAssociatedGroups $site.RootWeb
-
- $webUrls = $g_siteRelativeWebUrls
- $rootWeb = $site.RootWeb
-
- # disabling MDS feature
- DisableFeature $rootWeb "87294c72-f260-42f3-a41b-981a2ffce37a"
- # eabling wiki page lib
- EnableFeature $rootWeb "00bfea71-d8fe-4fec-8dad-01c19a6e4053"
-
- foreach($webUrl in $webUrls) {
-
- $fullwebUrl = $url + $webUrl
-
- $web = LookupWeb $site $fullwebUrl
-
- if($web -eq $null) {
-
- Write-Host "`tWeb [$fullwebUrl] does not exist." -fore Gray
- Write-Host "`tCreating web: [$fullwebUrl]" -fore DarkYellow
-
- $web = CreateWeb $fullwebUrl
-
- } else {
-
- Write-Host "`tWeb [$fullwebUrl] exists." -fore Gray
-
- }
-
- Write-Host "Ensuring Associated groups..."
-
- if($web.HasUniqueRoleAssignments -eq $false) {
- $web.RoleDefinitions.BreakInheritance($true,$true);
- }
-
- EnsureAssociatedGroups $web
-
- DisableFeature $web "87294c72-f260-42f3-a41b-981a2ffce37a"
- EnableFeature $web "00bfea71-d8fe-4fec-8dad-01c19a6e4053"
-
- }
-
- Write-Host ""
- }
-}
-
-function EnsureAssociatedGroups($web) {
-
- $assOwnerGroup = EnsureSecurityGroup $web "SPMeta2 AssociatedOwnerGroup"
- $web.AssociatedOwnerGroup = $assOwnerGroup
-
- $assMemberGroup = EnsureSecurityGroup $web "SPMeta2 AssociatedMemberGroup"
- $web.AssociatedMemberGroup = $assMemberGroup
-
- $assVisitorGroup = EnsureSecurityGroup $web "SPMeta2 AssociatedVisitorGroup"
- $web.AssociatedVisitorGroup = $assVisitorGroup
-
- $web.Update()
-
-}
-
-# test environment settings
-
-$envType = $g_M2TestEnvironment.EnvironmentType
-#$o365RuntimePath = "$PSScriptRoot\..\..\SPMeta2.Dependencies\SharePoint\O365 - 16.1.3912.1204"
-$o365RuntimePath = "$PSScriptRoot\..\..\SPMeta2.Dependencies\SharePoint\O365 - 16.1.5715.1200\NET45"
-
-$o365_UserName = $g_M2TestEnvironment.O365UserName
-$o365_UserPassword = $g_M2TestEnvironment.O365UserPassword
-
-$serverName = $g_M2WebAppSettings.MachineName
-$sqlServerName = $g_M2WebAppSettings.SqlServerMachineName
-
-$serverName = [Environment]::MachineName
-
-function SetSqlServerName($name)
-{
- SetEnvironmentVar "SPMeta2_DefaultSqlServerName" $name
-}
-
-function SetTestOnPremTestLogins()
-{
- $logins = $g_M2TestEnvironment.OnPremTestActiveDirectoryLogins
- $loginsString = [string]::Join(",", $logins);
-
- SetEnvironmentVar "SPMeta2_DefaultTestUserLogins" $loginsString
-}
-
-function SetTestO365Logins() {
-
- $logins = $g_M2TestEnvironment.O365DefaultTestUserLogins
- $loginsString = [string]::Join(",", $logins);
-
- SetEnvironmentVar "SPMeta2_DefaultTestUserLogins" $loginsString
-
-}
-
-function SetTestOnPremTestADGroups()
-{
- $groups = $g_M2TestEnvironment.OnPremTestActiveDirectoryGroups
- $groupsString = [string]::Join(",", $groups);
-
- SetEnvironmentVar "SPMeta2_DefaultTestADGroups" $groupsString
-}
-
-function SetEnvironmentVar($name, $value) {
-
- Write-Host "`tSetting [$name] - [$value]" -fore Gray
- [Environment]::SetEnvironmentVariable($name, $value, "Machine")
-}
-
-function SetSSOMManagedMetadataApplicationParams($siteUrl) {
-
- $session = Get-SPTaxonomySession -Site $siteUrl
- $store = $session.DefaultSiteCollectionTermStore;
-
- Write-Host "Setting up taxonomy store vars" -fore Yellow
-
- SetEnvironmentVar "SPMeta2_DefaultTaxonomyStoreId" $store.Id
- SetEnvironmentVar "SPMeta2_DefaultTaxonomyStoreName" $store.Name
-}
-
-function SetupSSOMEnvironment() {
-
- Write-Host "Setting up SSOM environment" -fore Yellow
-
-
- SetTestOnPremTestLogins
- SetTestOnPremTestADGroups
-
- SetEnvironmentVar "SPMeta2_RunnerLibraries" "SPMeta2.Containers.SSOM.dll"
- SetSqlServerName $sqlServerName
-
- $webAppUrls = $g_M2TestEnvironment.SSOMWebApplicationUrls
- $siteUrls = $g_M2TestEnvironment.SSOMSiteUrls
- $webUrls = $g_M2TestEnvironment.SSOMWebUrls
-
- SetSSOMManagedMetadataApplicationParams $siteUrls[0]
-
- $webAppUrlsValue = $webAppUrls -join ','
- $siteUrlsValue = $siteUrls -join ','
- $webUrlsValue = $webUrls -join ','
-
- SetEnvironmentVar "SPMeta2_SSOM_WebApplicationUrls" $webAppUrlsValue
- SetEnvironmentVar "SPMeta2_SSOM_SiteUrls" $siteUrlsValue
- SetEnvironmentVar "SPMeta2_SSOM_WebUrls" $webUrlsValue
-}
-
-function SetupCSOMEnvironment() {
-
-
- Write-Host "Setting up CSOM environment" -fore Yellow
-
- SetTestOnPremTestLogins
- SetTestOnPremTestADGroups
-
- SetEnvironmentVar "SPMeta2_RunnerLibraries" "SPMeta2.Containers.CSOM.dll"
- SetSqlServerName $sqlServerName
-
- $webAppUrls = $g_M2TestEnvironment.CSOMWebApplicationUrls
- $siteUrls = $g_M2TestEnvironment.CSOMSiteUrls
- $webUrls = $g_M2TestEnvironment.CSOMWebUrls
-
- SetSSOMManagedMetadataApplicationParams $siteUrls[0]
-
- $webAppUrlsValue = $webAppUrls -join ','
- $siteUrlsValue = $siteUrls -join ','
- $webUrlsValue = $webUrls -join ','
-
- SetEnvironmentVar "SPMeta2_CSOM_SiteUrls" $siteUrlsValue
- SetEnvironmentVar "SPMeta2_CSOM_WebUrls" $webUrlsValue
- SetEnvironmentVar "SPMeta2_CSOM_UserName" ""
- SetEnvironmentVar "SPMeta2_CSOM_Password" ""
-}
-
-function InitO365Runtime() {
- $files = [System.IO.Directory]::GetFiles($o365RuntimePath, "*.dll")
-
- foreach($filePath in $files) {
- Write-Host "`tLoading assembly: [$filePath]"
- $a = [System.Reflection.Assembly]::LoadFile($filePath)
- }
-}
-
-function SetO365MManagedMetadataApplicationParams($siteUrl) {
-
- InitO365Runtime
-
- $secO365_UserPassword = ConvertTo-SecureString $o365_UserPassword -AsPlainText -Force
-
- $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
- $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($o365_UserName, $secO365_UserPassword)
-
- $context.Credentials = $credentials
-
- $taxSession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($context)
- $store = $taxSession.GetDefaultSiteCollectionTermStore();
-
- $context.Load($store)
- $context.ExecuteQuery()
-
- Write-Host "Setting up taxonomy store vars" -fore Yellow
-
- SetEnvironmentVar "SPMeta2_DefaultTaxonomyStoreId" $store.Id
- SetEnvironmentVar "SPMeta2_DefaultTaxonomyStoreName" $store.Name
-}
-
-function SetO365RandomBalancedUrls() {
- $urls = $g_M2TestEnvironment.RandomBalancedUrls -join ','
-
- SetEnvironmentVar "SPMeta2_O365_RandomBalancedUrls" $urls
-}
-
-function SetupO365v16Environment() {
-
- Write-Host "Setting up O365 environment" -fore Yellow
-
- SetEnvironmentVar "SPMeta2_RunnerLibraries" "SPMeta2.Containers.O365v16.dll"
-
- $o365_siteUrls = $g_M2TestEnvironment.O365SiteUrls
- $o365_webUrls = $g_M2TestEnvironment.O365WebUrls
-
- SetO365MManagedMetadataApplicationParams $o365_siteUrls[0]
-
- $o365_siteUrlsValue = $o365_siteUrls -join ','
- $o365_webUrlsValue = $o365_webUrls -join ','
-
-
- SetEnvironmentVar "SPMeta2_O365_SiteUrls" $o365_siteUrlsValue
- SetEnvironmentVar "SPMeta2_O365_WebUrls" $o365_webUrlsValue
- SetEnvironmentVar "SPMeta2_O365_UserName" $g_M2TestEnvironment.O365UserName
- SetEnvironmentVar "SPMeta2_O365_Password" $g_M2TestEnvironment.O365UserPassword
-}
-
-function SetupO365Environment() {
-
- Write-Host "Setting up O365 environment" -fore Yellow
-
- SetTestO365Logins
- SetO365RandomBalancedUrls
-
- SetEnvironmentVar "SPMeta2_RunnerLibraries" "SPMeta2.Containers.O365.dll"
-
- $o365_siteUrls = $g_M2TestEnvironment.O365SiteUrls
- $o365_webUrls = $g_M2TestEnvironment.O365WebUrls
-
- SetO365MManagedMetadataApplicationParams $o365_siteUrls[0]
-
- $o365_siteUrlsValue = $o365_siteUrls -join ','
- $o365_webUrlsValue = $o365_webUrls -join ','
-
- SetEnvironmentVar "SPMeta2_O365_SiteUrls" $o365_siteUrlsValue
- SetEnvironmentVar "SPMeta2_O365_WebUrls" $o365_webUrlsValue
- SetEnvironmentVar "SPMeta2_O365_UserName" $g_M2TestEnvironment.O365UserName
- SetEnvironmentVar "SPMeta2_O365_Password" $g_M2TestEnvironment.O365UserPassword
-}
-
-function SetupSPMeta2RegressionTestEnvironment($envType) {
-
- if($envType -eq $null) {
- $envType = $g_M2TestEnvironment.EnvironmentType
- }
-
- Write-Host "Setting up [$envType] environment." -fore Green
-
- switch($envType)
- {
- "SSOM" {
- SetupSSOMEnvironment
- }
-
- "CSOM" {
- SetupCSOMEnvironment
- }
-
- "O365" {
- SetupO365Environment
- }
-
- "O365v16" {
- SetupO365v16Environment
- }
- }
-
- Write-Host "Setting up [$envType] environment completed." -fore Green
-}
diff --git a/SPMeta2/SPMeta2.Regression.Tests/Properties/AssemblyInfo.cs b/SPMeta2/SPMeta2.Regression.Tests/Properties/AssemblyInfo.cs
index a59cad00f..9b5cf2a5c 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/Properties/AssemblyInfo.cs
+++ b/SPMeta2/SPMeta2.Regression.Tests/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.2.17079.1254")]
+[assembly: AssemblyFileVersion("1.2.17104.0417")]
diff --git a/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Containers.O365.dll.config b/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Containers.O365.dll.config
deleted file mode 100644
index 0a80f5c35..000000000
--- a/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Containers.O365.dll.config
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.csproj b/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.csproj
index 423dd6f01..f2fd22710 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.csproj
+++ b/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.csproj
@@ -88,6 +88,7 @@
+
@@ -257,6 +258,7 @@
+
@@ -357,7 +359,7 @@
SPMeta2.Containers.CSOM.dll
Always
-
+
SPMeta2.Containers.O365v16.dll
Always
@@ -565,8 +567,6 @@
SPMeta2.dll
Always
-
-
@@ -586,12 +586,6 @@
-
-
-
-
- Always
-
Always
diff --git a/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.dll.config b/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.dll.config
index f38f061fb..c55a301b3 100644
--- a/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.dll.config
+++ b/SPMeta2/SPMeta2.Regression.Tests/SPMeta2.Regression.Tests.dll.config
@@ -31,6 +31,7 @@
switchName="sourceSwitch"
switchType="System.Diagnostics.SourceSwitch">
+
@@ -41,19 +42,22 @@
initializeData="spmeta2.log">
+
diff --git a/SPMeta2/SPMeta2.Regression/Properties/AssemblyInfo.cs b/SPMeta2/SPMeta2.Regression/Properties/AssemblyInfo.cs
index 6ab6dd9fd..91e1ca507 100644
--- a/SPMeta2/SPMeta2.Regression/Properties/AssemblyInfo.cs
+++ b/SPMeta2/SPMeta2.Regression/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.17079.1227")]
+[assembly: AssemblyFileVersion("1.0.17104.0417")]
diff --git a/SPMeta2/SPMeta2.SSOM.Standard/Properties/AssemblyInfo.cs b/SPMeta2/SPMeta2.SSOM.Standard/Properties/AssemblyInfo.cs
index 4e3c96605..bf184884d 100644
--- a/SPMeta2/SPMeta2.SSOM.Standard/Properties/AssemblyInfo.cs
+++ b/SPMeta2/SPMeta2.SSOM.Standard/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.2.17079.1254")]
+[assembly: AssemblyFileVersion("1.2.17104.0417")]
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeFieldLinkModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeFieldLinkModelHandler.cs
index f8610ed30..adda91ff2 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeFieldLinkModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeFieldLinkModelHandler.cs
@@ -7,7 +7,8 @@
using SPMeta2.Definitions.Base;
using SPMeta2.ModelHandlers;
using SPMeta2.Services;
-using SPMeta2.Utils;
+using SPMeta2.Utils;
+using SPMeta2.SSOM.ModelHosts;
namespace SPMeta2.SSOM.ModelHandlers
{
@@ -66,9 +67,11 @@ protected SPField FindAvailableField(SPWeb web, ContentTypeFieldLinkDefinition l
public override void DeployModel(object modelHost, DefinitionBase model)
- {
- var contentType = modelHost.WithAssertAndCast("modelHost", value => value.RequireNotNull());
- var contentTypeFieldLinkModel = model.WithAssertAndCast("model", value => value.RequireNotNull());
+ {
+ var typedModelHost = modelHost.WithAssertAndCast("modelHost", value => value.RequireNotNull());
+ var contentTypeFieldLinkModel = model.WithAssertAndCast("model", value => value.RequireNotNull());
+
+ var contentType = typedModelHost.HostContentType;
var web = contentType.ParentWeb;
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeLinkModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeLinkModelHandler.cs
index 0baa65d1e..0db546618 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeLinkModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeLinkModelHandler.cs
@@ -63,7 +63,7 @@ public override void WithResolvingModelHost(ModelHostResolveContext modelHostCon
action(contentTypeLinkHost);
- if (!contentTypeLinkHost.ShouldUpdateHost)
+ if (contentTypeLinkHost.ShouldUpdateHost)
contentType.Update(false);
}
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeModelHandler.cs
index 3b54023c4..39115acaa 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypeModelHandler.cs
@@ -10,6 +10,7 @@
using SPMeta2.SSOM.ModelHosts;
using SPMeta2.Syntax.Default;
using SPMeta2.Utils;
+using SPMeta2.ModelHosts;
namespace SPMeta2.SSOM.ModelHandlers
{
@@ -53,7 +54,10 @@ public override void WithResolvingModelHost(ModelHostResolveContext modelHostCon
}
else
{
- action(targetContentType);
+ action(ModelHostBase.Inherit(modelHost as ModelHostBase, host =>
+ {
+ host.HostContentType = targetContentType;
+ }));
}
targetContentType.Update(true);
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/HideContentTypeFieldLinksModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/HideContentTypeFieldLinksModelHandler.cs
index 2623211e0..b5c02d002 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/HideContentTypeFieldLinksModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/HideContentTypeFieldLinksModelHandler.cs
@@ -26,15 +26,16 @@ public override Type TargetType
#region methods
public override void DeployModel(object modelHost, DefinitionBase model)
- {
- var contentType = modelHost.WithAssertAndCast("model", value => value.RequireNotNull());
- var hideContentTypeFieldLinksDefinition = model.WithAssertAndCast("model", value => value.RequireNotNull());
-
- DeployHideContentTypeLinks(modelHost, contentType, hideContentTypeFieldLinksDefinition);
- }
-
- private void DeployHideContentTypeLinks(object modelHost, SPContentType contentType, HideContentTypeFieldLinksDefinition hideFieldLinksModel)
- {
+ {
+ var typedModelHost = modelHost.WithAssertAndCast("model", value => value.RequireNotNull());
+ var hideContentTypeFieldLinksDefinition = model.WithAssertAndCast("model", value => value.RequireNotNull());
+
+ DeployHideContentTypeLinks(modelHost, typedModelHost, hideContentTypeFieldLinksDefinition);
+ }
+
+ private void DeployHideContentTypeLinks(object modelHost, ContentTypeModelHost contentTypeModelHost, HideContentTypeFieldLinksDefinition hideFieldLinksModel)
+ {
+ var contentType = contentTypeModelHost.HostContentType;
var fieldLinks = contentType.FieldLinks.OfType().ToList();
InvokeOnModelEvent(this, new ModelEventArgs
@@ -76,7 +77,9 @@ private void DeployHideContentTypeLinks(object modelHost, SPContentType contentT
ObjectType = typeof(SPContentType),
ObjectDefinition = hideFieldLinksModel,
ModelHost = modelHost
- });
+ });
+
+ contentTypeModelHost.ShouldUpdateHost = true;
}
#endregion
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/RemoveContentTypeFieldLinksModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/RemoveContentTypeFieldLinksModelHandler.cs
index cc41fd811..4e45548e0 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/RemoveContentTypeFieldLinksModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/RemoveContentTypeFieldLinksModelHandler.cs
@@ -26,15 +26,16 @@ public override Type TargetType
#region methods
public override void DeployModel(object modelHost, DefinitionBase model)
- {
- var contentType = modelHost.WithAssertAndCast("model", value => value.RequireNotNull());
- var hideContentTypeFieldLinksDefinition = model.WithAssertAndCast("model", value => value.RequireNotNull());
-
- DeployHideContentTypeLinks(modelHost, contentType, hideContentTypeFieldLinksDefinition);
- }
-
- private void DeployHideContentTypeLinks(object modelHost, SPContentType contentType, RemoveContentTypeFieldLinksDefinition hideFieldLinksModel)
- {
+ {
+ var typedModelHost = modelHost.WithAssertAndCast("model", value => value.RequireNotNull());
+ var hideContentTypeFieldLinksDefinition = model.WithAssertAndCast("model", value => value.RequireNotNull());
+
+ DeployHideContentTypeLinks(modelHost, typedModelHost, hideContentTypeFieldLinksDefinition);
+ }
+
+ private void DeployHideContentTypeLinks(object modelHost, ContentTypeModelHost contentTypeModelHost, RemoveContentTypeFieldLinksDefinition hideFieldLinksModel)
+ {
+ var contentType = contentTypeModelHost.HostContentType;
var fieldLinks = contentType.FieldLinks.OfType().ToList();
InvokeOnModelEvent(this, new ModelEventArgs
@@ -74,7 +75,9 @@ private void DeployHideContentTypeLinks(object modelHost, SPContentType contentT
ObjectType = typeof(SPContentType),
ObjectDefinition = hideFieldLinksModel,
ModelHost = modelHost
- });
+ });
+
+ contentTypeModelHost.ShouldUpdateHost = true;
}
#endregion
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/UniqueContentTypeFieldsOrderModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/UniqueContentTypeFieldsOrderModelHandler.cs
index 3e2bb948c..cf759bfc6 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/UniqueContentTypeFieldsOrderModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ContentTypes/UniqueContentTypeFieldsOrderModelHandler.cs
@@ -26,15 +26,17 @@ public override Type TargetType
#region methods
public override void DeployModel(object modelHost, DefinitionBase model)
- {
- var contentType = modelHost.WithAssertAndCast("modelHost", value => value.RequireNotNull()); ;
- var contentTypeOrderDefinition = model.WithAssertAndCast("model", value => value.RequireNotNull());
-
- DeployContentTypeOrder(modelHost, contentType, contentTypeOrderDefinition);
- }
+ {
+ var typedModelHost = modelHost.WithAssertAndCast("modelHost", value => value.RequireNotNull()); ;
+ var contentTypeOrderDefinition = model.WithAssertAndCast("model", value => value.RequireNotNull());
+
+ DeployContentTypeOrder(modelHost, typedModelHost, contentTypeOrderDefinition);
+ }
+
+ private void DeployContentTypeOrder(object modelHost, ContentTypeModelHost contentTypeModellHost, UniqueContentTypeFieldsOrderDefinition reorderFieldLinksModel)
+ {
+ var contentType = contentTypeModellHost.HostContentType;
- private void DeployContentTypeOrder(object modelHost, SPContentType contentType, UniqueContentTypeFieldsOrderDefinition reorderFieldLinksModel)
- {
var fieldLinks = contentType.FieldLinks.OfType().ToList();
var fields = contentType.Fields.OfType().ToList();
@@ -84,7 +86,9 @@ private void DeployContentTypeOrder(object modelHost, SPContentType contentType,
ObjectType = typeof(SPContentType),
ObjectDefinition = reorderFieldLinksModel,
ModelHost = modelHost
- });
+ });
+
+ contentTypeModellHost.ShouldUpdateHost = true;
}
#endregion
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ListModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ListModelHandler.cs
index 8ff788e7e..326b066cc 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/ListModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/ListModelHandler.cs
@@ -12,6 +12,7 @@
using SPMeta2.SSOM.ModelHandlers.Base;
using SPMeta2.SSOM.ModelHosts;
using SPMeta2.Utils;
+using SPMeta2.ModelHosts;
namespace SPMeta2.SSOM.ModelHandlers
{
@@ -314,10 +315,10 @@ public override void WithResolvingModelHost(ModelHostResolveContext modelHostCon
var list = hostList ?? web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, listDefinition.GetListUrl()));
#pragma warning restore 618
- var listModelHost = new ListModelHost
+ var listModelHost = ModelHostBase.Inherit(modelHost as ModelHostBase, host =>
{
- HostList = list
- };
+ host.HostList = list;
+ });
if (childModelType == typeof(ModuleFileDefinition))
{
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHandlers/WorkflowAssociationModelHandler.cs b/SPMeta2/SPMeta2.SSOM/ModelHandlers/WorkflowAssociationModelHandler.cs
index f82daef77..f1d7db862 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHandlers/WorkflowAssociationModelHandler.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHandlers/WorkflowAssociationModelHandler.cs
@@ -51,11 +51,19 @@ public override void DeployModel(object modelHost, DefinitionBase model)
}
else if (modelHost is ContentTypeLinkModelHost)
{
- var contentType = (modelHost as ContentTypeLinkModelHost).HostContentType;
+ var contentTypeLinkMpodelHost = (modelHost as ContentTypeLinkModelHost);
+ var contentType = contentTypeLinkMpodelHost.HostContentType;
DeployContentTypeWorkflowAssociationDefinition(contentType, contentType, workflowAssociationModel);
+
+ contentTypeLinkMpodelHost.ShouldUpdateHost = false;
}
+ else if (modelHost is ContentTypeModelHost)
+ {
+ var contentType = (modelHost as ContentTypeModelHost).HostContentType;
+ DeployContentTypeWorkflowAssociationDefinition(contentType, contentType, workflowAssociationModel);
+ }
else
{
throw new SPMeta2NotSupportedException("model host should be of type ListModelHost or WebModelHost");
@@ -80,6 +88,12 @@ private SPWeb GetWebFromModelHost(object modelHost)
return (modelHost as SPContentType).ParentWeb;
}
+
+ if (modelHost is ContentTypeModelHost)
+ {
+ return (modelHost as ContentTypeModelHost).HostWeb;
+ }
+
if (modelHost is ContentTypeLinkModelHost)
{
return (modelHost as ContentTypeLinkModelHost).HostWeb;
@@ -97,22 +111,22 @@ protected SPWorkflowAssociation FindExistringWorkflowAssotiation(object modelHos
return list.WorkflowAssociations
.GetAssociationByName(def.Name, list.ParentWeb.UICulture);
}
- if (modelHost is WebModelHost)
+ else if (modelHost is WebModelHost)
{
var web = (modelHost as WebModelHost).HostWeb;
return web.WorkflowAssociations
.GetAssociationByName(def.Name, web.UICulture);
}
- if (modelHost is SPContentType)
+ else if (modelHost is SPContentType)
{
var contentType = (modelHost as SPContentType);
var web = contentType.ParentWeb;
return contentType.WorkflowAssociations
- .GetAssociationByName(def.Name, web.UICulture);
+ .GetAssociationByName(def.Name, web.UICulture);
}
- if (modelHost is ContentTypeLinkModelHost)
+ else if (modelHost is ContentTypeLinkModelHost)
{
var listContentTypeHost = (modelHost as ContentTypeLinkModelHost);
@@ -126,6 +140,14 @@ protected SPWorkflowAssociation FindExistringWorkflowAssotiation(object modelHos
return contentType.WorkflowAssociations
.GetAssociationByName(def.Name, web.UICulture);
}
+ else if (modelHost is ContentTypeModelHost)
+ {
+ var contentType = (modelHost as ContentTypeModelHost).HostContentType;
+ var web = contentType.ParentWeb;
+
+ return contentType.WorkflowAssociations
+ .GetAssociationByName(def.Name, web.UICulture);
+ }
else
{
throw new SPMeta2NotImplementedException(
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeLinkModelHost.cs b/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeLinkModelHost.cs
new file mode 100644
index 000000000..cf2013f17
--- /dev/null
+++ b/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeLinkModelHost.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Microsoft.SharePoint;
+
+namespace SPMeta2.SSOM.ModelHosts
+{
+
+ public class ContentTypeLinkModelHost : ContentTypeModelHost
+ {
+ #region constructors
+
+
+ #endregion
+
+ #region properties
+
+
+
+ #endregion
+
+
+
+ public SPList HostList { get; set; }
+
+ }
+}
diff --git a/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeModelHost.cs b/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeModelHost.cs
index 1acfc55fb..8265c5b21 100644
--- a/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeModelHost.cs
+++ b/SPMeta2/SPMeta2.SSOM/ModelHosts/ContentTypeModelHost.cs
@@ -7,7 +7,7 @@
namespace SPMeta2.SSOM.ModelHosts
{
- public class ContentTypeLinkModelHost : SSOMModelHostBase
+ public class ContentTypeModelHost : SSOMModelHostBase
{
#region constructors
@@ -22,7 +22,6 @@ public class ContentTypeLinkModelHost : SSOMModelHostBase
- public SPList HostList { get; set; }
public SPWeb HostWeb { get; set; }
}
}
diff --git a/SPMeta2/SPMeta2.SSOM/Properties/AssemblyInfo.cs b/SPMeta2/SPMeta2.SSOM/Properties/AssemblyInfo.cs
index 54ab8e737..0d47e1bc1 100644
--- a/SPMeta2/SPMeta2.SSOM/Properties/AssemblyInfo.cs
+++ b/SPMeta2/SPMeta2.SSOM/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.2.17079.1254")]
+[assembly: AssemblyFileVersion("1.2.17104.0417")]
diff --git a/SPMeta2/SPMeta2.SSOM/SPMeta2.SSOM.csproj b/SPMeta2/SPMeta2.SSOM/SPMeta2.SSOM.csproj
index f45593402..8b1438855 100644
--- a/SPMeta2/SPMeta2.SSOM/SPMeta2.SSOM.csproj
+++ b/SPMeta2/SPMeta2.SSOM/SPMeta2.SSOM.csproj
@@ -325,6 +325,7 @@
+
@@ -335,7 +336,7 @@
-
+
diff --git a/SPMeta2/SPMeta2.Standard/Definitions/Webparts/DocumentSetContentsWebPartDefinition.cs b/SPMeta2/SPMeta2.Standard/Definitions/Webparts/DocumentSetContentsWebPartDefinition.cs
index 72ebc7824..56f86f2e5 100644
Binary files a/SPMeta2/SPMeta2.Standard/Definitions/Webparts/DocumentSetContentsWebPartDefinition.cs and b/SPMeta2/SPMeta2.Standard/Definitions/Webparts/DocumentSetContentsWebPartDefinition.cs differ
diff --git a/SPMeta2/SPMeta2.Standard/Properties/AssemblyInfo.cs b/SPMeta2/SPMeta2.Standard/Properties/AssemblyInfo.cs
index 2a62bdd07..d8c8808a9 100644
--- a/SPMeta2/SPMeta2.Standard/Properties/AssemblyInfo.cs
+++ b/SPMeta2/SPMeta2.Standard/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.2.17079.1227")]
+[assembly: AssemblyFileVersion("1.2.17104.0417")]
diff --git a/SPMeta2/SPMeta2/Definitions/ContentDatabaseDefinition.cs b/SPMeta2/SPMeta2/Definitions/ContentDatabaseDefinition.cs
index fcf5779fd..eb4328f11 100644
--- a/SPMeta2/SPMeta2/Definitions/ContentDatabaseDefinition.cs
+++ b/SPMeta2/SPMeta2/Definitions/ContentDatabaseDefinition.cs
@@ -42,6 +42,7 @@ public ContentDatabaseDefinition()
[ExpectValidation]
[DataMember]
[IdentityKey]
+ [ExpectRequired]
public string ServerName { get; set; }
[ExpectValidation]
diff --git a/SPMeta2/SPMeta2/Extensions/ModelNodeExtensions.cs b/SPMeta2/SPMeta2/Extensions/ModelNodeExtensions.cs
index 9dda48707..e9b978142 100644
--- a/SPMeta2/SPMeta2/Extensions/ModelNodeExtensions.cs
+++ b/SPMeta2/SPMeta2/Extensions/ModelNodeExtensions.cs
@@ -324,7 +324,7 @@ public static bool GetIncrementalRequireSelfProcessingValue(this TMo
return false;
}
- private static TModelNode InternalSetIncrementalProvisionModelId(this TModelNode modelNode, string modelId)
+ internal static TModelNode InternalSetIncrementalProvisionModelId(this TModelNode modelNode, string modelId)
where TModelNode : ModelNode
{
modelNode.SetPropertyBagValue(DefaultModelNodePropertyBagValue.Sys.IncrementalProvision.PersistenceStorageModelId, modelId);
diff --git a/SPMeta2/SPMeta2/ModelHandlers/ModelHandlerBase.cs b/SPMeta2/SPMeta2/ModelHandlers/ModelHandlerBase.cs
index eae4c6e98..9363bc908 100644
--- a/SPMeta2/SPMeta2/ModelHandlers/ModelHandlerBase.cs
+++ b/SPMeta2/SPMeta2/ModelHandlers/ModelHandlerBase.cs
@@ -1,118 +1,121 @@
-using System;
-using SPMeta2.Common;
-using SPMeta2.Definitions;
-using SPMeta2.Services;
-
-namespace SPMeta2.ModelHandlers
-{
- ///
- /// Base handler for model provision.
- ///
- public abstract class ModelHandlerBase
- {
- #region constructors
-
- public ModelHandlerBase()
- {
- TraceService = ServiceContainer.Instance.GetService();
- }
-
- #endregion
-
- #region properties
-
- protected static TraceServiceBase TraceService { get; set; }
-
- ///
- /// Type of the definition which is handled by current model handler.
- ///
- public abstract Type TargetType { get; }
-
- #endregion
-
- #region events
-
- public EventHandler OnModelEvent;
-
- #endregion
-
- #region methods
-
- ///
- /// Handles model provision under particular modelHost.
- ///
- ///
- ///
- public virtual void DeployModel(object modelHost, DefinitionBase model)
- {
-
- }
-
- ///
- /// Handles model retraction under particular model host.
- ///
- ///
- ///
- public virtual void RetractModel(object modelHost, DefinitionBase model)
- {
-
- }
-
- ///
- /// Resolves a new model host per particular child definition type.
- ///
- ///
- public virtual void WithResolvingModelHost(ModelHostResolveContext context)
- {
- context.Action(context.ModelHost);
- }
-
- ///
- /// Promotes a model event outside of the model handler.
- ///
- ///
- ///
- protected void InvokeOnModelEvent(object sender, ModelEventArgs args)
- {
- TraceService.VerboseFormat((int)LogEventId.CoreCalls, "Entering InvokeOnModelEvent with sender: [{0}] and args: [{1}]",
- new object[] { sender, args });
-
- if (OnModelEvent != null)
- {
- TraceService.VerboseFormat((int)LogEventId.CoreCalls,
- "OnModelEvent is not NULL. Calling OnModelEvent with sender: [{0}] and args: [{1}]",
- new object[] { sender, args });
-
- OnModelEvent.Invoke(this, args);
- }
- else
- {
- TraceService.Verbose((int)LogEventId.CoreCalls, "OnModelEvent is NULL. Skipping.");
- }
-
- TraceService.VerboseFormat((int)LogEventId.CoreCalls, "Leaving InvokeOnModelEvent with sender: [{0}] and args: [{1}]",
- new object[] { sender, args });
- }
-
- ///
- /// Promotes a model event outside of the model handler.
- ///
- ///
- ///
- ///
- ///
- [Obsolete("Use InvokeOnModelEvents((object sender, ModelEventArgs args) with passing full ModelEventArgs")]
- protected void InvokeOnModelEvent(TSPObject rawObject, ModelEventType eventType)
- {
- InvokeOnModelEvent(this, new ModelEventArgs
- {
- Object = rawObject,
- EventType = eventType
- });
- }
-
- #endregion
-
-
- }
-}
+using System;
+using SPMeta2.Common;
+using SPMeta2.Definitions;
+using SPMeta2.Services;
+using SPMeta2.Services.Impl;
+
+namespace SPMeta2.ModelHandlers
+{
+ ///
+ /// Base handler for model provision.
+ ///
+ public abstract class ModelHandlerBase
+ {
+ #region constructors
+
+ public ModelHandlerBase()
+ {
+ TraceService = ServiceContainer.Instance.GetService();
+ TryRetryService = ServiceContainer.Instance.GetService() ?? new DefaultTryRetryService();
+ }
+
+ #endregion
+
+ #region properties
+
+ protected static TryRetryServiceBase TryRetryService { get; set; }
+ protected static TraceServiceBase TraceService { get; set; }
+
+ ///
+ /// Type of the definition which is handled by current model handler.
+ ///
+ public abstract Type TargetType { get; }
+
+ #endregion
+
+ #region events
+
+ public EventHandler OnModelEvent;
+
+ #endregion
+
+ #region methods
+
+ ///
+ /// Handles model provision under particular modelHost.
+ ///
+ ///
+ ///
+ public virtual void DeployModel(object modelHost, DefinitionBase model)
+ {
+
+ }
+
+ ///
+ /// Handles model retraction under particular model host.
+ ///
+ ///
+ ///
+ public virtual void RetractModel(object modelHost, DefinitionBase model)
+ {
+
+ }
+
+ ///
+ /// Resolves a new model host per particular child definition type.
+ ///
+ ///
+ public virtual void WithResolvingModelHost(ModelHostResolveContext context)
+ {
+ context.Action(context.ModelHost);
+ }
+
+ ///
+ /// Promotes a model event outside of the model handler.
+ ///
+ ///
+ ///
+ protected void InvokeOnModelEvent(object sender, ModelEventArgs args)
+ {
+ TraceService.VerboseFormat((int)LogEventId.CoreCalls, "Entering InvokeOnModelEvent with sender: [{0}] and args: [{1}]",
+ new object[] { sender, args });
+
+ if (OnModelEvent != null)
+ {
+ TraceService.VerboseFormat((int)LogEventId.CoreCalls,
+ "OnModelEvent is not NULL. Calling OnModelEvent with sender: [{0}] and args: [{1}]",
+ new object[] { sender, args });
+
+ OnModelEvent.Invoke(this, args);
+ }
+ else
+ {
+ TraceService.Verbose((int)LogEventId.CoreCalls, "OnModelEvent is NULL. Skipping.");
+ }
+
+ TraceService.VerboseFormat((int)LogEventId.CoreCalls, "Leaving InvokeOnModelEvent with sender: [{0}] and args: [{1}]",
+ new object[] { sender, args });
+ }
+
+ ///
+ /// Promotes a model event outside of the model handler.
+ ///
+ ///
+ ///
+ ///
+ ///
+ [Obsolete("Use InvokeOnModelEvents((object sender, ModelEventArgs args) with passing full ModelEventArgs")]
+ protected void InvokeOnModelEvent(TSPObject rawObject, ModelEventType eventType)
+ {
+ InvokeOnModelEvent(this, new ModelEventArgs
+ {
+ Object = rawObject,
+ EventType = eventType
+ });
+ }
+
+ #endregion
+
+
+ }
+}
diff --git a/SPMeta2/SPMeta2/Properties/AssemblyInfo.cs b/SPMeta2/SPMeta2/Properties/AssemblyInfo.cs
index 904477cce..2e0b5dbfd 100644
--- a/SPMeta2/SPMeta2/Properties/AssemblyInfo.cs
+++ b/SPMeta2/SPMeta2/Properties/AssemblyInfo.cs
@@ -32,4 +32,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.2.17079.1227")]
+[assembly: AssemblyFileVersion("1.2.17104.0417")]
diff --git a/SPMeta2/SPMeta2/SPMeta2.csproj b/SPMeta2/SPMeta2/SPMeta2.csproj
index 69e0f8216..f4388cb1f 100644
--- a/SPMeta2/SPMeta2/SPMeta2.csproj
+++ b/SPMeta2/SPMeta2/SPMeta2.csproj
@@ -372,6 +372,7 @@
+
@@ -422,6 +423,7 @@
+
diff --git a/SPMeta2/SPMeta2/ServiceContainer.cs b/SPMeta2/SPMeta2/ServiceContainer.cs
index 2f5daf153..1488763c6 100644
--- a/SPMeta2/SPMeta2/ServiceContainer.cs
+++ b/SPMeta2/SPMeta2/ServiceContainer.cs
@@ -53,6 +53,8 @@ private void InitServices()
RegisterService(typeof(FluentModelValidationServiceBase), new DefaultFluentModelValidationService());
RegisterService(typeof(ModelStatInfoServiceBase), new DefaultModelStatInfoService());
+
+ RegisterService(typeof(TryRetryServiceBase), new DefaultTryRetryService());
}
#endregion
diff --git a/SPMeta2/SPMeta2/Services/Impl/DefaultTryRetryService.cs b/SPMeta2/SPMeta2/Services/Impl/DefaultTryRetryService.cs
new file mode 100644
index 000000000..7b5107214
--- /dev/null
+++ b/SPMeta2/SPMeta2/Services/Impl/DefaultTryRetryService.cs
@@ -0,0 +1,108 @@
+using SPMeta2.Exceptions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+
+namespace SPMeta2.Services.Impl
+{
+ public class DefaultTryRetryService : TryRetryServiceBase
+ {
+ #region constructors
+
+ public DefaultTryRetryService()
+ {
+ MaxRetryCount = 10;
+ RetryTimeoutInMilliseconds = 1000;
+
+ DefaultRetryWaiter = (currentRetryIndex, maxRetryIndex, defaultTimeoutInMilliseconds) =>
+ {
+ Thread.Sleep(defaultTimeoutInMilliseconds);
+ };
+ }
+
+ #endregion
+
+ #region properties
+
+ public int MaxRetryCount { get; set; }
+ public int RetryTimeoutInMilliseconds { get; set; }
+
+ public Action DefaultRetryWaiter { get; set; }
+ protected TraceServiceBase TraceService
+ {
+ get
+ {
+ return ServiceContainer.Instance.GetService();
+ }
+ }
+
+ #endregion
+
+ public override void TryWithRetry(Func action)
+ {
+ TryWithRetry(action, MaxRetryCount);
+ }
+
+ public override void TryWithRetry(Func action, int maxTryCount)
+ {
+ TryWithRetry(action, MaxRetryCount, RetryTimeoutInMilliseconds);
+ }
+
+ public override void TryWithRetry(Func action, int maxTryCount, int retryTimeoutInMilliseconds)
+ {
+ TryWithRetry(action, maxTryCount, retryTimeoutInMilliseconds, this.DefaultRetryWaiter);
+ }
+
+ public override void TryWithRetry(Func action,
+ int maxTryCount, int retryTimeoutInMilliseconds,
+ Action waiter)
+ {
+ ValidateParameters(action, maxTryCount, retryTimeoutInMilliseconds, waiter);
+
+ var currentTryIndex = 1;
+ var actionResult = action();
+
+ while (actionResult != true)
+ {
+ TraceService.Warning((int)LogEventId.ModelProvision,
+ string.Format("Coudn't perform action. Waiting and retrying [{1}/{2}]",
+ retryTimeoutInMilliseconds,
+ currentTryIndex,
+ MaxRetryCount));
+
+ if (currentTryIndex >= maxTryCount)
+ break;
+
+ waiter(currentTryIndex, maxTryCount, retryTimeoutInMilliseconds);
+ currentTryIndex++;
+
+ actionResult = action();
+ }
+
+ if (actionResult != true)
+ {
+ throw new SPMeta2Exception(string.Format(
+ "Error while performing requested action. Tried [{0}] out of [{1}], raising exception",
+ currentTryIndex, maxTryCount));
+ }
+ }
+
+ private static void ValidateParameters(Func action, int maxTryCount, int retryTimeoutInMilliseconds, Action waiter)
+ {
+ if (action == null)
+ throw new ArgumentNullException("action");
+
+ if (waiter == null)
+ throw new ArgumentNullException("waiter");
+
+ if (maxTryCount <= 0)
+ throw new ArgumentOutOfRangeException("maxTryCount must be greater than 0");
+
+ if (retryTimeoutInMilliseconds <= 0)
+ throw new ArgumentOutOfRangeException("retryTimeoutInMilliseconds must be greater than 0");
+ }
+ }
+}
diff --git a/SPMeta2/SPMeta2/Services/Impl/TraceSourceService.cs b/SPMeta2/SPMeta2/Services/Impl/TraceSourceService.cs
index dcb685e9b..648334f4c 100644
--- a/SPMeta2/SPMeta2/Services/Impl/TraceSourceService.cs
+++ b/SPMeta2/SPMeta2/Services/Impl/TraceSourceService.cs
@@ -132,7 +132,7 @@ public override void Verbose(int id, object message, Exception exception)
#region utils
- protected virtual void TraceEvent(int id, TraceEventType messageType, object message, Exception exception)
+ protected virtual string GetTraceEventString(int id, TraceEventType messageType, object message, Exception exception)
{
var traceString = string.Empty;
var messageString = message == null ? string.Empty : message.ToString();
@@ -156,8 +156,14 @@ protected virtual void TraceEvent(int id, TraceEventType messageType, object mes
traceString = string.Format("{0}", subMessage);
}
- TraceSource.TraceEvent(messageType, id, traceString);
+ return traceString;
+ }
+ protected virtual void TraceEvent(int id, TraceEventType messageType, object message, Exception exception)
+ {
+ var traceString = GetTraceEventString(id, messageType, message, exception);
+
+ TraceSource.TraceEvent(messageType, id, traceString);
if (AutoFlush)
{
diff --git a/SPMeta2/SPMeta2/Services/IncrementalProvisionServiceBaseExtensions.cs b/SPMeta2/SPMeta2/Services/IncrementalProvisionServiceBaseExtensions.cs
index 321aa9f68..328e6c857 100644
--- a/SPMeta2/SPMeta2/Services/IncrementalProvisionServiceBaseExtensions.cs
+++ b/SPMeta2/SPMeta2/Services/IncrementalProvisionServiceBaseExtensions.cs
@@ -7,6 +7,9 @@
using SPMeta2.Definitions;
using SPMeta2.Common;
using SPMeta2.Exceptions;
+using SPMeta2.ModelHosts;
+using SPMeta2.Models;
+using SPMeta2.Extensions;
namespace SPMeta2.Services
{
@@ -86,5 +89,64 @@ private static DefaultIncrementalModelTreeTraverseService GetIncrementalModelTra
}
#endregion
+
+ #region deployment helpers
+
+ ///
+ /// A shortcut for incremental provision
+ /// Sets incremental provision mode with AutoDetectSharePointPersistenceStorage = true
+ /// Once done, reverts back to default provision mode
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static void DeployModelIncrementally(this ProvisionServiceBase provisionService,
+ ModelHostBase modelHost,
+ ModelNode model,
+ string incrementalModelId)
+ {
+ DeployModelIncrementally(provisionService, modelHost, model, incrementalModelId, null);
+ }
+
+ ///
+ /// A shortcut for incremental provision
+ /// Sets incremental provision mode with IncrementalProvisionConfig.AutoDetectSharePointPersistenceStorage = true
+ /// Once done, reverts back to default provision mode
+ /// Callback on IncrementalProvisionConfig makes it easy to configure IncrementalProvisionConfig instance
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static void DeployModelIncrementally(this ProvisionServiceBase provisionService,
+ ModelHostBase modelHost,
+ ModelNode model,
+ string incrementalModelId,
+ Action config)
+ {
+ try
+ {
+ var incrementalProvisionConfig = new IncrementalProvisionConfig
+ {
+ AutoDetectSharePointPersistenceStorage = true
+ };
+
+ if (config != null)
+ config(incrementalProvisionConfig);
+
+ provisionService.SetIncrementalProvisionMode(incrementalProvisionConfig);
+ model.InternalSetIncrementalProvisionModelId(incrementalModelId);
+
+ provisionService.DeployModel(modelHost, model);
+ }
+ finally
+ {
+ provisionService.SetDefaultProvisionMode();
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/SPMeta2/SPMeta2/Services/TryRetryServiceBase.cs b/SPMeta2/SPMeta2/Services/TryRetryServiceBase.cs
new file mode 100644
index 000000000..bb92fa9b4
--- /dev/null
+++ b/SPMeta2/SPMeta2/Services/TryRetryServiceBase.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+
+namespace SPMeta2.Services
+{
+ public abstract class TryRetryServiceBase
+ {
+ #region properties
+
+ #endregion
+
+ #region methods
+
+ public abstract void TryWithRetry(Func action);
+ public abstract void TryWithRetry(Func action, int maxTryCount);
+ public abstract void TryWithRetry(Func action, int maxTryCount, int retryTimeoutInMilliseconds);
+ public abstract void TryWithRetry(Func action, int maxTryCount, int retryTimeoutInMilliseconds, Action waiter);
+
+ #endregion
+ }
+}
diff --git a/SPMeta2/SPMeta2/Utils/ReflectionUtils.cs b/SPMeta2/SPMeta2/Utils/ReflectionUtils.cs
index 60ff6dbcc..8886d8651 100644
--- a/SPMeta2/SPMeta2/Utils/ReflectionUtils.cs
+++ b/SPMeta2/SPMeta2/Utils/ReflectionUtils.cs
@@ -303,6 +303,29 @@ public static bool HasPropertyPublicSetter(object obj, string propName)
return false;
}
+ public static int? GetHResultValue(Exception exception)
+ {
+ // .net 4 hack to get HResult
+ var hResultProp = exception.GetType()
+ .GetProperty("HResult",
+ BindingFlags.NonPublic
+ | BindingFlags.Public
+ | BindingFlags.Instance
+ | BindingFlags.Static);
+
+
+ if (hResultProp != null)
+ {
+ var hResultValue = hResultProp.GetValue(exception, null);
+ if (hResultValue is int)
+ {
+ return (int)hResultValue;
+ }
+ }
+
+ return null;
+ }
+
#endregion
}
}