Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Tuesday, 29 March 2016

https://chocolatey.org/

“Chocolatey is a package manager for Windows (like apt-get or yum but for Windows). It was designed to be a decentralized framework for quickly installing applications and tools that you need. It is built on the NuGet infrastructure currently using PowerShell as its focus for delivering packages from the distros to your door, err computer.”

  • Open Cmd prompt as admin
  • Paste in code
  • choco

image

https://chocolatey.org/packages

choco install ccleaner

Very useful for new build!

| | # 
# Thursday, 24 March 2016

for %%a in ("*.mp4") do ffmpeg -i "%%a" "newfiles\%%~na.mp3"

Pause

Converts all mp4's in directory to newfiles\

Open ffmpeg in its own cmd shell

| | # 
# Friday, 19 February 2016
( Azure )

“The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”

http://stackoverflow.com/a/18938991/26086

<httpErrors existingResponse="PassThrough"/>
| | # 
# Wednesday, 17 February 2016
( MVC5 )

http://stackoverflow.com/questions/18570158/handling-singular-and-plural-controllers-routes/21227932#21227932

From this answer I’m considering the Authors and Books example I am building:

/Authors                               - list of Authors (multiple)
/Authors/1                           - individual Author  (this is the only non default route in MVC)
/Authors/Create                 - create an Author
/Authors/Edit/1                   - edit an Author
/Authors/Delete/1              - delete an Author


/Authors/Search?lastName=mateer  - search for an Author lastName=mateer
/Authors/Search?tab=newest&lastName=mateer

/Authors/1/Dave-Mateer   - individual Author  (first name / last name)

Database

image
Pluralising the table name.  Discussion here: http://stackoverflow.com/questions/338156/table-naming-dilemma-singular-vs-plural-names?rq=1
A descriptive auto-inc ID.

Stored Proc Parameters

CREATE PROCEDURE [dbo].SearchAuthorByLastName
    @LastName varchar(255)
AS
    SELECT * FROM [Authors] WHERE LastName like '%' + @LastName + '%'

Use capital letters for SP parameters

| | # 
# Tuesday, 16 February 2016

Exploring workflows of

  • DB Project in VS2015
  • Appveyor
  • Deploying to Azure

with the end goal of having a well tested app, which has good automated deployment.

image

So, easy to easily redeploy a standard db

If I put a BookTech.mdf and .ldf in the IntegrationTests project then in Appveyor, before tests, run this PS:

$startPath = "$($env:appveyor_build_folder)\BookTechSite.IntegrationTests\bin\debug\"
$sqlInstance = "(local)\SQL2014"
$dbName = "BookTech"

# replace the db connection with the local instance
$config = join-path $startPath "BookTechSite.IntegrationTests.dll.config"
$doc = (gc $config) -as [xml]
$doc.SelectSingleNode('//connectionStrings/add[@name="BookTechConnectionString"]').connectionString = "Server=$sqlInstance; Database=$dbName; Trusted_connection=true"
$doc.Save($config)

# attach mdf to local instance
$mdfFile = join-path $startPath "BookTech.mdf"
$ldfFile = join-path $startPath "BookTech_log.ldf"
sqlcmd -S "$sqlInstance" -Q "Use [master]; CREATE DATABASE [$dbName] ON (FILENAME = '$mdfFile'),(FILENAME = '$ldfFile') for ATTACH"

this works, but clunky.

dacpac

This is working well and great to have the database source controlled.

https://bitbucket.org/davemateer/booktech/src

https://www.appveyor.com/docs/deployment/sql-database-ssdt

https://github.com/FeodorFitsner/dacpac-sample/blob/master/appveyor.yml – useful starting config file

https://www.appveyor.com/docs/build-configuration#secure-variables - Connection strings are encrypted

https://ci.appveyor.com/tools/encrypt – took to encrypt

 

version: 1.0.{build}

environment:
  # CI Appveyor connection string - if this Environment Variable is present, then the Repository code uses this connection string.
  AppveyorSQL2014ConnectionString: Server=(local)\SQL2014;Database=BookTech;User ID=sa;Password=Password12!
 
  # Live Azure db connection string - encrypted using tool in Appeyor UI
  # Server=tcp:booktechserver.database.windows.net,1433;Database=booktech2;User ID=dave@booktechserver;Password=******;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
  # update line 45 too!
  BookTechConnectionString-Web.config Connection String:
    secure:  LCcX3rMYSmcHDQ966zbpW/sUFD1xQe3J0mwAzYj7t/y1r25psjHhoU6lBVmlZyhQYPGumsxvPQ20IZRJohWCVMRYxiSmkvJWKHT9yO9HMKPr1HRLnjt6iYKExQD30KnQUAjc93DNWFtCax4lSXlP5rjUC3ssx7XJJTdQ4MwTI9LHhBH7CBQuWvTNqMTQ8ps+X3Hl4T1zXnUJY/0x0olFvxqDPuY1PlQt8hd69Jc9l2yA4vaG/QAKiGsKtmUnc4EV
  matrix:
  - {}
 
services: mssql2014

# deploy .dacpac package to local SQL Server instance for integration testing
after_build:
  - '"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:dbDacFx="C:\projects\BookTech\BookTechDatabase\bin\Debug\BookTechDatabase.dacpac" -dest:dbDacFx="%AppveyorSQL2014ConnectionString%",dacpacAction=Deploy,CreateNewDatabase=True'
      
before_build:
  - cmd: appveyor-retry nuget restore

build:
  publish_wap: true
  verbosity: minimal

artifacts:
  - path: BookTechDatabase\bin\debug\BookTechDatabase.dacpac
    name: BookTech 
 
deploy:
  # Deploy website to Azure
  - provider: WebDeploy
    server: https://booktech.scm.azurewebsites.net/msdeploy.axd?site=booktech
    website: booktech
    username: $booktech
    password:
      # Was put in via the UI and exported to yml - essentially the publish settings for the website from Azure
      secure: rkp03SX+duzOUKu/ZRymYUXI4b6OIXIrEzIIDm2605q8MBTBlrQwxGN8zxCCovEYj2lkv5qoMvy8TTAW+zASVA==
    remove_files: true
   
    # Deploy Database to Azure - firewall rules are setup on Azure side to allow inbound connections..
  - provider: SqlDatabase
    artifact: BookTech
    # Same as line 8
    connection_string:
      secure:  LCcX3rMYSmcHDQ966zbpW/sUFD1xQe3J0mwAzYj7t/y1r25psjHhoU6lBVmlZyhQYPGumsxvPQ20IZRJohWCVMRYxiSmkvJWKHT9yO9HMKPr1HRLnjt6iYKExQD30KnQUAjc93DNWFtCax4lSXlP5rjUC3ssx7XJJTdQ4MwTI9LHhBH7CBQuWvTNqMTQ8ps+X3Hl4T1zXnUJY/0x0olFvxqDPuY1PlQt8hd69Jc9l2yA4vaG/QAKiGsKtmUnc4EV

| | #