String Writer

my tech stuffs…

Posts Tagged ‘comadmin

Source Code for COM Deployer

with one comment

In my earlier post, I had published COM Deployer which is just to copy the dlls into Tridion System. Here I’m briefing the source code of the tool …

Namespaces:

using System;
using System.Configuration;
using System.IO;
using COMAdmin;

All these are common .Net namespaces excep COMAdmin. For this , you need to include Interop.COMAdmin.dll reference. This is common dll which is provided by Microsoft to access COM services on Windows OS. More details on this can be found in MSDN.

But if you don’t have time to go through all these stuffs, you can simply copy the file from the following directory on any Windows OS J

%windir%/System32/com/comadmin.dll

Configuration Entries:

I’ve stored these entries app.config file. Hope I don’t need to explain more about these configuration entries.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <!--COM Service Name ex) "Tridion Content Manager" -->
    <add key="application" value="Tridion Content Manager"/>
    <!--Server name or IP where COM services are installed -->
    <add key="server" value="192.168.0.2"/>
    <!--Source file location (local/remote shared path), including file name & use ; to include multiple files-->
    <add key="sourceFiles" value="D:\Training\SDL Tridion\wkflw.dll;D:\Training\SDL Tridion\evntSystem.dll "/>
    <!--Target file location (local), without file name-->
    <add key="targetLocation" value="C:\Program Files\Tridion\bin"/>
  </appSettings>
</configuration>

Source Code:

//read config entries to local variables
string server = ConfigurationManager.AppSettings["server"];
string application = ConfigurationManager.AppSettings["application"];
string sourceFiles = ConfigurationManager.AppSettings["sourceFiles"];
string targetLocation = ConfigurationManager.AppSettings["targetLocation"];

COMAdminCatalog is the root object to access the sevice. Please note that the user must be having admin access to run this tool otherwise you will get Access Denied error.

COMAdminCatalog catalog = new COMAdminCatalogClass();
//connecting to server to access COM services
catalog.Connect(server);
//stopping service
catalog.ShutdownApplication(application);

COMAdminCatalog is an interface so we need to instantiate with COMAdminCatalogClass object.

//copy file to target location
File.Copy(file, targetLocation + "\\" + file.GetFileName(), true);

Just copying the source files to target location.

//restarting service
catalog.StartApplication(application);

After copied all the files, the services will be restarted by calling StartApplication method.

Sub methods:

Other private methods used in this utility…


/// <summary>
/// Method to write the output to the user
/// </summary>
/// <param name="message"></param>
private static void WriteMessage(string message)
{
    Console.WriteLine(Environment.NewLine + message);
}

public static class FileExtentionClass
{
  /// <summary>
  /// This extention method will be accessible from any string object.
  /// Intention is to retrieve the file name alone from the file path
  /// </summary>
  /// <param name="filePath">file path of string type</param>
  /// <returns>file name of string type</returns>
  public static string GetFileName(this string filePath)
  {
      return filePath.Substring(filePath.LastIndexOf("\\") + 1);
  }
}

Written by visvabalaji

February 3, 2011 at 6:36 am

Posted in Tridion

Tagged with , , ,

Custom utility for deploying COM dlls in Tridion

leave a comment »

Deploying Tridion COM dlls should be carried out in the following sequences. I believe this is common process for any COM deployment so this utility is not restricted only to Tridion but here I’m specifically talking about Tridion Services.

1) Shut down Tridion Content Manager

2) Copy the dlls into <<Tridion bin location>>

3) Start Tridion Content Manager

We were doing these each actions manually since we are working on remote environment. If you are working on Tridion COM assemblies like tridion event systems, you might need to deploy the dlls frequently during development phase.

This can be done manually but since they are frequent actions, I wanted to automate this process. After few hours of coding I’ve written a custom utility which will perform this deployment activities.

COM Deployer.zip can be downloaded from this link.

It has the following files…

1) COMDeployer.exe

2) COMDeployer.exe.config

3) Interop.COMAdmin.dll

The only place where user should make change is config file.


<appSettings>
<!--COM Service Name ex) "Tridion Content Manager" -->
<add key="application" value="Tridion Content Manager"/>
<!--Server name or IP where COM services are installed -->
<add key="server" value="192.168.0.2"/>
<!--Source file location (local/remote shared path), including file name & use ; to include multiple files-->
<add key="sourceFiles" value="D:\TridionPOC\evntSystem.dll "/>
<!--Target file location (local), without file name-->
<add key="targetLocation" value="D:\Training"/>
</appSettings>

Prerequisite:
1) .Net framework 3.0 or higher

2) User must have admin rights

3) Tool must run on Tridion Server

Sad thing is that I developed this utility after we had completed our project :( . I’ll share the source code details of this utility later.

Written by visvabalaji

January 22, 2011 at 5:51 am

Posted in Tridion

Tagged with , , ,

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: