Compare commits
485 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08d74e3320 | |||
| 98fd75b55d | |||
| e7da70e076 | |||
| 200cec0e23 | |||
| 807778a737 | |||
| 66d61c9d20 | |||
| ecae5a856a | |||
| bf8add4f8d | |||
| 256fa3385a | |||
| ebaa46b2fc | |||
| e207185d51 | |||
| 5efc45a7dd | |||
| c3fc27565d | |||
| 0af3f9dce0 | |||
| 426b02b08a | |||
| a4e23ef82b | |||
| d0c6c4aafa | |||
| 3ea7e6fb8a | |||
| 9940b78a57 | |||
| 8371105c10 | |||
| d4b0f3c570 | |||
| 29416320d2 | |||
| d11eb485e1 | |||
| 300bd3bed4 | |||
| 3ca5443350 | |||
| f6d56f51d4 | |||
| 53c0bd6938 | |||
| 174aa9f4ad | |||
| a768fe5bb3 | |||
| d9c66cd4b3 | |||
| 6d3e8e1f6d | |||
| b6185b847f | |||
| c8877d0a2c | |||
| 891810b045 | |||
| 77d910b6b6 | |||
| 47044b3a77 | |||
| 5b693f9310 | |||
| 40ebc1295c | |||
| b769b224c2 | |||
| 89efe40f41 | |||
| 51660d918c | |||
| ea7b053106 | |||
| 3e17201ce7 | |||
| 1f03983628 | |||
| 15aa6fc4b8 | |||
| 41e8a9ef2d | |||
| a492976a32 | |||
| 88e09f9077 | |||
| 65a1709bd3 | |||
| 6478a8424a | |||
| 55ade4e491 | |||
| a767aa9f3a | |||
| 50321e5936 | |||
| 1321702d19 | |||
| 005ff2f830 | |||
| dff3fde840 | |||
| 44504ff6af | |||
| 25d3389759 | |||
| 3f97c74712 | |||
| 1152b61fb0 | |||
| b1842de045 | |||
| 750a2862ee | |||
| 7632075df4 | |||
| aa75cd4ea8 | |||
| 06827bd7a5 | |||
| 9a82ab7d4a | |||
| b1037d1936 | |||
| ccdc3a1eab | |||
| a47387fec0 | |||
| c29d08c915 | |||
| b8f796eb2c | |||
| b9088c9ac0 | |||
| 7a8f8ac0fe | |||
| 49cf0f98ce | |||
| 22ffa86e18 | |||
| c4e2d98138 | |||
| c01211c62d | |||
| d8a3e00440 | |||
| 264c537b50 | |||
| f26c61d736 | |||
| 43f647fd94 | |||
| cc0bcc2d59 | |||
| 1b23540b87 | |||
| c309e18f13 | |||
| dec60885b4 | |||
| eee09ec45b | |||
| b4daab2856 | |||
| fdfbad254d | |||
| 0c6e766030 | |||
| 7444363cef | |||
| a82097b92b | |||
| 07934161a4 | |||
| 9194030a9a | |||
| 1cbaace777 | |||
| ef5052324b | |||
| 204a8d813c | |||
| 8009cb3892 | |||
| 284d168cd7 | |||
| fdd025aefd | |||
| e36d4768e1 | |||
| df2047e8f8 | |||
| d9280d5238 | |||
| 388249f500 | |||
| a08b75592e | |||
| 38ea6dfbfe | |||
| 39ccde221a | |||
| 17b6366ea3 | |||
| 3d6a608b12 | |||
| 851f58df9c | |||
| 0ff0cc6366 | |||
| 08004ecc68 | |||
| 4a2544d0e6 | |||
| bace1cce74 | |||
| acc88e25d8 | |||
| 2a1a16d478 | |||
| a5afb8ed19 | |||
| d02678e05c | |||
| 9e0bbd3c99 | |||
| 539efcc669 | |||
| d0d9d85151 | |||
| ffa307613c | |||
| 19ea6d6005 | |||
| 155b1737d3 | |||
| b66253f33e | |||
| bcbadfe648 | |||
| 3325b06873 | |||
| 852914bf6b | |||
| 3e14807370 | |||
| e44cb6708d | |||
| fd43b27d00 | |||
| 524f113611 | |||
| 04dcf50218 | |||
| 2b497deaa3 | |||
| dbe2f8ea37 | |||
| 7dc0239ad1 | |||
| 72fdc5f472 | |||
| cde3c42cec | |||
| 10b544abb9 | |||
| 88aecdf672 | |||
| ad95736eaa | |||
| 34a21a78a0 | |||
| 1e01c2669f | |||
| d3a7389b89 | |||
| bc8b6c4bea | |||
| 3953a48a3b | |||
| 2f44e94bd0 | |||
| 5eeb8d7df6 | |||
| 231f23cc6e | |||
| 3235678d29 | |||
| f13ddddc16 | |||
| 490c346fcf | |||
| 8f1d8419a0 | |||
| be8320bb4b | |||
| 1d4b6178e5 | |||
| 3427f596e3 | |||
| c31ea7409f | |||
| f88e60bcb5 | |||
| c81919e269 | |||
| c936aaa517 | |||
| b8f88e0459 | |||
| 1628ac917c | |||
| ab586a49ce | |||
| ff2ee540e2 | |||
| b450299d45 | |||
| 0ebe535922 | |||
| f5f8fe7b42 | |||
| f51a66b728 | |||
| f8a7b453c7 | |||
| 89235f707c | |||
| 550166c41b | |||
| 40be3957f6 | |||
| 6ccce4d914 | |||
| 14ea374b24 | |||
| 4d49268c47 | |||
| a569796adb | |||
| 59de0613f5 | |||
| 8391c32886 | |||
| bf2efd30e9 | |||
| 187373132f | |||
| 79584a9cf9 | |||
| 96fa8c7dc9 | |||
| 5e43ddc13c | |||
| 98f76a989f | |||
| 2e8993adb8 | |||
| 81600f0f3c | |||
| 74ccd79408 | |||
| 3e0a754dc0 | |||
| 006a89e136 | |||
| 29dbbee173 | |||
| cd31637371 | |||
| ab70c98d4c | |||
| 424ff02734 | |||
| 80bd8d962b | |||
| 4b4efde490 | |||
| 956364decd | |||
| 7bc2bdae75 | |||
| c43ab7942a | |||
| 166f9b939c | |||
| ede9e00a7f | |||
| 0bfbacfd66 | |||
| 5c5827e319 | |||
| 05ca98219d | |||
| a83a0f1e25 | |||
| ea7d476559 | |||
| 2d2f57a71b | |||
| 6133e8f8c2 | |||
| bfaace373c | |||
| a6d24fce93 | |||
| 7e8aaebfce | |||
| 6a3fb87499 | |||
| 74cad56a6b | |||
| 9b02457f7a | |||
| 6077e24685 | |||
| 39a3a9dc56 | |||
| 801a3731a2 | |||
| bcb7561e74 | |||
| f077520781 | |||
| 61ec1e4c35 | |||
| 3710c0916c | |||
| 863667f5bd | |||
| 7475851bb5 | |||
| a721ed5e0f | |||
| 0bc621c40f | |||
| 620fbde1db | |||
| 39e7947435 | |||
| 2792937b17 | |||
| af9a9a9a7a | |||
| 83f4c0262e | |||
| 08d4ce7667 | |||
| 2340adbe94 | |||
| fb6b234491 | |||
| 15222e176e | |||
| 63b92eaee5 | |||
| 84dd7dc61a | |||
| 5a4b09f9d1 | |||
| bbbd03f001 | |||
| 4a721ddf34 | |||
| d88745bf49 | |||
| 3543204794 | |||
| c565744a9b | |||
| 2470ec3ded | |||
| 7b4f7abbcd | |||
| 1573eb2f74 | |||
| e8e8b536f1 | |||
| 704c3df597 | |||
| 36c107c0ef | |||
| 70f5641b83 | |||
| bbb5fe728a | |||
| 307ea6bd74 | |||
| 76eb06784d | |||
| c6e1235ac4 | |||
| 6ac2cc9f8b | |||
| 9d5c8e5aed | |||
| 56001a8ccb | |||
| ff5dadde53 | |||
| 6d92393f08 | |||
| 6169d13eb5 | |||
| 361c382a2e | |||
| 375b3948e0 | |||
| 6453a82717 | |||
| a4c9fae05c | |||
| 29edbb90a6 | |||
| 71201970e9 | |||
| 992727821b | |||
| 67fd3cc234 | |||
| f70717985c | |||
| ded82611a7 | |||
| 6a8cb5e123 | |||
| 09428d703c | |||
| 2b6b8e9e8c | |||
| a46c088d0c | |||
| 65e591501c | |||
| a0541b000e | |||
| 1f6b139cde | |||
| 17893715fc | |||
| a25e6e0d2c | |||
| 668935548d | |||
| 14141fcaa5 | |||
| 1948fe12b3 | |||
| 4bcf3983c5 | |||
| 7c5942b05f | |||
| 8b4d4e3189 | |||
| 4f008f5848 | |||
| 1a40ccc838 | |||
| 0bf43da825 | |||
| c83db52bd7 | |||
| 00e1556504 | |||
| 5c8440a7d6 | |||
| 3e86fb6298 | |||
| 9b0895c5b0 | |||
| 4ad9ea1537 | |||
| 0b08f19f53 | |||
| 527402a6d8 | |||
| 9eea8c85e0 | |||
| e80963093d | |||
| 6f586c7eeb | |||
| ff3b5baf06 | |||
| 0749124f45 | |||
| 549aeecf31 | |||
| bef970437a | |||
| 0898b13072 | |||
| dda36f0147 | |||
| 9d3f362029 | |||
| 4d13925e3b | |||
| 02481dcfba | |||
| caad775399 | |||
| fd14065f14 | |||
| 7a7720c460 | |||
| b2aeb835d5 | |||
| 8dd950bd52 | |||
| e2881e07d1 | |||
| e0e0076a7a | |||
| 00a96a4888 | |||
| b16cf375b9 | |||
| a3b433c73c | |||
| 855a4961dd | |||
| 71de4dc7de | |||
| 19d3c06470 | |||
| e22476f54a | |||
| 20ae16b2d7 | |||
| 9e466971af | |||
| 7017d8094d | |||
| 0e40971178 | |||
| 1ae9816c28 | |||
| e40cf3b8fc | |||
| 09ea82b37f | |||
| c44918f830 | |||
| 760dd42c43 | |||
| 0409192892 | |||
| d575eaa9c1 | |||
| 373e9755ed | |||
| d6f00d9367 | |||
| 3cabec84d4 | |||
| c9d12f7dc5 | |||
| 9e97b84fb8 | |||
| f4fa090857 | |||
| 0e22a2bb5a | |||
| 36b10e71d7 | |||
| 3c6029c969 | |||
| a4a0de3503 | |||
| 217267bf94 | |||
| 4748366766 | |||
| de15dc36e7 | |||
| ab00782d84 | |||
| 2d6d95a63e | |||
| d19d1b3a18 | |||
| 5a779c24d0 | |||
| c669a2702b | |||
| f777f1b3d6 | |||
| 3e8ada24e4 | |||
| fe884b2070 | |||
| 30cfa4c0ae | |||
| 66aa3084f9 | |||
| d028ee2c3e | |||
| 2bd5e908db | |||
| 154652c896 | |||
| a60e2318ad | |||
| f642a7fd63 | |||
| b4cce4860f | |||
| d1d54d8e84 | |||
| bbeedb6c1b | |||
| 4745995f92 | |||
| c66aca2d41 | |||
| af148a4544 | |||
| d7ea8e02d6 | |||
| 3acec1dd65 | |||
| e52f8dcbc9 | |||
| 60edf7d3b9 | |||
| f626738174 | |||
| ad3c004d95 | |||
| 58814d4ac2 | |||
| c29dbf444a | |||
| bd06729619 | |||
| bd1dc4f88d | |||
| 67c1cc44c5 | |||
| b680f87c12 | |||
| 8db6633c91 | |||
| 8843f6c02c | |||
| 6561a79b5c | |||
| 3e5128147c | |||
| 64c126ea61 | |||
| 3dcbcba9cf | |||
| b5329ace3b | |||
| e1a134f587 | |||
| 1ec2901762 | |||
| 58bfb6999d | |||
| e8056de589 | |||
| bbe6194b06 | |||
| 06a08be6de | |||
| f1e8e845a2 | |||
| 20c5be0a8e | |||
| 6990c46262 | |||
| 099c558797 | |||
| d76fd7d25e | |||
| e020989577 | |||
| f2541cae86 | |||
| a907b5bdcd | |||
| 7258964bb7 | |||
| d290ffa306 | |||
| 75bc3e09c6 | |||
| bcc2424577 | |||
| 67f8b8f88b | |||
| 2d44650139 | |||
| 8eaea3fb54 | |||
| 2166a4a5ac | |||
| 3ba6391dda | |||
| 8574c6b7d0 | |||
| b533a9f690 | |||
| 221bfa5f3d | |||
| 85a74e4fa7 | |||
| 62d4bff8aa | |||
| 095be823c6 | |||
| a8858ecfdd | |||
| 9c48330aae | |||
| 22792a2f8e | |||
| 0dc00a62e2 | |||
| 0c4e442578 | |||
| 9d7d866467 | |||
| 3b26834484 | |||
| aee10348e5 | |||
| d0fc3ddba5 | |||
| 3aadca167f | |||
| 3a92c26a7f | |||
| 6a4ea56dc5 | |||
| cdd6768966 | |||
| d89205abaf | |||
| ff21379547 | |||
| 74f00a9f89 | |||
| 3912300f83 | |||
| c8ff708a43 | |||
| 693899935b | |||
| 1a87d96f77 | |||
| 0a959b5b84 | |||
| f2202eb337 | |||
| 19b7a9dfff | |||
| f432e23a47 | |||
| 20d92432b2 | |||
| 59cdb8a6fe | |||
| aed4c1faed | |||
| 2ecab70772 | |||
| 894a649574 | |||
| 48bbf1ecb2 | |||
| 5dc44ca612 | |||
| 3c771648e3 | |||
| c500d29029 | |||
| 2c8fe5a130 | |||
| d737afa327 | |||
| 2db1c1bb40 | |||
| d95ca7bc6f | |||
| 6b491ac6cd | |||
| 278b681501 | |||
| abd72e7676 | |||
| ec6cb4520c | |||
| 2dfa85c9b4 | |||
| 921a5963e2 | |||
| 3626d5b79d | |||
| 980e8e84a6 | |||
| 4070669e7d | |||
| b20e61d316 | |||
| fb764641c5 | |||
| 405727f1ac | |||
| 6446f63dcb | |||
| f1963fb404 | |||
| c26b72bd10 | |||
| b94cee68e7 | |||
| b67fbbcbd8 | |||
| 71fcc77e9b | |||
| 38509f9d5a | |||
| 3ff04f585c | |||
| 3de8f9bd18 | |||
| c95e7c245e | |||
| 4d3eef1124 | |||
| b048ae4d36 | |||
| 366697f4eb | |||
| 987644379e | |||
| 4a095184bb | |||
| f674fdf014 | |||
| 6eeb9d6af4 | |||
| cbefabb724 | |||
| f7f6cc64ce | |||
| 1408e4f64e | |||
| 0a68d2f4ee | |||
| 11a4a0436d | |||
| 2583800b2c | |||
| 067268a96e |
+5
-1
@@ -1,6 +1,6 @@
|
||||
@ECHO OFF
|
||||
SET release=7.1.0
|
||||
SET comment=beta
|
||||
SET comment=
|
||||
SET version=%release%
|
||||
|
||||
IF [%comment%] EQU [] (SET version=%release%) ELSE (SET version=%release%-%comment%)
|
||||
@@ -12,6 +12,9 @@ ECHO Installing the Microsoft.Bcl.Build package before anything else, otherwise
|
||||
SET nuGetFolder=%CD%\..\src\packages\
|
||||
..\src\.nuget\NuGet.exe install ..\src\Umbraco.Web.UI\packages.config -OutputDirectory %nuGetFolder%
|
||||
|
||||
ECHO Removing the belle build folder to make sure everything is clean as a whistle
|
||||
RD ..\src\Umbraco.Web.UI.Client\build /Q /S
|
||||
|
||||
ECHO Performing MSBuild and producing Umbraco binaries zip files
|
||||
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.proj" /p:BUILD_RELEASE=%release% /p:BUILD_COMMENT=%comment%
|
||||
|
||||
@@ -30,6 +33,7 @@ echo This file is only here so that the containing folder will be included in th
|
||||
ECHO Adding Web.config transform files to the NuGet package
|
||||
ren .\_BuildOutput\WebApp\MacroScripts\Web.config Web.config.transform
|
||||
ren .\_BuildOutput\WebApp\Views\Web.config Web.config.transform
|
||||
ren .\_BuildOutput\WebApp\Xslt\Web.config Web.config.transform
|
||||
|
||||
ECHO Packing the NuGet release files
|
||||
..\src\.nuget\NuGet.exe pack NuSpecs\UmbracoCms.Core.nuspec -Version %version%
|
||||
|
||||
+11
-1
@@ -310,7 +310,12 @@
|
||||
</Target>
|
||||
|
||||
<Target Name="SetVersionNumber" Condition="'$(BUILD_RELEASE)'!=''">
|
||||
<!-- Match & replace 3 and 4 digit version numbers and -beta (if it's there) -->
|
||||
<PropertyGroup>
|
||||
<NewVersion>$(BUILD_RELEASE)</NewVersion>
|
||||
<NewVersion Condition="'$(BUILD_COMMENT)'!=''">$(BUILD_RELEASE)-$(BUILD_COMMENT)</NewVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Match & replace 3 and 4 digit version numbers and -beta (if it's there) -->
|
||||
<FileUpdate
|
||||
Files="..\src\Umbraco.Core\Configuration\UmbracoVersion.cs"
|
||||
Regex="(\d+)\.(\d+)\.(\d+)(.(\d+))?"
|
||||
@@ -319,5 +324,10 @@
|
||||
<FileUpdate Files="..\src\Umbraco.Core\Configuration\UmbracoVersion.cs"
|
||||
Regex="CurrentComment { get { return "([a-zA-Z]+)?""
|
||||
ReplacementText="CurrentComment { get { return "$(BUILD_COMMENT)""/>
|
||||
|
||||
<XmlPoke XmlInputPath=".\NuSpecs\build\UmbracoCms.targets"
|
||||
Namespaces="<Namespace Prefix='x' Uri='http://schemas.microsoft.com/developer/msbuild/2003' />"
|
||||
Query="//x:UmbracoVersion"
|
||||
Value="$(NewVersion)" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -4,7 +4,7 @@
|
||||
<id>UmbracoCms.Core</id>
|
||||
<version>7.0.0</version>
|
||||
<title>Umbraco Cms Core Binaries</title>
|
||||
<authors>Morten Christensen</authors>
|
||||
<authors>Umbraco HQ</authors>
|
||||
<owners>Umbraco HQ</owners>
|
||||
<licenseUrl>http://umbraco.codeplex.com/license</licenseUrl>
|
||||
<projectUrl>http://umbraco.com/</projectUrl>
|
||||
@@ -16,8 +16,8 @@
|
||||
<tags>umbraco</tags>
|
||||
<dependencies>
|
||||
<dependency id="Microsoft.AspNet.Mvc" version="[4.0.0,5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi" version="[4.0.0,5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Client" version="[4.0.0, 5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi" version="[4.0.30506,5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Client" version="[4.0.30506, 5.0.0)" />
|
||||
<dependency id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" />
|
||||
<dependency id="Microsoft.Net.Http" version="[2.0.0, 3.0.0)" />
|
||||
<dependency id="MiniProfiler" version="[2.1.0, 3.0.0)" />
|
||||
@@ -26,16 +26,17 @@
|
||||
<dependency id="SharpZipLib" version="[0.86.0, 1.0.0)" />
|
||||
<dependency id="MySql.Data" version="[6.6.5]" />
|
||||
<dependency id="xmlrpcnet" version="[2.5.0, 3.0.0)" />
|
||||
<!--<dependency id="ClientDependency" version="[1.7.0, 2.0.0)" />-->
|
||||
<dependency id="ClientDependency-Mvc" version="[1.7.0, 2.0.0)" />
|
||||
<dependency id="ClientDependency" version="[1.7.1.2, 2.0.0)" />
|
||||
<dependency id="ClientDependency-Mvc" version="[1.7.0.4, 2.0.0)" />
|
||||
<dependency id="AutoMapper" version="[3.0.0, 4.0.0)" />
|
||||
<dependency id="Newtonsoft.Json" version="[4.5.11, 5.0.0)" />
|
||||
<dependency id="ImageProcessor" version="[1.8.7, 2.0.0)" />
|
||||
<dependency id="ImageProcessor.Web" version="[3.2.1, 4.0.0)" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\_BuildOutput\WebApp\bin\businesslogic.dll" target="lib\businesslogic.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\businesslogic.xml" target="lib\businesslogic.xml" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\ClientDependency.Core.dll" target="lib\ClientDependency.Core.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\cms.dll" target="lib\cms.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\cms.xml" target="lib\cms.xml" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\controls.dll" target="lib\controls.dll" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<id>UmbracoCms</id>
|
||||
<version>7.0.0</version>
|
||||
<title>Umbraco Cms</title>
|
||||
<authors>Morten Christensen</authors>
|
||||
<authors>Umbraco HQ</authors>
|
||||
<owners>Umbraco HQ</owners>
|
||||
<licenseUrl>http://umbraco.codeplex.com/license</licenseUrl>
|
||||
<projectUrl>http://umbraco.com/</projectUrl>
|
||||
@@ -19,8 +19,6 @@
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\_BuildOutput\WebApp\bin\amd64\**" target="Content\bin\amd64" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\x86\**" target="Content\bin\x86" />
|
||||
<file src="..\_BuildOutput\Configs\**" target="Content\config" exclude="..\_BuildOutput\Configs\Web.config.transform" />
|
||||
<file src="..\_BuildOutput\WebApp\css\**" target="Content\css" />
|
||||
<file src="..\_BuildOutput\WebApp\macroScripts\**" target="Content\macroScripts" exclude="..\_BuildOutput\WebApp\macroScripts\Web.config" />
|
||||
@@ -32,14 +30,14 @@
|
||||
<file src="..\_BuildOutput\WebApp\xslt\**" target="Content\xslt" />
|
||||
<file src="..\_BuildOutput\WebApp\default.aspx" target="Content\default.aspx" />
|
||||
<file src="..\_BuildOutput\WebApp\Web.config" target="Content\Web.config" />
|
||||
<file src="..\_BuildOutput\WebApp\Global.asax" target="Content\Global.asax" />
|
||||
<file src="..\_BuildOutput\WebApp\App_Browsers\**" target="UmbracoFiles\App_Browsers" />
|
||||
<file src="..\_BuildOutput\WebApp\App_Code\**" target="UmbracoFiles\App_Code" />
|
||||
<file src="..\_BuildOutput\WebApp\App_Data\**" target="UmbracoFiles\App_Data" />
|
||||
<file src="..\_BuildOutput\WebApp\App_Plugins\**" target="UmbracoFiles\App_Plugins" />
|
||||
<file src="..\_BuildOutput\WebApp\App_Plugins\**" target="UmbracoFiles\App_Plugins" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\amd64\**" target="UmbracoFiles\bin\amd64" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\x86\**" target="UmbracoFiles\bin\x86" />
|
||||
<file src="..\_BuildOutput\WebApp\config\splashes\**" target="UmbracoFiles\config\splashes" />
|
||||
<file src="..\_BuildOutput\WebApp\umbraco\**" target="UmbracoFiles\umbraco" />
|
||||
<file src="..\_BuildOutput\WebApp\umbraco_client\**" target="UmbracoFiles\umbraco_client" />
|
||||
<file src="..\_BuildOutput\WebApp\Global.asax" target="UmbracoFiles\Global.asax" />
|
||||
<file src="..\_BuildOutput\WebApp\Web.config" target="UmbracoFiles\Web.config" />
|
||||
<file src="tools\install.ps1" target="tools\install.ps1" />
|
||||
<file src="tools\Readme.txt" target="tools\Readme.txt" />
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
|
||||
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
</PropertyGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
|
||||
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<UmbracoVersion>7.1.0</UmbracoVersion>
|
||||
</PropertyGroup>
|
||||
<Target Name="CopyUmbracoFilesToWebRoot" BeforeTargets="AfterBuild">
|
||||
<PropertyGroup>
|
||||
<UmbracoFilesFolder>..\packages\UmbracoCms.$(UmbracoVersion)\UmbracoFiles\</UmbracoFilesFolder>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<UmbracoFiles Include="$(UmbracoFilesFolder)**\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="%(UmbracoFiles.FullPath)" DestinationFiles="%(RecursiveDir)%(Filename)%(Extension)" Condition="!Exists('%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
</Target>
|
||||
<Target Name="AddUmbracoFilesToOutput">
|
||||
<!-- With help from: http://blog.samstephens.co.nz/2010-10-18/msbuild-including-extra-files-multiple-builds/ -->
|
||||
<ItemGroup>
|
||||
<CustomFilesToInclude Include=".\App_Browsers\**\*">
|
||||
<Dir>App_Browsers</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\App_Code\**\*">
|
||||
<Dir>App_Code</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\App_Plugins\**\*">
|
||||
<Dir>App_Plugins</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\bin\amd64\**\*">
|
||||
<Dir>bin\amd64</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\bin\x86\**\*">
|
||||
<Dir>bin\x86</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\Config\Splashes\**\*">
|
||||
<Dir>Config\Splashes</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\umbraco\**\*">
|
||||
<Dir>umbraco</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\umbraco_client\**\*">
|
||||
<Dir>umbraco_client</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<CustomFilesToInclude Include=".\Global.asax">
|
||||
<Dir>.</Dir>
|
||||
</CustomFilesToInclude>
|
||||
<FilesForPackagingFromProject Include="@(CustomFilesToInclude)">
|
||||
<DestinationRelativePath>%(CustomFilesToInclude.Dir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="AddUmbracoFilesToOutput">
|
||||
<ItemGroup>
|
||||
<UmbracoFiles Include=".\umbraco\**\*;" />
|
||||
<UmbracoClientFiles Include=".\umbraco_client\**\*;" />
|
||||
<AppBrowsersFiles Include=".\App_Browsers\**\*" />
|
||||
<FilesForPackagingFromProject Include="%(UmbracoFiles.Identity)">
|
||||
<DestinationRelativePath>umbraco\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
<FilesForPackagingFromProject Include="%(UmbracoClientFiles.Identity)">
|
||||
<DestinationRelativePath>umbraco_client\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
<FilesForPackagingFromProject Include="%(AppBrowsersFiles.Identity)">
|
||||
<DestinationRelativePath>App_Browsers\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
|
||||
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="AddUmbracoFilesToOutput">
|
||||
<ItemGroup>
|
||||
<UmbracoFiles Include=".\umbraco\**\*;" />
|
||||
<UmbracoClientFiles Include=".\umbraco_client\**\*;" />
|
||||
<AppBrowsersFiles Include=".\App_Browsers\**\*" />
|
||||
<FilesForPackagingFromProject Include="%(UmbracoFiles.Identity)">
|
||||
<DestinationRelativePath>umbraco\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
<FilesForPackagingFromProject Include="%(UmbracoClientFiles.Identity)">
|
||||
<DestinationRelativePath>umbraco_client\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
<FilesForPackagingFromProject Include="%(AppBrowsersFiles.Identity)">
|
||||
<DestinationRelativePath>App_Browsers\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
|
||||
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
AddUmbracoFilesToOutput;
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="AddUmbracoFilesToOutput">
|
||||
<ItemGroup>
|
||||
<UmbracoFiles Include=".\umbraco\**\*;" />
|
||||
<UmbracoClientFiles Include=".\umbraco_client\**\*;" />
|
||||
<AppBrowsersFiles Include=".\App_Browsers\**\*" />
|
||||
<FilesForPackagingFromProject Include="%(UmbracoFiles.Identity)">
|
||||
<DestinationRelativePath>umbraco\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
<FilesForPackagingFromProject Include="%(UmbracoClientFiles.Identity)">
|
||||
<DestinationRelativePath>umbraco_client\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
<FilesForPackagingFromProject Include="%(AppBrowsersFiles.Identity)">
|
||||
<DestinationRelativePath>App_Browsers\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,8 +1,17 @@
|
||||
A note about running Umbraco from Visual Studio.
|
||||
|
||||
When upgrading your website using nuget a backup of config files and web.config will be created. Only the web.config will
|
||||
be overwritten by default to ensure that it has the necessary settings from the current release. This means that you'll
|
||||
have to merge the files if you made any changes to the previous config files.
|
||||
When upgrading your website using NuGet you should answer "No" to the questions to overwrite the Web.config
|
||||
file (and config files in the config folder).
|
||||
We will overwrite Web.config anyway but we keep a backup in the App_Data\NuGetBackup folder. There you'll
|
||||
find a folder with the current date and time in which the backup has been placed. Make sure to merge the
|
||||
new file with the old backup files before you proceed.
|
||||
The web.config will be overwritten by default to ensure that it has the necessary settings from the current release.
|
||||
|
||||
We've also overwritten all the files in the Umbraco and Umbraco_Client folder, these have also been backed up in
|
||||
App_Data\NuGetBackup. We didn't overwrite the UI.xml file nor did we remove any files or folders that you or a package
|
||||
might have added. Only the existing files were overwritten. If you customized anything then make sure to do a compare
|
||||
and merge with the NuGetBackup folder.
|
||||
|
||||
The config files found in the config folder will usually not be changed for patch releases, so they can usually be skipped,
|
||||
but the web.config will have to have its previous "umbracoConfigurationStatus"-appsetting and "umbracoDbDSN" connection string
|
||||
copied over (as a minimum).
|
||||
@@ -10,8 +19,8 @@ copied over (as a minimum).
|
||||
This nuget package includes build targets that extends the creation of a deploy package, which is generated by
|
||||
Publishing from Visual Studio. The targets will only work once Publishing is configured, so if you don't use
|
||||
Publish this won't affect you.
|
||||
These folders will now be automatically included when creating a deploy package or publishing to the file system:
|
||||
umbraco and umbraco_client.
|
||||
These things will now be automatically included when creating a deploy package or publishing to the file system:
|
||||
umbraco, umbraco_client, config\splashes and global.asax.
|
||||
|
||||
Please read the release notes on our.umbraco.org:
|
||||
http://our.umbraco.org/contribute/releases
|
||||
|
||||
@@ -1,27 +1,38 @@
|
||||
param($rootPath, $toolsPath, $package, $project)
|
||||
|
||||
if ($project) {
|
||||
# Create a backup of extisting umbraco config files
|
||||
$configPath = Join-Path (Split-Path $project.FullName -Parent) "\config"
|
||||
$backupPath = Join-Path $configPath "\backup"
|
||||
Get-ChildItem -path $configPath |
|
||||
Where -filterscript {($_.Name.EndsWith("config"))} | Foreach-Object {
|
||||
$newFileName = Join-Path $backupPath $_.Name.replace(".config",".config.backup")
|
||||
New-Item -ItemType File -Path $newFileName -Force
|
||||
Copy-Item $_.FullName $newFileName -Force
|
||||
}
|
||||
|
||||
if ($project) {
|
||||
$dateTime = Get-Date -Format yyyyMMdd-HHmmss
|
||||
$backupPath = Join-Path (Split-Path $project.FullName -Parent) "\App_Data\NuGetBackup\$dateTime"
|
||||
|
||||
# Create backup folder if it doesn't exist yet
|
||||
New-Item -ItemType Directory -Force -Path $backupPath
|
||||
|
||||
# Create a backup of original web.config
|
||||
$projectDestinationPath = Split-Path $project.FullName -Parent
|
||||
$webConfigSource = Join-Path $projectDestinationPath "web.config"
|
||||
$webConfigDestination = Join-Path $projectDestinationPath "web.config.backup"
|
||||
Copy-Item $webConfigSource $webConfigDestination
|
||||
$webConfigSource = Join-Path $projectDestinationPath "Web.config"
|
||||
Copy-Item $webConfigSource $backupPath -Force
|
||||
|
||||
# Copy umbraco files from package to project folder
|
||||
$projectDestinationPath = Split-Path $project.FullName -Parent
|
||||
$umbracoFilesPath = Join-Path $rootPath "UmbracoFiles\*"
|
||||
Copy-Item $umbracoFilesPath $projectDestinationPath -recurse -force
|
||||
|
||||
# Copy Web.config from package to project folder
|
||||
$umbracoFilesPath = Join-Path $rootPath "UmbracoFiles\Web.config"
|
||||
Copy-Item $umbracoFilesPath $projectDestinationPath -Force
|
||||
|
||||
# Copy umbraco and umbraco_files from package to project folder
|
||||
# This is only done when these folders already exist because we
|
||||
# only want to do this for upgrades
|
||||
$umbracoFolder = Join-Path $projectDestinationPath "Umbraco\"
|
||||
if(Test-Path $umbracoFolder) {
|
||||
$umbracoFolderSource = Join-Path $rootPath "UmbracoFiles\Umbraco"
|
||||
Copy-Item $umbracoFolder $backupPath -Force
|
||||
robocopy $umbracoFolderSource $umbracoFolder /e /xf UI.xml
|
||||
}
|
||||
|
||||
$umbracoClientFolder = Join-Path $projectDestinationPath "Umbraco_Client"
|
||||
if(Test-Path $umbracoClientFolder) {
|
||||
$umbracoClientFolderSource = Join-Path $rootPath "UmbracoFiles\Umbraco_Client"
|
||||
Copy-Item $umbracoClientFolder $backupPath -Force
|
||||
robocopy $umbracoFolderSource $umbracoClientFolder /e
|
||||
}
|
||||
|
||||
# Open readme.txt file
|
||||
$DTE.ItemOperations.OpenFile($toolsPath + '\Readme.txt')
|
||||
}
|
||||
@@ -287,11 +287,11 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsConfiguredMembershipProviderUsingLegacyEncoding(Constants.Conventions.User.UmbracoUsersProviderName);
|
||||
return IsConfiguredMembershipProviderUsingLegacyEncoding(UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetMembershipProvidersLegacyEncoding(Constants.Conventions.User.UmbracoUsersProviderName, value);
|
||||
SetMembershipProvidersLegacyEncoding(UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,31 +34,19 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
if (_umbracoSettings == null)
|
||||
{
|
||||
var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettingsSection;
|
||||
if (umbracoSettings == null)
|
||||
{
|
||||
LogHelper.Warn<UmbracoConfig>("Could not load the " + typeof(IUmbracoSettingsSection) + " from config file!");
|
||||
}
|
||||
var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettingsSection;
|
||||
SetUmbracoSettings(umbracoSettings);
|
||||
}
|
||||
|
||||
if (_baseRestExtensions == null)
|
||||
{
|
||||
var baseRestExtensions = ConfigurationManager.GetSection("umbracoConfiguration/BaseRestExtensions") as IBaseRestSection;
|
||||
if (baseRestExtensions == null)
|
||||
{
|
||||
LogHelper.Warn<UmbracoConfig>("Could not load the " + typeof(IBaseRestSection) + " from config file!");
|
||||
}
|
||||
var baseRestExtensions = ConfigurationManager.GetSection("umbracoConfiguration/BaseRestExtensions") as IBaseRestSection;
|
||||
SetBaseRestExtensions(baseRestExtensions);
|
||||
}
|
||||
|
||||
if (_dashboardSection == null)
|
||||
{
|
||||
var dashboardConfig = ConfigurationManager.GetSection("umbracoConfiguration/dashBoard") as IDashboardSection;
|
||||
if (dashboardConfig == null)
|
||||
{
|
||||
LogHelper.Warn<UmbracoConfig>("Could not load the " + typeof(IDashboardSection) + " from config file!");
|
||||
}
|
||||
var dashboardConfig = ConfigurationManager.GetSection("umbracoConfiguration/dashBoard") as IDashboardSection;
|
||||
SetDashboardSettings(dashboardConfig);
|
||||
}
|
||||
}
|
||||
@@ -85,6 +73,13 @@ namespace Umbraco.Core.Configuration
|
||||
/// </summary>
|
||||
public IDashboardSection DashboardSettings()
|
||||
{
|
||||
if (_dashboardSection == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof(IDashboardSection) + " from config file, ensure the web.config and Dashboard.config files are formatted correctly");
|
||||
LogHelper.Error<UmbracoConfig>("Config error", ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _dashboardSection;
|
||||
}
|
||||
|
||||
@@ -105,6 +100,13 @@ namespace Umbraco.Core.Configuration
|
||||
/// </summary>
|
||||
public IUmbracoSettingsSection UmbracoSettings()
|
||||
{
|
||||
if (_umbracoSettings == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof (IUmbracoSettingsSection) + " from config file, ensure the web.config and umbracoSettings.config files are formatted correctly");
|
||||
LogHelper.Error<UmbracoConfig>("Config error", ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _umbracoSettings;
|
||||
}
|
||||
|
||||
@@ -119,6 +121,13 @@ namespace Umbraco.Core.Configuration
|
||||
/// </summary>
|
||||
public IBaseRestSection BaseRestExtensions()
|
||||
{
|
||||
if (_baseRestExtensions == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof(IBaseRestSection) + " from config file, ensure the web.config and BaseRestExtensions.config files are formatted correctly");
|
||||
LogHelper.Error<UmbracoConfig>("Config error", ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _baseRestExtensions;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
return new OptionalInnerTextConfigurationElement<string>(
|
||||
(InnerTextConfigurationElement<string>)this["DefaultBackofficeProvider"],
|
||||
//set the default
|
||||
Constants.Conventions.User.UmbracoUsersProviderName);
|
||||
//set the default
|
||||
"UsersMembershipProvider");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Configuration
|
||||
/// Gets the version comment (like beta or RC).
|
||||
/// </summary>
|
||||
/// <value>The version comment.</value>
|
||||
public static string CurrentComment { get { return "beta"; } }
|
||||
public static string CurrentComment { get { return ""; } }
|
||||
|
||||
// Get the version of the umbraco.dll by looking at a class in that dll
|
||||
// Had to do it like this due to medium trust issues, see: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx
|
||||
|
||||
@@ -93,16 +93,7 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
public const string Image = "Image";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constants for Umbraco user
|
||||
/// </summary>
|
||||
public static class User
|
||||
{
|
||||
public static readonly string UmbracoUsersProviderName = "UsersMembershipProvider";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constants for Umbraco Member property aliases.
|
||||
/// </summary>
|
||||
@@ -136,28 +127,28 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
public const string Comments = "umbracoMemberComments";
|
||||
|
||||
public const string CommentsLabel = "Comments";
|
||||
public const string CommentsLabel = "Comments";
|
||||
|
||||
/// <summary>
|
||||
/// Property alias for the Approved boolean of a Member
|
||||
/// </summary>
|
||||
public const string IsApproved = "umbracoMemberApproved";
|
||||
|
||||
public const string IsApprovedLabel = "Is Approved";
|
||||
public const string IsApprovedLabel = "Is Approved";
|
||||
|
||||
/// <summary>
|
||||
/// Property alias for the Locked out boolean of a Member
|
||||
/// </summary>
|
||||
public const string IsLockedOut = "umbracoMemberLockedOut";
|
||||
|
||||
public const string IsLockedOutLabel = "Is Locked Out";
|
||||
public const string IsLockedOutLabel = "Is Locked Out";
|
||||
|
||||
/// <summary>
|
||||
/// Property alias for the last date the Member logged in
|
||||
/// </summary>
|
||||
public const string LastLoginDate = "umbracoMemberLastLogin";
|
||||
|
||||
public const string LastLoginDateLabel = "Last Login Date";
|
||||
public const string LastLoginDateLabel = "Last Login Date";
|
||||
|
||||
/// <summary>
|
||||
/// Property alias for the last date a Member changed its password
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public static partial class Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the constants used for Umbraco packages in the package.config xml
|
||||
/// </summary>
|
||||
public static class Packaging
|
||||
{
|
||||
public const string UmbPackageNodeName = "umbPackage";
|
||||
public const string DataTypesNodeName = "DataTypes";
|
||||
public const string PackageXmlFileName = "package.xml";
|
||||
public const string UmbracoPackageExtention = ".umb";
|
||||
public const string DataTypeNodeName = "DataType";
|
||||
public const string LanguagesNodeName = "Languages";
|
||||
public const string FilesNodeName = "Files";
|
||||
public const string StylesheetsNodeName = "Stylesheets";
|
||||
public const string TemplatesNodeName = "Templates";
|
||||
public const string OrgnameNodeName = "orgName";
|
||||
public const string NameNodeName = "Name";
|
||||
public const string TemplateNodeName = "Template";
|
||||
public const string AliasNodeName = "Alias";
|
||||
public const string DictionaryitemsNodeName = "DictionaryItems";
|
||||
public const string MacrosNodeName = "macros";
|
||||
public const string DocumentSetNodeName = "DocumentSet";
|
||||
public const string DocumentTypesNodeName = "DocumentTypes";
|
||||
public const string DocumentTypeNodeName = "DocumentType";
|
||||
public const string FileNodeName = "file";
|
||||
public const string OrgPathNodeName = "orgPath";
|
||||
public const string GuidNodeName = "guid";
|
||||
public const string StylesheetNodeName = "styleSheet";
|
||||
public const string MacroNodeName = "macro";
|
||||
public const string InfoNodeName = "info";
|
||||
public const string PackageRequirementsMajorXpath = "/package/requirements/major";
|
||||
public const string PackageRequirementsMinorXpath = "/package/requirements/minor";
|
||||
public const string PackageRequirementsPatchXpath = "/package/requirements/patch";
|
||||
public const string PackageNameXpath = "/package/name";
|
||||
public const string PackageVersionXpath = "/package/version";
|
||||
public const string PackageUrlXpath = "/package/url";
|
||||
public const string PackageLicenseXpath = "/package/license";
|
||||
public const string AuthorNameXpath = "/author/name";
|
||||
public const string AuthorWebsiteXpath = "/author/website";
|
||||
public const string ReadmeXpath = "/readme";
|
||||
public const string ControlNodeName = "control";
|
||||
public const string ActionNodeName = "Action";
|
||||
public const string ActionsNodeName = "Actions";
|
||||
public const string UndoNodeAttribute = "undo";
|
||||
public const string RunatNodeAttribute = "runat";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,6 @@ namespace Umbraco.Core
|
||||
|
||||
//stop the timer and log the output
|
||||
_timer.Dispose();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -312,17 +311,15 @@ namespace Umbraco.Core
|
||||
|
||||
//the database migration objects
|
||||
MigrationResolver.Current = new MigrationResolver(
|
||||
() => PluginManager.Current.ResolveMigrationTypes());
|
||||
() => PluginManager.Current.ResolveTypes<IMigration>());
|
||||
|
||||
// todo: remove once we drop IPropertyEditorValueConverter support.
|
||||
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
|
||||
PluginManager.Current.ResolvePropertyEditorValueConverters());
|
||||
|
||||
//add the internal ones, these are not public currently so need to add them manually
|
||||
PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver(
|
||||
PluginManager.Current.ResolvePropertyValueConverters());
|
||||
// fixme - why not use the following syntax?
|
||||
//PluginManager.Current.ResolveTypes<IPropertyValueConverter>());
|
||||
// need to filter out the ones we dont want!!
|
||||
PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver(
|
||||
PluginManager.Current.ResolveTypes<IPropertyValueConverter>());
|
||||
|
||||
// use the new DefaultShortStringHelper
|
||||
ShortStringHelperResolver.Current = new ShortStringHelperResolver(
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Configuration;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
@@ -435,6 +436,13 @@ namespace Umbraco.Core
|
||||
|
||||
if (_result == null)
|
||||
{
|
||||
|
||||
if (SystemUtilities.GetCurrentTrustLevel() != AspNetHostingPermissionLevel.Unrestricted
|
||||
&& ProviderName == "MySql.Data.MySqlClient")
|
||||
{
|
||||
throw new InvalidOperationException("Cannot use MySql in Medium Trust configuration");
|
||||
}
|
||||
|
||||
var database = new UmbracoDatabase(_connectionString, ProviderName);
|
||||
var dbSchema = new DatabaseSchemaCreation(database);
|
||||
_result = dbSchema.ValidateSchema();
|
||||
@@ -443,15 +451,15 @@ namespace Umbraco.Core
|
||||
}
|
||||
|
||||
internal Result CreateDatabaseSchemaAndData()
|
||||
{
|
||||
var readyForInstall = CheckReadyForInstall();
|
||||
if (readyForInstall.Success == false)
|
||||
{
|
||||
return readyForInstall.Result;
|
||||
}
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
var readyForInstall = CheckReadyForInstall();
|
||||
if (readyForInstall.Success == false)
|
||||
{
|
||||
return readyForInstall.Result;
|
||||
}
|
||||
|
||||
LogHelper.Info<DatabaseContext>("Database configuration status: Started");
|
||||
|
||||
string message;
|
||||
@@ -509,14 +517,15 @@ namespace Umbraco.Core
|
||||
/// <returns></returns>
|
||||
internal Result UpgradeSchemaAndData()
|
||||
{
|
||||
var readyForInstall = CheckReadyForInstall();
|
||||
if (readyForInstall.Success == false)
|
||||
{
|
||||
return readyForInstall.Result;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var readyForInstall = CheckReadyForInstall();
|
||||
if (readyForInstall.Success == false)
|
||||
{
|
||||
return readyForInstall.Result;
|
||||
}
|
||||
|
||||
LogHelper.Info<DatabaseContext>("Database upgrade started");
|
||||
|
||||
var database = new UmbracoDatabase(_connectionString, ProviderName);
|
||||
@@ -529,11 +538,11 @@ namespace Umbraco.Core
|
||||
|
||||
//DO the upgrade!
|
||||
|
||||
var configuredVersion = string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus)
|
||||
var currentVersion = string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus)
|
||||
? installedVersion
|
||||
: new Version(GlobalSettings.ConfigurationStatus);
|
||||
var targetVersion = UmbracoVersion.Current;
|
||||
var runner = new MigrationRunner(configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName);
|
||||
var runner = new MigrationRunner(currentVersion, targetVersion, GlobalSettings.UmbracoMigrationName);
|
||||
var upgraded = runner.Execute(database, true);
|
||||
message = message + "<p>Upgrade completed!</p>";
|
||||
|
||||
@@ -576,6 +585,12 @@ namespace Umbraco.Core
|
||||
|
||||
private Attempt<Result> CheckReadyForInstall()
|
||||
{
|
||||
if (SystemUtilities.GetCurrentTrustLevel() != AspNetHostingPermissionLevel.Unrestricted
|
||||
&& ProviderName == "MySql.Data.MySqlClient")
|
||||
{
|
||||
throw new InvalidOperationException("Cannot use MySql in Medium Trust configuration");
|
||||
}
|
||||
|
||||
if (_configured == false || (string.IsNullOrEmpty(_connectionString) || string.IsNullOrEmpty(ProviderName)))
|
||||
{
|
||||
return Attempt.Fail(new Result
|
||||
@@ -591,7 +606,7 @@ namespace Umbraco.Core
|
||||
|
||||
private Result HandleInstallException(Exception ex)
|
||||
{
|
||||
LogHelper.Info<DatabaseContext>("Database configuration failed with the following error and stack trace: " + ex.Message + "\n" + ex.StackTrace);
|
||||
LogHelper.Error<DatabaseContext>("Database configuration failed", ex);
|
||||
|
||||
if (_result != null)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
@@ -14,7 +15,7 @@ namespace Umbraco.Core
|
||||
public static IEnumerable<IEnumerable<T>> InGroupsOf<T>(this IEnumerable<T> source, int groupSize)
|
||||
{
|
||||
if (source == null)
|
||||
throw new NullReferenceException("source");
|
||||
throw new NullReferenceException("source");
|
||||
|
||||
// enumerate the source only once!
|
||||
return new InGroupsEnumerator<T>(source, groupSize).Groups();
|
||||
@@ -125,23 +126,13 @@ namespace Umbraco.Core
|
||||
}
|
||||
|
||||
/// <summary>The flatten list.</summary>
|
||||
/// <param name="items">The items.</param>
|
||||
/// <param name="selectChild">The select child.</param>
|
||||
/// <typeparam name="TItem">Item type</typeparam>
|
||||
/// <param name="e">The items.</param>
|
||||
/// <param name="f">The select child.</param>
|
||||
/// <typeparam name="T">Item type</typeparam>
|
||||
/// <returns>list of TItem</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "By design")]
|
||||
public static IEnumerable<TItem> FlattenList<TItem>(this IEnumerable<TItem> items, Func<TItem, IEnumerable<TItem>> selectChild)
|
||||
public static IEnumerable<T> FlattenList<T>(this IEnumerable<T> e, Func<T, IEnumerable<T>> f)
|
||||
{
|
||||
IEnumerable<TItem> children = items != null && items.Any()
|
||||
? items.SelectMany(selectChild).FlattenList(selectChild)
|
||||
: Enumerable.Empty<TItem>();
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
return items.Concat(children);
|
||||
}
|
||||
|
||||
return null;
|
||||
return e.SelectMany(c => f(c).FlattenList(f)).Concat(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to notify the TypeFinder to ignore any class attributed with this during it's discovery
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class HideFromTypeFinderAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -206,11 +206,10 @@ namespace Umbraco.Core.IO
|
||||
var fileNameThumb = string.IsNullOrWhiteSpace(fileNameAddition)
|
||||
? string.Format("{0}_UMBRACOSYSTHUMBNAIL.jpg", Path.Substring(0, Path.LastIndexOf(".", StringComparison.Ordinal)))
|
||||
: string.Format("{0}_{1}.jpg", Path.Substring(0, Path.LastIndexOf(".", StringComparison.Ordinal)), fileNameAddition);
|
||||
|
||||
|
||||
var thumbnail = maxWidthHeight == -1
|
||||
?ImageHelper.GenerateThumbnail(image, maxWidthHeight, fileNameThumb, Extension, _fs)
|
||||
: ImageHelper.GenerateThumbnail(image, width, height, fileNameThumb, Extension, _fs);
|
||||
|
||||
var thumbnail = maxWidthHeight == -1
|
||||
? ImageHelper.GenerateThumbnail(image, width, height, fileNameThumb, Extension, _fs)
|
||||
: ImageHelper.GenerateThumbnail(image, maxWidthHeight, fileNameThumb, Extension, _fs);
|
||||
|
||||
return thumbnail.FileName;
|
||||
}
|
||||
|
||||
@@ -15,65 +15,104 @@ namespace Umbraco.Core.Models
|
||||
public class Member : ContentBase, IMember
|
||||
{
|
||||
private readonly IMemberType _contentType;
|
||||
private string _contentTypeAlias;
|
||||
private readonly string _contentTypeAlias;
|
||||
private string _username;
|
||||
private string _email;
|
||||
private string _password;
|
||||
private string _rawPasswordValue;
|
||||
private object _providerUserKey;
|
||||
private Type _userTypeKey;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for creating an empty Member object
|
||||
/// </summary>
|
||||
/// <param name="contentType">ContentType for the current Content object</param>
|
||||
public Member(IMemberType contentType)
|
||||
: base("", -1, contentType, new PropertyCollection())
|
||||
{
|
||||
Mandate.ParameterNotNull(contentType, "contentType");
|
||||
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
_contentType = contentType;
|
||||
IsApproved = true;
|
||||
|
||||
//this cannot be null but can be empty
|
||||
_rawPasswordValue = "";
|
||||
_email = "";
|
||||
_username = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for creating a Member object
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the content</param>
|
||||
/// <param name="contentType">ContentType for the current Content object</param>
|
||||
public Member(string name, IMemberType contentType)
|
||||
: this(contentType)
|
||||
{
|
||||
Mandate.ParameterNotNull(contentType, "contentType");
|
||||
Mandate.ParameterNotNullOrEmpty(name, "name");
|
||||
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
_contentType = contentType;
|
||||
IsApproved = true;
|
||||
|
||||
//this cannot be null but can be empty
|
||||
_rawPasswordValue = "";
|
||||
_email = "";
|
||||
_username = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for creating a Member object
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="email"></param>
|
||||
/// <param name="username"></param>
|
||||
/// <param name="contentType"></param>
|
||||
public Member(string name, string email, string username, IMemberType contentType)
|
||||
: base(name, -1, contentType, new PropertyCollection())
|
||||
{
|
||||
_contentType = contentType;
|
||||
IsApproved = true;
|
||||
}
|
||||
|
||||
//TODO: Should we just get rid of this one? no reason to have a level set.
|
||||
internal Member(string name, string email, string username, string password, int parentId, IMemberType contentType)
|
||||
: base(name, parentId, contentType, new PropertyCollection())
|
||||
{
|
||||
Mandate.ParameterNotNull(contentType, "contentType");
|
||||
Mandate.ParameterNotNullOrEmpty(name, "name");
|
||||
Mandate.ParameterNotNullOrEmpty(email, "email");
|
||||
Mandate.ParameterNotNullOrEmpty(username, "username");
|
||||
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
_contentType = contentType;
|
||||
_email = email;
|
||||
_username = username;
|
||||
_password = password;
|
||||
IsApproved = true;
|
||||
|
||||
//this cannot be null but can be empty
|
||||
_rawPasswordValue = "";
|
||||
}
|
||||
|
||||
public Member(string name, string email, string username, string password, IMemberType contentType)
|
||||
: this(name, email, username, password, -1, contentType)
|
||||
/// <summary>
|
||||
/// Constructor for creating a Member object
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="email"></param>
|
||||
/// <param name="username"></param>
|
||||
/// <param name="rawPasswordValue">
|
||||
/// The password value passed in to this parameter should be the encoded/encrypted/hashed format of the member's password
|
||||
/// </param>
|
||||
/// <param name="contentType"></param>
|
||||
public Member(string name, string email, string username, string rawPasswordValue, IMemberType contentType)
|
||||
: base(name, -1, contentType, new PropertyCollection())
|
||||
{
|
||||
Mandate.ParameterNotNull(contentType, "contentType");
|
||||
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
_contentType = contentType;
|
||||
_email = email;
|
||||
_username = username;
|
||||
_password = password;
|
||||
_rawPasswordValue = rawPasswordValue;
|
||||
IsApproved = true;
|
||||
}
|
||||
|
||||
//public Member(string name, string email, string username, string password, IContentBase parent, IMemberType contentType)
|
||||
// : base(name, parent, contentType, new PropertyCollection())
|
||||
//{
|
||||
// Mandate.ParameterNotNull(contentType, "contentType");
|
||||
|
||||
// _contentType = contentType;
|
||||
// _email = email;
|
||||
// _username = username;
|
||||
// _password = password;
|
||||
//}
|
||||
|
||||
private static readonly PropertyInfo DefaultContentTypeAliasSelector = ExpressionHelper.GetPropertyInfo<Member, string>(x => x.ContentTypeAlias);
|
||||
private static readonly PropertyInfo UsernameSelector = ExpressionHelper.GetPropertyInfo<Member, string>(x => x.Username);
|
||||
private static readonly PropertyInfo EmailSelector = ExpressionHelper.GetPropertyInfo<Member, string>(x => x.Email);
|
||||
private static readonly PropertyInfo PasswordSelector = ExpressionHelper.GetPropertyInfo<Member, string>(x => x.Password);
|
||||
private static readonly PropertyInfo PasswordSelector = ExpressionHelper.GetPropertyInfo<Member, string>(x => x.RawPasswordValue);
|
||||
private static readonly PropertyInfo ProviderUserKeySelector = ExpressionHelper.GetPropertyInfo<Member, object>(x => x.ProviderUserKey);
|
||||
private static readonly PropertyInfo UserTypeKeySelector = ExpressionHelper.GetPropertyInfo<Member, Type>(x => x.ProviderUserKeyType);
|
||||
|
||||
@@ -112,19 +151,19 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Password
|
||||
/// Gets or sets the raw password value
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string Password
|
||||
public string RawPasswordValue
|
||||
{
|
||||
get { return _password; }
|
||||
get { return _rawPasswordValue; }
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_password = value;
|
||||
return _password;
|
||||
}, _password, PasswordSelector);
|
||||
_rawPasswordValue = value;
|
||||
return _rawPasswordValue;
|
||||
}, _rawPasswordValue, PasswordSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,14 +207,16 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Password Answer
|
||||
/// Gets or sets the raw password answer value
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For security reasons this value should be encrypted, the encryption process is handled by the memberhip provider
|
||||
/// Alias: umbracoMemberPasswordRetrievalAnswer
|
||||
///
|
||||
/// Part of the standard properties collection.
|
||||
/// </remarks>
|
||||
[IgnoreDataMember]
|
||||
public string PasswordAnswer
|
||||
public string RawPasswordAnswerValue
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -433,14 +474,6 @@ namespace Umbraco.Core.Models
|
||||
public virtual string ContentTypeAlias
|
||||
{
|
||||
get { return _contentTypeAlias; }
|
||||
internal set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_contentTypeAlias = value;
|
||||
return _contentTypeAlias;
|
||||
}, _contentTypeAlias, DefaultContentTypeAliasSelector);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -44,7 +44,9 @@ namespace Umbraco.Core.Models
|
||||
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_alias = value == "_umbracoSystemDefaultProtectType" ? value : value.ToSafeAlias();
|
||||
_alias = value == "_umbracoSystemDefaultProtectType"
|
||||
? value
|
||||
: (value == null ? string.Empty : value.ToSafeAlias() );
|
||||
return _alias;
|
||||
}, _alias, AliasSelector);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,19 @@ namespace Umbraco.Core.Models.Membership
|
||||
object ProviderUserKey { get; set; }
|
||||
string Username { get; set; }
|
||||
string Email { get; set; }
|
||||
string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the raw password value
|
||||
/// </summary>
|
||||
string RawPasswordValue { get; set; }
|
||||
|
||||
string PasswordQuestion { get; set; }
|
||||
string PasswordAnswer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the raw password answer value
|
||||
/// </summary>
|
||||
string RawPasswordAnswerValue { get; set; }
|
||||
|
||||
string Comments { get; set; }
|
||||
bool IsApproved { get; set; }
|
||||
bool IsLockedOut { get; set; }
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Umbraco.Core.Services
|
||||
namespace Umbraco.Core.Models.Membership
|
||||
{
|
||||
/// <summary>
|
||||
/// The types of members to count
|
||||
+4
-2
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.Models.Membership
|
||||
{
|
||||
internal static class MembershipExtensions
|
||||
internal static class MembershipUserExtensions
|
||||
{
|
||||
internal static UmbracoMembershipMember AsConcreteMembershipUser(this IMembershipUser member, string providerName)
|
||||
{
|
||||
@@ -32,7 +33,8 @@ namespace Umbraco.Core.Models.Membership
|
||||
{
|
||||
if (_scenario.HasValue == false)
|
||||
{
|
||||
if (System.Web.Security.Membership.Provider.Name == Constants.Conventions.Member.UmbracoMemberProviderName)
|
||||
var provider = MembershipProviderExtensions.GetMembersMembershipProvider();
|
||||
if (provider.IsUmbracoMembershipProvider())
|
||||
{
|
||||
return MembershipScenario.NativeUmbraco;
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
if (userType == null) throw new ArgumentNullException("userType");
|
||||
|
||||
_userType = userType;
|
||||
_defaultPermissions = _userType.Permissions;
|
||||
//Groups = new List<object> { userType };
|
||||
SessionTimeout = 60;
|
||||
_sectionCollection = new ObservableCollection<string>();
|
||||
@@ -38,15 +39,17 @@ namespace Umbraco.Core.Models.Membership
|
||||
_isLockedOut = false;
|
||||
_startContentId = -1;
|
||||
_startMediaId = -1;
|
||||
//cannot be null
|
||||
_rawPasswordValue = "";
|
||||
}
|
||||
|
||||
public User(string name, string email, string username, string password, IUserType userType)
|
||||
public User(string name, string email, string username, string rawPasswordValue, IUserType userType)
|
||||
: this(userType)
|
||||
{
|
||||
_name = name;
|
||||
_email = email;
|
||||
_username = username;
|
||||
_password = password;
|
||||
_rawPasswordValue = rawPasswordValue;
|
||||
_isApproved = true;
|
||||
_isLockedOut = false;
|
||||
_startContentId = -1;
|
||||
@@ -67,7 +70,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
|
||||
private string _username;
|
||||
private string _email;
|
||||
private string _password;
|
||||
private string _rawPasswordValue;
|
||||
private bool _isApproved;
|
||||
private bool _isLockedOut;
|
||||
private string _language;
|
||||
@@ -84,7 +87,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
|
||||
private static readonly PropertyInfo UsernameSelector = ExpressionHelper.GetPropertyInfo<User, string>(x => x.Username);
|
||||
private static readonly PropertyInfo EmailSelector = ExpressionHelper.GetPropertyInfo<User, string>(x => x.Email);
|
||||
private static readonly PropertyInfo PasswordSelector = ExpressionHelper.GetPropertyInfo<User, string>(x => x.Password);
|
||||
private static readonly PropertyInfo PasswordSelector = ExpressionHelper.GetPropertyInfo<User, string>(x => x.RawPasswordValue);
|
||||
private static readonly PropertyInfo IsLockedOutSelector = ExpressionHelper.GetPropertyInfo<User, bool>(x => x.IsLockedOut);
|
||||
private static readonly PropertyInfo IsApprovedSelector = ExpressionHelper.GetPropertyInfo<User, bool>(x => x.IsApproved);
|
||||
private static readonly PropertyInfo LanguageSelector = ExpressionHelper.GetPropertyInfo<User, string>(x => x.Language);
|
||||
@@ -204,16 +207,16 @@ namespace Umbraco.Core.Models.Membership
|
||||
}
|
||||
}
|
||||
[DataMember]
|
||||
public string Password
|
||||
public string RawPasswordValue
|
||||
{
|
||||
get { return _password; }
|
||||
get { return _rawPasswordValue; }
|
||||
set
|
||||
{
|
||||
SetPropertyValueAndDetectChanges(o =>
|
||||
{
|
||||
_password = value;
|
||||
return _password;
|
||||
}, _password, PasswordSelector);
|
||||
_rawPasswordValue = value;
|
||||
return _rawPasswordValue;
|
||||
}, _rawPasswordValue, PasswordSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +254,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
[IgnoreDataMember]
|
||||
public string PasswordQuestion { get; set; }
|
||||
[IgnoreDataMember]
|
||||
public string PasswordAnswer { get; set; }
|
||||
public string RawPasswordAnswerValue { get; set; }
|
||||
[IgnoreDataMember]
|
||||
public string Comments { get; set; }
|
||||
[IgnoreDataMember]
|
||||
|
||||
@@ -5,10 +5,17 @@
|
||||
/// </summary>
|
||||
public class PreValue
|
||||
{
|
||||
public PreValue(int id, string value, int sortOrder)
|
||||
{
|
||||
Id = id;
|
||||
Value = value;
|
||||
SortOrder = sortOrder;
|
||||
}
|
||||
|
||||
public PreValue(int id, string value)
|
||||
{
|
||||
Value = value;
|
||||
Id = id;
|
||||
Id = id;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public PreValue(string value)
|
||||
@@ -25,5 +32,10 @@
|
||||
/// The database id for the pre-value field value
|
||||
/// </summary>
|
||||
public int Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sort order stored for the pre-value field value
|
||||
/// </summary>
|
||||
public int SortOrder { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -141,9 +141,21 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
if (GetPublishedContentTypeCallback != null)
|
||||
return GetPublishedContentTypeCallback(alias);
|
||||
|
||||
var contentType = itemType == PublishedItemType.Content
|
||||
? (IContentTypeComposition) ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias)
|
||||
: (IContentTypeComposition) ApplicationContext.Current.Services.ContentTypeService.GetMediaType(alias);
|
||||
IContentTypeComposition contentType;
|
||||
switch (itemType)
|
||||
{
|
||||
case PublishedItemType.Content:
|
||||
contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias);
|
||||
break;
|
||||
case PublishedItemType.Media:
|
||||
contentType = ApplicationContext.Current.Services.ContentTypeService.GetMediaType(alias);
|
||||
break;
|
||||
case PublishedItemType.Member:
|
||||
contentType = ApplicationContext.Current.Services.MemberTypeService.Get(alias);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("itemType");
|
||||
}
|
||||
|
||||
if (contentType == null)
|
||||
throw new Exception(string.Format("ContentTypeService failed to find a {0} type with alias \"{1}\".",
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
: Enumerable.Empty<IPropertyValueConverter>();
|
||||
}
|
||||
|
||||
class CompatConverter : PropertyValueConverterBase
|
||||
private class CompatConverter : PropertyValueConverterBase
|
||||
{
|
||||
private readonly IPropertyEditorValueConverter _converter;
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// A media.
|
||||
/// </summary>
|
||||
Media
|
||||
Media,
|
||||
|
||||
/// <summary>
|
||||
/// A member.
|
||||
/// </summary>
|
||||
Member
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models.Rdbms
|
||||
internal class PreviewXmlDto
|
||||
{
|
||||
[Column("nodeId")]
|
||||
[PrimaryKeyColumn(AutoIncrement = false, Name = "", OnColumns = "nodeId, versionId")]
|
||||
[PrimaryKeyColumn(AutoIncrement = false, Name = "PK_cmsContentPreviewXml", OnColumns = "nodeId, versionId")]
|
||||
[ForeignKey(typeof(ContentDto), Column = "nodeId")]
|
||||
public int NodeId { get; set; }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Models.Rdbms
|
||||
internal class UserLoginDto
|
||||
{
|
||||
[Column("contextID")]
|
||||
[Index(IndexTypes.Clustered, Name = "umbracoUserLogins_Index")]
|
||||
[Index(IndexTypes.Clustered, Name = "IX_umbracoUserLogins_Index")]
|
||||
public Guid ContextId { get; set; }
|
||||
|
||||
[Column("userID")]
|
||||
|
||||
@@ -21,9 +21,18 @@ namespace Umbraco.Core.Models
|
||||
|
||||
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(@alias, "alias");
|
||||
_childObjectType = childObjectType;
|
||||
_parentObjectType = parentObjectType;
|
||||
_alias = alias;
|
||||
Name = _alias;
|
||||
}
|
||||
|
||||
public RelationType(Guid childObjectType, Guid parentObjectType, string @alias, string name)
|
||||
:this(childObjectType, parentObjectType, @alias)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(name, "name");
|
||||
Name = name;
|
||||
}
|
||||
|
||||
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<RelationType, string>(x => x.Name);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Core.ObjectResolution
|
||||
@@ -8,7 +9,10 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <summary>
|
||||
/// A resolver to return all IApplicationEvents objects
|
||||
/// </summary>
|
||||
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationEventHandler>
|
||||
/// <remarks>
|
||||
/// This is disposable because after the app has started it should be disposed to release any memory being occupied by instances.
|
||||
/// </remarks>
|
||||
internal sealed class ApplicationEventsResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationEventHandler>, IDisposable
|
||||
{
|
||||
|
||||
private readonly LegacyStartupHandlerResolver _legacyResolver;
|
||||
@@ -53,7 +57,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
|
||||
protected override bool SupportsClear
|
||||
{
|
||||
get { return false; }
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
protected override bool SupportsInsert
|
||||
@@ -61,7 +65,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
private class LegacyStartupHandlerResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>
|
||||
private class LegacyStartupHandlerResolver : ManyObjectsResolverBase<ApplicationEventsResolver, IApplicationStartupHandler>, IDisposable
|
||||
{
|
||||
internal LegacyStartupHandlerResolver(IEnumerable<Type> legacyStartupHandlers)
|
||||
: base(legacyStartupHandlers)
|
||||
@@ -73,7 +77,72 @@ namespace Umbraco.Core.ObjectResolution
|
||||
{
|
||||
get { return Values; }
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ResetCollections();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
private readonly ReaderWriterLockSlim _disposalLocker = new ReaderWriterLockSlim();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is disposed.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is disposed; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool IsDisposed
|
||||
{
|
||||
get { return _disposed; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
// Use SupressFinalize in case a subclass of this type implements a finalizer.
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~ApplicationEventsResolver()
|
||||
{
|
||||
// Run dispose but let the class know it was due to the finalizer running.
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
// Only operate if we haven't already disposed
|
||||
if (IsDisposed || disposing == false) return;
|
||||
|
||||
using (new WriteLock(_disposalLocker))
|
||||
{
|
||||
// Check again now we're inside the lock
|
||||
if (IsDisposed) return;
|
||||
|
||||
// Call to actually release resources. This method is only
|
||||
// kept separate so that the entire disposal logic can be used as a VS snippet
|
||||
DisposeResources();
|
||||
|
||||
// Indicate that the instance has been disposed.
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear out all of the instances, we don't want them hanging around and cluttering up memory
|
||||
/// </summary>
|
||||
private void DisposeResources()
|
||||
{
|
||||
_legacyResolver.Dispose();
|
||||
ResetCollections();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
/// <para>Important notes about this resolver: it does not support Insert or Remove and therefore does not support any ordering unless
|
||||
/// the types are marked with the WeightedPluginAttribute.</para>
|
||||
/// </remarks>
|
||||
internal abstract class LazyManyObjectsResolverBase<TResolver, TResolved> : ManyObjectsResolverBase<TResolver, TResolved>
|
||||
public abstract class LazyManyObjectsResolverBase<TResolver, TResolved> : ManyObjectsResolverBase<TResolver, TResolved>
|
||||
where TResolved : class
|
||||
where TResolver : ResolverBase
|
||||
{
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace Umbraco.Core.ObjectResolution
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the list of types.
|
||||
/// Clears the list of types
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">the resolver does not support clearing types.</exception>
|
||||
public virtual void Clear()
|
||||
@@ -336,6 +336,20 @@ namespace Umbraco.Core.ObjectResolution
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WARNING! Do not use this unless you know what you are doing, clear all types registered and instances
|
||||
/// created. Typically only used if a resolver is no longer used in an application and memory is to be GC'd
|
||||
/// </summary>
|
||||
internal void ResetCollections()
|
||||
{
|
||||
using (new WriteLock(_lock))
|
||||
{
|
||||
_instanceTypes.Clear();
|
||||
_sortedValues = null;
|
||||
_applicationInstances = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a type at the specified index.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
namespace Umbraco.Core.Packaging.Models
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
internal class InstallAction
|
||||
{
|
||||
public string Alias { get; set; }
|
||||
|
||||
public string PackageName { get; set; }
|
||||
|
||||
public string RunAt { get; set; }//NOTE Should this default to "install"
|
||||
|
||||
public bool Undo { get; set; }
|
||||
|
||||
public XmlNode XmlData { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Packaging.Models
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
internal class InstallationSummary
|
||||
{
|
||||
public MetaData MetaData { get; set; }
|
||||
public IEnumerable<int> DataTypesInstalled { get; set; }
|
||||
public IEnumerable<int> LanguagesInstalled { get; set; }
|
||||
public IEnumerable<int> DictionaryItemsInstalled { get; set; }
|
||||
public IEnumerable<int> MacrosInstalled { get; set; }
|
||||
public IEnumerable<KeyValuePair<string, bool>> FilesInstalled { get; set;}
|
||||
public IEnumerable<int> TemplatesInstalled { get; set; }
|
||||
public IEnumerable<int> DocumentTypesInstalled { get; set; }
|
||||
public IEnumerable<int> StylesheetsInstalled { get; set; }
|
||||
public IEnumerable<int> DocumentsInstalled { get; set; }
|
||||
public IEnumerable<InstallAction> InstallActions { get; set; }
|
||||
public IEnumerable<UninstallAction> UninstallActions { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Packaging.Models
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
internal class MetaData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string License { get; set; }
|
||||
public string LicenseUrl { get; set; }
|
||||
public int ReqMajor { get; set; }
|
||||
public int ReqMinor { get; set; }
|
||||
public int ReqPatch { get; set; }
|
||||
public string AuthorName { get; set; }
|
||||
public string AuthorUrl { get; set; }
|
||||
public string Readme { get; set; }
|
||||
public string Control { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
namespace Umbraco.Core.Packaging.Models
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
internal class UninstallAction
|
||||
{
|
||||
public string Alias { get; set; }
|
||||
|
||||
public string PackageName { get; set; }
|
||||
|
||||
public string RunAt { get; set; }//NOTE Should this default to "install"
|
||||
|
||||
public bool Undo { get; set; }//NOTE: Should thid default to "False"?
|
||||
|
||||
public XmlNode XmlData { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.Packaging
|
||||
{
|
||||
internal interface IPackageBuilding
|
||||
{
|
||||
}
|
||||
|
||||
internal class PackageBuilding : IPackageBuilding
|
||||
{
|
||||
private readonly PackagingService _packagingService;
|
||||
|
||||
public PackageBuilding(PackagingService packagingService)
|
||||
{
|
||||
_packagingService = packagingService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Packaging
|
||||
{
|
||||
internal interface IPackageExtraction
|
||||
{
|
||||
bool Extract(string packageFilePath, string destinationFolder);
|
||||
string ExtractToTemporaryFolder(string packageFilePath);
|
||||
string GetPackageConfigFromArchive(string packageFilePath, string fileToRead = "package.xml");
|
||||
}
|
||||
|
||||
internal class PackageExtraction : IPackageExtraction
|
||||
{
|
||||
public bool Extract(string packageFilePath, string destinationFolder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public string ExtractToTemporaryFolder(string packageFilePath)
|
||||
{
|
||||
string tempDir = Path.Combine(IOHelper.MapPath(SystemDirectories.Data), Guid.NewGuid().ToString("D"));
|
||||
Directory.CreateDirectory(tempDir);
|
||||
Extract(packageFilePath, tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
public string GetPackageConfigFromArchive(string packageFilePath, string fileToRead = "package.xml")
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Umbraco.Core.Packaging.Models;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.Packaging
|
||||
{
|
||||
internal interface IPackageInstallation
|
||||
{
|
||||
InstallationSummary InstallPackage(string packageFilePath, int userId = 0);
|
||||
MetaData GetPackageMetaData(string packageFilePath);
|
||||
}
|
||||
|
||||
internal class PackageInstallation : IPackageInstallation
|
||||
{
|
||||
private readonly PackagingService _packagingService;
|
||||
private readonly PackageExtraction _packageExtraction;
|
||||
|
||||
public PackageInstallation(PackagingService packagingService, PackageExtraction packageExtraction)
|
||||
{
|
||||
_packagingService = packagingService;
|
||||
_packageExtraction = packageExtraction;
|
||||
}
|
||||
|
||||
public InstallationSummary InstallPackage(string packageFilePath, int userId = 0)
|
||||
{
|
||||
var summary = new InstallationSummary();
|
||||
return summary;
|
||||
}
|
||||
|
||||
public MetaData GetPackageMetaData(string packageFilePath)
|
||||
{
|
||||
var metaData = new MetaData();
|
||||
return metaData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Umbraco.Core.Persistence.DatabaseModelDefinitions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a database index definition retreived by querying the database
|
||||
/// </summary>
|
||||
internal class DbIndexDefinition
|
||||
{
|
||||
public virtual string IndexName { get; set; }
|
||||
public virtual string TableName { get; set; }
|
||||
public virtual string ColumnName { get; set; }
|
||||
public virtual bool IsUnique { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
internal static class DbConnectionExtensions
|
||||
{
|
||||
|
||||
public static DatabaseProviders DetectProviderFromConnectionString(string connString)
|
||||
{
|
||||
var builder = new DbConnectionStringBuilder {ConnectionString = connString};
|
||||
var allKeys = builder.Keys.Cast<string>();
|
||||
|
||||
var mySql = new[] {"Server", "Database", "Uid", "Pwd"};
|
||||
if (mySql.All(x => allKeys.InvariantContains(x)))
|
||||
{
|
||||
return DatabaseProviders.MySql;
|
||||
}
|
||||
|
||||
if (allKeys.InvariantContains("Data Source")
|
||||
//this dictionary is case insensitive
|
||||
&& builder["Data source"].ToString().InvariantContains(".sdf"))
|
||||
{
|
||||
return DatabaseProviders.SqlServerCE;
|
||||
}
|
||||
|
||||
return DatabaseProviders.SqlServer;
|
||||
}
|
||||
|
||||
public static bool IsConnectionAvailable(string connString, DatabaseProviders provider)
|
||||
{
|
||||
DbProviderFactory factory;
|
||||
switch (provider)
|
||||
{
|
||||
case DatabaseProviders.SqlServer:
|
||||
case DatabaseProviders.SqlAzure:
|
||||
factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
|
||||
break;
|
||||
case DatabaseProviders.SqlServerCE:
|
||||
factory = DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0");
|
||||
break;
|
||||
case DatabaseProviders.MySql:
|
||||
factory = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
|
||||
break;
|
||||
case DatabaseProviders.PostgreSQL:
|
||||
case DatabaseProviders.Oracle:
|
||||
case DatabaseProviders.SQLite:
|
||||
default:
|
||||
throw new NotSupportedException("The provider " + provider + " is not supported");
|
||||
}
|
||||
|
||||
var conn = factory.CreateConnection();
|
||||
if (conn == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not create a connection for provider " + provider);
|
||||
}
|
||||
conn.ConnectionString = connString;
|
||||
using (var connection = conn)
|
||||
{
|
||||
return connection.IsAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsAvailable(this IDbConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
connection.Close();
|
||||
}
|
||||
catch (SqlException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
NodeId = entity.Id,
|
||||
Email = entity.Email,
|
||||
LoginName = entity.Username,
|
||||
Password = entity.Password,
|
||||
Password = entity.RawPasswordValue,
|
||||
ContentVersionDto = BuildDto(entity as Member)
|
||||
};
|
||||
return member;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
var properties = CreateProperties(_memberTypes[dto.ContentTypeAlias], dto.Properties, dto.CreateDate);
|
||||
|
||||
var member = new Member(dto.Text, dto.Email, dto.LoginName, dto.Password, dto.ParentId, _memberTypes[dto.ContentTypeAlias])
|
||||
var member = new Member(dto.Text, dto.Email, dto.LoginName, dto.Password, _memberTypes[dto.ContentTypeAlias])
|
||||
{
|
||||
Id = dto.NodeId,
|
||||
CreateDate = dto.CreateDate,
|
||||
@@ -33,7 +33,6 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
Path = dto.Path,
|
||||
SortOrder = dto.SortOrder,
|
||||
Version = dto.VersionId,
|
||||
ContentTypeAlias = dto.ContentTypeAlias,
|
||||
Properties = new PropertyCollection(properties)
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
Key = guidId,
|
||||
StartContentId = dto.ContentStartId,
|
||||
StartMediaId = dto.MediaStartId.HasValue ? dto.MediaStartId.Value : -1,
|
||||
Password = dto.Password,
|
||||
RawPasswordValue = dto.Password,
|
||||
Username = dto.Login,
|
||||
Name = dto.UserName,
|
||||
IsLockedOut = dto.NoConsole,
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
Email = entity.Email,
|
||||
Login = entity.Username,
|
||||
NoConsole = entity.IsLockedOut,
|
||||
Password = entity.Password,
|
||||
Password = entity.RawPasswordValue,
|
||||
UserLanguage = entity.Language,
|
||||
UserName = entity.Name,
|
||||
Type = short.Parse(entity.UserType.Id.ToString(CultureInfo.InvariantCulture)),
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
|
||||
CacheMap<Member, MemberDto>(src => src.Email, dto => dto.Email);
|
||||
CacheMap<Member, MemberDto>(src => src.Username, dto => dto.LoginName);
|
||||
CacheMap<Member, MemberDto>(src => src.Password, dto => dto.Password);
|
||||
CacheMap<Member, MemberDto>(src => src.RawPasswordValue, dto => dto.Password);
|
||||
|
||||
CacheMap<Member, PropertyDataDto>(src => src.IsApproved, dto => dto.Integer);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.IsLockedOut, dto => dto.Integer);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.Comments, dto => dto.Text);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.PasswordAnswer, dto => dto.VarChar);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.RawPasswordAnswerValue, dto => dto.VarChar);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.PasswordQuestion, dto => dto.VarChar);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.FailedPasswordAttempts, dto => dto.Integer);
|
||||
CacheMap<Member, PropertyDataDto>(src => src.LastLockoutDate, dto => dto.Date);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Tag"/> to DTO mapper used to translate the properties of the public api
|
||||
/// implementation to that of the database's DTO as sql: [tableName].[columnName].
|
||||
/// </summary>
|
||||
[MapperFor(typeof(Tag))]
|
||||
[MapperFor(typeof(ITag))]
|
||||
public sealed class TagMapper : BaseMapper
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, DtoMapModel> PropertyInfoCacheInstance = new ConcurrentDictionary<string, DtoMapModel>();
|
||||
|
||||
//NOTE: its an internal class but the ctor must be public since we're using Activator.CreateInstance to create it
|
||||
// otherwise that would fail because there is no public constructor.
|
||||
public TagMapper()
|
||||
{
|
||||
BuildMap();
|
||||
}
|
||||
|
||||
#region Overrides of BaseMapper
|
||||
|
||||
internal override ConcurrentDictionary<string, DtoMapModel> PropertyInfoCache
|
||||
{
|
||||
get { return PropertyInfoCacheInstance; }
|
||||
}
|
||||
|
||||
internal override void BuildMap()
|
||||
{
|
||||
if (PropertyInfoCache.IsEmpty)
|
||||
{
|
||||
CacheMap<Tag, TagDto>(src => src.Id, dto => dto.Id);
|
||||
CacheMap<Tag, TagDto>(src => src.Text, dto => dto.Tag);
|
||||
CacheMap<Tag, TagDto>(src => src.Group, dto => dto.Group);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<User, UserDto>(src => src.Id, dto => dto.Id);
|
||||
CacheMap<User, UserDto>(src => src.Email, dto => dto.Email);
|
||||
CacheMap<User, UserDto>(src => src.Username, dto => dto.Login);
|
||||
CacheMap<User, UserDto>(src => src.Password, dto => dto.Password);
|
||||
CacheMap<User, UserDto>(src => src.RawPasswordValue, dto => dto.Password);
|
||||
CacheMap<User, UserDto>(src => src.Name, dto => dto.UserName);
|
||||
//NOTE: This column in the db is *not* used!
|
||||
//CacheMap<User, UserDto>(src => src.DefaultPermissions, dto => dto.DefaultPermissions);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// Used if a migration has executed but the whole process has failed and cannot be rolled back
|
||||
/// </summary>
|
||||
internal class DataLossException : Exception
|
||||
{
|
||||
public DataLossException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DataLossException(string msg, Exception inner)
|
||||
: base(msg, inner)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,67 +124,60 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
{
|
||||
var result = new DatabaseSchemaResult();
|
||||
|
||||
//get the db index defs
|
||||
result.DbIndexDefinitions = SqlSyntaxContext.SqlSyntaxProvider.GetDefinedIndexes(_database)
|
||||
.Select(x => new DbIndexDefinition()
|
||||
{
|
||||
TableName = x.Item1,
|
||||
IndexName = x.Item2,
|
||||
ColumnName = x.Item3,
|
||||
IsUnique = x.Item4
|
||||
}).ToArray();
|
||||
|
||||
foreach (var item in OrderedTables.OrderBy(x => x.Key))
|
||||
{
|
||||
var tableDefinition = DefinitionFactory.GetTableDefinition(item.Value);
|
||||
result.TableDefinitions.Add(tableDefinition);
|
||||
}
|
||||
|
||||
//Check tables in configured database against tables in schema
|
||||
var tablesInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetTablesInSchema(_database).ToList();
|
||||
var tablesInSchema = result.TableDefinitions.Select(x => x.Name).ToList();
|
||||
//Add valid and invalid table differences to the result object
|
||||
var validTableDifferences = tablesInDatabase.Intersect(tablesInSchema);
|
||||
foreach (var tableName in validTableDifferences)
|
||||
{
|
||||
result.ValidTables.Add(tableName);
|
||||
}
|
||||
var invalidTableDifferences =
|
||||
tablesInDatabase.Except(tablesInSchema)
|
||||
.Union(tablesInSchema.Except(tablesInDatabase));
|
||||
foreach (var tableName in invalidTableDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Table", tableName));
|
||||
}
|
||||
ValidateDbTables(result);
|
||||
|
||||
//Check columns in configured database against columns in schema
|
||||
var columnsInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetColumnsInSchema(_database);
|
||||
var columnsPerTableInDatabase = columnsInDatabase.Select(x => string.Concat(x.TableName, ",", x.ColumnName)).ToList();
|
||||
var columnsPerTableInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => string.Concat(y.TableName, ",", y.Name))).ToList();
|
||||
//Add valid and invalid column differences to the result object
|
||||
var validColumnDifferences = columnsPerTableInDatabase.Intersect(columnsPerTableInSchema);
|
||||
foreach (var column in validColumnDifferences)
|
||||
{
|
||||
result.ValidColumns.Add(column);
|
||||
}
|
||||
var invalidColumnDifferences = columnsPerTableInDatabase.Except(columnsPerTableInSchema);
|
||||
foreach (var column in invalidColumnDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Column", column));
|
||||
}
|
||||
ValidateDbColumns(result);
|
||||
|
||||
ValidateDbIndexes(result);
|
||||
|
||||
ValidateDbConstraints(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ValidateDbConstraints(DatabaseSchemaResult result)
|
||||
{
|
||||
//MySql doesn't conform to the "normal" naming of constraints, so there is currently no point in doing these checks.
|
||||
//NOTE: At a later point we do other checks for MySql, but ideally it should be necessary to do special checks for different providers.
|
||||
//TODO: At a later point we do other checks for MySql, but ideally it should be necessary to do special checks for different providers.
|
||||
// ALso note that to get the constraints for MySql we have to open a connection which we currently have not.
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider is MySqlSyntaxProvider)
|
||||
return result;
|
||||
return;
|
||||
|
||||
//Check constraints in configured database against constraints in schema
|
||||
var constraintsInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetConstraintsPerColumn(_database).DistinctBy(x => x.Item3).ToList();
|
||||
var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.StartsWith("FK_")).Select(x => x.Item3).ToList();
|
||||
var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.StartsWith("PK_")).Select(x => x.Item3).ToList();
|
||||
var indexesInDatabase = constraintsInDatabase.Where(x => x.Item3.StartsWith("IX_")).Select(x => x.Item3).ToList();
|
||||
var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("FK_")).Select(x => x.Item3).ToList();
|
||||
var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("PK_")).Select(x => x.Item3).ToList();
|
||||
var indexesInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("IX_")).Select(x => x.Item3).ToList();
|
||||
var indexesInSchema = result.TableDefinitions.SelectMany(x => x.Indexes.Select(y => y.Name)).ToList();
|
||||
var unknownConstraintsInDatabase =
|
||||
constraintsInDatabase.Where(
|
||||
x =>
|
||||
x.Item3.StartsWith("FK_") == false && x.Item3.StartsWith("PK_") == false &&
|
||||
x.Item3.StartsWith("IX_") == false).Select(x => x.Item3).ToList();
|
||||
x.Item3.InvariantStartsWith("FK_") == false && x.Item3.InvariantStartsWith("PK_") == false &&
|
||||
x.Item3.InvariantStartsWith("IX_") == false).Select(x => x.Item3).ToList();
|
||||
var foreignKeysInSchema = result.TableDefinitions.SelectMany(x => x.ForeignKeys.Select(y => y.Name)).ToList();
|
||||
var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName)).ToList();
|
||||
var indexesInSchema = result.TableDefinitions.SelectMany(x => x.Indexes.Select(y => y.Name)).ToList();
|
||||
var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName))
|
||||
.Where(x => x.IsNullOrWhiteSpace() == false).ToList();
|
||||
|
||||
//Add valid and invalid foreign key differences to the result object
|
||||
foreach (var unknown in unknownConstraintsInDatabase)
|
||||
{
|
||||
if (foreignKeysInSchema.Contains(unknown) || primaryKeysInSchema.Contains(unknown) || indexesInSchema.Contains(unknown))
|
||||
if (foreignKeysInSchema.InvariantContains(unknown) || primaryKeysInSchema.InvariantContains(unknown) || indexesInSchema.InvariantContains(unknown))
|
||||
{
|
||||
result.ValidConstraints.Add(unknown);
|
||||
}
|
||||
@@ -193,40 +186,122 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
result.Errors.Add(new Tuple<string, string>("Unknown", unknown));
|
||||
}
|
||||
}
|
||||
var validForeignKeyDifferences = foreignKeysInDatabase.Intersect(foreignKeysInSchema);
|
||||
|
||||
//Foreign keys:
|
||||
|
||||
var validForeignKeyDifferences = foreignKeysInDatabase.Intersect(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var foreignKey in validForeignKeyDifferences)
|
||||
{
|
||||
result.ValidConstraints.Add(foreignKey);
|
||||
}
|
||||
var invalidForeignKeyDifferences = foreignKeysInDatabase.Except(foreignKeysInSchema);
|
||||
var invalidForeignKeyDifferences =
|
||||
foreignKeysInDatabase.Except(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Union(foreignKeysInSchema.Except(foreignKeysInDatabase, StringComparer.InvariantCultureIgnoreCase));
|
||||
foreach (var foreignKey in invalidForeignKeyDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Constraint", foreignKey));
|
||||
}
|
||||
|
||||
|
||||
//Primary keys:
|
||||
|
||||
//Add valid and invalid primary key differences to the result object
|
||||
var validPrimaryKeyDifferences = primaryKeysInDatabase.Intersect(primaryKeysInSchema);
|
||||
var validPrimaryKeyDifferences = primaryKeysInDatabase.Intersect(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var primaryKey in validPrimaryKeyDifferences)
|
||||
{
|
||||
result.ValidConstraints.Add(primaryKey);
|
||||
}
|
||||
var invalidPrimaryKeyDifferences = primaryKeysInDatabase.Except(primaryKeysInSchema);
|
||||
var invalidPrimaryKeyDifferences =
|
||||
primaryKeysInDatabase.Except(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Union(primaryKeysInSchema.Except(primaryKeysInDatabase, StringComparer.InvariantCultureIgnoreCase));
|
||||
foreach (var primaryKey in invalidPrimaryKeyDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Constraint", primaryKey));
|
||||
}
|
||||
|
||||
//Constaints:
|
||||
|
||||
//NOTE: SD: The colIndex checks above should really take care of this but I need to keep this here because it was here before
|
||||
// and some schema validation checks might rely on this data remaining here!
|
||||
//Add valid and invalid index differences to the result object
|
||||
var validIndexDifferences = indexesInDatabase.Intersect(indexesInSchema);
|
||||
var validIndexDifferences = indexesInDatabase.Intersect(indexesInSchema, StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var index in validIndexDifferences)
|
||||
{
|
||||
result.ValidConstraints.Add(index);
|
||||
}
|
||||
var invalidIndexDifferences = indexesInDatabase.Except(indexesInSchema);
|
||||
var invalidIndexDifferences =
|
||||
indexesInDatabase.Except(indexesInSchema, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Union(indexesInSchema.Except(indexesInDatabase, StringComparer.InvariantCultureIgnoreCase));
|
||||
foreach (var index in invalidIndexDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Constraint", index));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
private void ValidateDbColumns(DatabaseSchemaResult result)
|
||||
{
|
||||
//Check columns in configured database against columns in schema
|
||||
var columnsInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetColumnsInSchema(_database);
|
||||
var columnsPerTableInDatabase = columnsInDatabase.Select(x => string.Concat(x.TableName, ",", x.ColumnName)).ToList();
|
||||
var columnsPerTableInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => string.Concat(y.TableName, ",", y.Name))).ToList();
|
||||
//Add valid and invalid column differences to the result object
|
||||
var validColumnDifferences = columnsPerTableInDatabase.Intersect(columnsPerTableInSchema, StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var column in validColumnDifferences)
|
||||
{
|
||||
result.ValidColumns.Add(column);
|
||||
}
|
||||
|
||||
var invalidColumnDifferences =
|
||||
columnsPerTableInDatabase.Except(columnsPerTableInSchema, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Union(columnsPerTableInSchema.Except(columnsPerTableInDatabase, StringComparer.InvariantCultureIgnoreCase));
|
||||
foreach (var column in invalidColumnDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Column", column));
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateDbTables(DatabaseSchemaResult result)
|
||||
{
|
||||
//Check tables in configured database against tables in schema
|
||||
var tablesInDatabase = SqlSyntaxContext.SqlSyntaxProvider.GetTablesInSchema(_database).ToList();
|
||||
var tablesInSchema = result.TableDefinitions.Select(x => x.Name).ToList();
|
||||
//Add valid and invalid table differences to the result object
|
||||
var validTableDifferences = tablesInDatabase.Intersect(tablesInSchema, StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var tableName in validTableDifferences)
|
||||
{
|
||||
result.ValidTables.Add(tableName);
|
||||
}
|
||||
|
||||
var invalidTableDifferences =
|
||||
tablesInDatabase.Except(tablesInSchema, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Union(tablesInSchema.Except(tablesInDatabase, StringComparer.InvariantCultureIgnoreCase));
|
||||
foreach (var tableName in invalidTableDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Table", tableName));
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateDbIndexes(DatabaseSchemaResult result)
|
||||
{
|
||||
//These are just column indexes NOT constraints or Keys
|
||||
//var colIndexesInDatabase = result.DbIndexDefinitions.Where(x => x.IndexName.InvariantStartsWith("IX_")).Select(x => x.IndexName).ToList();
|
||||
var colIndexesInDatabase = result.DbIndexDefinitions.Select(x => x.IndexName).ToList();
|
||||
var indexesInSchema = result.TableDefinitions.SelectMany(x => x.Indexes.Select(y => y.Name)).ToList();
|
||||
|
||||
//Add valid and invalid index differences to the result object
|
||||
var validColIndexDifferences = colIndexesInDatabase.Intersect(indexesInSchema, StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var index in validColIndexDifferences)
|
||||
{
|
||||
result.ValidIndexes.Add(index);
|
||||
}
|
||||
|
||||
var invalidColIndexDifferences =
|
||||
colIndexesInDatabase.Except(indexesInSchema, StringComparer.InvariantCultureIgnoreCase)
|
||||
.Union(indexesInSchema.Except(colIndexesInDatabase, StringComparer.InvariantCultureIgnoreCase));
|
||||
foreach (var index in invalidColIndexDifferences)
|
||||
{
|
||||
result.Errors.Add(new Tuple<string, string>("Index", index));
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -17,6 +17,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
ValidTables = new List<string>();
|
||||
ValidColumns = new List<string>();
|
||||
ValidConstraints = new List<string>();
|
||||
ValidIndexes = new List<string>();
|
||||
}
|
||||
|
||||
public List<Tuple<string, string>> Errors { get; set; }
|
||||
@@ -29,6 +30,10 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
public List<string> ValidConstraints { get; set; }
|
||||
|
||||
public List<string> ValidIndexes { get; set; }
|
||||
|
||||
internal IEnumerable<DbIndexDefinition> DbIndexDefinitions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines the version of the currently installed database.
|
||||
/// </summary>
|
||||
@@ -39,43 +44,53 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
public Version DetermineInstalledVersion()
|
||||
{
|
||||
//If (ValidTables.Count == 0) database is empty and we return -> new Version(0, 0, 0);
|
||||
if(ValidTables.Count == 0)
|
||||
if (ValidTables.Count == 0)
|
||||
return new Version(0, 0, 0);
|
||||
|
||||
//If Errors is empty or if TableDefinitions tables + columns correspond to valid tables + columns then we're at current version
|
||||
if (!Errors.Any() ||
|
||||
if (Errors.Any() == false ||
|
||||
(TableDefinitions.All(x => ValidTables.Contains(x.Name))
|
||||
&& TableDefinitions.SelectMany(definition => definition.Columns).All(x => ValidColumns.Contains(x.Name))))
|
||||
return UmbracoVersion.Current;
|
||||
|
||||
//If Errors contains umbracoApp or umbracoAppTree its pre-6.0.0 -> new Version(4, 10, 0);
|
||||
if (Errors.Any(x => x.Item1.Equals("Table") && (x.Item2.Equals("umbracoApp") || x.Item2.Equals("umbracoAppTree"))))
|
||||
if (Errors.Any(x => x.Item1.Equals("Table") && (x.Item2.InvariantEquals("umbracoApp") || x.Item2.InvariantEquals("umbracoAppTree"))))
|
||||
{
|
||||
//If Errors contains umbracoUser2app or umbracoAppTree foreignkey to umbracoApp exists its pre-4.8.0 -> new Version(4, 7, 0);
|
||||
if (Errors.Any(x =>
|
||||
x.Item1.Equals("Constraint")
|
||||
&& (x.Item2.Contains("umbracoUser2app_umbracoApp")
|
||||
|| x.Item2.Contains("umbracoAppTree_umbracoApp"))))
|
||||
&& (x.Item2.InvariantContains("umbracoUser2app_umbracoApp")
|
||||
|| x.Item2.InvariantContains("umbracoAppTree_umbracoApp"))))
|
||||
{
|
||||
return new Version(4, 7, 0);
|
||||
}
|
||||
|
||||
return new Version(4, 9, 0);
|
||||
}
|
||||
|
||||
|
||||
//if the error is for umbracoServer
|
||||
if (Errors.Any(x => x.Item1.Equals("Table") && (x.Item2.Equals("umbracoServer"))))
|
||||
if (Errors.Any(x => x.Item1.Equals("Table") && (x.Item2.InvariantEquals("umbracoServer"))))
|
||||
{
|
||||
return new Version(6, 0, 0);
|
||||
}
|
||||
|
||||
//if the error indicates a problem with the column cmsMacroProperty.macroPropertyType then it is not version 7 and the
|
||||
// last db change we made was the umbracoServer in 6.1
|
||||
if (Errors.Any(x => x.Item1.Equals("Column") && (x.Item2.Equals("cmsMacroProperty,macroPropertyType"))))
|
||||
//if the error indicates a problem with the column cmsMacroProperty.macroPropertyType then it is not version 7
|
||||
// since these columns get removed in v7
|
||||
if (Errors.Any(x => x.Item1.Equals("Column") && (x.Item2.InvariantEquals("cmsMacroProperty,macroPropertyType"))))
|
||||
{
|
||||
return new Version(6, 1, 0);
|
||||
//if the error is for this IX_umbracoNodeTrashed which is added in 6.2 AND in 7.1 but we do not have the above columns
|
||||
// then it must mean that we aren't on 6.2 so must be 6.1
|
||||
if (Errors.Any(x => x.Item1.Equals("Index") && (x.Item2.InvariantEquals("IX_umbracoNodeTrashed"))))
|
||||
{
|
||||
return new Version(6, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if there are no errors for that index, then the person must have 6.2 installed
|
||||
return new Version(6, 2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return UmbracoVersion.Current;
|
||||
}
|
||||
|
||||
@@ -113,6 +128,13 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
sb.AppendLine(string.Join(",", Errors.Where(x => x.Item1.Equals("Constraint")).Select(x => x.Item2)));
|
||||
sb.AppendLine(" ");
|
||||
}
|
||||
//Index error summary
|
||||
if (Errors.Any(x => x.Item1.Equals("Index")))
|
||||
{
|
||||
sb.AppendLine("The following indexes were found in the database, but are not in the current schema:");
|
||||
sb.AppendLine(string.Join(",", Errors.Where(x => x.Item1.Equals("Index")).Select(x => x.Item2)));
|
||||
sb.AppendLine(" ");
|
||||
}
|
||||
//Unknown constraint error summary
|
||||
if (Errors.Any(x => x.Item1.Equals("Unknown")))
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
/// Represents the Migration attribute, which is used to mark classes as
|
||||
/// database migrations with Up/Down methods for pushing changes UP or pulling them DOWN.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class MigrationAttribute : Attribute
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class MigrationAttribute : Attribute
|
||||
{
|
||||
public MigrationAttribute(string targetVersion, int sortOrder, string product)
|
||||
{
|
||||
@@ -16,8 +16,21 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
ProductName = product;
|
||||
}
|
||||
|
||||
public MigrationAttribute(string minimumCurrentVersion, string targetVersion, int sortOrder, string product)
|
||||
{
|
||||
TargetVersion = new Version(targetVersion);
|
||||
MinimumCurrentVersion = new Version(minimumCurrentVersion);
|
||||
SortOrder = sortOrder;
|
||||
ProductName = product;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the target version of this migration.
|
||||
/// Gets the minimum current version for which this migration is allowed to execute
|
||||
/// </summary>
|
||||
public Version MinimumCurrentVersion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target version of this migration.
|
||||
/// </summary>
|
||||
public Version TargetVersion { get; private set; }
|
||||
|
||||
|
||||
@@ -27,26 +27,8 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
/// </summary>
|
||||
public IEnumerable<IMigration> Migrations
|
||||
{
|
||||
get { return GetSortedValues(); }
|
||||
get { return Values; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override how we determine object weight, for this resolver we use the MigrationAttribute attribute
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <returns></returns>
|
||||
protected override int GetObjectWeight(object o)
|
||||
{
|
||||
var type = o.GetType();
|
||||
var attr = type.GetCustomAttribute<MigrationAttribute>(true);
|
||||
return attr == null ? DefaultPluginWeight : attr.SortOrder;
|
||||
}
|
||||
|
||||
protected override int DefaultPluginWeight
|
||||
{
|
||||
get { return 0; } //set's the default to 0
|
||||
set { base.DefaultPluginWeight = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Represents the Migration Runner, which is used to apply migrations to
|
||||
/// the umbraco database.
|
||||
/// </summary>
|
||||
public class MigrationRunner
|
||||
{
|
||||
private readonly Version _configuredVersion;
|
||||
private readonly Version _currentVersion;
|
||||
private readonly Version _targetVersion;
|
||||
private readonly string _productName;
|
||||
|
||||
public MigrationRunner(Version configuredVersion, Version targetVersion, string productName)
|
||||
public MigrationRunner(Version currentVersion, Version targetVersion, string productName)
|
||||
{
|
||||
_configuredVersion = configuredVersion;
|
||||
_currentVersion = currentVersion;
|
||||
_targetVersion = targetVersion;
|
||||
_productName = productName;
|
||||
}
|
||||
@@ -45,33 +46,50 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
{
|
||||
LogHelper.Info<MigrationRunner>("Initializing database migrations");
|
||||
|
||||
var foundMigrations = MigrationResolver.Current.Migrations;
|
||||
var foundMigrations = MigrationResolver.Current.Migrations.ToArray();
|
||||
|
||||
//filter all non-schema migrations
|
||||
var migrations = isUpgrade
|
||||
? OrderedUpgradeMigrations(foundMigrations).ToList()
|
||||
: OrderedDowngradeMigrations(foundMigrations).ToList();
|
||||
|
||||
if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _configuredVersion, _targetVersion, true), this))
|
||||
//SD: Why do we want this?
|
||||
if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _currentVersion, _targetVersion, true), this))
|
||||
return false;
|
||||
|
||||
//Loop through migrations to generate sql
|
||||
var context = new MigrationContext(databaseProvider, database);
|
||||
foreach (MigrationBase migration in migrations)
|
||||
var migrationContext = InitializeMigrations(migrations, database, databaseProvider, isUpgrade);
|
||||
|
||||
try
|
||||
{
|
||||
if (isUpgrade)
|
||||
ExecuteMigrations(migrationContext, database);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if this fails then the transaction will be rolled back, BUT if we are using MySql this is not the case,
|
||||
//since it does not support schema changes in a transaction, see: http://dev.mysql.com/doc/refman/5.0/en/implicit-commit.html
|
||||
//so in that case we have to downgrade
|
||||
|
||||
if (databaseProvider == DatabaseProviders.MySql)
|
||||
{
|
||||
migration.GetUpExpressions(context);
|
||||
LogHelper.Info<MigrationRunner>(string.Format("Added UPGRADE migration '{0}' to context", migration.GetType().Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
migration.GetDownExpressions(context);
|
||||
LogHelper.Info<MigrationRunner>(string.Format("Added DOWNGRADE migration '{0}' to context", migration.GetType().Name));
|
||||
throw new DataLossException(
|
||||
"An error occurred running a schema migration but the changes could not be rolled back. Error: " + ex.Message + ". In some cases, it may be required that the database be restored to it's original state before running this upgrade process again.",
|
||||
ex);
|
||||
}
|
||||
|
||||
//continue throwing the exception
|
||||
throw;
|
||||
}
|
||||
|
||||
Migrated.RaiseEvent(new MigrationEventArgs(migrations, migrationContext, _currentVersion, _targetVersion, false), this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ExecuteMigrations(IMigrationContext context, Database database)
|
||||
{
|
||||
//Transactional execution of the sql that was generated from the found migrations
|
||||
using (Transaction transaction = database.GetTransaction())
|
||||
using (var transaction = database.GetTransaction())
|
||||
{
|
||||
int i = 1;
|
||||
foreach (var expression in context.Expressions)
|
||||
@@ -90,38 +108,89 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
Migrated.RaiseEvent(new MigrationEventArgs(migrations, context, _configuredVersion, _targetVersion, false), this);
|
||||
internal MigrationContext InitializeMigrations(List<IMigration> migrations, Database database, DatabaseProviders databaseProvider, bool isUpgrade = true)
|
||||
{
|
||||
//Loop through migrations to generate sql
|
||||
var context = new MigrationContext(databaseProvider, database);
|
||||
|
||||
foreach (var migration in migrations)
|
||||
{
|
||||
var baseMigration = migration as MigrationBase;
|
||||
if (baseMigration != null)
|
||||
{
|
||||
if (isUpgrade)
|
||||
{
|
||||
baseMigration.GetUpExpressions(context);
|
||||
LogHelper.Info<MigrationRunner>(string.Format("Added UPGRADE migration '{0}' to context", baseMigration.GetType().Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
baseMigration.GetDownExpressions(context);
|
||||
LogHelper.Info<MigrationRunner>(string.Format("Added DOWNGRADE migration '{0}' to context", baseMigration.GetType().Name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//this is just a normal migration so we can only call Up/Down
|
||||
if (isUpgrade)
|
||||
{
|
||||
migration.Up();
|
||||
LogHelper.Info<MigrationRunner>(string.Format("Added UPGRADE migration '{0}' to context", migration.GetType().Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
migration.Down();
|
||||
LogHelper.Info<MigrationRunner>(string.Format("Added DOWNGRADE migration '{0}' to context", migration.GetType().Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filters and orders migrations based on the migrations listed and the currently configured version and the target installation version
|
||||
/// </summary>
|
||||
/// <param name="foundMigrations"></param>
|
||||
/// <returns></returns>
|
||||
internal IEnumerable<IMigration> OrderedUpgradeMigrations(IEnumerable<IMigration> foundMigrations)
|
||||
{
|
||||
var migrations = (from migration in foundMigrations
|
||||
let migrationAttribute = migration.GetType().FirstAttribute<MigrationAttribute>()
|
||||
where migrationAttribute != null
|
||||
where
|
||||
migrationAttribute.TargetVersion > _configuredVersion &&
|
||||
migrationAttribute.TargetVersion <= _targetVersion &&
|
||||
migrationAttribute.ProductName == _productName
|
||||
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder ascending
|
||||
select migration);
|
||||
let migrationAttributes = migration.GetType().GetCustomAttributes<MigrationAttribute>(false)
|
||||
from migrationAttribute in migrationAttributes
|
||||
where migrationAttribute != null
|
||||
where
|
||||
migrationAttribute.TargetVersion > _currentVersion &&
|
||||
migrationAttribute.TargetVersion <= _targetVersion &&
|
||||
migrationAttribute.ProductName == _productName &&
|
||||
//filter if the migration specifies a minimum current version for which to execute
|
||||
(migrationAttribute.MinimumCurrentVersion == null || _currentVersion >= migrationAttribute.MinimumCurrentVersion)
|
||||
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder ascending
|
||||
select migration).Distinct();
|
||||
return migrations;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filters and orders migrations based on the migrations listed and the currently configured version and the target installation version
|
||||
/// </summary>
|
||||
/// <param name="foundMigrations"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<IMigration> OrderedDowngradeMigrations(IEnumerable<IMigration> foundMigrations)
|
||||
{
|
||||
var migrations = (from migration in foundMigrations
|
||||
let migrationAttribute = migration.GetType().FirstAttribute<MigrationAttribute>()
|
||||
where migrationAttribute != null
|
||||
where
|
||||
migrationAttribute.TargetVersion > _configuredVersion &&
|
||||
migrationAttribute.TargetVersion <= _targetVersion &&
|
||||
migrationAttribute.ProductName == _productName
|
||||
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder descending
|
||||
|
||||
select migration);
|
||||
let migrationAttributes = migration.GetType().GetCustomAttributes<MigrationAttribute>(false)
|
||||
from migrationAttribute in migrationAttributes
|
||||
where migrationAttribute != null
|
||||
where
|
||||
migrationAttribute.TargetVersion > _currentVersion &&
|
||||
migrationAttribute.TargetVersion <= _targetVersion &&
|
||||
migrationAttribute.ProductName == _productName &&
|
||||
//filter if the migration specifies a minimum current version for which to execute
|
||||
(migrationAttribute.MinimumCurrentVersion == null || _currentVersion >= migrationAttribute.MinimumCurrentVersion)
|
||||
orderby migrationAttribute.TargetVersion, migrationAttribute.SortOrder descending
|
||||
select migration).Distinct();
|
||||
return migrations;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
@@ -41,7 +42,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
|
||||
if (string.IsNullOrEmpty(ForeignKey.Name))
|
||||
{
|
||||
ForeignKey.Name = string.Format("FK_{0}_{1}", ForeignKey.ForeignTable, ForeignKey.PrimaryTable);
|
||||
ForeignKey.Name = string.Format("FK_{0}_{1}_{2}", ForeignKey.ForeignTable, ForeignKey.PrimaryTable, ForeignKey.PrimaryColumns.First());
|
||||
}
|
||||
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteConstraint,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Delete.Column;
|
||||
using System;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Delete.Column;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Delete.Constraint;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Delete.DefaultConstraint;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Delete.ForeignKey;
|
||||
@@ -11,6 +12,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete
|
||||
void Table(string tableName);
|
||||
IDeleteColumnFromTableSyntax Column(string columnName);
|
||||
IDeleteForeignKeyFromTableSyntax ForeignKey();
|
||||
[Obsolete("Do not use this construct as it does not work with MySql, use the syntax: Delete.ForeignKey().FromTable(\"umbracoUser2app\").ForeignColumn(... instead")]
|
||||
IDeleteForeignKeyOnTableSyntax ForeignKey(string foreignKeyName);
|
||||
IDeleteDataSyntax FromTable(string tableName);
|
||||
IDeleteIndexForTableSyntax Index();
|
||||
|
||||
+14
-2
@@ -8,9 +8,21 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
Delete.ForeignKey().FromTable("umbracoUser2app").ForeignColumn("app").ToTable("umbracoApp").PrimaryColumn("appAlias");
|
||||
//This will work on mysql and should work on mssql however the old keys were not named consistently with how the keys are
|
||||
// structured now. So we need to do a check and manually remove them based on their old aliases.
|
||||
|
||||
Delete.ForeignKey().FromTable("umbracoAppTree").ForeignColumn("appAlias").ToTable("umbracoApp").PrimaryColumn("appAlias");
|
||||
if (this.Context.CurrentDatabaseProvider == DatabaseProviders.MySql)
|
||||
{
|
||||
Delete.ForeignKey().FromTable("umbracoUser2app").ForeignColumn("app").ToTable("umbracoApp").PrimaryColumn("appAlias");
|
||||
Delete.ForeignKey().FromTable("umbracoAppTree").ForeignColumn("appAlias").ToTable("umbracoApp").PrimaryColumn("appAlias");
|
||||
}
|
||||
else
|
||||
{
|
||||
//These are the old aliases
|
||||
Delete.ForeignKey("FK_umbracoUser2app_umbracoApp").OnTable("umbracoUser2app");
|
||||
Delete.ForeignKey("FK_umbracoUser2app_umbracoUser").OnTable("umbracoUser2app");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
|
||||
+32
-2
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
@@ -9,18 +12,45 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
[Migration("7.0.0", 5, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AddIndexToCmsMacroPropertyTable : MigrationBase
|
||||
{
|
||||
private readonly bool _skipIndexCheck;
|
||||
|
||||
internal AddIndexToCmsMacroPropertyTable(bool skipIndexCheck)
|
||||
{
|
||||
_skipIndexCheck = skipIndexCheck;
|
||||
}
|
||||
|
||||
public AddIndexToCmsMacroPropertyTable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
{
|
||||
Create.Index("IX_cmsMacroProperty_Alias").OnTable("cmsMacroProperty")
|
||||
var dbIndexes = _skipIndexCheck ? new DbIndexDefinition[]{} : SqlSyntaxContext.SqlSyntaxProvider.GetDefinedIndexes(Context.Database)
|
||||
.Select(x => new DbIndexDefinition()
|
||||
{
|
||||
TableName = x.Item1,
|
||||
IndexName = x.Item2,
|
||||
ColumnName = x.Item3,
|
||||
IsUnique = x.Item4
|
||||
}).ToArray();
|
||||
|
||||
//make sure it doesn't already exist
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsMacroProperty_Alias")) == false)
|
||||
{
|
||||
Create.Index("IX_cmsMacroProperty_Alias").OnTable("cmsMacroProperty")
|
||||
.OnColumn("macro")
|
||||
.Ascending()
|
||||
.OnColumn("macroPropertyAlias")
|
||||
.Unique();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
Delete.Index("IX_cmsMacroProperty_Alias").OnTable("cmsMacroProperty");
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
-2
@@ -1,5 +1,9 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
@@ -9,14 +13,40 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
[Migration("7.0.0", 4, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AddIndexToCmsMacroTable : MigrationBase
|
||||
{
|
||||
private readonly bool _skipIndexCheck;
|
||||
|
||||
internal AddIndexToCmsMacroTable(bool skipIndexCheck)
|
||||
{
|
||||
_skipIndexCheck = skipIndexCheck;
|
||||
}
|
||||
|
||||
public AddIndexToCmsMacroTable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
{
|
||||
Create.Index("IX_cmsMacro_Alias").OnTable("cmsMacro").OnColumn("macroAlias").Unique();
|
||||
var dbIndexes = _skipIndexCheck ? new DbIndexDefinition[] { } : SqlSyntaxContext.SqlSyntaxProvider.GetDefinedIndexes(Context.Database)
|
||||
.Select(x => new DbIndexDefinition()
|
||||
{
|
||||
TableName = x.Item1,
|
||||
IndexName = x.Item2,
|
||||
ColumnName = x.Item3,
|
||||
IsUnique = x.Item4
|
||||
}).ToArray();
|
||||
|
||||
//make sure it doesn't already exist
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsMacro_Alias")) == false)
|
||||
{
|
||||
Create.Index("IX_cmsMacro_Alias").OnTable("cmsMacro").OnColumn("macroAlias").Unique();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
Delete.Index("IX_cmsMacro_Alias").OnTable("cmsMacro");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
Delete.Column("propertyEditorAlias").FromTable("cmsDataType");
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -22,8 +22,8 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
Delete.Column("macroPropertyHidden").FromTable("cmsMacroProperty");
|
||||
|
||||
Delete.ForeignKey("FK_cmsMacroProperty_cmsMacroPropertyType_id").OnTable("cmsMacroProperty");
|
||||
|
||||
Delete.ForeignKey().FromTable("cmsMacroProperty").ForeignColumn("macroPropertyType").ToTable("cmsMacroPropertyType").PrimaryColumn("id");
|
||||
|
||||
Alter.Table("cmsMacroProperty").AddColumn("editorAlias").AsString(255).NotNullable().WithDefaultValue("");
|
||||
|
||||
//we need to get the data and create the migration scripts before we change the actual schema bits below!
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
-5
@@ -4,6 +4,8 @@ using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
@@ -25,12 +27,28 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
//create a new col which we will make a foreign key, but first needs to be populated with data.
|
||||
Alter.Table("cmsTagRelationship").AddColumn("propertyTypeId").AsInt32().Nullable();
|
||||
|
||||
|
||||
//drop the foreign key on umbracoNode. Must drop foreign key first before primary key can be removed in MySql.
|
||||
Delete.ForeignKey("FK_cmsTagRelationship_umbracoNode_id").OnTable("cmsTagRelationship");
|
||||
|
||||
//we need to drop the primary key
|
||||
Delete.PrimaryKey("PK_cmsTagRelationship").FromTable("cmsTagRelationship");
|
||||
Delete.ForeignKey().FromTable("cmsTagRelationship").ForeignColumn("nodeId").ToTable("umbracoNode").PrimaryColumn("id");
|
||||
|
||||
//we need to drop the primary key, this is sql specific since MySQL has never had primary keys on this table
|
||||
// at least since 6.0 and the new installation way but perhaps it had them way back in 4.x so we need to check
|
||||
// it exists before trying to drop it.
|
||||
if (Context.CurrentDatabaseProvider == DatabaseProviders.MySql)
|
||||
{
|
||||
var constraints = SqlSyntaxContext.SqlSyntaxProvider.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
|
||||
//this will let us know if this pk exists on this table
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsTagRelationship") && x.Item3.InvariantEquals("PRIMARY")) > 0)
|
||||
{
|
||||
Delete.PrimaryKey("PK_cmsTagRelationship").FromTable("cmsTagRelationship");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Delete.PrimaryKey("PK_cmsTagRelationship").FromTable("cmsTagRelationship");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Upgrade()
|
||||
@@ -115,7 +133,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+21
-4
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
@@ -9,6 +12,15 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
var dbIndexes = SqlSyntaxContext.SqlSyntaxProvider.GetDefinedIndexes(Context.Database)
|
||||
.Select(x => new DbIndexDefinition()
|
||||
{
|
||||
TableName = x.Item1,
|
||||
IndexName = x.Item2,
|
||||
ColumnName = x.Item3,
|
||||
IsUnique = x.Item4
|
||||
}).ToArray();
|
||||
|
||||
//add a foreign key to the parent id column too!
|
||||
Create.ForeignKey("FK_cmsTags_cmsTags")
|
||||
.FromTable("cmsTags")
|
||||
@@ -16,15 +28,20 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
.ToTable("cmsTags")
|
||||
.PrimaryColumn("id")
|
||||
.OnDelete(Rule.None)
|
||||
.OnUpdate(Rule.None);
|
||||
.OnUpdate(Rule.None);
|
||||
|
||||
//add an index to tag/group since it's queried often
|
||||
Create.Index("IX_cmsTags").OnTable("cmsTags").OnColumn("tag").Ascending().OnColumn("group").Ascending().WithOptions().NonClustered();
|
||||
//make sure it doesn't already exist
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsTags")) == false)
|
||||
{
|
||||
//add an index to tag/group since it's queried often
|
||||
Create.Index("IX_cmsTags").OnTable("cmsTags").OnColumn("tag").Ascending().OnColumn("group").Ascending().WithOptions().NonClustered();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -55,7 +55,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
-57
@@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -26,81 +27,86 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
|
||||
{
|
||||
if (database != null)
|
||||
{
|
||||
try
|
||||
var dtSql = new Sql().Select("nodeId").From<DataTypeDto>().Where<DataTypeDto>(dto => dto.PropertyEditorAlias == Constants.PropertyEditors.RelatedLinksAlias);
|
||||
var dataTypeIds = database.Fetch<int>(dtSql);
|
||||
|
||||
var propertyData =
|
||||
database.Fetch<PropertyDataDto>(
|
||||
"WHERE propertyTypeId in (SELECT id from cmsPropertyType where dataTypeID IN (@dataTypeIds))", new { dataTypeIds = dataTypeIds });
|
||||
if (!propertyData.Any()) return string.Empty;
|
||||
|
||||
var nodesIdsWithProperty = propertyData.Select(x => x.NodeId).Distinct();
|
||||
var cmsContentXmlEntries = database.Fetch<ContentXmlDto>(
|
||||
"WHERE nodeId in (@nodeIds)", new { nodeIds = nodesIdsWithProperty });
|
||||
var propertyTypeIds = propertyData.Select(x => x.PropertyTypeId).Distinct();
|
||||
var propertyTypes = database.Fetch<PropertyTypeDto>(
|
||||
"WHERE id in (@propertyTypeIds)", new { propertyTypeIds = propertyTypeIds });
|
||||
|
||||
foreach (var data in propertyData)
|
||||
{
|
||||
var propertyData =
|
||||
database.Fetch<PropertyDataDto>(
|
||||
"WHERE propertyTypeId in (SELECT id from cmsPropertyType where dataTypeID = 1040)");
|
||||
foreach (var data in propertyData)
|
||||
if (string.IsNullOrEmpty(data.Text) == false)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(data.Text))
|
||||
//fetch the current data (that's in xml format)
|
||||
var xml = new XmlDocument();
|
||||
xml.LoadXml(data.Text);
|
||||
|
||||
var links = new List<ExpandoObject>();
|
||||
|
||||
//loop all the stored links
|
||||
foreach (XmlNode node in xml.DocumentElement.ChildNodes)
|
||||
{
|
||||
//var cs = ApplicationContext.Current.Services.ContentService;
|
||||
var title = node.Attributes["title"].Value;
|
||||
var type = node.Attributes["type"].Value;
|
||||
var newwindow = node.Attributes["newwindow"].Value.Equals("1") ? true : false;
|
||||
var lnk = node.Attributes["link"].Value;
|
||||
|
||||
//fetch the current data (that's in xml format)
|
||||
var xml = new XmlDocument();
|
||||
xml.LoadXml(data.Text);
|
||||
//create the links in the format the new prop editor expects it to be
|
||||
var link = new ExpandoObject() as IDictionary<string, Object>;
|
||||
link.Add("title", title);
|
||||
link.Add("caption", title);
|
||||
link.Add("link", lnk);
|
||||
link.Add("newWindow", newwindow);
|
||||
link.Add("type", type.Equals("internal") ? "internal" : "external");
|
||||
link.Add("internal", type.Equals("internal") ? lnk : null);
|
||||
|
||||
if (xml != null)
|
||||
link.Add("edit", false);
|
||||
link.Add("isInternal", type.Equals("internal"));
|
||||
|
||||
links.Add((ExpandoObject)link);
|
||||
}
|
||||
|
||||
//store the serialized data
|
||||
data.Text = JsonConvert.SerializeObject(links);
|
||||
|
||||
database.Update(data);
|
||||
|
||||
//now we need to update the cmsContentXml table
|
||||
var propertyType = propertyTypes.SingleOrDefault(x => x.Id == data.PropertyTypeId);
|
||||
if (propertyType != null)
|
||||
{
|
||||
var xmlItem = cmsContentXmlEntries.SingleOrDefault(x => x.NodeId == data.NodeId);
|
||||
if (xmlItem != null)
|
||||
{
|
||||
var links = new List<ExpandoObject>();
|
||||
|
||||
//loop all the stored links
|
||||
foreach (XmlNode node in xml.DocumentElement.ChildNodes)
|
||||
var x = XElement.Parse(xmlItem.Xml);
|
||||
var prop = x.Element(propertyType.Alias);
|
||||
if (prop != null)
|
||||
{
|
||||
var title = node.Attributes["title"].Value;
|
||||
var type = node.Attributes["type"].Value;
|
||||
var newwindow = node.Attributes["newwindow"].Value.Equals("1") ? true : false;
|
||||
var lnk = node.Attributes["link"].Value;
|
||||
|
||||
//create the links in the format the new prop editor expects it to be
|
||||
var link = new ExpandoObject() as IDictionary<string, Object>;
|
||||
link.Add("title", title);
|
||||
link.Add("caption", title);
|
||||
link.Add("link", lnk);
|
||||
link.Add("newWindow", newwindow);
|
||||
link.Add("type", type.Equals("internal") ? "internal" : "external");
|
||||
link.Add("internal", type.Equals("internal") ? lnk : null);
|
||||
|
||||
link.Add("edit", false);
|
||||
link.Add("isInternal", type.Equals("internal"));
|
||||
|
||||
//try
|
||||
//{
|
||||
// if (type.Equals("internal"))
|
||||
// {
|
||||
// int nodeId;
|
||||
// if (int.TryParse(lnk, out nodeId))
|
||||
// link.Add("internalName", cs.GetById(nodeId).Name);
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// LogHelper.Error<UpdateRelatedLinksData>("Exception was thrown when trying to update related links property data, fetching internal node id", ex);
|
||||
//}
|
||||
|
||||
links.Add((ExpandoObject) link);
|
||||
prop.ReplaceAll(new XCData(data.Text));
|
||||
database.Update(xmlItem);
|
||||
}
|
||||
|
||||
//store the serialized data
|
||||
data.Text = JsonConvert.SerializeObject(links);
|
||||
|
||||
database.Update(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<UpdateRelatedLinksData>("Exception was thrown when trying to update related links property data", ex);
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new DataLossException("Cannot downgrade from a version 7 database to a prior version, the database schema has already been modified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenOneZero
|
||||
{
|
||||
//see: http://issues.umbraco.org/issue/U4-4430 - Except this one is specific to 7 because
|
||||
// we've modified the tagRelationship PK already.
|
||||
//We have to target this specifically however to ensure this DOES NOT execute if upgrading from a version previous to 7.0,
|
||||
// this is because when the 7.0.0 migrations are executed, this primary key get's created so if this migration is also executed
|
||||
// we will get exceptions because it is trying to create the PK two times.
|
||||
|
||||
[Migration("7.0.0", "7.1.0", 0, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AssignMissingPrimaryForMySqlKeys : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
if (Context.CurrentDatabaseProvider == DatabaseProviders.MySql)
|
||||
{
|
||||
var constraints = SqlSyntaxContext.SqlSyntaxProvider.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
|
||||
|
||||
//This should be 3 because this table has 3 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsTagRelationship") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_cmsTagRelationship")
|
||||
.OnTable("cmsTagRelationship")
|
||||
.Columns(new[] { "nodeId", "propertyTypeId", "tagId" });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
//don't do anything, these keys should have always existed!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
|
||||
{
|
||||
|
||||
[Migration("6.0.0", 10, GlobalSettings.UmbracoMigrationName)]
|
||||
public class DeleteAppTables : MigrationBase
|
||||
{
|
||||
@@ -14,6 +15,8 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
//This cannot be rolled back!!
|
||||
throw new DataLossException("Cannot rollback migration " + typeof(DeleteAppTables) + " the db tables umbracoAppTree and umbracoApp have been droppped");
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -10,15 +10,15 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix
|
||||
{
|
||||
Alter.Table("cmsPropertyTypeGroup").AddColumn("parentGroupId").AsInt16().Nullable();
|
||||
|
||||
Create.ForeignKey("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup")
|
||||
Create.ForeignKey("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup_id")
|
||||
.FromTable("cmsPropertyTypeGroup").ForeignColumn("parentGroupId")
|
||||
.ToTable("cmsPropertyTypeGroup").PrimaryColumn("id").OnDeleteOrUpdate(Rule.None);
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
Delete.ForeignKey("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup").OnTable("cmsPropertyTypeGroup");
|
||||
|
||||
Delete.ForeignKey().FromTable("cmsPropertyTypeGroup").ForeignColumn("parentGroupId").ToTable("cmsPropertyTypeGroup").PrimaryColumn("id");
|
||||
|
||||
Delete.Column("parentGroupId").FromTable("cmsPropertyTypeGroup");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -13,11 +13,13 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixOneZero
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
base.Context.Database.CreateTable<ServerRegistrationDto>();
|
||||
//NOTE: This isn't the correct way to do this but to manually create this table with the Create syntax is a pain in the arse
|
||||
Context.Database.CreateTable<ServerRegistrationDto>();
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
Delete.Table("umbracoServer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -4,7 +4,8 @@ using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
|
||||
{
|
||||
[Migration("6.2.0", 1, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("7.1.0", 3, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("6.2.0", 3, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AddChangeDocumentTypePermission : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
|
||||
+50
-22
@@ -1,37 +1,65 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Migrations.Initial;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
|
||||
{
|
||||
[Migration("6.2.0", 0, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("7.1.0", 1, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("6.2.0", 1, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AdditionalIndexesAndKeys : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
Create.Index("IX_umbracoNodeTrashed").OnTable("umbracoNode").OnColumn("trashed").Ascending().WithOptions().NonClustered();
|
||||
Create.Index("IX_cmsContentVersion_ContentId").OnTable("cmsContentVersion").OnColumn("ContentId").Ascending().WithOptions().NonClustered();
|
||||
Create.Index("IX_cmsDocument_published").OnTable("cmsDocument").OnColumn("published").Ascending().WithOptions().NonClustered();
|
||||
Create.Index("IX_cmsDocument_newest").OnTable("cmsDocument").OnColumn("newest").Ascending().WithOptions().NonClustered();
|
||||
{
|
||||
|
||||
var dbIndexes = SqlSyntaxContext.SqlSyntaxProvider.GetDefinedIndexes(Context.Database)
|
||||
.Select(x => new DbIndexDefinition()
|
||||
{
|
||||
TableName = x.Item1,
|
||||
IndexName = x.Item2,
|
||||
ColumnName = x.Item3,
|
||||
IsUnique = x.Item4
|
||||
}).ToArray();
|
||||
|
||||
//do not create any indexes if they already exist in the database
|
||||
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoNodeTrashed")) == false)
|
||||
{
|
||||
Create.Index("IX_umbracoNodeTrashed").OnTable("umbracoNode").OnColumn("trashed").Ascending().WithOptions().NonClustered();
|
||||
}
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsContentVersion_ContentId")) == false)
|
||||
{
|
||||
Create.Index("IX_cmsContentVersion_ContentId").OnTable("cmsContentVersion").OnColumn("ContentId").Ascending().WithOptions().NonClustered();
|
||||
}
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsDocument_published")) == false)
|
||||
{
|
||||
Create.Index("IX_cmsDocument_published").OnTable("cmsDocument").OnColumn("published").Ascending().WithOptions().NonClustered();
|
||||
}
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsDocument_newest")) == false)
|
||||
{
|
||||
Create.Index("IX_cmsDocument_newest").OnTable("cmsDocument").OnColumn("newest").Ascending().WithOptions().NonClustered();
|
||||
}
|
||||
|
||||
//we want to drop the umbracoUserLogins_Index index since it is named incorrectly and then re-create it so
|
||||
// it follows the standard naming convention
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("umbracoUserLogins_Index")))
|
||||
{
|
||||
Delete.Index("umbracoUserLogins_Index").OnTable("umbracoUserLogins");
|
||||
}
|
||||
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoUserLogins_Index")) == false)
|
||||
{
|
||||
Create.Index("IX_umbracoUserLogins_Index").OnTable("umbracoUserLogins").OnColumn("contextID").Ascending().WithOptions().Clustered();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[Migration("6.2.0", 2, GlobalSettings.UmbracoMigrationName)]
|
||||
public class ChangePasswordColumn : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
//up to 500 chars
|
||||
Alter.Table("umbracoUser").AlterColumn("userPassword").AsString(500).NotNullable();
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Delete.Index("IX_umbracoNodeTrashed").OnTable("umbracoNode");
|
||||
Delete.Index("IX_cmsContentVersion_ContentId").OnTable("cmsContentVersion");
|
||||
Delete.Index("IX_cmsDocument_published").OnTable("cmsDocument");
|
||||
Delete.Index("IX_cmsDocument_newest").OnTable("cmsDocument");
|
||||
}
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
using System.Linq;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
|
||||
{
|
||||
//see: http://issues.umbraco.org/issue/U4-4430
|
||||
[Migration("7.1.0", 0, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("6.2.0", 0, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AssignMissingPrimaryForMySqlKeys : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
if (Context.CurrentDatabaseProvider == DatabaseProviders.MySql)
|
||||
{
|
||||
var constraints = SqlSyntaxContext.SqlSyntaxProvider.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
|
||||
|
||||
//This should be 2 because this table has 2 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsContentType2ContentType") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_cmsContentType2ContentType")
|
||||
.OnTable("cmsContentType2ContentType")
|
||||
.Columns(new[] {"parentContentTypeId", "childContentTypeId"});
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 2 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsContentTypeAllowedContentType") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_cmsContentTypeAllowedContentType")
|
||||
.OnTable("cmsContentTypeAllowedContentType")
|
||||
.Columns(new[] { "Id", "AllowedId" });
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 2 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsDocumentType") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_cmsDocumentType")
|
||||
.OnTable("cmsDocumentType")
|
||||
.Columns(new[] { "contentTypeNodeId", "templateNodeId" });
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 2 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsMember2MemberGroup") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_cmsMember2MemberGroup")
|
||||
.OnTable("cmsMember2MemberGroup")
|
||||
.Columns(new[] { "Member", "MemberGroup" });
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 2 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_cmsContentPreviewXml")
|
||||
.OnTable("cmsPreviewXml")
|
||||
.Columns(new[] { "nodeId", "versionId" });
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 2 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("umbracoUser2app") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_user2app")
|
||||
.OnTable("umbracoUser2app")
|
||||
.Columns(new[] { "user", "app" });
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 3 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("umbracoUser2NodeNotify") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_umbracoUser2NodeNotify")
|
||||
.OnTable("umbracoUser2NodeNotify")
|
||||
.Columns(new[] { "userId", "nodeId", "action" });
|
||||
}
|
||||
|
||||
//This should be 2 because this table has 3 keys
|
||||
if (constraints.Count(x => x.Item1.InvariantEquals("umbracoUser2NodePermission") && x.Item3.InvariantEquals("PRIMARY")) == 0)
|
||||
{
|
||||
Create.PrimaryKey("PK_umbracoUser2NodePermission")
|
||||
.OnTable("umbracoUser2NodePermission")
|
||||
.Columns(new[] { "userId", "nodeId", "permission" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
//don't do anything, these keys should have always existed!
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
|
||||
{
|
||||
[Migration("7.1.0", 2, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("6.2.0", 2, GlobalSettings.UmbracoMigrationName)]
|
||||
public class ChangePasswordColumn : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
//up to 500 chars
|
||||
Alter.Table("umbracoUser").AlterColumn("userPassword").AsString(500).NotNullable();
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
//back to 125 chars
|
||||
Alter.Table("umbracoUser").AlterColumn("userPassword").AsString(125).NotNullable();
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-15
@@ -1,20 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Deployment.Internal;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenOne
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero
|
||||
{
|
||||
[Migration("7.1.0", 1, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("7.1.0", 4, GlobalSettings.UmbracoMigrationName)]
|
||||
[Migration("6.2.0", 4, GlobalSettings.UmbracoMigrationName)]
|
||||
public class UpdateToNewMemberPropertyAliases : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
@@ -39,13 +32,17 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenOne
|
||||
{"umbracoFailedPasswordAttemptsPropertyTypeAlias", Constants.Conventions.Member.FailedPasswordAttempts}
|
||||
};
|
||||
|
||||
|
||||
//This query is structured to work with MySql, SQLCE and SqlServer:
|
||||
// http://issues.umbraco.org/issue/U4-3876
|
||||
|
||||
const string propertyTypeUpdateSql = @"UPDATE cmsPropertyType
|
||||
SET Alias = @newAlias
|
||||
WHERE Alias = @oldAlias AND contentTypeId IN (
|
||||
SELECT DISTINCT cmsContentType.nodeId FROM cmsPropertyType
|
||||
SELECT nodeId FROM (SELECT DISTINCT cmsContentType.nodeId FROM cmsPropertyType
|
||||
INNER JOIN cmsContentType ON cmsPropertyType.contentTypeId = cmsContentType.nodeId
|
||||
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
|
||||
WHERE umbracoNode.nodeObjectType = @objectType)";
|
||||
WHERE umbracoNode.nodeObjectType = @objectType) x)";
|
||||
|
||||
const string xmlSelectSql = @"SELECT cmsContentXml.* FROM cmsContentXml
|
||||
INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id
|
||||
@@ -63,7 +60,7 @@ WHERE umbracoNode.nodeObjectType = @objectType";
|
||||
}
|
||||
|
||||
//Update all of the XML
|
||||
var items = database.Fetch<ContentXmlDto>(xmlSelectSql, new {objectType = Constants.ObjectTypes.Member});
|
||||
var items = database.Fetch<ContentXmlDto>(xmlSelectSql, new { objectType = Constants.ObjectTypes.Member });
|
||||
foreach (var item in items)
|
||||
{
|
||||
foreach (var map in aliasMap)
|
||||
@@ -80,10 +77,10 @@ WHERE umbracoNode.nodeObjectType = @objectType";
|
||||
{
|
||||
LogHelper.Error<UpdateToNewMemberPropertyAliases>("Exception was thrown when trying to upgrade old member aliases to the new ones", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
@@ -37,7 +37,8 @@ namespace Umbraco.Core.Persistence
|
||||
var tableNameAttribute = type.FirstAttribute<TableNameAttribute>();
|
||||
string tableName = tableNameAttribute == null ? string.Empty : tableNameAttribute.Value;
|
||||
|
||||
var syntax = string.Format("{0}.{1}",
|
||||
//need to ensure the order by is in brackets, see: https://github.com/toptensoftware/PetaPoco/issues/177
|
||||
var syntax = string.Format("({0}.{1})",
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(tableName),
|
||||
SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(columnName));
|
||||
|
||||
|
||||
@@ -9,6 +9,41 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
/// </summary>
|
||||
internal class BaseExpressionHelper
|
||||
{
|
||||
protected string HandleStringComparison(string col, string val, string verb, TextColumnType columnType)
|
||||
{
|
||||
switch (verb)
|
||||
{
|
||||
case "SqlWildcard":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnWildcardComparison(col, RemoveQuote(val), columnType);
|
||||
case "Equals":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnEqualComparison(col, RemoveQuote(val), columnType);
|
||||
case "StartsWith":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnStartsWithComparison(col, RemoveQuote(val), columnType);
|
||||
case "EndsWith":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnEndsWithComparison(col, RemoveQuote(val), columnType);
|
||||
case "Contains":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnContainsComparison(col, RemoveQuote(val), columnType);
|
||||
case "InvariantEquals":
|
||||
case "SqlEquals":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "Equals", columnType);
|
||||
case "InvariantStartsWith":
|
||||
case "SqlStartsWith":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "StartsWith", columnType);
|
||||
case "InvariantEndsWith":
|
||||
case "SqlEndsWith":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "EndsWith", columnType);
|
||||
case "InvariantContains":
|
||||
case "SqlContains":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "Contains", columnType);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("verb");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetQuotedValue(object value, Type fieldType, Func<object, string> escapeCallback = null, Func<Type, bool> shouldQuoteCallback = null)
|
||||
{
|
||||
if (value == null) return "NULL";
|
||||
|
||||
@@ -227,41 +227,6 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
|
||||
}
|
||||
|
||||
private string HandleStringComparison(string col, string val, string verb, TextColumnType columnType)
|
||||
{
|
||||
switch (verb)
|
||||
{
|
||||
case "SqlWildcard":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnWildcardComparison(col, RemoveQuote(val), columnType);
|
||||
case "Equals":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnEqualComparison(col, RemoveQuote(val), columnType);
|
||||
case "StartsWith":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnStartsWithComparison(col, RemoveQuote(val), columnType);
|
||||
case "EndsWith":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnEndsWithComparison(col, RemoveQuote(val), columnType);
|
||||
case "Contains":
|
||||
return SqlSyntaxContext.SqlSyntaxProvider.GetStringColumnContainsComparison(col, RemoveQuote(val), columnType);
|
||||
case "InvariantEquals":
|
||||
case "SqlEquals":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "Equals", columnType);
|
||||
case "InvariantStartsWith":
|
||||
case "SqlStartsWith":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "StartsWith", columnType);
|
||||
case "InvariantEndsWith":
|
||||
case "SqlEndsWith":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "EndsWith", columnType);
|
||||
case "InvariantContains":
|
||||
case "SqlContains":
|
||||
//recurse
|
||||
return HandleStringComparison(col, val, "Contains", columnType);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("verb");
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string VisitMethodCall(MethodCallExpression m)
|
||||
{
|
||||
List<Object> args = this.VisitExpressionList(m.Arguments);
|
||||
|
||||
@@ -253,12 +253,31 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
return string.Format("upper({0})", r);
|
||||
case "ToLower":
|
||||
return string.Format("lower({0})", r);
|
||||
case "SqlWildcard":
|
||||
case "StartsWith":
|
||||
return string.Format("upper({0}) like '{1}%'", r, RemoveQuote(args[0].ToString().ToUpper()));
|
||||
case "EndsWith":
|
||||
return string.Format("upper({0}) like '%{1}'", r, RemoveQuote(args[0].ToString()).ToUpper());
|
||||
case "Contains":
|
||||
return string.Format("upper({0}) like '%{1}%'", r, RemoveQuote(args[0].ToString()).ToUpper());
|
||||
case "Equals":
|
||||
case "SqlStartsWith":
|
||||
case "SqlEndsWith":
|
||||
case "SqlContains":
|
||||
case "SqlEquals":
|
||||
case "InvariantStartsWith":
|
||||
case "InvariantEndsWith":
|
||||
case "InvariantContains":
|
||||
case "InvariantEquals":
|
||||
//default
|
||||
var colType = TextColumnType.NVarchar;
|
||||
//then check if this arg has been passed in
|
||||
if (m.Arguments.Count > 1)
|
||||
{
|
||||
var colTypeArg = m.Arguments.FirstOrDefault(x => x is ConstantExpression && x.Type == typeof(TextColumnType));
|
||||
if (colTypeArg != null)
|
||||
{
|
||||
colType = (TextColumnType)((ConstantExpression)colTypeArg).Value;
|
||||
}
|
||||
}
|
||||
return HandleStringComparison(r.ToString(), args[0].ToString(), m.Method.Name, colType);
|
||||
case "Substring":
|
||||
var startIndex = Int32.Parse(args[0].ToString()) + 1;
|
||||
if (args.Count == 2)
|
||||
|
||||
@@ -433,7 +433,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
}
|
||||
else
|
||||
{
|
||||
//In order to update the ContentVersion we need to retreive its primary key id
|
||||
//In order to update the ContentVersion we need to retrieve its primary key id
|
||||
var contentVerDto = Database.SingleOrDefault<ContentVersionDto>("WHERE VersionId = @Version", new { Version = entity.Version });
|
||||
contentVersionDto.Id = contentVerDto.Id;
|
||||
|
||||
@@ -638,4 +638,4 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return currentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -11,6 +12,7 @@ using Umbraco.Core.Persistence.Caching;
|
||||
using Umbraco.Core.Persistence.Factories;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.Relators;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Repositories
|
||||
@@ -63,6 +65,17 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected void PersistNewBaseContentType(ContentTypeDto dto, IContentTypeComposition entity)
|
||||
{
|
||||
//Cannot add a duplicate content type type
|
||||
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsContentType
|
||||
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
|
||||
WHERE cmsContentType." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("alias") + @"= @alias
|
||||
AND umbracoNode.nodeObjectType = @objectType",
|
||||
new { alias = entity.Alias, objectType = NodeObjectTypeId });
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new DuplicateNameException("An item with the alias " + entity.Alias + " already exists");
|
||||
}
|
||||
|
||||
//Logic for setting Path, Level and SortOrder
|
||||
var parent = Database.First<NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
|
||||
int level = parent.Level + 1;
|
||||
@@ -165,6 +178,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected void PersistUpdatedBaseContentType(ContentTypeDto dto, IContentTypeComposition entity)
|
||||
{
|
||||
|
||||
//Cannot update to a duplicate alias
|
||||
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsContentType
|
||||
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
|
||||
WHERE cmsContentType." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("alias") + @"= @alias
|
||||
AND umbracoNode.nodeObjectType = @objectType
|
||||
AND umbracoNode.id <> @id",
|
||||
new { id = dto.NodeId, alias = entity.Alias, objectType = NodeObjectTypeId });
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new DuplicateNameException("An item with the alias " + entity.Alias + " already exists");
|
||||
}
|
||||
|
||||
var propertyGroupFactory = new PropertyGroupFactory(entity.Id);
|
||||
|
||||
var nodeDto = dto.NodeDto;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -8,6 +9,7 @@ using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
using Umbraco.Core.Persistence.Factories;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Repositories
|
||||
@@ -119,6 +121,15 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
((DataTypeDefinition)entity).AddingEntity();
|
||||
|
||||
//Cannot add a duplicate data type
|
||||
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsDataType
|
||||
INNER JOIN umbracoNode ON cmsDataType.nodeId = umbracoNode.id
|
||||
WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("text") + "= @name", new {name = entity.Name});
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new DuplicateNameException("A data type with the name " + entity.Name + " already exists");
|
||||
}
|
||||
|
||||
var factory = new DataTypeDefinitionFactory(NodeObjectTypeId);
|
||||
var dto = factory.BuildDto(entity);
|
||||
|
||||
@@ -154,6 +165,18 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistUpdatedItem(IDataTypeDefinition entity)
|
||||
{
|
||||
|
||||
//Cannot change to a duplicate alias
|
||||
var exists = Database.ExecuteScalar<int>(@"SELECT COUNT(*) FROM cmsDataType
|
||||
INNER JOIN umbracoNode ON cmsDataType.nodeId = umbracoNode.id
|
||||
WHERE umbracoNode." + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("text") + @"= @name
|
||||
AND umbracoNode.id <> @id",
|
||||
new { id = entity.Id, name = entity.Name });
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new DuplicateNameException("A data type with the name " + entity.Name + " already exists");
|
||||
}
|
||||
|
||||
//Updates Modified date and Version Guid
|
||||
((DataTypeDefinition)entity).UpdatingEntity();
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
foreach (var textDto in dto.LanguageTextDtos)
|
||||
{
|
||||
var language = _languageRepository.Get(textDto.LanguageId);
|
||||
if (language == null)
|
||||
continue;
|
||||
var translationFactory = new DictionaryTranslationFactory(dto.UniqueId, language);
|
||||
list.Add(translationFactory.BuildEntity(textDto));
|
||||
}
|
||||
|
||||
@@ -50,5 +50,9 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <returns></returns>
|
||||
IEnumerable<IMember> GetPagedResultsByQuery(IQuery<IMember> query, int pageIndex, int pageSize, out int totalRecords, Expression<Func<IMember, string>> orderBy);
|
||||
|
||||
IEnumerable<IMember> GetPagedResultsByQuery<TDto>(
|
||||
Sql sql, int pageIndex, int pageSize, out int totalRecords,
|
||||
Func<IEnumerable<TDto>, int[]> resolveIds);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var sql = GetBaseQuery(false);
|
||||
sql.Where(GetBaseWhereClause(), new { Id = id });
|
||||
|
||||
var languageDto = Database.First<LanguageDto>(sql);
|
||||
var languageDto = Database.FirstOrDefault<LanguageDto>(sql);
|
||||
if (languageDto == null)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Database.Update(newContentDto);
|
||||
}
|
||||
|
||||
//In order to update the ContentVersion we need to retreive its primary key id
|
||||
//In order to update the ContentVersion we need to retrieve its primary key id
|
||||
var contentVerDto = Database.SingleOrDefault<ContentVersionDto>("WHERE VersionId = @Version", new { Version = entity.Version });
|
||||
dto.Id = contentVerDto.Id;
|
||||
//Updates the current version - cmsContentVersion
|
||||
@@ -403,4 +403,4 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return currentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,10 +121,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var dto = _modelFactory.BuildDto(group);
|
||||
var o = Database.IsNew(dto) ? Convert.ToInt32(Database.Insert(dto)) : Database.Update(dto);
|
||||
|
||||
//Update with new correct path
|
||||
//Update with new correct path and id
|
||||
dto.Path = string.Concat("-1,", dto.NodeId);
|
||||
Database.Update(dto);
|
||||
|
||||
//assign to entity
|
||||
group.Id = o;
|
||||
group.ResetDirtyProperties();
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Database.Update(newContentDto);
|
||||
}
|
||||
|
||||
//In order to update the ContentVersion we need to retreive its primary key id
|
||||
//In order to update the ContentVersion we need to retrieve its primary key id
|
||||
var contentVerDto = Database.SingleOrDefault<ContentVersionDto>("WHERE VersionId = @Version", new { Version = entity.Version });
|
||||
dto.ContentVersionDto.Id = contentVerDto.Id;
|
||||
//Updates the current version - cmsContentVersion
|
||||
@@ -318,7 +318,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Database.Update(dto.ContentVersionDto);
|
||||
|
||||
//Updates the cmsMember entry if it has changed
|
||||
|
||||
//NOTE: these cols are the REAL column names in the db
|
||||
var changedCols = new List<string>();
|
||||
|
||||
if (dirtyEntity.IsPropertyDirty("Email"))
|
||||
{
|
||||
changedCols.Add("Email");
|
||||
@@ -328,7 +331,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
changedCols.Add("LoginName");
|
||||
}
|
||||
// DO NOT update the password if it is null or empty
|
||||
if (dirtyEntity.IsPropertyDirty("Password") && entity.Password.IsNullOrWhiteSpace() == false)
|
||||
if (dirtyEntity.IsPropertyDirty("RawPasswordValue") && entity.RawPasswordValue.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
changedCols.Add("Password");
|
||||
}
|
||||
@@ -565,7 +568,6 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
resultQuery = sql;
|
||||
}
|
||||
|
||||
|
||||
//get the referenced column name
|
||||
var expressionMember = ExpressionHelper.GetMemberInfo(orderBy);
|
||||
//now find the mapped column name
|
||||
@@ -577,8 +579,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
}
|
||||
//need to ensure the order by is in brackets, see: https://github.com/toptensoftware/PetaPoco/issues/177
|
||||
resultQuery.OrderBy(string.Format("({0})", mappedField));
|
||||
|
||||
var result = GetPagedResultsByQuery<MemberDto>(resultQuery, pageIndex, pageSize, out totalRecords,
|
||||
dtos => dtos.Select(x => x.NodeId).ToArray());
|
||||
|
||||
//now we need to ensure this result is also ordered by the same order by clause
|
||||
return result.OrderBy(orderBy.Compile());
|
||||
}
|
||||
|
||||
var pagedResult = Database.Page<MemberDto>(pageIndex + 1, pageSize, resultQuery);
|
||||
public IEnumerable<IMember> GetPagedResultsByQuery<TDto>(
|
||||
Sql sql, int pageIndex, int pageSize, out int totalRecords,
|
||||
Func<IEnumerable<TDto>, int[]> resolveIds)
|
||||
{
|
||||
var pagedResult = Database.Page<TDto>(pageIndex + 1, pageSize, sql);
|
||||
|
||||
totalRecords = Convert.ToInt32(pagedResult.TotalItems);
|
||||
|
||||
@@ -587,10 +600,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
return Enumerable.Empty<IMember>();
|
||||
}
|
||||
var result = GetAll(pagedResult.Items.Select(x => x.NodeId).ToArray());
|
||||
|
||||
//now we need to ensure this result is also ordered by the same order by clause
|
||||
return result.OrderBy(orderBy.Compile());
|
||||
return GetAll(resolveIds(pagedResult.Items)).ToArray();
|
||||
}
|
||||
|
||||
private IMember BuildFromDto(List<MemberReadOnlyDto> dtos)
|
||||
@@ -636,4 +646,4 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +166,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistNewItem(IMemberType entity)
|
||||
{
|
||||
((MemberType)entity).AddingEntity();
|
||||
ValidateAlias(entity);
|
||||
|
||||
((MemberType)entity).AddingEntity();
|
||||
|
||||
//By Convention we add 9 stnd PropertyTypes to an Umbraco MemberType
|
||||
entity.AddPropertyGroup(Constants.Conventions.Member.StandardPropertiesGroupName);
|
||||
var standardPropertyTypes = Constants.Conventions.Member.GetStandardPropertyTypeStubs();
|
||||
|
||||
@@ -223,8 +223,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="entity"></param>
|
||||
public virtual void PersistNewItem(IEntity entity)
|
||||
{
|
||||
PersistNewItem((TEntity)entity);
|
||||
_cache.Save(typeof(TEntity), entity);
|
||||
try
|
||||
{
|
||||
PersistNewItem((TEntity)entity);
|
||||
_cache.Save(typeof(TEntity), entity);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way
|
||||
// that we cache entities: http://issues.umbraco.org/issue/U4-4259
|
||||
_cache.Delete(typeof (TEntity), entity);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -233,8 +244,19 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// <param name="entity"></param>
|
||||
public virtual void PersistUpdatedItem(IEntity entity)
|
||||
{
|
||||
PersistUpdatedItem((TEntity)entity);
|
||||
_cache.Save(typeof(TEntity), entity);
|
||||
try
|
||||
{
|
||||
PersistUpdatedItem((TEntity)entity);
|
||||
_cache.Save(typeof(TEntity), entity);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way
|
||||
// that we cache entities: http://issues.umbraco.org/issue/U4-4259
|
||||
_cache.Delete(typeof (TEntity), entity);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -83,6 +83,27 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
return nodeDto == null ? 0 : nodeDto.NodeId;
|
||||
}
|
||||
|
||||
//This should be used later to do GetAll properly without individual selections
|
||||
private IEnumerable<Tuple<int, string>> GetStylesheetIds(string[] paths)
|
||||
{
|
||||
var sql = new Sql()
|
||||
.Select("*")
|
||||
.From<NodeDto>()
|
||||
.Where("nodeObjectType = @NodeObjectType AND umbracoNode.text in (@aliases)",
|
||||
new
|
||||
{
|
||||
NodeObjectType = UmbracoObjectTypes.Stylesheet.GetGuid(),
|
||||
aliases = paths.Select(x => x.TrimEnd(".css").Replace("\\", "/")).ToArray()
|
||||
});
|
||||
var dtos = _dbwork.Database.Fetch<NodeDto>(sql);
|
||||
|
||||
return dtos.Select(x => new Tuple<int, string>(
|
||||
//the id
|
||||
x.NodeId,
|
||||
//the original path requested for the id
|
||||
paths.First(p => p.TrimEnd(".css").Replace("\\", "/") == x.Text)));
|
||||
}
|
||||
|
||||
public override IEnumerable<Stylesheet> GetAll(params string[] ids)
|
||||
{
|
||||
if (ids.Any())
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user