How to Write a Custom Connector: CSV Connector Example

How to Write a Custom Connector: CSV Connector Example

  • Comments 25
  • Likes

One of the most important common ways partners and customers will extend Service Manager is to create custom connectors to get data into the system.  There are many ways of doing this and we will catalog all of them at this blog post.

The post and linked (at the bottom) Visual Studio project and detailed implementation guide describe how to build a CSV “connector”.   It  builds on the idea in this post CSV Import Connector using the Service Manager workflow platform and PowerShell of using the Import-SCSMOjbect PowerShell cmdlet to import the data in a CSV file.  This particular example takes it to the next level by allowing a user to quickly create a CSV connector instance using a wizard in the Connectors view in the main console.  Once the connector is created it can be managed like other connectors – edit, delete, and enable/disable.

While the main purpose of this example is to show how to create a fancy custom connector it also is good for showing how to create console tasks, task handlers, and using the wizard/property sheet framework.  It also shows how to use the SDK to manipulate EnterpriseManagementObjects and create/edit/delete Rules in a management pack.

The end result is a user experience that looks like this:

image

Opens this wizard:

image

Provide configuration…

image

Confirmation…

image

Completion..

image

Which then creates a connector…

image

That you can manage like any other connector…

image

including editing the configuration…

image

You can get the source files for the project and a detailed document describing the implementation from here:

UPDATE: This is now a Code Plex project.  You can download just the Released versions to install in your environment and use or you can contribute to the project by joining up as a developer on the project.

http://scsmcsvconnector.codeplex.com/

This project is intended more for a developer audience!  If you want to simply use the solution, please be aware that this is not an officially supported component of the Service Manager product.  It has been tested somewhat, but you are on your own to use it.  To use it, please follow the directions in the Deployment section of the attached document.

