Exemplo n.º 1
0
        public OOFWrapper GetOOFCriteria()
        {
            var config  = new OutOfOfficeConfig(_connection);
            var wrapper = new OOFWrapper();

            wrapper.Status = config.GetOOFStatus();

            var shared = config.LoadOOF();

            if (shared == null || shared.Count == 0)
            {
                return(wrapper);
            }

            var oof = shared[0];

            if (shared.Count == 1 && oof.WorkTypes != null && oof.WorkTypes.Count == 1)
            {
                var worktype     = oof.WorkTypes[0];
                var destinations = worktype.Destinations;
                wrapper.EndDate   = Convert.ToDateTime(oof.EndDate);
                wrapper.StartDate = Convert.ToDateTime(oof.StartDate);
                wrapper.ShareType = Convert.ToInt16(oof.ShareType);
                wrapper.WorkType  = config.GetWorktypeDto(worktype);

                foreach (WorkTypeException w in worktype.WorkTypeExceptions)
                {
                    var processPath = Convert.ToString(w.WorklistCriteria.Filters[0].Value);
                    var act         = Convert.ToString(w.WorklistCriteria.Filters[1].Value);

                    if (string.IsNullOrEmpty(processPath))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(act))
                    {
                        continue;
                    }

                    string activityKey = string.Format("{0}\\{1}", processPath, act);

                    var dto = new WorkTypeExceptionDto()
                    {
                        Name           = w.Name,
                        Process        = processPath,
                        ProcessPath    = processPath,
                        Activity       = act,
                        ActDisplayName = activityKey,
                        Destinations   = config.GetDestinationDto(w.Destinations)
                    };
                    wrapper.WorkType.WorkTypeExceptions.Add(dto);
                }
            }
            return(wrapper);
        }
Exemplo n.º 2
0
        public bool SetOOFCriteria(OOFWrapper wrapper)
        {
            var config = new OutOfOfficeConfig(_connection);

            if (wrapper.WorkType == null)
            {
                _connection.SetUserStatus(Convert.ToBoolean(wrapper.Status) ? UserStatuses.Available : UserStatuses.OOF);
                return(false);
            }

            bool           isNew          = false;
            WorklistShares worklistShares = new WorklistShares();

            worklistShares = _connection.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)
            {
                var destination = new Destination(dest.LoginName.FQNWithK2Label(), DestinationType.User);
                destinations.Add(destination);
            }

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

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

            return(true);
        }