Category: remember-this

Oct 06 2013

Things to remember about extending Orchard CMS

  1. Use the Orchard command line to create a module   —
    Type “help command” to get a list of command available in the orchard console.
    Enable code generation – type “feature enable Orchard.CodeGeneration”
    Type “help codegen module” to get usage on creating a module
    Type “codegen  module <projectname> /IncludeInSolution:true” to create your module.
  2. Use the Orchard command line to create a migration —
    Type “help codegen datamigration” to get usage
    Type “codegen datamigration <projectname> to create a migration for your project.
  3. To deploy an Orchard site —
    Open a VS command prompt at the root of your build sources
    type “build Precompiled”…this will create “build” and “buildtasks” folders
    The deployment source is in “build\Precompiled”
    Be sure that the App_Pool security context has write permissions on App_Data, and a Media folder (which you will have to create) of the IIS root
    NOTE -
  4. Info on handling existing databases
  5. Handling 1-1 and n-n db relaitonships in Orchard…

TO MAKE A NEW ORCHARD CONTENT PART…Lets call it the Xyz part

  1. Create a XyzPart  class.  Inherit from ContentPart<XyzPartRecord>
    This is a simple poco with property setters and gettters for each field in the part.
    The GET wll return Record..<FieldName>  like get {return Record.ItemCode; }
    The SET does the same like  set { Record.ItemCode = value;}
    Using Orchard and Orchard.ContentManagement
  2. Create a XyzPartRecord (per the reference in step 1) class that inherits from ContentPartRecord. 
    It uses matching virtual properties (so NHibernate can deal with it) like …
      public virtual string ItemCode{ get; set; }
    Using Orchard and Orchard.ContentManagement.Records
  3. Add migrations for updating the database.  
    Add a Create method.
    Use SchemaBuild.CreateTable to create the table and associate the content part with the record using lambdas like this…
    SchemaBuilder.CreateTable(“XyzPartRecord”, table=>table.ContentPartRecord().Column<string>(“ITemCode”));
  4. Creae a XyzPartHandler class which inherits from ContentHandler…
    This class just wires up the IRepository for the part like this…
    CTOR –
    publci XyzPartHandler(IRepository<XyzPartRecord> repository)  {
    Filters.Add(StorageFilter.For(repository));   }
    Using Orchard.Data and Orchard.ContentManagement.Handlers
    The handler plugs into the event lifecycle of a part and is typically used to wire up events.
  5. Please note that a Handler can hook into any part of the Part lifecycle.
    Add a XyzFeatureEventHandler file.
    Inherit from IFeatureEventHandler….implement the interfaces as necessary.  Notice that it has very generous Event Model…Number of points in the lifecycle.
    Delete  the not implemented exception we don’t need.
  6. Create XyzPartDriver which inherits from ContentPartDriver<XyzPart>
    The Driver serves the same function as an MVC Controller except that it operates at the part level rather than the page request level. 
  7. Creaet an XyzService class that Inherits from IXyzService which is an interface declard in the same file (I think this design is to enable use with an IOC).
    At the ver least add an Update method called something like UpwardXyzFor ContentItem and pass in a viewmodel and ContentItem. 
Aug 26 2013

How to create a gmail filter for a google contact group.

It is totally amazing that Google gmail does not support this out of the box. But the following will work, especially for a fairly static group.

  1. Start gmail.
  2. Compose a new email.
  3. In the TO box type the name of your gmail contact group. It should expand to show all the members.
  4. Do CTRL-A to select all of the members in the TO box.
  5. Do CTRL-C to copy them to the clipboard.
  6. Browse to here…
  7. On the web page, step 4, click in the convert textblock.
  8. Do CTRL-V to paste in your contacts from the clipboard.
  9. Click the [Convert] button.
  10. Click in the output textbox and do CTRL-A/CTRL-C to copy the results to the clipboard.
  11. Back in GMail, go to your settings page and click on Filters.
  12. Create a new Filter and in the FROM box paste in your results.
  13. Finish creating the filter (not covered here).


Jun 07 2013

AWESOME sql script for monitor the progress of a db restore

SELECT r.session_id,r.command,CONVERT(NUMERIC(6,2),r.percent_complete)
AS [Percent Complete],CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) AS [ETA Completion Time],
CONVERT(NUMERIC(10,2),r.total_elapsed_time/1000.0/60.0) AS [Elapsed Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0) AS [ETA Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0/60.0) AS [ETA Hours],
CONVERT(VARCHAR(1000),(SELECT SUBSTRING(text,r.statement_start_offset/2,
CASE WHEN r.statement_end_offset = -1 THEN 1000 ELSE (r.statement_end_offset-r.statement_start_offset)/2 END)
FROM sys.dm_exec_sql_text(sql_handle)))
FROM sys.dm_exec_requests r WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')

