Exemplo n.º 1
0
        private void ListSharedUsers()
        {
            string userFQN = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN);

            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)
            {
                // None for userstatus means the users is not configured, throw an exception
                if (mngServer.GetUserStatus(userFQN) == UserStatuses.None)
                {
                    throw new ApplicationException(Resources.OutOfOfficeNotConfiguredForUser);
                }
                WorklistShares wsColl = mngServer.GetCurrentSharingSettings(userFQN, 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]         = userFQN;
                            dr[Constants.SOProperties.OutOfOffice.DestinationUser] = dest.Name.ToString();
                            results.Rows.Add(dr);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 4
0
        private void RemoveAllShares()
        {
            string userFQN = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN);

            WorkflowManagementServer mngServer = this.ServiceBroker.K2Connection.GetConnection <WorkflowManagementServer>();

            using (mngServer.Connection)
            {
                if (mngServer.GetUserStatus(userFQN) == UserStatuses.None)
                {
                    throw new ApplicationException(Resources.OutOfOfficeNotConfiguredForUser);
                }

                WorklistShares shares = mngServer.GetCurrentSharingSettings(userFQN, ShareType.OOF);

                if (shares == null || shares.Count > 0)
                {
                    mngServer.UnShareAll(userFQN);
                }

                mngServer.Connection.Close();
            }
            SetStatus(UserStatuses.Available, false);
        }
Exemplo n.º 5
0
        private void ListSharedUsers()
        {
            string userFQN = base.GetStringProperty(Constants.Properties.OutOfOffice.UserFQN);

            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);

                // None for userstatus means the users is not configured, throw an exception
                if (UserStatuses.None == mngServer.GetUserStatus(userFQN))
                    throw new ApplicationException(Constants.ErrorMessages.OutOfOfficeNotConfiguredForUser);

                WorklistShares wsColl = mngServer.GetCurrentSharingSettings(userFQN, ShareType.OOF);

                foreach (WorklistShare ws in wsColl)
                {
                    //throw new ApplicationException("collection count is: "+ wsColl.Count.ToString());
                    foreach (WorkType wt in ws.WorkTypes)
                    {
                        foreach (Destination dest in wt.Destinations)
                        {
                            DataRow dr = results.NewRow();
                            dr[Constants.Properties.OutOfOffice.DestinationUser] = dest.Name.ToString();
                            results.Rows.Add(dr);
                        }
                    }
                }

            }
        }
Exemplo n.º 6
0
        // Example from page - http://help.k2.com/onlinehelp/k2blackpearl/DevRef/4.6.9/default.htm#How_to_set_a_users_Out_of_Office_Status.html%3FTocPath%3DRuntime%2520APIs%2520and%2520Services%7CWorkflow%7CWorkflow%2520Client%2520API%7CWorkflow%2520Client%2520API%2520Samples%7C_____10
        private void AddOutOfOffice()
        {
            string userFQN = base.GetStringProperty(Constants.Properties.OutOfOffice.UserFQN);
            string destinationUser = base.GetStringProperty(Constants.Properties.OutOfOffice.DestinationUser);

            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);

                WorklistShares wsColl = mngServer.GetCurrentSharingSettings(userFQN, ShareType.OOF);

                //  Throw error if multiple configurations (WorklistShare objects) detected, as this method cannot support that
                if (wsColl.Count > 1)
                {
                    throw new ApplicationException(Constants.ErrorMessages.MultipleOOFConfigurations);
                }

                //  If configuration exist already, add to it
                if (wsColl.Count == 1)
                {

                    WorklistShare worklistshare = wsColl[0];
                    worklistshare.WorkTypes[0].Destinations.Add(new Destination(destinationUser, DestinationType.User));
                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);

                    DataRow dr = results.NewRow();
                    dr[Constants.Properties.OutOfOffice.UserFQN] = userFQN;
                    dr[Constants.Properties.OutOfOffice.DestinationUser] = destinationUser;
                    dr[Constants.Properties.OutOfOffice.CallSuccess] = result;
                    results.Rows.Add(dr); ;

                }
                // New user, create configuration for OOF
                else
                {
                    // 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(destinationUser, DestinationType.User));

                    // Link the filters and destinations to the Work
                    WorkType worktype = new WorkType("MyWork", worklistcriteria, worktypedestinations);

                    WorklistShare worklistshare = new WorklistShare();
                    worklistshare.ShareType = ShareType.OOF;
                    worklistshare.WorkTypes.Add(worktype);

                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);
                    mngServer.SetUserStatus(userFQN, UserStatuses.Available);

                    DataRow dr = results.NewRow();
                    dr[Constants.Properties.OutOfOffice.UserFQN] = userFQN;
                    dr[Constants.Properties.OutOfOffice.DestinationUser] = destinationUser;
                    dr[Constants.Properties.OutOfOffice.CallSuccess] = result;
                    results.Rows.Add(dr);
                }

            }
        }
Exemplo n.º 7
0
        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);
                                }
                            }
                        }
                    }
                }

            }
        }
Exemplo n.º 8
0
        private void AddOutOfOffice()
        {
            string userFQN         = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN, true);
            string destinationUser = base.GetStringProperty(Constants.SOProperties.OutOfOffice.DestinationUser, true);

            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);

                WorklistShares wsColl = mngServer.GetCurrentSharingSettings(userFQN, ShareType.OOF);

                //  Throw error if multiple configurations (WorklistShare objects) detected, as this method cannot support that
                if (wsColl.Count > 1)
                {
                    throw new ApplicationException(Constants.ErrorMessages.MultipleOOFConfigurations);
                }

                //  If configuration exist already, add to it
                if (wsColl.Count == 1)
                {
                    WorklistShare worklistshare = wsColl[0];
                    worklistshare.WorkTypes[0].Destinations.Add(new Destination(destinationUser, DestinationType.User));
                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);
                    if (!result)
                    {
                        throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                    }
                    DataRow dr = results.NewRow();
                    dr[Constants.SOProperties.OutOfOffice.UserFQN]         = userFQN;
                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;

                    results.Rows.Add(dr);;
                }
                // New user, create configuration for OOF
                else
                {
                    // 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(destinationUser, DestinationType.User));

                    // Link the filters and destinations to the Work
                    WorkType worktype = new WorkType("MyWork", worklistcriteria, worktypedestinations);

                    WorklistShare worklistshare = new WorklistShare();
                    worklistshare.ShareType = ShareType.OOF;
                    worklistshare.WorkTypes.Add(worktype);

                    bool result = mngServer.ShareWorkList(userFQN, worklistshare);
                    if (!result)
                    {
                        throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                    }
                    result = mngServer.SetUserStatus(userFQN, UserStatuses.Available);
                    if (!result)
                    {
                        throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                    }

                    DataRow dr = results.NewRow();
                    dr[Constants.SOProperties.OutOfOffice.UserFQN]         = userFQN;
                    dr[Constants.SOProperties.OutOfOffice.DestinationUser] = destinationUser;
                    results.Rows.Add(dr);
                }
            }
        }