Beispiel #1
0
        /// <summary>
        /// Gets the approval member result from delegate.
        /// </summary>
        /// <param name="person">The person.</param>
        private void GetApprovalMemberResultFromDelegate(PersonInfo person)
        {
            var personIds = GetAllOutOfOfficePersonsThatDelegateTo(person.Id);
            personIds.Add(person.Id);

            var filtDescriptors = new MobileObservableCollection<IFilterDescriptor>();
            filtDescriptors.AddRange(personIds.Select(id => new FilterDescriptor("OriginalApproverId", FilterOperator.IsEqualTo, id)));

            var filterList = new FilterList { new FilterDescriptor(LogicalOperators.Or, filtDescriptors) };

            var amrList = DynamicTypeManager.GetInfoList<IApprovalMemberResultInfo>(
                Constants.ApprovalMemberResultProcessName,
                string.Empty,
                0,
                int.MaxValue,
                null,
                filterList);

            foreach (var amrInfo in amrList)
            {
                var amrEdit = DynamicTypeManager.GetEditableRoot<IApprovalMemberResultEdit>(Constants.ApprovalMemberResultProcessName, amrInfo.Id);

                if (amrEdit == null || amrEdit.Id != amrInfo.Id)
                    continue;

                amrEdit.Person = person.Id;

                amrEdit.Save();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Moves the approval member result to delegate.
        /// </summary>
        /// <param name="person">The person.</param>
        private void MoveApprovalMemberResultToDelegate(PersonInfo person)
        {
            if (person.DelegateApproverId == null || person.DelegateApproverId <= 0)
                return;

            var delegateApprover = PersonManager.GetFirstActiveApprover(person.Id);
            if (delegateApprover == null || delegateApprover.Id == person.Id)
                return;

            var filterList = new FilterList
                                 {
                                     new FilterDescriptor("PersonId", FilterOperator.IsEqualTo, person.Id),
                                     new FilterDescriptor("AllowDelegation", FilterOperator.IsEqualTo, true)
                                 };

            var amrList = DynamicTypeManager.GetInfoList<IApprovalMemberResultInfo>(
                Constants.ApprovalMemberResultProcessName,
                string.Empty,
                0,
                int.MaxValue,
                null,
                filterList);

            foreach (var amrInfo in amrList)
            {
                var amrEdit = DynamicTypeManager.GetEditableRoot<IApprovalMemberResultEdit>(Constants.ApprovalMemberResultProcessName, amrInfo.Id);

                if (amrEdit == null || amrEdit.Id != amrInfo.Id)
                    continue;

                amrEdit.Person = delegateApprover.Id;

                amrEdit.Save();
            }
        }
Beispiel #3
0
        private void MoveActionToDelegate(PersonInfo person, int actionId)
        {
            var action = DynamicTypeManager.GetEditableRoot<IActionItemEdit>(Constants.ActionItemsProcessName, actionId);
            if (action == null || action.Id != actionId)
                return;

            var item = GetSourceItem(action);
            if (item == null)
                return;

            var actionDefinition = item.ActionManager.ActionDefinitions.FirstOrDefault(ad => ad.Guid.ToString() == action.ActionGuid);
            if (actionDefinition == null)
                return;

            var approvalAction = actionDefinition as ApprovalActionDefinition;
            if (approvalAction != null)
            {
                var approvalDefinition = ApprovalManager.GetApprovalDefinition(item, approvalAction.ApprovalFieldName);
                if (!approvalDefinition.AllowDelegation)
                    return;
            }

            action.PersonId = person.Id;
            action.IsActionNew = true;

            action.Save();

            if (actionDefinition.SendEmail && !string.IsNullOrWhiteSpace(person.Email))
            {
                actionDefinition.SendMessage(item, person);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets the actions from delegate.
        /// </summary>
        /// <param name="person">The person.</param>
        /// <param name="sendEmail">If set to <c>true</c> [send email].</param>
        private void GetActionsFromDelegate(PersonInfo person, bool sendEmail = true)
        {
            var personIds = GetAllOutOfOfficePersonsThatDelegateTo(person.Id);
            personIds.Add(person.Id);

            var filtDescriptors = new MobileObservableCollection<IFilterDescriptor>();
            filtDescriptors.AddRange(personIds.Select(id => new FilterDescriptor("BasePersonId", FilterOperator.IsEqualTo, id)));

            var filterList = new FilterList { new FilterDescriptor(LogicalOperators.Or, filtDescriptors) };
            var actions = DynamicTypeManager.GetInfoList<IActionItemInfo>(Constants.ActionItemsProcessName, string.Empty, 0, int.MaxValue, null, filterList);
            var actionsChanged = false;

            foreach (var actionInfo in actions)
            {
                var action = DynamicTypeManager.GetEditableRoot<IActionItemEdit>(Constants.ActionItemsProcessName, actionInfo.Id);
                if (action == null || action.Id != actionInfo.Id)
                    continue;

                var item = GetSourceItem(action);
                if (item == null)
                    continue;

                var actionDefinition = item.ActionManager.ActionDefinitions.FirstOrDefault(ad => ad.Guid.ToString() == action.ActionGuid);
                if (actionDefinition == null)
                    continue;

                action.PersonId = person.Id;
                action.IsActionNew = true;

                action.Save();
                actionsChanged = true;

                if (!sendEmail || !actionDefinition.SendEmail)
                    continue;

                if (!string.IsNullOrWhiteSpace(person.Email))
                {
                    actionDefinition.SendMessage(item, person);
                }
            }

            if (actionsChanged && sendEmail)
            {
                CommunicationService.NotifyActionsChanged(person.Id);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Moves the actions to delegate.
        /// </summary>
        /// <param name="person">The person.</param>
        private void MoveActionsToDelegate(PersonInfo person)
        {
            if (person.DelegateApproverId == null)
                return;

            var delegateApprover = PersonManager.GetFirstActivePerson(person.Id);
            if (delegateApprover == null || delegateApprover.Id == person.Id)
                return;

            var filterList = new FilterList { new FilterDescriptor("PersonId", FilterOperator.IsEqualTo, person.Id) };
            var actions = DynamicTypeManager.GetInfoList<IActionItemInfo>(Constants.ActionItemsProcessName, string.Empty, 0, int.MaxValue, null, filterList);
            var actionsChanged = false;

            foreach (var actionInfo in actions)
            {
                MoveActionToDelegate(delegateApprover, actionInfo.Id);
                actionsChanged = true;
            }

            if (actionsChanged)
            {
                CommunicationService.NotifyActionsChanged(delegateApprover.Id);
            }
        }