Example #1
0
        /// <summary>
        /// Get In Of Office or Out Of Office of current user
        /// </summary>
        /// <returns>The Out Of Office(true) or In Of Office(false)</returns>
        public bool GetOOFStatus()
        {
            bool status = false;

            switch (_connection.GetUserStatus())
            {
            case UserStatuses.None:
            case UserStatuses.Available:
                status = true;
                break;

            case UserStatuses.OOF:
                status = false;
                break;
            }

            return(status);
        }
Example #2
0
        /// <summary>
        /// Get In Of Office or Out Of Office of current user
        /// </summary>
        /// <returns>The Out Of Office(true) or In Of Office(false)</returns>
        public bool GetOOFStatus()
        {
            bool status = false;

            using (Connection workflowClient = this.GetWorkflowClient()) {
                switch (workflowClient.GetUserStatus())
                {
                case UserStatuses.None:
                case UserStatuses.Available:
                    status = true;
                    break;

                case UserStatuses.OOF:
                    status = false;
                    break;
                }
            }

            return(status);
        }
Example #3
0
        /// <summary>
        /// Get OOF status for current user from Client API and return it
        /// TODO: Remove User FQN parameter
        /// </summary>
        private void GetUserStatus()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];

            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                SourceCode.Workflow.Client.UserStatuses status = k2Con.GetUserStatus();
                DataRow dr = results.NewRow();

                dr[Constants.SOProperties.OutOfOffice.UserStatus] = status.ToString();

                results.Rows.Add(dr);

                k2Con.Close();
            }
        }
Example #4
0
        /// <summary>
        /// Get User Out of Office status from K2 HostServer
        /// </summary>
        /// <param name="originalDestinationUser">The Originator Destination User</param>
        /// <returns>The Worklist user status</returns>
        public WorklistUserStatus GetOOFStatus(string originalDestinationUser)
        {
            bool status = false;
            WorklistUserStatus worklistUserStatus = new WorklistUserStatus();

            using (Connection workflowClient = this.GetWorkflowClient()) {
                switch (string.IsNullOrEmpty(originalDestinationUser) ? workflowClient.GetUserStatus() : workflowClient.GetUserStatus(originalDestinationUser))
                {
                case UserStatuses.None:
                case UserStatuses.Available:
                    status = true;
                    break;

                case UserStatuses.OOF:
                    status = false;
                    break;
                }
                worklistUserStatus.Status = status;
                if (!worklistUserStatus.Status)
                {
                    WorklistShares worklistShares = new WorklistShares();
                    worklistShares = workflowClient.GetCurrentSharingSettings(ShareType.OOF);
                    if (worklistShares.Count > 0)
                    {
                        WorklistShare worklistShare = worklistShares[0];
                        worklistShare.ShareType = ShareType.OOF;
                        List <OOFUser> list = new List <OOFUser>();
                        foreach (K2.Destination destination in worklistShare.WorkTypes[0].Destinations)
                        {
                            list.Add(new OOFUser {
                                UserName = destination.Name,
                                Type     = destination.DestinationType.ToString()
                            });
                        }
                        worklistUserStatus.users = list;
                    }
                }
            }
            return(worklistUserStatus);
        }
        /// <summary>
        /// Set OOF status for a user
        /// </summary>
        /// <param name="status">OOF Status (Available, OOF, None)</param>
        private void SetStatus(SourceCode.Workflow.Client.UserStatuses status)
        {
            using (Connection k2Con = this.ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                // None for userstatus means the users is not configured, throw an exception
                if (UserStatuses.None == k2Con.GetUserStatus() && UserStatuses.OOF == status)
                {
                    // exception should be thrown only in case that user tries to set OOF,
                    throw new ApplicationException(Resources.OutOfOfficeNotConfiguredForUser);
                }

                try
                {
                    k2Con.SetUserStatus(status);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(Resources.FailedToSetOOF, ex);
                }

                k2Con.Close();
            }
        }
Example #6
0
        /// <summary>
        /// List all existing shares for a current user
        /// </summary>
        private void ListSharedUsers()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];

            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

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

                WorklistShares wsColl = k2Con.GetCurrentSharingSettings(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.SOProperties.OutOfOffice.DestinationUser] = dest.Name.ToString();
                            results.Rows.Add(dr);
                        }
                    }
                }

                k2Con.Close();
            }
        }
        /// <summary>
        /// Set OOF status for a user
        /// </summary>
        /// <param name="status">OOF Status (Available, OOF, None)</param>
        private void SetStatus(SourceCode.Workflow.Client.UserStatuses status)
        {
            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);
                // None for userstatus means the users is not configured, throw an exception
                if (UserStatuses.None == k2Con.GetUserStatus() && UserStatuses.OOF == status)
                {
                    // exception should be thrown only in case that user tries to  set OOF,
                    throw new ApplicationException(Constants.ErrorMessages.OutOfOfficeNotConfiguredForUser);
                }

                try
                {
                    k2Con.SetUserStatus(status);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(Constants.ErrorMessages.FailedToSetOOF, ex);
                }

                k2Con.Close();
            }
        }
        /// <summary>
        /// List all existing shares for a current user
        /// </summary>
        private void ListSharedUsers()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

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

                WorklistShares wsColl = k2Con.GetCurrentSharingSettings(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.SOProperties.OutOfOffice.DestinationUser] = dest.Name.ToString();
                            results.Rows.Add(dr);
                        }
                    }
                }

                k2Con.Close();

            }
        }
        /// <summary>
        /// Get OOF status for current user from Client API and return it
        /// TODO: Remove User FQN parameter
        /// </summary>
        private void GetUserStatus()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                SourceCode.Workflow.Client.UserStatuses status = k2Con.GetUserStatus();
                DataRow dr = results.NewRow();

                dr[Constants.SOProperties.OutOfOffice.UserStatus] = status.ToString();

                results.Rows.Add(dr);

                k2Con.Close();
            }
        }