How to retrieve the list of Out-of-Office users using the SourceCode.Workflow.Management API

Somebody posed me this question recently.  Basically I covered in my training that you can create a custom Out-of-Office page which allows you to set your Out-of-Office configure the Out-of-Office settings to use a Start Date and End Date.  Now the question is how we can view the configured OOF users to see the StartDate and EndDate period.

The current Management Console interface doesn't allow you to see that currently (it probably will be enhanced in the future) but basically it isn't too hard to do with the SourceCode.Workflow.Management API.

Here's a simple code sample that I wrote in a Console Program to retrieve that information.

--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using SourceCode.Hosting.Client.BaseAPI;
using SourceCode.Workflow.Management;
using SourceCode.Workflow.Management.OOF;

namespace ConsoleApplicationOOFList
{
    class Program
    {
        static void Main(string[] args)
        {
            SCConnectionStringBuilder connStr = new SCConnectionStringBuilder();
            connStr.Host = "localhost";
            connStr.Port = 5555;
            connStr.Integrated = true;
            connStr.IsPrimaryLogin = true;
            WorkflowManagementServer wfServer = new WorkflowManagementServer();
            wfServer.CreateConnection();
            wfServer.Connection.Open(connStr.ToString());
            SourceCode.Workflow.Management.OOF.Users OOFUsers = wfServer.GetUsers(ShareType.OOF);

            foreach (SourceCode.Workflow.Management.OOF.User OOFUser in OOFUsers)
            {
                WorklistShares wlss = wfServer.GetCurrentSharingSettings(OOFUser.FQN, ShareType.OOF);
                foreach (WorklistShare wls in wlss)
                {
                    Console.WriteLine("User Name: " + OOFUser.FQN);
                    Console.WriteLine("Start Date: " + wls.StartDate.ToString());
                    Console.WriteLine("End Date: " + wls.EndDate.ToString());
                }
            }
            if(wfServer != null)
                if(!wfServer.Connection.IsConnected)
                    wfServer.Connection.Close();
            Console.ReadLine();
        }
    }


Posted Thu, Dec 17 2009 2:33 PM by johnny

Comments

Getonline wrote re: How to retrieve the list of Out-of-Office users using the SourceCode.Workflow.Management API
on Thu, Mar 4 2010 10:10 PM

Hi ,

This is Me... :)

Getonline wrote re: How to retrieve the list of Out-of-Office users using the SourceCode.Workflow.Management API
on Thu, Mar 4 2010 10:25 PM

Hi,

I am right now migrating the K2.NET workflow to the Blackpearl version. so can you suggest me the correct way to update and migrate . as i am gettig few errors also.

The process i am following is as :

I right clicked the K2 net 2003 Worklow and selected open2 from the option which directly converted the project to the Blackpearl . I updated the datafields also.

When I am changing the asp.net code , then i am getting a few error. as I don't know to what this conversion equivalents in blackpearl :such as

K2Manager K2mng = new K2Manager();

The type or namespace name 'K2Manager' could not be found (are you missing a using directive or an assembly reference?)

For worklist items , to update and finish there are

item.Finish();

items.update()

'SourceCode.Workflow.Client.WorklistItem' does not contain a definition for 'Finish'

and

is there any assembly reference missing ?

I have used

'SourceCode.Workflow.Client.WorklistItem'

should i use

SourceCode.Workflow.Management instead of the above one ?

Having trouble with "ProcessInstances " also.

It would be great if you can reply with some example also.

Thanks

johnny wrote re: How to retrieve the list of Out-of-Office users using the SourceCode.Workflow.Management API
on Tue, Mar 16 2010 8:17

I believe with the K2 blackpearl install, there are K2 blackpearl versions of the K2ROM and K2MNG dll in the bin folder.  You can use these I believe for the old K2.net 2003 processes.  However, the cleanest way to migrate of course would be to rebuild the process as a fresh K2 blackpearl process.  This is normally my recommendation as the process building portion is usually quite fast in relation to the work required for the porting the forms.