Welcome to K2 Underground Sign In | Join | Help

Using the Archiving functionality throught API

The archiving functionality is available in the Workspace but that is a manual that can automated using the API.

Here is a sample c# console application code that does that :

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using SourceCode.Workflow.Management;

namespace archiving
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 5 )
            {
                Console.WriteLine("Argument required usage is : archiving.exe connectionstring LogDB archiveDB FromDate ToDate");
                Console.WriteLine("server=BLACKPEARL;database=K2ServerLog;Integrated Security=SSPI");
                Console.WriteLine("LogDB = K2ServerLog");
                Console.WriteLine("archiveDB = MyarchiveDB");
                Console.WriteLine("FromDate = 8/20/2008");
                Console.WriteLine("ToDate = 8/25/2008");
                return;
            }
            string connectionstring = args[0];
            string LogDB = args[1];
            string archiveDB = args[2];
            DateTime from = DateTime.Parse(args[3]);
            DateTime to = DateTime.Parse(args[4]);

            WorkflowArchiving MyarchivingClass = new WorkflowArchiving();

            //try
            //{
            Console.WriteLine("executing archive command with parameters = " + connectionstring + " // " + LogDB + " // " + archiveDB + " // " + from.ToString() + " // " + to.ToStrin());
                MyarchivingClass.Archive(connectionstring, LogDB, archiveDB, from, to);   
            //}catch (Exception e) {
            //    FileStream file = new FileStream("execption.txt",FileMode.OpenOrCreate, FileAccess.ReadWrite);
            //    StreamWriter sw = new StreamWriter(file);
            //    sw.WriteLine("Message = " + e.Message);
            //    sw.WriteLine("stack trace = "  + e.StackTrace);
            //    sw.Close();
            //}
        }
    }
}

 

Here is a vbscript that does acheive the same thing (note that you will need to run “rgasm” on the SourceCode.Workspace.Management.dll ) :

 Option Explicit
msgbox "Start Archiving"

Dim objShell
Set objShell = CreateObject("SourceCode.Workflow.Management.WorkflowArchiving")

if err.number <> 0 then
    msgbox "Error " & Err.number & " Creating Customer: " & Err.description
else
objshell.Archive "server=BLACKPEARL;database=K2ServerLog;Integrated Security=SSPI", "K2ServerLog", "Myarchive", "8/20/2008", "8/24/2008"
 msgbox "Done"
end if

 

Published Friday, August 29, 2008 3:34 PM by chalama
Filed under:

Comments

No Comments

Anonymous comments are disabled