Unlike most shells, which accept and return text, Windows PowerShell is built on top of the .NET common language runtime (CLR) and the .NET Framework, and accepts and returns .NET objects. This fundamental change in the environment brings entirely new tools and methods to the management and configuration of Windows.
using System;
using System.Text;
using System.Management.Automation;
using System.Management.Automation.Provider;
using System.Diagnostics;
using System.ComponentModel;
[Cmdlet(VerbsCommon.Get, "ParcelMap",DefaultParameterSetName = "")]
public class GetParcelMapCommand : PSCmdlet
{
private string _pid;
private string _outputFile;
[Parameter(Position = 0)]
[ValidateNotNullOrEmpty]
public string PID
get { return _pid; }
set { _pid = value; }
}
[Parameter(Position = 1)]
public string OutputFile
get { return _outputFile; }
set { _outputFile = value; }
/// <summary>
/// Code here runs the commandline parameters
/// </summary>
protected override void BeginProcessing()
//We are hardcoding the location of the mxd file and the output type
DaBo.MapMaker.MapMakerService service = new DaBo.MapMaker.MapMakerService("ParcelMap",@"c:\parcelmap.mxd","Parcels","PIDN");
DaBo.MapMaker.MapMaker mm = new DaBo.MapMaker.MapMaker();
//we just pass in the parcel id and the output file
mm.ExportMap(service, DaBo.MapMaker.MapTypeEnum.PDF, _outputFile, _pid, 10, 10);
/// If we implemented code here, it would allow pipleline type operations
protected override void ProcessRecord()
{}
/// We'll use the name of this class with add-pssnapin later
[RunInstaller(true)]
public class GetParcelMapPSSnapIn : PSSnapIn
public GetParcelMapPSSnapIn() : base()
{ }
///code continues...
I'm Dave and this is my blog. I'm usually writing about .NET Software Development, ArcGIS, or Agile Practices, but other stuff does creep in from time to time. I hope you find something of use, and feel free to contact me if you have any questions. You can also check out my profile on LinkedIn
dojo.DTSAgile.com is our technology preview / demo site. As I and my team cook up cool things we post them here.
ArcDeveloper.net is a site that hosts a set of open source projects related to ArcGIS. This includes Tile Cache for .NET (TC4N) and Feature Server for .NET (FS4N). Come over and check it out!
Assembla is a free service that provides Subversion source control, wikis and work Tracking. The ArcDeveloper project is run from here. It rocks. Check them out today.
Agilistas is a LinkedIn group focused on discussing and promoting Agile practices. Everyone is welcome to join in the conversation as we evolve the process of creating software to make it more enjoyable for all involved.