Found at stackoverflow here…

Oct 17 2012

MSBuild Tutorial # 4

Last time we talked about controlling the order that Targets

There is one other way I want to mention that is pretty cool. 
Try this…












1, Message1”




1, Message2”










2, Message1”




2, Message2”









3, Message1”




3, Message2”






Notice that the Target node supports a DependsOnTarget attribute. 
Even though Target 1  was supposed to execute first, when you run it you get
this output…


(R) Build Engine version 4.0.30319.17929


.NET Framework, version 4.0.30319.17929]


(C) Microsoft Corporation. All rights reserved.



started 10/17/2012 4:45:26 PM.


“C:\Users\sspearman\Documents\MSBuild\” on node 1 (default targets).




3, Message1



3, Message2




2, Message1



2, Message2




1, Message1



1, Message2


Building Project “C:\Users\sspearman.UPWARD\Documents\MSBuild\” (default












Elapsed 00:00:00.03


The DependOnTarget attribute ensured that Target 2 ran first. 
But Target 2 needed Target 3 to run first.  So the execution order was Target
3, Target 2, and then Target 1. 

Pretty cool.

Aug 26 2012

To enable automatic start and stop of VirtualBox VM in Ubuntu do this…

Put this script into your /etc/init.d folder. give it a name without an extension…in this case start-stop-vbox-vm.

Give it execute permissions by running
sudo chmod +x /etc/init.d/start-stop-vbox-vm

then run this to enable auto start and stop…

sudo update-rc.d start-stop=vbox=vm defaults 99 01


# Provides: start-stop-vbox-vm
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start vbox --headless at boot time.
# Description: Script will start VBOX VM at startup savestate for the VM at shutdown.

#! /bin/sh
# /etc/init.d/start-stop-vbox-vm

#Edit these variables!

case "$1" in
echo "Starting VirtualBox VM..."
sudo -H -b -u $VMUSER /usr/bin/VBoxManage startvm "$VMNAME" --type headless
echo "Saving state of Virtualbox VM..."
sudo -H -u $VMUSER /usr/bin/VBoxManage controlvm "$VMNAME" savestate
echo "Usage: /etc/init.d/SpodeVM {start|stop}"
exit 1

exit 0

Mar 11 2012

To screen capture issues with your Windows 7 computer you can use…

Problem Steps Recorder…


Jan 25 2012

To restore a “plain” postgresql backup …

1.  Drop/Recreate the target database using PGAdmin

2.  Be sure to add logins to all roles that are referenced in the backup script.  This should only be necessary the first time.  The phonesystem db references the following logins… phonesystem, phoneadmin, logsreader.

3.  From a terminal window run the following command

sudo psql -d phonesystem -U seths -f “<path-to-backup>”


Nov 19 2011

To get postgresql running on ubuntu to listen for external connections I did this…

  1. From a terminal window run “sudo gedit” and type your password when prompted.  Gedit opens and you edit the conf files using it.
  2. Edit the file at /etc/postgresql/8.3/main/postgresql.conf and change
    . This will enable TCPIP connections to the server.
  3. Edit the file at /etc/postgresql/8.3/main/pg_hba.conf and add the following line(s)
    host    all         all          trust
  4. This will allow tcpip connections (host) on any database (all) for any user (all) for CIDR-address 192.168.0 – any 16 high-level bits (  and authenticates anyone that can connect to the server-no pass (trust)
    See for details
  5. Add any additional ip address ranges you need to that file
  6. From a new terminal window restart postgresql by typing the following command from a new terminal window…
    sudo /etc/init.d/postgresql-8.4 restart
    and type your password…if you setup the configuration correctly you should get an [OK] from the terminal.

I was also worried I would have to learn how to open up an ubuntu firewall but that was not needed.

This article helped me…


Nov 17 2011

To extract all files from a Wise Installbuilder EXE do this…

I use Wise Installbuilder to deliver updates to software I write.  It is an old tool (no longer even available) but it works great for me.

Today I began to wonder if there was a way to EXTRACT the files that are included with the setup EXE that wise creates.

There is.  From the command line browse to the folder where you saved the EXE.  Type <EXENAME>.exe /X  .

The /X tells the installer to extract the files.  It will show a dialog with all of the extractable file (displayed as the script VARIABLE NAME) and when you select one and click okay you can browse for a target folder and, voila, it is done.

This is helpful to me because I embed SQL scripts into my updaters and if I ever want to see what I sent this does the trick.


Aug 04 2011

To create an event log entry in windows from the command line

I don’t know how often this would be helpful but today I needed it to solve a problem.  If you ever need to create an Windows Event Log entry you can do it from an ELEVATED Command Prompt as follows:

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO “My Event Source” /D “Actual Log Entry”