Skip to main content

Dear all,


 


i have problem with K2 out of office


i want to share some people worklist to other people at some period of time


then i watch about out office system with code like this


 




Normal
0




false
false
false

IN
X-NONE
X-NONE











MicrosoftInternetExplorer4





























































































































































Connection connection = new
Connection();


 


           
ConnectionSetup connectionsetup = new ConnectionSetup();


 


           
connectionsetup.ConnectionParameterss"Authenticate"]
= "true";


 


           
connectionsetup.ConnectionParameters/"Host"]
= Environment.MachineName;


 


           
connectionsetup.ConnectionParametersÂ"Integrated"]
= "true";


 


           
connectionsetup.ConnectionParametersÂ"IsPrimaryLogin"]
= "true";


 


           
connectionsetup.ConnectionParameters>"Password"]
= "{YourPassword}";


 


           
connectionsetup.ConnectionParametersa"Port"]
= "5252";


 


           
connectionsetup.ConnectionParametersn"SecurityLabelName"]
= "K2";


 


           
connectionsetup.ConnectionParameterss"UserID"]
= "{YourUser}";


 


           
connectionsetup.ConnectionParametersp"WindowsDomain"]
= "{YourDomain}";


 


           
connection.Open(connectionsetup);


 


 


           
// ALL Work that remains which does not form part of
any 'WorkTypeException' Filter


           
WorklistCriteria worklistcriteria = new WorklistCriteria();


           
worklistcriteria.Platform = "ASP";


 


           
// Send ALL Work based on the above Filter to the
following User


           
Destinations worktypedestinations = new Destinations();


           
worktypedestinations.Add(new Destination(@"K2:DOMAINUser",
DestinationType.User));


 


           
// Link the filters and destinations to the Work


           
WorkType worktype = new
WorkType("MyWork",
worklistcriteria, worktypedestinations);


 


           
// ALL Work that remains which does not form part of
any 'WorkType' Filter


           
WorklistCriteria worklistexceptioncriteria =
new WorklistCriteria();


           
worklistexceptioncriteria.Platform = "ASP";


           
worklistexceptioncriteria.AddFilterField(WCField.ProcessName,
WCCompare.Equal, "MyExceptionProcess");


 


           
// Send ALL Work based on the above Filter to the
following User


       
    Destinations
worktypeexceptiondestinations = new Destinations();


           
worktypedestinations.Add(new Destination(@"K2:DOMAINExceptionUser",
DestinationType.User));


 


           
// Link the filters and destinations to the Exception
Work


           
WorkTypeException worktypeexception = new WorkTypeException("MyWorkException",
worklistexceptioncriteria, worktypeexceptiondestinations);


 


           
worktype.WorkTypeExceptions.Add(worktypeexception);


 


           
WorklistShare worklistshare = new WorklistShare();


 


           
worklistshare.ShareType = ShareType.OOF;


 


           
// Sharing dates as per the sample indicates that
work will always be shared as long as the correct status is set


           
// These dates may also be used to only share work
for a specific period


           
worklistshare.StartDate = DateTime.MinValue;


           
worklistshare.EndDate = DateTime.MinValue;


 


           
worklistshare.WorkTypes.Add(worktype);


 


           
// K2Server will create the user's Worklist Sharing,
but no sharing will take place unless the Status of the Share is updated


           
connection.ShareWorkList(@"K2:DOMAINSharer",
worklistshare);


 


           
// Once this status is updated, each time a user,
which the sharing user is sharing any work with opens their Worklist, K2Server
will combine the Worklist(s) based on the opening user(s) Worklist Filters


           
connection.SetUserStatus(@"K2:DOMAINSharer",
UserStatuses.OOF);


 


 


           
connection.Close();


 


 


but then i got an error message like this


"the user does not appear to be managed by the connection user"


when call this method
connection.ShareWorkList(@"K2:DOMAINSharer",
worklistshare);


 


is there someone can help me?


btw i'm using K2 BP 4.5 kb 1370


Hi,

 

If you use Connection statement, you have to impersonate Connection, something like that

 

connection.ImpersonateUser(@"K2:" + userName);
connection.ShareWorkList(wkShare);
connection.SetUserStatus(SourceCode.Workflow.Client.UserStatuses.OOF);

 

Regards,

Jay-Z


Reply