Ejemplo n.º 1
0
 public bool DoRedirect(string serialNumber, DestinationDto user)
 {
     if (user == null || string.IsNullOrEmpty(user.LoginName) || !SecurityLabelUtils.IsCorrectUserName(user.LoginName))
     {
         return(false);
     }
     _client.RedirectWorklistItem(serialNumber, SecurityLabelUtils.GetNameWithLabel(user.LoginName));
     return(true);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get The Out Of Office work type exception
        /// </summary>
        /// <param name="exceptionDtos">The Work type exceptions</param>
        /// <returns>The work type exception</returns>
        public WorkTypeExceptions GetWorkTypeExceptions(IList <WorkTypeExceptionDto> exceptionDtos)
        {
            WorkTypeExceptions worktypeExceptions = new WorkTypeExceptions();

            foreach (WorkTypeExceptionDto exceptionDto in exceptionDtos)
            {
                var          exception    = new WorkTypeException();
                Destinations destinations = new Destinations();
                foreach (DestinationDto dest in exceptionDto.Destinations)
                {
                    var destination = new K2.Destination(SecurityLabelUtils.GetNameWithLabel(dest.LoginName), DestinationType.User);
                    destinations.Add(destination);
                }
                exception.Name             = exceptionDto.Name;
                exception.Destinations     = destinations;
                exception.WorklistCriteria = this.configureWorklistCriteria(exceptionDto.ProcessPath, exceptionDto.Activity);
                worktypeExceptions.Add(exception);
            }

            return(worktypeExceptions);
        }
Ejemplo n.º 3
0
        public bool DoShare(string sn, IList <DestinationDto> users)
        {
            if (users == null || users.Count == 0)
            {
                return(false);
            }
            IList <string> destinationUsers = new List <string>();

            foreach (var dest in users)
            {
                if (string.IsNullOrEmpty(dest.LoginName))
                {
                    continue;
                }
                var userAccount = SecurityLabelUtils.GetNameWithLabel(dest.LoginName);
                destinationUsers.Add(userAccount);
            }

            _client.Share(sn, destinationUsers);

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create or set the Out Of Office of current user
        /// </summary>
        /// <param name="wrapper">The Out Of Office criteria</param>
        /// <returns>Success(true) or Fail(False)</returns>
        public bool SetOutOfOffice(OOFWrapper wrapper)
        {
            if (wrapper.WorkType == null)
            {
                using (Connection workflowClient = this.GetWorkflowClient()) {
                    workflowClient.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);
                }

                return(false);
            }

            using (Connection workflowClient = this.GetWorkflowClient()) {
                bool           isNew          = false;
                WorklistShares worklistShares = new WorklistShares();
                worklistShares = workflowClient.GetCurrentSharingSettings(ShareType.OOF);
                WorklistShare worklistShare = null;
                if (worklistShares.Count > 0)
                {
                    worklistShare           = worklistShares[0];
                    worklistShare.ShareType = ShareType.OOF;
                }
                else
                {
                    isNew = true;
                }

                if (worklistShare == null)
                {
                    worklistShare           = new WorklistShare();
                    worklistShare.ShareType = ShareType.OOF;
                    isNew = true;
                }


                worklistShare.StartDate = wrapper.StartDate;
                worklistShare.EndDate   = wrapper.EndDate;

                WorkTypes workTypes = worklistShare.WorkTypes;
                WorkType  workType  = new WorkType();

                if (workTypes.Count > 0)
                {
                    workType = workTypes[0];
                }
                else
                {
                    workType = new WorkType();
                    workTypes.Add(workType);
                }
                workType.Name = Guid.NewGuid().ToString();
                Destinations destinations = new Destinations();

                foreach (DestinationDto dest in wrapper.WorkType.Destinations)
                {
                    if (SecurityLabelUtils.IsCorrectUserName(dest.LoginName))
                    {
                        var destination = new K2.Destination(SecurityLabelUtils.GetNameWithLabel(dest.LoginName), DestinationType.User);
                        destinations.Add(destination);
                    }
                }

                workType.Destinations       = destinations;
                workType.WorkTypeExceptions = GetWorkTypeExceptions(wrapper.WorkType.WorkTypeExceptions);
                worklistShare.WorkTypes     = workTypes;

                if (isNew)
                {
                    workflowClient.ShareWorkList(worklistShare);
                }
                workflowClient.UpdateWorkType(worklistShare.WorkTypes[0]);
                workflowClient.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);
            }

            return(true);
        }