Enjoy!

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • This will not start running.  Am I missing something.  I put 5 min and it never runs.  I then tried 1 min and still nothing happens.

    Thanks.

  • This will not start running.  Am I missing something?  I put 5 min and it never runs.  I then tried 1 min and still nothing happens.

    Thanks.

  • Please follow this blog post to troubleshoot the workflow:

    blogs.technet.com/.../troubleshooting-workflows-in-service-manager.aspx

    Please make sure the System Center Management Service is started on the Management Server.

  • Sorry for the double post yesterday.

    I tried everything in the troubleshooting post already and still nothing.  The connector is there but it just never runs.  I have done a manual import and all the data and the XML files are fine.

    When I look in the status of the workflows, there is nothing there for the connector.  I restarted all the services on the management server to see if that would help. (they were running)  Still won't run.

    Any ideas?  

    Thanks.

  • @Dave -

    Please contact me @ scsmbeta [at] live [dot] com.  This will be faster to sort out in email.  :)

  • I have such problem too. In the SCSM/Administration/Workflows there is no any "SCVConnectorWorkflow" - I have found it name into text of MP. And what is the file "DoWork.ps1"? Where this file locate?

  • This will not start running. There is no workflow. How can i make this work?

  • @Patrick -

    Did you import the MP and copy the assembly to C:\Program Files\Microsfot System Center\Service Manager 2010 on the management server where your workflows are running?

  • @Travis

    I followed the instructions from readme.txt

    -I've copied the files: CSVConnectorWorkflow.dll, Microsoft.ServiceManager.WorkflowAuthoring.ActivityLibrary.dll, Microsoft.ServiceManager.WorkflowAuthoring.Common.dll to "C:\Program Files\Microsoft System Center\Service Manager 2010" on the SCSM server

    -I've copied Microsoft.Demo.Connectors.dll to my local machine at C:\Program Files\Microsoft System Center\Service Manager 2010

    -I've Imported the Microsoft.Demo.Connectors.xml MP

    -I've set up the connector (No errors)

    And nothing happens. The connector is enabled.

    When i look at the workflows in SCSM, there is no microsoft.demo workflow.

    What am i doing wrong?  

  • @Patrick - please check the Operations Manager event log on the SCSM management server to see if there are some failure events there.

  • @travis

    Error importing solutions. Error message:Management Pack [Microsoft.EnterpriseManagement.ServiceManager.Connector.AD,d43c3091-62c2-6404-607d-4376e592a89b] already imported.

    Management Pack [Microsoft.EnterpriseManagement.ServiceManager.Connector.Sms,f772aa89-b934-2fac-4f37-5e0165d390ec] already imported.

    I get the above error.

    I still get this error even if I disable the other connectors.

  • @Patrick - Those events are unrelated to the CSV connector - anything else?

  • @Patrick - also see this blog post about troubleshooting workflows.  You may find the error in the database.

    blogs.technet.com/.../troubleshooting-workflows-in-service-manager.aspx

  • That's the problem, there in no CSV connectoer workflow in SCSM.

    I will have a look in the database

    Thanks for your help!

  • Good morning, my name is Cesar I'm from Mexico wisar and GRUMA work, our company is implementing the SCSM and the task that I have assigned to update the inventory of computer equipment, I made a class and an MP and I went up to manually , but ideally it as CSV connector for time, I have a doubt, install it as you indicate but I have not worked, will not start, I made a workflow with but does nothing not execute the activity

    it does not work??

    This is the code

    ManagementPack ContentReadable="true" SchemaVersion="1.1" OriginalSchemaVersion="1.1" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:xsl="www.w3.org/.../Transform">

    - <Manifest>

    - <Identity>

     <ID>Importar.Activos.Gruma</ID>

     <Version>1.0.0.0</Version>

     </Identity>

     <Name>Importar.Activos.Gruma</Name>

    - <References>

    - <Reference Alias="System">

     <ID>System.Library</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

    - <Reference Alias="Console">

     <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

    - <Reference Alias="EnterpriseManagement">

     <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

    - <Reference Alias="SystemCenter">

     <ID>Microsoft.SystemCenter.Library</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

    - <Reference Alias="SystemCenter1">

     <ID>Microsoft.SystemCenter.Subscriptions</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

    - <Reference Alias="Core">

     <ID>ServiceManager.Core.Library</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

    - <Reference Alias="Windows">

     <ID>Microsoft.Windows.Library</ID>

     <Version>7.0.6555.0</Version>

     <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>

     </Reference>

     </References>

     </Manifest>

    - <TypeDefinitions>

    - <EntityTypes>

    - <ClassTypes>

    - <ClassType ID="Activos.Gruma" Accessibility="Public" Abstract="false" Base="System!System.ConfigItem" Hosted="false" Singleton="false" Extension="false">

     <Property ID="Costo" Type="decimal" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="18" MinLength="0" Required="false" />

     <Property ID="FechaAnexo" Type="datetime" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />

     <Property ID="VencimintoAnexo" Type="datetime" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />

     <Property ID="FechaPrimerPago" Type="datetime" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />

     <Property ID="FolioAnexo" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="225" MinLength="0" Required="false" />

     <Property ID="Arrendador" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="225" MinLength="0" Required="false" />

     <Property ID="NetbiosComputerName" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="128" MinLength="0" Required="false" />

     <Property ID="Descripcion" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="225" MinLength="0" Required="false" />

     <Property ID="NombreResponsable" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="40" MinLength="0" Required="false" />

     <Property ID="EmpolyeeId" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="128" MinLength="0" Required="false" />

     <Property ID="UserName" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="20" MinLength="0" Required="false" />

     <Property ID="Division" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="40" MinLength="0" Required="false" />

     <Property ID="Empresa" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="225" MinLength="0" Required="false" />

     <Property ID="FolioFactura" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="128" MinLength="0" Required="false" />

     <Property ID="Localidad" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="50" MinLength="0" Required="false" />

     <Property ID="StatusEquipo" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="225" MinLength="0" Required="false" />

     <Property ID="TipoEquipo" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="225" MinLength="0" Required="false" />

     <Property ID="dtmBILastModified" Type="datetime" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" />

     <Property ID="SerialNumber" Type="string" AutoIncrement="false" Key="true" CaseSensitive="false" MaxLength="128" MinLength="0" Required="false" />

     </ClassType>

     </ClassTypes>

     </EntityTypes>

    - <ModuleTypes>

    - <WriteActionModuleType ID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7.MT" Accessibility="Public" RunAs="Core!Microsoft.SystemCenter.ServiceManager.WorkflowAccount" Batching="false">

    - <Configuration>

    - <IncludeSchemaTypes>

     <SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>

     </IncludeSchemaTypes>

     </Configuration>

    - <ModuleImplementation Isolation="Any">

    - <Composite>

    - <MemberModules>

    - <WriteAction ID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7.PSWA" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">

     <ScriptName>DoWork.ps1</ScriptName>

     <ScriptBody>Add-PSSnapIn SMCMdletSnapIn; ConverTo-CSV -NoTypeInformation -OutVariable OutputData; Clear-Content -Path "c:\users\cwisar\conectorGruma\Activos.Gruma.csv"; $OutputData[1..($OutputData.Count-1)]|ForEach-Object{Add-Content -Value $_ -Path "c:\users\cwisar\conectorGruma\Activos.Gruma.csv"}; Import-SCSMInstance -DataFilename "c:\users\cwisar\conectorGruma\Activos.Gruma.csv" -FormatFilename "c:\users\cwisar\conectorGruma\Activos.Gruma.xml"</ScriptBody>

     <SnapIns />

     <Parameters />

     <TimeoutSeconds>300</TimeoutSeconds>

     <StrictErrorHandling>true</StrictErrorHandling>

     <SerializationDepth>3</SerializationDepth>

     </WriteAction>

     </MemberModules>

    - <Composition>

     <Node ID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7.PSWA" />

     </Composition>

     </Composite>

     </ModuleImplementation>

     <InputType>System!System.BaseData</InputType>

     </WriteActionModuleType>

    - <WriteActionModuleType ID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15.MT" Accessibility="Public" RunAs="Core!Microsoft.SystemCenter.ServiceManager.WorkflowAccount" Batching="false">

    - <Configuration>

    - <IncludeSchemaTypes>

     <SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>

     </IncludeSchemaTypes>

     </Configuration>

    - <ModuleImplementation Isolation="Any">

    - <Composite>

    - <MemberModules>

    - <WriteAction ID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15.PSWA" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">

     <ScriptName>DoWork.ps1</ScriptName>

     <ScriptBody>Add-PSSnapin SMCmdletSnapin;Import-SCSMMInstance -DataFileName "c:\users\cwisar\conectorGruma\Activos.Gruma.csv" -FormatFileName "c:\users\cwisar\conectorGruma\Activos.Gruma.xml"</ScriptBody>

     <SnapIns />

     <Parameters />

     <TimeoutSeconds>300</TimeoutSeconds>

     <StrictErrorHandling>true</StrictErrorHandling>

     <SerializationDepth>3</SerializationDepth>

     </WriteAction>

     </MemberModules>

    - <Composition>

     <Node ID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15.PSWA" />

     </Composition>

     </Composite>

     </ModuleImplementation>

     <InputType>System!System.BaseData</InputType>

     </WriteActionModuleType>

     </ModuleTypes>

     </TypeDefinitions>

    - <Categories>

    - <Category ID="Importar.Activos.Gruma.Category" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack">

     <ManagementPackName>Importar.Activos.Gruma</ManagementPackName>

     <ManagementPackVersion>1.0.0.0</ManagementPackVersion>

     </Category>

     <Category ID="CVSConnectorWFCategory" Target="CVSConnectorWF" Value="EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions" />

     </Categories>

    - <Monitoring>

    - <Rules>

    - <Rule ID="CVSConnectorWF" Enabled="true" Target="SystemCenter!Microsoft.SystemCenter.SubscriptionWorkflowTarget" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">

     <Category>Notification</Category>

    - <DataSources>

    - <DataSource ID="SchedulerDS" RunAs="SystemCenter!Microsoft.SystemCenter.DatabaseWriteActionAccount" TypeID="System!System.Scheduler">

    - <Scheduler>

    - <SimpleReccuringSchedule>

     <Interval Unit="Minutes">20</Interval>

     </SimpleReccuringSchedule>

     <ExcludeDates />

     </Scheduler>

     </DataSource>

     </DataSources>

    - <WriteActions>

    - <WriteAction ID="WA" TypeID="SystemCenter1!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">

    - <Subscription>

    - <WindowsWorkflowConfiguration>

     <AssemblyName>CVSConnectorWF</AssemblyName>

     <WorkflowTypeName>WorkflowAuthoring.CVSConnectorWF</WorkflowTypeName>

     <WorkflowParameters />

     <RetryExceptions />

     <RetryDelaySeconds>60</RetryDelaySeconds>

     <MaximumRunningTimeSeconds>300</MaximumRunningTimeSeconds>

     </WindowsWorkflowConfiguration>

     </Subscription>

     </WriteAction>

     </WriteActions>

     </Rule>

     </Rules>

    - <Tasks>

    - <Task ID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7" Accessibility="Public" Enabled="true" Target="Windows!Microsoft.Windows.Computer" Timeout="300" Remotable="true">

     <Category>Notification</Category>

     <WriteAction ID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7.WA" TypeID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7.MT" />

     </Task>

    - <Task ID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15" Accessibility="Public" Enabled="true" Target="Windows!Microsoft.Windows.Computer" Timeout="300" Remotable="true">

     <Category>Notification</Category>

     <WriteAction ID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15.WA" TypeID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15.MT" />

     </Task>

     </Tasks>

     </Monitoring>

    - <LanguagePacks>

    - <LanguagePack ID="ESM" IsDefault="true">

    - <DisplayStrings>

    - <DisplayString ElementID="Importar.Activos.Gruma">

     <Name>Importar.Activos.Gruma</Name>

     </DisplayString>

     </DisplayStrings>

     </LanguagePack>

    - <LanguagePack ID="ENU" IsDefault="false">

    - <DisplayStrings>

    - <DisplayString ElementID="Importar.Activos.Gruma">

     <Name>Importar.Activos.Gruma</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma">

     <Name>Activos.Gruma</Name>

     <Description>Specify your class description.</Description>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="Costo">

     <Name>Costo</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="FechaAnexo">

     <Name>FechaAnexo</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="VencimintoAnexo">

     <Name>VencimientoAnexo</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="FechaPrimerPago">

     <Name>FechaPrimerPago</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="FolioAnexo">

     <Name>FolioAnexo</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="Arrendador">

     <Name>Arrendador</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="NetbiosComputerName">

     <Name>NetbiosComputerName</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="Descripcion">

     <Name>Descripcion</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="NombreResponsable">

     <Name>NombreResponsable</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="EmpolyeeId">

     <Name>EmpolyeeId</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="UserName">

     <Name>UserName</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="SerialNumber">

     <Name>SerialNumber</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="Division">

     <Name>Division</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="Empresa">

     <Name>Empresa</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="FolioFactura">

     <Name>FolioFactura</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="Localidad">

     <Name>Localidad</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="StatusEquipo">

     <Name>StatusEquipo</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="TipoEquipo">

     <Name>TipoEquipo</Name>

     </DisplayString>

    - <DisplayString ElementID="Activos.Gruma" SubElementID="dtmBILastModified">

     <Name>dtmBILastModified</Name>

     </DisplayString>

    - <DisplayString ElementID="CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15">

     <Name>CVSConnectorWF.WindowsPowerShellScript.50dcde2d_d39e_4d1f_aa32_df641be86e15</Name>

     </DisplayString>

    - <DisplayString ElementID="AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7">

     <Name>AddInventarioGrumaWF.WindowsPowerShellScript.ec82de5e_1b0a_428b_b1b2_a49d38220dc7</Name>

     </DisplayString>

    - <DisplayString ElementID="CVSConnectorWF">

     <Name>CVSConnectorWF</Name>

     <Description />

     </DisplayString>

     </DisplayStrings>

     </LanguagePack>

     </LanguagePacks>

     </ManagementPack>