Beispiel #1
0
        private void ListUsers()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];

            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;
            WorkflowManagementServer mngServer = this.ServiceBroker.K2Connection.GetConnection <WorkflowManagementServer>();

            using (mngServer.Connection)
            {
                SourceCode.Workflow.Management.OOF.Users users = mngServer.GetUsers(ShareType.OOF);


                foreach (SourceCode.Workflow.Management.OOF.User user in users)
                {
                    if (user.Status != UserStatuses.None)
                    {
                        WorklistShares wsColl = mngServer.GetCurrentSharingSettings(user.FQN, ShareType.OOF);
                        foreach (WorklistShare ws in wsColl)
                        {
                            foreach (WorkType wt in ws.WorkTypes)
                            {
                                foreach (Destination dest in wt.Destinations)
                                {
                                    DataRow dr = results.NewRow();
                                    dr[Constants.SOProperties.OutOfOffice.UserFQN]         = user.FQN;
                                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = dest.Name;
                                    results.Rows.Add(dr);
                                }
                            }
                        }
                    }
                }
            }
        }
        //sample that shows how to use Out-of-Office in the workflow management API
        //in this example, we just want to output all users that are currently out-of-office
        public void ListOutOfOfficeUsers()
        {
            //establish the connection
            WorkflowManagementServer K2Mgmt = new WorkflowManagementServer();

            K2Mgmt.CreateConnection();
            K2Mgmt.Connection.Open("connectionstring");
            SourceCode.Workflow.Management.OOF.Users OOFUsers = K2Mgmt.GetUsers(ShareType.OOF);
            foreach (SourceCode.Workflow.Management.OOF.User OOFUser in OOFUsers)
            {
                WorklistShares wlss = K2Mgmt.GetCurrentSharingSettings(OOFUser.FQN, ShareType.OOF);
                foreach (WorklistShare wls in wlss)
                {
                    //do something with each "share" record
                    Console.WriteLine("User Name: " + OOFUser.FQN);
                    Console.WriteLine("Start Date: " + wls.StartDate.ToString());
                    Console.WriteLine("End Date: " + wls.EndDate.ToString());
                }
            }

            //close the connection
            K2Mgmt.Connection.Close();
        }
        private void ListUsers()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;
            WorkflowManagementServer mngServer = new WorkflowManagementServer();

            using (mngServer.CreateConnection())
            {
                mngServer.Open(BaseAPIConnectionString);
                SourceCode.Workflow.Management.OOF.Users  users = mngServer.GetUsers(ShareType.OOF);

                foreach (SourceCode.Workflow.Management.OOF.User user in users)
                {
                    if (user.Status != UserStatuses.None)
                    {
                        WorklistShares wsColl = mngServer.GetCurrentSharingSettings(user.FQN, ShareType.OOF);
                        foreach (WorklistShare ws in wsColl)
                        {
                            foreach (WorkType wt in ws.WorkTypes)
                            {
                                foreach (Destination dest in wt.Destinations)
                                {
                                    DataRow dr = results.NewRow();
                                    dr[Constants.SOProperties.OutOfOffice.UserFQN] = user.FQN;
                                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = dest.Name;
                                    results.Rows.Add(dr);
                                }
                            }
                        }
                    }
                }

            }
        }