Skip to content

Instantly share code, notes, and snippets.

Add-WebTransform -ProjectPath "WebApplication1.csproj" -Environment "Dev"
Add-WebTransform -ProjectPath "WebApplication1.csproj" -Environment "Live"
Add-WebTransform -ProjectPath "WebApplication1.csproj" -Environment "PreLive"
Add-WebTransform -ProjectPath "WebApplication1.csproj" -Environment "Staging"
function Add-WebTransform() {
Param(
$ProjectPath = "WebApplication1.csproj",
$Environment = "Dev"
@johnmmoss
johnmmoss / Install-ScheduledTask.ps1
Created September 9, 2019 12:26
Example script to install a scheduled task for a console application
Param(
$userAccount = "NT AUTHORITY\SYSTEM",
$exePath = "C:\Code\SampleTaskConsole\bin\Debug\SampleTaskConsole.exe",
$taskName = "ScormCloudReporting"
)
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
$action = New-ScheduledTaskAction -Execute $exePath
$trigger = New-ScheduledTaskTrigger -Daily -At 1am
@johnmmoss
johnmmoss / AutoMapperSample.cs
Created September 5, 2019 13:04
AutoMapper sample
public static CustomerDto Map(Customer customerEntity)
{
var config = new MapperConfiguration(cfg => cfg.CreateMap<Customer, CustomerDto>());
var mapper = new Mapper(config);
return mapper.Map<CustomerDto>(customerEntity);
}
@johnmmoss
johnmmoss / TestHttpClient.cs
Created July 16, 2019 10:14
Methods using HttpClient for Integration style testing
public (HttpStatusCode Status, string Content) Get(string url)
{
HttpResponseMessage response;
string content = string.Empty;
using (var client = new HttpClient())
{
response = client.GetAsync(url).Result;
}
public class LogController : ApiController
{
public log4net.Repository.Hierarchy.Hierarchy LogHierarchy
{
get
{
return (log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository();
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
<log4net configSource="log4net.config"/>
<startup>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\Users\jmoss\Desktop\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>
write-host "Removing existing user $(BasicHttpUsername)"
Get-LocalUser | Where { $_.Name -eq $(BasicHttpUsername) } | Remove-LocalUser
$pwd = ConvertTo-SecureString $(BasicHttpPassword) -AsPlainText -Force
New-LocalUser $(BasicHttpUsername) -Password $pwd -FullName $(BasicHttpUsername) -Description "Http Basic Auth Account"
import-module DevProjectTools
# Edit this file
function Edit-Profile() {
vim $profile
}
# Edit the vimrc file
function Edit-Vimrc() {
vim $HOME\_vimrc
public void AddOrUpdate<T>(string fileName, params string[] columnNames) where T : class
{
Console.WriteLine($"AddOrUpdate : {fileName} ");
var entityRows = new List<T>();
var csvRows = _csvFileReader.ReadAllRows("DataFiles\\" + fileName);
foreach (var csvRow in csvRows)
{