Example #1
0
        private void SetStatus(UserStatuses status, bool checkCurrentStatus = true)
        {
            string userFQN = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN);

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

            using (mngServer.Connection)
            {
                // None for userstatus means the users is not configured, throw an exception
                if (checkCurrentStatus && UserStatuses.None == mngServer.GetUserStatus(userFQN))
                {
                    throw new ApplicationException(Resources.OutOfOfficeNotConfiguredForUser);
                }
                bool result = mngServer.SetUserStatus(userFQN, status);
                if (!result)
                {
                    throw new ApplicationException(Resources.FailedToSetOOF);
                }
            }
        }
Example #2
0
        private void SetStatus(UserStatuses status)
        {
            string userFQN = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN);

            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);
                }
                bool result = mngServer.SetUserStatus(userFQN, status);
                if (!result)
                {
                    throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                }
            }
        }
        private void SetOutOfOffice()
        {
            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);

                bool result = mngServer.SetUserStatus(userFQN, UserStatuses.OOF);
                DataRow dr = results.NewRow();
                dr[Constants.Properties.OutOfOffice.UserFQN] = userFQN;
                dr[Constants.Properties.OutOfOffice.CallSuccess] = result;
                results.Rows.Add(dr);
            }
        }
        // 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);
                }

            }
        }
        private void SetStatus(UserStatuses status)
        {
            string userFQN = base.GetStringProperty(Constants.SOProperties.OutOfOffice.UserFQN);

            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);
                }
                bool result = mngServer.SetUserStatus(userFQN, status);
                if (!result)
                {
                    throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF);
                }
            }
        }
Example #6
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);
                }
            }
        }