Commit 45cf74e2 authored by Tran Anh Tu's avatar Tran Anh Tu
Browse files

umbraco

parent 52663462
This diff is collapsed.
using AFL;
using AFLUmbraco8.Models;
using Umbraco.Core.Models.PublishedContent;
namespace CloudDeploy.Core
{
public class BasePage : AFLModelBase
{
public BasePage(IPublishedContent node) : base(node)
{
}
public string ComponentSection => Memo();
public string OverviewTitle => Memo();
public string OverviewText => Memo();
public UmbracoFile OverviewImage => Memo<UmbracoFile>();
public string DocumentTitle => Memo();
public string MetaDescription => Memo();
public string MetaKeywords => Memo();
public bool RobotsNoFollow => Memo<bool>();
public bool UmbracoNaviHide => Memo<bool>();
public string NameInNavigationMenu => Memo();
public string UmbracoRedirect => Memo();
public string UmbracoRedirectOverview => Memo();
public string OpenGraphTitle => Memo();
public string OpenGraphDescription => Memo();
public UmbracoFile OpenGraphImage => Memo<UmbracoFile>();
public UmbracoFile TwitterImage => Memo<UmbracoFile>();
}
}
This diff is collapsed.
using AFLUmbraco8;
using System.Web.Mvc;
namespace CloudDeploy.Core
{
public class DefaultController : UmbracoDefaultControllerBase
{
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
}
}
}
using AFL;
using AFLUmbraco8.Models;
using Umbraco.Core.Models.PublishedContent;
namespace CloudDeploy.Core
{
[Renderable]
public class FrontPage : BasePage
{
public FrontPage(IPublishedContent node) : base(node)
{
}
public string PageContent => Memo();
public string Menu => Memo();
public string UtilityNavigationMenu => Memo();
public string HeaderNavigationMenuPrefix => Memo();
public string FooterLinks => Memo();
public string FooterDescription => Memo();
public string FooterCopyrightText => Memo();
public string FooterUtilityMenu => Memo();
public UmbracoFile Logo => Memo<UmbracoFile>();
public UmbracoFile FooterLogo => Memo<UmbracoFile>();
public string Color => Memo();
public UmbracoFile PlaceholderImage => Memo<UmbracoFile>();
public string SearchResultPageSize => Memo();
public string AnalyticsCode => Memo();
public string NewletterText => Memo();
public string NewsletterConsentText => Memo();
public string NewsletterSuccessText => Memo();
public string NewsletterListId => Memo();
public string NewsletterPage => Memo();
public ProjectLibrary Children => Memo<ProjectLibrary>();
}
}
using AFL;
using AFL.EventHandling;
using AFLUmbraco8.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.Json.Serialization;
using Umbraco.Core.Models.PublishedContent;
namespace CloudDeploy.Core
{
public class Project : AFLModelBase
{
public Project(IPublishedContent node) : base(node)
{
}
public string ProjectName => Memo();
public string ServicePlanTier => Memo();
public string ServicePlanSKU => Memo();
public string DatabaseServerName => Memo();
public string DatabaseAdminLogin => Memo();
public string DatabaseAdminPassword => Memo();
public string DatabaseNonAdminLogin => Memo();
public string DatabaseNonAdminPassword => Memo();
public string GitRepository => Memo();
[CMSEventHandler(CMSEvent.Saved)]
public void OnSaved(CMSEventArgs args)
{
//using (StreamReader file = File.OpenText(@"c:\Temp\azuredeploy.json"))
//using (JsonTextReader reader = new JsonTextReader(file))
//{
// JObject o2 = (JObject)JToken.ReadFrom(reader);
// var x = JsonConvert.DeserializeObject<DeployConfiguration>(o2.ToString());
//}
//string json = JsonConvert.SerializeObject(new DeployConfiguration { schema = "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", contentVersion = "1.0.0.0" });
DeployConfiguration dc = new DeployConfiguration
{
Schema = "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
contentVersion = "1.0.0.0",
parameters = new Parameters {
repoUrl = new RepoUrl
{
type = "string",
defaultValue = "https://gitlab.dev.appstract.dk/internal/umbracobase/-/raw/master/",
metadata = new Metadata { description = "repo url"}
},
appName = new AppName
{
type = "string",
defaultValue = "[concat('umbraco', uniqueString(resourceGroup().id))]",
metadata = new Metadata { description = "name of azure app"}
},
servicePlanTier = new ServicePlanTier
{
type = "string",
defaultValue = "PremiumV2",
allowedValues = new string [] {"Standard","Premium","PremiumV2"}
}
},
};
File.WriteAllText(@"C:\Temp\testWrite.json", JsonConvert.SerializeObject(dc));
string batDir = string.Format(@"C:\Projects\clouddeploy\");
Process proc = null;
proc = new Process();
proc.StartInfo.WorkingDirectory = batDir;
proc.StartInfo.FileName = "yourbatch.bat";
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
}
}
public class DeployConfiguration
{
[JsonProperty("$schema")]
public string Schema { get; set; }
public string contentVersion { get; set; }
public Parameters parameters { get; set; }
public Variables variables { get; set; }
public List<Resource> resources { get; set; }
}
public class Parameters
{
public RepoUrl repoUrl { get; set; }
public AppName appName { get; set; }
public ServicePlanTier servicePlanTier { get; set; }
public ServicePlanSku servicePlanSku { get; set; }
public DbServerName dbServerName { get; set; }
public DbAdministratorLogin dbAdministratorLogin { get; set; }
public DbAdministratorLoginPassword dbAdministratorLoginPassword { get; set; }
public DbName dbName { get; set; }
public NonAdminDatabaseUserName nonAdminDatabaseUserName { get; set; }
public NonAdminDatabasePassword nonAdminDatabasePassword { get; set; }
public StorageAccountType storageAccountType { get; set; }
public Location location { get; set; }
public ArtifactsLocation _artifactsLocation { get; set; }
public ArtifactsLocationSasToken _artifactsLocationSasToken { get; set; }
}
public class RepoUrl
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class Metadata
{
public string description { get; set; }
}
public class AppName
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class ServicePlanTier
{
public string type { get; set; }
public string[] allowedValues { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class ServicePlanSku
{
public string type { get; set; }
public List<string> allowedValues { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class DbServerName
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class DbAdministratorLogin
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class DbAdministratorLoginPassword
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class DbName
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class NonAdminDatabaseUserName
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class NonAdminDatabasePassword
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class StorageAccountType
{
public string type { get; set; }
public List<string> allowedValues { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class Location
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class ArtifactsLocation
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class ArtifactsLocationSasToken
{
public string type { get; set; }
public string defaultValue { get; set; }
public Metadata metadata { get; set; }
}
public class Variables
{
public string storageAccountName { get; set; }
public string appServicePlanName { get; set; }
}
public class Resource
{
public string type { get; set; }
public string apiVersion { get; set; }
public string name { get; set; }
public string location { get; set; }
public Sku sku { get; set; }
public string kind { get; set; }
public List<string> dependsOn { get; set; }
public Properties properties { get; set; }
public List<Resource> resources { get; set; }
public Tags tags { get; set; }9
}
public class Sku
{
public string name { get; set; }
public string tier { get; set; }
public string Tier { get; set; }
public string Name { get; set; }
}
}
using AFL;
using AFLUmbraco8.Models;
using Umbraco.Core.Models.PublishedContent;
namespace CloudDeploy.Core
{
public class ProjectLibrary : AFLModelBase
{
public ProjectLibrary(IPublishedContent node) : base(node)
{
}
public Project Children => Memo<Project>();
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CloudDeploy.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CloudDeploy.Core")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f22022a7-faa4-45a8-9dda-2ed03482c243")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
:: ISSUE :: Exception is thrown when calling CompileAssemblyFromDom
This is the exception
System.IO.DirectoryNotFoundException: 'Could not find a part of the path '<path to your project>\bin\Debug\bin\roslyn\csc.exe'.'
Fix:
1) Uninstall NuGet package Microsoft.CodeDom.Providers.DotNetCompilerPlatform 2.0.0
2) Install NuGet package Microsoft.CodeDom.Providers.DotNetCompilerPlatform 2.0.0
3) This will update your config file and now it should work
:: OTHER ISSUES ::
Ensure all required assemblies are loaded before invoking Razor.Evaluate method
Ensure that required namespaces are added to either the view or using the engineHost.NamespaceImports.Add() method in the Razor.GenerateType method
using AFL;
using AFL.Core;
using AFL.Search;
using System.Web.Mvc;
using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web;
namespace CloudDeploy.Core
{
public class Startup : IUserComposer
{
void IComposer.Compose(Composition composition)
{
composition.SetDefaultRenderMvcController(typeof(DefaultController));
composition.Components().Append<AFLComponent>();
}
}
public class AFLComponent : IComponent
{
private readonly string wsRouteBase = "ws";
public void Initialize()
{
Registry.Initialize(new AFLUmbraco8.AFLUmbraco(), new NoSearch(), new[] { GetType().Assembly }, wsRouteBase);
RouteTable.Routes.MapRoute(
"ws",
wsRouteBase + "/{*anything}",
new { controller = "Default", action = "HandleWSCall" }
);
RouteTable.Routes.MapRoute(
name: "xmlsitemap",
url: "xmlsitemap",
new { controller = "Default", action = "Sitemap" }
);
}
public void Terminate()
{
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.4.0.0" newVersion="5.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.4.0.0" newVersion="5.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.4.0.0" newVersion="5.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.4.0.0" newVersion="5.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="aspnet:RoslynCompilerLocation" value="roslyn" />
</appSettings>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data></configuration>
\ No newline at end of file
<?xml version="1.0"?>
<doc>
<assembly>
<name>Microsoft.CodeDom.Providers.DotNetCompilerPlatform</name>
</assembly>
<members>
<member name="T:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider">
<summary>
Provides access to instances of the .NET Compiler Platform C# code generator and code compiler.
</summary>
</member>
<member name="M:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider.#ctor">
<summary>
Default Constructor
</summary>
</member>
<member name="M:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider.#ctor(Microsoft.CodeDom.Providers.DotNetCompilerPlatform.ICompilerSettings)">
<summary>
Creates an instance using the given ICompilerSettings
</summary>
<param name="compilerSettings"></param>
</member>
<member name="M:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider.CreateCompiler">
<summary>
Gets an instance of the .NET Compiler Platform C# code compiler.
</summary>
<returns>An instance of the .NET Compiler Platform C# code compiler</returns>
</member>
<member name="T:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.ICompilerSettings">
<summary>
Provides settings for the C# and VB CodeProviders
</summary>
</member>
<member name="P:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.ICompilerSettings.CompilerFullPath">
<summary>
The full path to csc.exe or vbc.exe
</summary>
</member>
<member name="P:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.ICompilerSettings.CompilerServerTimeToLive">
<summary>
TTL in seconds
</summary>
</member>
<member name="T:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider">
<summary>
Provides access to instances of the .NET Compiler Platform VB code generator and code compiler.
</summary>
</member>
<member name="M:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider.#ctor">
<summary>
Default Constructor
</summary>
</member>
<member name="M:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider.#ctor(Microsoft.CodeDom.Providers.DotNetCompilerPlatform.ICompilerSettings)">
<summary>
Creates an instance using the given ICompilerSettings
</summary>
<param name="compilerSettings"></param>
</member>
<member name="M:Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider.CreateCompiler">
<summary>
Gets an instance of the .NET Compiler Platform VB code compiler.
</summary>
<returns>An instance of the .NET Compiler Platform VB code compiler</returns>
</member>
</members>
</doc>
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]