├── UmbConsole
├── media
│ └── empty.txt
├── App_Plugins
│ └── empty.txt
├── App_Data
│ ├── Logs
│ │ └── empty.txt
│ └── TEMP
│ │ └── PluginCache
│ │ └── empty.txt
├── config
│ ├── metablogConfig.config
│ ├── 404handlers.config
│ ├── FileSystemProviders.config
│ ├── feedProxy.config
│ ├── applications.config
│ ├── BaseRestExtensions.config
│ ├── scripting.config
│ ├── log4net.config
│ ├── ExamineIndex.config
│ ├── UrlRewriting.config
│ ├── ExamineSettings.config
│ ├── Dashboard.config
│ ├── ClientDependency.config
│ ├── EmbeddedMedia.config
│ ├── trees.config
│ ├── umbracoSettings.config
│ └── tinyMceConfig.config
├── ConsoleBootManager.cs
├── Properties
│ └── AssemblyInfo.cs
├── packages.config
├── ConsoleApplicationBase.cs
├── Program.cs
├── UmbConsole.csproj
└── App.config
├── .nuget
├── NuGet.exe
├── NuGet.Config
└── NuGet.targets
├── UmbConsole.sln
├── .gitignore
└── README.md
/UmbConsole/media/empty.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/UmbConsole/App_Plugins/empty.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/UmbConsole/App_Data/Logs/empty.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/UmbConsole/App_Data/TEMP/PluginCache/empty.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sitereactor/umbraco-console-example/HEAD/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/UmbConsole/config/metablogConfig.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UmbConsole/config/404handlers.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/UmbConsole/config/FileSystemProviders.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/UmbConsole/config/feedProxy.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/UmbConsole/config/applications.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/UmbConsole/config/BaseRestExtensions.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
19 |
--------------------------------------------------------------------------------
/UmbConsole/config/scripting.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/UmbConsole/config/log4net.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/UmbConsole.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UmbConsole", "UmbConsole\UmbConsole.csproj", "{348CA314-DA08-474E-A236-173F82236EE2}"
5 | EndProject
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{07549C10-E1D1-42DB-957B-C0FC3EA31610}"
7 | ProjectSection(SolutionItems) = preProject
8 | .nuget\NuGet.Config = .nuget\NuGet.Config
9 | .nuget\NuGet.exe = .nuget\NuGet.exe
10 | .nuget\NuGet.targets = .nuget\NuGet.targets
11 | EndProjectSection
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {348CA314-DA08-474E-A236-173F82236EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {348CA314-DA08-474E-A236-173F82236EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {348CA314-DA08-474E-A236-173F82236EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {348CA314-DA08-474E-A236-173F82236EE2}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | EndGlobal
28 |
--------------------------------------------------------------------------------
/UmbConsole/config/ExamineIndex.config:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/UmbConsole/config/UrlRewriting.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/UmbConsole/ConsoleBootManager.cs:
--------------------------------------------------------------------------------
1 | using Umbraco.Core;
2 | using umbraco.editorControls;
3 | using umbraco.interfaces;
4 |
5 | namespace UmbConsole
6 | {
7 | ///
8 | /// Extends the CoreBootManager for use in this Console app.
9 | ///
10 | public class ConsoleBootManager : CoreBootManager
11 | {
12 | public ConsoleBootManager(UmbracoApplicationBase umbracoApplication, string baseDirectory)
13 | : base(umbracoApplication)
14 | {
15 | //This is only here to ensure references to the assemblies needed for the DataTypesResolver
16 | //otherwise they won't be loaded into the AppDomain.
17 | var interfacesAssemblyName = typeof(IDataType).Assembly.FullName;
18 | var editorControlsAssemblyName = typeof(uploadField).Assembly.FullName;
19 |
20 | base.InitializeApplicationRootPath(baseDirectory);
21 | }
22 |
23 | ///
24 | /// Can be used to initialize our own Application Events
25 | ///
26 | protected override void InitializeApplicationEventsResolver()
27 | {
28 | base.InitializeApplicationEventsResolver();
29 | }
30 |
31 | ///
32 | /// Can be used to add custom resolvers or overwrite existing resolvers once they are made public
33 | ///
34 | protected override void InitializeResolvers()
35 | {
36 | base.InitializeResolvers();
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/UmbConsole/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UmbConsole")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UmbConsole")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1b3cde86-cfb6-4a60-b55e-e24d2a287db6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/UmbConsole/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/UmbConsole/config/ExamineSettings.config:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
33 |
34 |
35 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/UmbConsole/config/Dashboard.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | settings
7 |
8 |
9 |
10 | views/dashboard/settings/settingsdashboardintro.html
11 |
12 |
13 |
14 |
15 |
16 |
17 | developer
18 |
19 |
20 |
21 | views/dashboard/developer/developerdashboardvideos.html
22 |
23 |
24 |
25 | /umbraco/dashboard/ExamineManagement.ascx
26 |
27 |
28 |
29 |
30 |
31 | media
32 |
33 |
34 |
35 | views/dashboard/media/mediafolderbrowser.html
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | translator
44 |
45 |
46 | content
47 |
48 |
49 |
50 | admin
51 |
52 |
53 | views/dashboard/default/startupdashboardintro.html
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | member
63 |
64 |
65 |
66 | views/dashboard/members/membersdashboardvideos.html
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.log
36 | *.vspscc
37 | *.vssscc
38 | .builds
39 |
40 | # Visual C++ cache files
41 | ipch/
42 | *.aps
43 | *.ncb
44 | *.opensdf
45 | *.sdf
46 |
47 | # Visual Studio profiler
48 | *.psess
49 | *.vsp
50 | *.vspx
51 |
52 | # Guidance Automation Toolkit
53 | *.gpState
54 |
55 | # ReSharper is a .NET coding add-in
56 | _ReSharper*
57 |
58 | # NCrunch
59 | *.ncrunch*
60 | .*crunch*.local.xml
61 |
62 | # Installshield output folder
63 | [Ee]xpress
64 |
65 | # DocProject is a documentation generator add-in
66 | DocProject/buildhelp/
67 | DocProject/Help/*.HxT
68 | DocProject/Help/*.HxC
69 | DocProject/Help/*.hhc
70 | DocProject/Help/*.hhk
71 | DocProject/Help/*.hhp
72 | DocProject/Help/Html2
73 | DocProject/Help/html
74 |
75 | # Click-Once directory
76 | publish
77 |
78 | # Publish Web Output
79 | *.Publish.xml
80 |
81 | # NuGet Packages Directory
82 | packages/
83 |
84 | # Windows Azure Build Output
85 | csx
86 | *.build.csdef
87 |
88 | # Windows Store app package directory
89 | AppPackages/
90 |
91 | # Others
92 | [Bb]in
93 | [Oo]bj
94 | sql
95 | TestResults
96 | [Tt]est[Rr]esult*
97 | *.Cache
98 | ClientBin
99 | [Ss]tyle[Cc]op.*
100 | ~$*
101 | *.dbmdl
102 | Generated_Code #added for RIA/Silverlight projects
103 |
104 | # Backup & report files from converting an old project file to a newer
105 | # Visual Studio version. Backup files are not needed, because we have git ;-)
106 | _UpgradeReport_Files/
107 | Backup*/
108 | UpgradeLog*.XML
109 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Umbraco 6 + 7 Console Example
2 | =======================
3 |
4 | Sample implementation of a Console application using the Umbraco ContentService for creating and saving content.
5 |
6 |
7 | *Applies to the version 6 example*: Before running this console app please ensure that the "umbracoDbDSN" ConnectionString is pointing to your database.
8 | If you are using Sql Ce please replace "|DataDirectory|" with a real path or alternatively place your database in the debug folder before running the application in debug mode.
9 |
10 | You can start off with an empty database and install the umbraco database schema from the application, but this will require that the 'umbracoConfigurationStatus' setting under appSettings is left blank. And if you are using Sql Ce an empty Umbraco.sdf file should exist in the DataDictionary.
11 |
12 | *Applies to the version 7 example*: This example assumes that the console executable is placed in the bin folder along side all the Umbraco assemblies. So the structure corresponds to that of a regular Umbraco site in that it assumes an AppData and Config folder to be present in the base directory. When using a Sql Ce database the "|DataDirectory|" part will be updated to the App_Data folder in the base directory and a new database will be created here if one doesn't already exists.
13 |
14 | This is a very simple implementation so it currently only has 3 options:
15 |
16 | - List content nodes
17 | - Create new content
18 | - Create database schema
19 |
20 |
21 | **NOTE:** The Umbraco 6 version of this console example is tagged with 'Umbraco-v.6.0.1' in the master branch. The latest commits found in the master branch is using version 7.0.2 of Umbraco.
22 |
23 | The main difference between the version 6 and 7 examples is an updated use of a base directory, which tells Umbraco to use a specific path as its base. This path is typically used to save media and other files to a specific set of folders.
24 |
25 | A special note about the version 7 example: Because all config files are now standard .NET config files they have to be placed side-by-side or in a subfolder of the web.config file (app.config for this console app) in order for the console to run. All config files placed in the \root\Config folder is therefor copied into the bin folder on application start.
26 |
27 | *PS: No WebContext is required*
--------------------------------------------------------------------------------
/UmbConsole/ConsoleApplicationBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using Umbraco.Core;
5 |
6 | namespace UmbConsole
7 | {
8 | ///
9 | /// Extends the UmbracoApplicationBase, which is needed to start the application with out own BootManager.
10 | ///
11 | public class ConsoleApplicationBase : UmbracoApplicationBase
12 | {
13 | public string BaseDirectory { get; private set; }
14 | public string DataDirectory { get; private set; }
15 |
16 | protected override IBootManager GetBootManager()
17 | {
18 | var binDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
19 | BaseDirectory = ResolveBasePath(binDirectory);
20 | DataDirectory = Path.Combine(BaseDirectory, "app_data");
21 | var appDomainConfigPath = new DirectoryInfo(Path.Combine(binDirectory.FullName, "config"));
22 |
23 | //Copy config files to AppDomain's base directory
24 | if (binDirectory.FullName.Equals(BaseDirectory) == false &&
25 | appDomainConfigPath.Exists == false)
26 | {
27 | appDomainConfigPath.Create();
28 | var baseConfigPath = new DirectoryInfo(Path.Combine(BaseDirectory, "config"));
29 | var sourceFiles = baseConfigPath.GetFiles("*.config", SearchOption.TopDirectoryOnly);
30 | foreach (var sourceFile in sourceFiles)
31 | {
32 | sourceFile.CopyTo(sourceFile.FullName.Replace(baseConfigPath.FullName, appDomainConfigPath.FullName), true);
33 | }
34 | }
35 |
36 | AppDomain.CurrentDomain.SetData("DataDirectory", DataDirectory);
37 |
38 | return new ConsoleBootManager(this, BaseDirectory);
39 | }
40 |
41 | public void Start(object sender, EventArgs e)
42 | {
43 | base.Application_Start(sender, e);
44 | }
45 |
46 | private string ResolveBasePath(DirectoryInfo currentFolder)
47 | {
48 | var folders = currentFolder.GetDirectories();
49 | if (folders.Any(x => x.Name.Equals("app_data", StringComparison.OrdinalIgnoreCase)) &&
50 | folders.Any(x => x.Name.Equals("config", StringComparison.OrdinalIgnoreCase)))
51 | {
52 | return currentFolder.FullName;
53 | }
54 |
55 | if (currentFolder.Parent == null)
56 | throw new Exception("Base directory containing an 'App_Data' and 'Config' folder was not found."+
57 | " These folders are required to run this console application as it relies on the normal umbraco configuration files.");
58 |
59 | return ResolveBasePath(currentFolder.Parent);
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/UmbConsole/config/ClientDependency.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
45 |
46 |
47 |
56 |
57 |
58 |
59 |
60 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/UmbConsole/config/EmbeddedMedia.config:
--------------------------------------------------------------------------------
1 |
2 |
71 |
--------------------------------------------------------------------------------
/UmbConsole/config/trees.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
42 |
--------------------------------------------------------------------------------
/UmbConsole/config/umbracoSettings.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 | 1
15 |
21 |
22 |
23 |
24 |
25 | your@email.here
26 |
27 |
28 |
29 | text
30 |
31 |
32 | In Preview Mode - click to end]]>
33 |
34 |
35 |
36 | 1800
37 |
38 |
44 | inline
45 |
46 |
47 | ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd
48 |
49 |
50 | Textstring
51 |
52 |
53 |
54 |
55 | false
56 |
57 | false
58 |
59 |
60 |
61 |
62 | false
63 |
64 | true
65 |
66 |
67 |
68 |
69 | Mvc
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | 0
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
104 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config"))
32 |
33 |
34 |
35 |
36 | $(SolutionDir).nuget
37 | packages.config
38 |
39 |
40 |
41 |
42 | $(NuGetToolsPath)\nuget.exe
43 | @(PackageSource)
44 |
45 | "$(NuGetExePath)"
46 | mono --runtime=v4.0.30319 $(NuGetExePath)
47 |
48 | $(TargetDir.Trim('\\'))
49 |
50 | -RequireConsent
51 |
52 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "
53 | $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols
54 |
55 |
56 |
57 | RestorePackages;
58 | $(BuildDependsOn);
59 |
60 |
61 |
62 |
63 | $(BuildDependsOn);
64 | BuildPackage;
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
87 |
88 |
91 |
92 |
93 |
94 |
96 |
97 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/UmbConsole/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlServerCe;
3 | using System.IO;
4 | using System.Linq;
5 | using Umbraco.Core;
6 | using Umbraco.Core.Persistence;
7 | using Umbraco.Core.Services;
8 |
9 | namespace UmbConsole
10 | {
11 | ///
12 | /// Before running this console app please ensure that the "umbracoDbDSN" ConnectionString is pointing to your database.
13 | /// If you are using Sql Ce please replace "|DataDirectory|" with a real path or alternatively place
14 | /// your database in the debug folder before running the application in debug mode.
15 | ///
16 | class Program
17 | {
18 | static void Main(string[] args)
19 | {
20 | Console.Title = "Umbraco Console";
21 |
22 | //Initialize the application
23 | var application = new ConsoleApplicationBase();
24 | application.Start(application, new EventArgs());
25 | Console.WriteLine("Application Started");
26 |
27 | Console.WriteLine("--------------------");
28 | //Write status for ApplicationContext
29 | var context = ApplicationContext.Current;
30 | Console.WriteLine("ApplicationContext is available: " + (context != null).ToString());
31 | //Write status for DatabaseContext
32 | var databaseContext = context.DatabaseContext;
33 | Console.WriteLine("DatabaseContext is available: " + (databaseContext != null).ToString());
34 | //Write status for Database object
35 | var database = databaseContext.Database;
36 | Console.WriteLine("Database is available: " + (database != null).ToString());
37 | Console.WriteLine("--------------------");
38 |
39 | //Get the ServiceContext and the two services we are going to use
40 | var serviceContext = context.Services;
41 | var contentService = serviceContext.ContentService;
42 | var contentTypeService = serviceContext.ContentTypeService;
43 |
44 | //Exit the application?
45 | var waitOrBreak = true;
46 | while (waitOrBreak)
47 | {
48 | //List options
49 | Console.WriteLine("-- Options --");
50 | Console.WriteLine("List content nodes: l");
51 | Console.WriteLine("Create new content: c");
52 | Console.WriteLine("Create Umbraco database schema in empty db: d");
53 | Console.WriteLine("Quit application: q");
54 |
55 | var input = Console.ReadLine();
56 | if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("q"))
57 | waitOrBreak = false;//Quit the application
58 | else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("l"))
59 | ListContentNodes(contentService);//Call the method that lists all the content nodes
60 | else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("c"))
61 | CreateNewContent(contentService, contentTypeService);//Call the method that does the actual creation and saving of the Content object
62 | else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("d"))
63 | CreateDatabaseSchema(database, databaseContext.DatabaseProvider, application.DataDirectory);
64 | }
65 | }
66 |
67 | ///
68 | /// Private method to list all content nodes
69 | ///
70 | ///
71 | private static void ListContentNodes(IContentService contentService)
72 | {
73 | //Get the Root Content
74 | var rootContent = contentService.GetRootContent();
75 | foreach (var content in rootContent)
76 | {
77 | Console.WriteLine("Root Content: " + content.Name + ", Id: " + content.Id);
78 | //Get Descendants of the current content and write it to the console ordered by level
79 | var descendants = contentService.GetDescendants(content);
80 | foreach (var descendant in descendants.OrderBy(x => x.Level))
81 | {
82 | Console.WriteLine("Name: " + descendant.Name + ", Id: " + descendant.Id + " - Parent Id: " + descendant.ParentId);
83 | }
84 | }
85 | }
86 |
87 | ///
88 | /// Private method to create new content
89 | ///
90 | ///
91 | ///
92 | private static void CreateNewContent(IContentService contentService, IContentTypeService contentTypeService)
93 | {
94 | //We find all ContentTypes so we can show a nice list of everything that is available
95 | var contentTypes = contentTypeService.GetAllContentTypes();
96 | var contentTypeAliases = string.Join(", ", contentTypes.Select(x => x.Alias));
97 |
98 | Console.WriteLine("Please enter the Alias of the ContentType ({0}):", contentTypeAliases);
99 | var contentTypeAlias = Console.ReadLine();
100 |
101 | Console.WriteLine("Please enter the Id of the Parent:");
102 | var strParentId = Console.ReadLine();
103 | int parentId;
104 | if (int.TryParse(strParentId, out parentId) == false)
105 | parentId = -1;//Default to -1 which is the root
106 |
107 | Console.WriteLine("Please enter the name of the Content to create:");
108 | var name = Console.ReadLine();
109 |
110 | //Create the Content
111 | var content = contentService.CreateContent(name, parentId, contentTypeAlias);
112 | foreach (var property in content.Properties)
113 | {
114 | Console.WriteLine("Please enter the value for the Property with Alias '{0}':", property.Alias);
115 | var value = Console.ReadLine();
116 | var isValid = property.IsValid(value);
117 | if (isValid)
118 | {
119 | property.Value = value;
120 | }
121 | else
122 | {
123 | Console.WriteLine("The entered value was not valid and thus not saved");
124 | }
125 | }
126 |
127 | //Save the Content
128 | contentService.Save(content);
129 |
130 | Console.WriteLine("Content was saved: " + content.HasIdentity);
131 | }
132 |
133 | ///
134 | /// Private method to install the umbraco database schema in an empty database
135 | ///
136 | ///
137 | ///
138 | ///
139 | private static void CreateDatabaseSchema(Database database, DatabaseProviders databaseProvider, string dataDirectory)
140 | {
141 | Console.WriteLine("Please note that installing the umbraco database schema requires an empty database configured in config.");
142 | Console.WriteLine("The 'umbracoConfigurationStatus' under appSettings should be left blank.");
143 | Console.WriteLine("If you are using Sql Ce an empty Umbraco.sdf file should exist in the DataDictionary.");
144 | Console.WriteLine("Press y to continue");
145 |
146 | var input = Console.ReadLine();
147 | if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("y"))
148 | {
149 | try
150 | {
151 | if (databaseProvider == DatabaseProviders.SqlServerCE)
152 | {
153 | var dbPath = Path.Combine(dataDirectory, "Umbraco.sdf");
154 | if (File.Exists(dbPath) == false)
155 | {
156 | var engine = new SqlCeEngine(@"Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;");
157 | engine.CreateDatabase();
158 | }
159 | }
160 |
161 | database.CreateDatabaseSchema(false);
162 |
163 | Console.WriteLine("The database schema has been installed");
164 | Console.WriteLine("Note: This is just an example, so no backoffice user has been created.");
165 | }
166 | catch (Exception e)
167 | {
168 | Console.WriteLine("An error occured while trying to install the database schema");
169 | Console.WriteLine(e.Message);
170 | Console.WriteLine(e.StackTrace);
171 | }
172 | }
173 | }
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/UmbConsole/UmbConsole.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {348CA314-DA08-474E-A236-173F82236EE2}
8 | Exe
9 | Properties
10 | UmbConsole
11 | UmbConsole
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 | false
28 |
29 |
30 | AnyCPU
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 | false
38 |
39 |
40 |
41 | ..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll
42 |
43 |
44 | ..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll
45 |
46 |
47 | ..\packages\UmbracoCms.Core.7.0.2\lib\businesslogic.dll
48 |
49 |
50 | ..\packages\UmbracoCms.Core.7.0.2\lib\ClientDependency.Core.dll
51 |
52 |
53 | ..\packages\ClientDependency-Mvc.1.7.0.4\lib\ClientDependency.Core.Mvc.dll
54 |
55 |
56 | ..\packages\UmbracoCms.Core.7.0.2\lib\cms.dll
57 |
58 |
59 | ..\packages\UmbracoCms.Core.7.0.2\lib\controls.dll
60 |
61 |
62 | ..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll
63 |
64 |
65 | ..\packages\UmbracoCms.Core.7.0.2\lib\Examine.dll
66 |
67 |
68 | ..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll
69 |
70 |
71 | ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
72 |
73 |
74 | ..\packages\UmbracoCms.Core.7.0.2\lib\interfaces.dll
75 |
76 |
77 | ..\packages\UmbracoCms.Core.7.0.2\lib\log4net.dll
78 |
79 |
80 | ..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll
81 |
82 |
83 | ..\packages\UmbracoCms.Core.7.0.2\lib\Microsoft.ApplicationBlocks.Data.dll
84 |
85 |
86 | ..\packages\UmbracoCms.Core.7.0.2\lib\Microsoft.Web.Helpers.dll
87 |
88 |
89 | True
90 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
91 |
92 |
93 | ..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.1\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll
94 |
95 |
96 | ..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll
97 |
98 |
99 | False
100 | ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll
101 |
102 |
103 | ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll
104 |
105 |
106 | ..\packages\UmbracoCms.Core.7.0.2\lib\SQLCE4Umbraco.dll
107 |
108 |
109 |
110 |
111 | True
112 | ..\packages\UmbracoCms.Core.7.0.2\lib\System.Data.SqlServerCe.dll
113 |
114 |
115 | True
116 | ..\packages\UmbracoCms.Core.7.0.2\lib\System.Data.SqlServerCe.Entity.dll
117 |
118 |
119 |
120 | ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll
121 |
122 |
123 |
124 |
125 | True
126 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll
127 |
128 |
129 | ..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll
130 |
131 |
132 | ..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.30506.0\lib\net40\System.Web.Http.WebHost.dll
133 |
134 |
135 | True
136 | ..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll
137 |
138 |
139 | True
140 | ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll
141 |
142 |
143 | True
144 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll
145 |
146 |
147 | True
148 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll
149 |
150 |
151 | True
152 | ..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll
153 |
154 |
155 |
156 |
157 |
158 |
159 | ..\packages\UmbracoCms.Core.7.0.2\lib\TidyNet.dll
160 |
161 |
162 | ..\packages\UmbracoCms.Core.7.0.2\lib\umbraco.dll
163 |
164 |
165 | ..\packages\UmbracoCms.Core.7.0.2\lib\Umbraco.Core.dll
166 |
167 |
168 | ..\packages\UmbracoCms.Core.7.0.2\lib\umbraco.DataLayer.dll
169 |
170 |
171 | ..\packages\UmbracoCms.Core.7.0.2\lib\umbraco.editorControls.dll
172 |
173 |
174 | ..\packages\UmbracoCms.Core.7.0.2\lib\umbraco.MacroEngines.dll
175 |
176 |
177 | ..\packages\UmbracoCms.Core.7.0.2\lib\umbraco.providers.dll
178 |
179 |
180 | ..\packages\UmbracoCms.Core.7.0.2\lib\Umbraco.Web.UI.dll
181 |
182 |
183 | ..\packages\UmbracoCms.Core.7.0.2\lib\umbraco.XmlSerializers.dll
184 |
185 |
186 | ..\packages\UmbracoCms.Core.7.0.2\lib\UmbracoExamine.dll
187 |
188 |
189 | ..\packages\UmbracoCms.Core.7.0.2\lib\UrlRewritingNet.UrlRewriter.dll
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
211 |
--------------------------------------------------------------------------------
/UmbConsole/config/tinyMceConfig.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | code
8 | images/editor/code.gif
9 | code
10 | 1
11 |
12 |
13 | removeformat
14 | images/editor/removeformat.gif
15 | removeformat
16 | 2
17 |
18 |
19 |
20 | Undo
21 | images/editor/undo.gif
22 | undo
23 | 11
24 |
25 |
26 | Redo
27 | images/editor/redo.gif
28 | redo
29 | 12
30 |
31 |
32 | Cut
33 | images/editor/cut.gif
34 | cut
35 | 13
36 |
37 |
38 | Copy
39 | images/editor/copy.gif
40 | copy
41 | 14
42 |
43 |
44 |
45 | styleselect
46 | images/editor/showStyles.png
47 | styleselect
48 | 20
49 |
50 |
51 | bold
52 | images/editor/bold.gif
53 | bold
54 | 21
55 |
56 |
57 | italic
58 | images/editor/italic.gif
59 | italic
60 | 22
61 |
62 |
63 | Underline
64 | images/editor/underline.gif
65 | underline
66 | 23
67 |
68 |
69 | Strikethrough
70 | images/editor/strikethrough.gif
71 | strikethrough
72 | 24
73 |
74 |
75 |
76 | JustifyLeft
77 | images/editor/justifyleft.gif
78 | justifyleft
79 | 31
80 |
81 |
82 | JustifyCenter
83 | images/editor/justifycenter.gif
84 | justifycenter
85 | 32
86 |
87 |
88 | JustifyRight
89 | images/editor/justifyright.gif
90 | justifyright
91 | 33
92 |
93 |
94 | JustifyFull
95 | images/editor/justifyfull.gif
96 | alignjustify
97 | 34
98 |
99 |
100 |
101 | bullist
102 | images/editor/bullist.gif
103 | bullist
104 | 41
105 |
106 |
107 | numlist
108 | images/editor/numlist.gif
109 | numlist
110 | 42
111 |
112 |
113 | Outdent
114 | images/editor/outdent.gif
115 | outdent
116 | 43
117 |
118 |
119 | Indent
120 | images/editor/indent.gif
121 | indent
122 | 44
123 |
124 |
125 |
126 | mceLink
127 | images/editor/link.gif
128 | link
129 | 51
130 |
131 |
132 | unlink
133 | images/editor/unLink.gif
134 | unlink
135 | 52
136 |
137 |
138 | mceInsertAnchor
139 | images/editor/anchor.gif
140 | anchor
141 | 53
142 |
143 |
144 |
145 | mceImage
146 | images/editor/image.gif
147 | image
148 | 61
149 |
150 |
151 |
152 | umbracomacro
153 | images/editor/insMacro.gif
154 | umbracomacro
155 | 62
156 |
157 |
158 |
159 |
160 |
161 | mceInsertTable
162 | images/editor/table.gif
163 | table
164 | 63
165 |
166 |
167 |
168 | umbracoembed
169 | images/editor/media.gif
170 | umbracoembed
171 | 66
172 |
173 |
174 | inserthorizontalrule
175 | images/editor/hr.gif
176 | hr
177 | 71
178 |
179 |
180 | subscript
181 | images/editor/sub.gif
182 | subscript
183 | 72
184 |
185 |
186 |
187 | superscript
188 | images/editor/sup.gif
189 | superscript
190 | 73
191 |
192 |
193 |
194 | mceCharMap
195 | images/editor/charmap.gif
196 | charmap
197 | 74
198 |
199 |
200 |
201 |
202 | code
203 | paste
204 | umbracolink
205 | anchor
206 | charmap
207 | table
208 | lists
209 |
210 |
211 |
223 |
224 | font
225 |
226 |
227 |
228 |
229 | raw
230 | GoogleSpellChecker.ashx
231 |
232 |
--------------------------------------------------------------------------------
/UmbConsole/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
--------------------------------------------------------------------------------