Skip to content

Instantly share code, notes, and snippets.

Warren Buckley warrenbuckley

  • Umbraco
  • Westcliff on Sea, Essex, UK
View GitHub Profile
@warrenbuckley
warrenbuckley / WebApiAttributeRoutes.cs
Created Feb 4, 2019
How to register & use WebAPI with Attribute Routes in Umbraco V8
View WebApiAttributeRoutes.cs
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Core.Components;
namespace My.Website
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class ApiComposer : IUserComposer
{
public void Compose(Composition composition)
@warrenbuckley
warrenbuckley / DatabaseExample.cs
Created Feb 4, 2019
Super simple example of using Database inside Umbraco V8
View DatabaseExample.cs
using Umbraco.Core.Scoping;
namespace My.Website
public class DatabaseExample
{
private IScopeProvider _scopeProvider;
public DatabaseExample(IScopeProvider scopeProvider)
{
_scopeProvider = scopeProvider;
View TestCancelSave.cs
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Components;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
namespace Umbraco.Web.UI
{
@warrenbuckley
warrenbuckley / iisexpress-vscode-install.bat
Last active Jan 6, 2017
A work in progress Batch file to automate downloading & installing Visual Studio Code, the IIS Express VS Code extension & IISExpress itself if its not installed already
View iisexpress-vscode-install.bat
ECHO OFF
rem Check if VS Code is installed - Checks if its in the path
rem Not 100% sure best way as think installer allows yout to NOT put it in the %PATH%
CALL where /q code
IF ERRORLEVEL 1 (
ECHO Visual Studio Code is not installed.
ECHO Downloading installer from https://vscode-update.azurewebsites.net/latest/win32/stable
rem Download the file & name it VSCodeSetup.exe relative to this running batch file
@warrenbuckley
warrenbuckley / SomeTreeController.cs
Last active Oct 28, 2016
This is a way to determine what version of Umbraco is being used & conditionally change Angular views or logic based on that.
View SomeTreeController.cs
public static bool UseLegacyEditors()
{
return UmbracoVersion.Current < new Version(7, 4);
}
var someRoutePath = Core.Configuration.UseLegacyEditors()
? "/myApp/treeAlias/edit-legacy/" + someObj.Id
: "/myApp/treeAlias/edit/" + someObj.Id;
@warrenbuckley
warrenbuckley / UpdateCheckerController.cs
Last active Nov 27, 2016
V3 Nuget API using Nuget.Core Package
View UpdateCheckerController.cs
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using NuGet.Configuration;
using NuGet.Protocol.Core.Types;
using NuGet.Protocol.Core.v3;
using NuGet.Versioning;
namespace Umbraco.Forms.UpdateChecker.Controller
{
View gist:a486d50d39024415001d
/*
SQL CMD
-S Server Name
-U Username
-P MyPassword
-d Datbase file to excute SQL script against
-i SQL file to excute
-x Super magic switch that managed to get SQL to run when it bombed first time
*/
View gist:28243300b2907677a1fa
@{
//Obviously get header from umbraco value
var header = string.empty;
var mainHeader = Model.Content.GetPropertyValue<string>("mainHeader");
var secondaryHeader = Model.Content.GetPropertyValue<string>("secondaryHeader");
var nodeName = Model.Content.Name;
//Check if we have mainHeader value, fallback to secondaryHeader
header = !string.IsNullOrEmpty(mainHeader) : mainHeader ? secondaryHeader;
View gist:7498daadb52f9e8c65c1
[03/14/2015 20:00:25 > 73746b: INFO] Try and get 'videos' doctype
[03/14/2015 20:00:55 > 73746b: INFO] Exception Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
[03/14/2015 20:00:55 > 73746b: INFO] Exception Source: .Net SqlClient Data Provider
[03/14/2015 20:00:55 > 73746b: INFO] Exception StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
[03/14/2015 20:00:55 > 73746b: INFO] at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
[03/14/2015 20:00:55 > 73746b: INFO] at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
[03/14/2015 20:00:55 > 73746b: INFO] at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkC
View Azure WebJob Output
[03/14/2015 12:00:04 > 73746b: SYS INFO] Status changed to Initializing
[03/14/2015 12:00:08 > 73746b: SYS INFO] Run script 'uHangout.WebJob.exe' with script host - 'WindowsScriptHost'
[03/14/2015 12:00:08 > 73746b: SYS INFO] Status changed to Running
[03/14/2015 12:00:09 > 73746b: INFO] WEBJOBS_PATH:D:\local\Temp\jobs\triggered\uHangout-WebJob\kh5oaqlx.pvr\
[03/14/2015 12:00:09 > 73746b: INFO] Created D:\local\Temp\jobs\triggered\uHangout-WebJob\kh5oaqlx.pvr\App_Data
[03/14/2015 12:00:09 > 73746b: INFO] Created D:\local\Temp\jobs\triggered\uHangout-WebJob\kh5oaqlx.pvr\App_Plugins
[03/14/2015 12:00:09 > 73746b: INFO] Created D:\local\Temp\jobs\triggered\uHangout-WebJob\kh5oaqlx.pvr\media
[03/14/2015 12:00:09 > 73746b: INFO] uHangout YouTube Importer
[03/14/2015 12:00:09 > 73746b: INFO] ==================================
[03/14/2015 12:00:12 > 73746b: INFO] ******
You can’t perform that action at this time.