/// <summary>
        /// Результат - список AppUser, вычисленный по параметрам.
        /// Из Butrs пользователи собираются по спискам самих пользователей, по ролям и по группам
        /// Из userNameList пользователи воссоздаются по их логинам (UserName)
        /// </summary>
        /// <param name="tp"></param>
        /// <returns></returns>
        public override List <AppUser> GetUserList(IList <BaseUserTaskReference> Butrs, IList <string> userNameList)
        {
            List <AppUser> Res = new List <AppUser>();

            foreach (BaseUserTaskReference butr in Butrs)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    Res.Add(userbutr.AppUser);
                }
            }

            foreach (string username in userNameList)
            {
                AppUser appUser = PopulateUserByUserName(username, this.Session);
                if (appUser != null)
                {
                    if (Res.IndexOf(appUser) == -1)
                    {
                        Res.Add(appUser);
                    }
                }
            }

            return(Res);
        }
Exemple #2
0
        /// <summary>
        /// Заполнение коллекции пользователей из массива
        /// </summary>
        /// <param name="mArray"></param>
        /// <param name="UserAssociationTypeName"></param>
        /// <param name="ual"></param>
        public static void ProcessElements(Array mArray, string UserAssociationTypeName, ref DealWithoutStageTaskInstanceDefinition task, List <AppUser> ual, Session ssn)
        {
            foreach (string elem in mArray)
            {
                Array mElems = elem.Split(new string[] { CommonConstants.ElemSeparator }, StringSplitOptions.None);

                if (((string)(mElems.GetValue(0))).Trim() == UserAssociationTypeName)
                {
                    // Восстанавливаем пользователя по его UserName
                    AppUser au = null;
                    if (!string.IsNullOrEmpty((string)(mElems.GetValue(1))))
                    {
                        au = UserTaskReference.PopulateUserByUserName((string)(mElems.GetValue(1)), ssn);
                    }
                    if (au != null)
                    {
                        if (ual == null)
                        {
                            ual = new List <AppUser>();
                        }
                        if (ual.IndexOf(au) == -1)
                        {
                            ual.Add(au);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Собирает пользователей из всех соответствующих подсписков коллекции BaseUserTaskReference и добавляет их к
        /// соответствующему списку пользователей задачи
        /// Сбор пользвателей из ролей и групп пока не реализован!
        /// </summary>
        /// <param name="Butrs"></param>
        /// <param name="ual"></param>
        public static void FillUsersFromAdminTaskCollection(XPCollection <BaseUserTaskReference> Butrs, ref DealWithoutStageTaskInstanceDefinition task, UserListType userListType)
        {
            foreach (BaseUserTaskReference butr in Butrs)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    switch (userListType)
                    {
                    case UserListType.BusinessAdministrators:
                        if (AppUserbutr != null & task.BusinessAdministrators.IndexOf(AppUserbutr) == -1)
                        {
                            AppUserbutr.BaseUserTaskBusinessAdministrators.Add(task);
                        }
                        break;

                    case UserListType.ExcludedOwners:
                        if (AppUserbutr != null & task.ExcludedOwners.IndexOf(AppUserbutr) == -1)
                        {
                            AppUserbutr.BaseUserTaskExcludedOwners.Add(task);
                        }
                        break;

                    case UserListType.NotificationRecipients:
                        if (AppUserbutr != null & task.NotificationRecipients.IndexOf(AppUserbutr) == -1)
                        {
                            AppUserbutr.BaseUserTaskNotificationRecipients.Add(task);
                        }
                        break;

                    case UserListType.PossibleDelegates:
                        if (AppUserbutr != null & task.PossibleDelegates.IndexOf(AppUserbutr) == -1)
                        {
                            AppUserbutr.BaseUserTaskPossibleDelegates.Add(task);
                        }
                        break;

                    case UserListType.PotentialOwners:
                        if (AppUserbutr != null & task.PotentialOwners.IndexOf(AppUserbutr) == -1)
                        {
                            AppUserbutr.BaseUserTaskPotentialOwners.Add(task);
                        }
                        break;

                    case UserListType.TaskStakeholders:
                        if (AppUserbutr != null & task.TaskStakeholders.IndexOf(AppUserbutr) == -1)
                        {
                            AppUserbutr.BaseUserTaskTaskStakeholders.Add(task);
                        }
                        break;
                    }
                }
                if (butr.GetType() == typeof(RoleTaskReference))
                {
                    RoleTaskReference rolebutr = (RoleTaskReference)butr;
                    //AppUser AppUserbutr = rolebutr.AppUser;
                    //if (ual.IndexOf(AppUserbutr) == -1) ual.Add(AppUserbutr);
                }
                if (butr.GetType() == typeof(GroupTaskReference))
                {
                    GroupTaskReference groupbutr = (GroupTaskReference)butr;
                    //AppUser AppUserbutr = userbutr.AppUser;
                    //if (ual.IndexOf(AppUserbutr) == -1) ual.Add(AppUserbutr);
                }
            }
        }
Exemple #4
0
        public static void ProcessElements(TaskParameters tp, ref DealWithoutStageTaskInstanceDefinition task, Session ssn)
        {
            foreach (string userName in tp.BusinessAdministrators)
            {
                // Восстанавливаем пользователя по его UserName
                AppUser au = UserTaskReference.PopulateUserByUserName(userName, ssn);
                if (au != null)
                {
                    if (task.BusinessAdministrators.IndexOf(au) == -1)
                    {
                        au.BaseUserTaskBusinessAdministrators.Add(task);
                    }
                }
            }

            foreach (string userName in tp.ExcludedOwners)
            {
                // Восстанавливаем пользователя по его UserName
                AppUser au = UserTaskReference.PopulateUserByUserName(userName, ssn);
                if (au != null)
                {
                    if (task.ExcludedOwners.IndexOf(au) == -1)
                    {
                        au.BaseUserTaskExcludedOwners.Add(task);
                    }
                }
            }

            foreach (string userName in tp.NotificationRecipients)
            {
                // Восстанавливаем пользователя по его UserName
                AppUser au = UserTaskReference.PopulateUserByUserName(userName, ssn);
                if (au != null)
                {
                    if (task.NotificationRecipients.IndexOf(au) == -1)
                    {
                        au.BaseUserTaskNotificationRecipients.Add(task);
                    }
                }
            }

            foreach (string userName in tp.PossibleDelegates)
            {
                // Восстанавливаем пользователя по его UserName
                AppUser au = UserTaskReference.PopulateUserByUserName(userName, ssn);
                if (au != null)
                {
                    if (task.PossibleDelegates.IndexOf(au) == -1)
                    {
                        au.BaseUserTaskPossibleDelegates.Add(task);
                    }
                }
            }

            foreach (string userName in tp.PotentialOwners)
            {
                // Восстанавливаем пользователя по его UserName
                AppUser au = UserTaskReference.PopulateUserByUserName(userName, ssn);
                if (au != null)
                {
                    if (task.PotentialOwners.IndexOf(au) == -1)
                    {
                        au.BaseUserTaskPotentialOwners.Add(task);
                    }
                }
            }

            foreach (string userName in tp.TaskStakeholders)
            {
                // Восстанавливаем пользователя по его UserName
                AppUser au = UserTaskReference.PopulateUserByUserName(userName, ssn);
                if (au != null)
                {
                    if (task.TaskStakeholders.IndexOf(au) == -1)
                    {
                        au.BaseUserTaskTaskStakeholders.Add(task);
                    }
                }
            }
        }
Exemple #5
0
        public static void FillUsersFromAdminTaskCollection(DealWithoutStageTaskInstanceDefinitionAdmin tiid, ref DealWithoutStageTaskInstanceDefinition task)
        {
            foreach (BaseUserTaskReference butr in tiid.BusinessAdministratorsAdmin)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    if (AppUserbutr != null & task.BusinessAdministrators.IndexOf(AppUserbutr) == -1)
                    {
                        AppUserbutr.BaseUserTaskBusinessAdministrators.Add(task);
                    }
                }
            }

            foreach (BaseUserTaskReference butr in tiid.ExcludedOwnersAdmin)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    if (AppUserbutr != null & task.ExcludedOwners.IndexOf(AppUserbutr) == -1)
                    {
                        AppUserbutr.BaseUserTaskExcludedOwners.Add(task);
                    }
                }
            }

            foreach (BaseUserTaskReference butr in tiid.NotificationRecipientsAdmin)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    if (AppUserbutr != null & task.NotificationRecipients.IndexOf(AppUserbutr) == -1)
                    {
                        AppUserbutr.BaseUserTaskNotificationRecipients.Add(task);
                    }
                }
            }

            foreach (BaseUserTaskReference butr in tiid.PossibleDelegatesAdmin)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    if (AppUserbutr != null & task.PossibleDelegates.IndexOf(AppUserbutr) == -1)
                    {
                        AppUserbutr.BaseUserTaskPossibleDelegates.Add(task);
                    }
                }
            }

            foreach (BaseUserTaskReference butr in tiid.PotentialOwnersAdmin)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    if (AppUserbutr != null & task.PotentialOwners.IndexOf(AppUserbutr) == -1)
                    {
                        AppUserbutr.BaseUserTaskPotentialOwners.Add(task);
                    }
                }
            }

            foreach (BaseUserTaskReference butr in tiid.TaskStakeholdersAdmin)
            {
                UserTaskReference userbutr = butr as UserTaskReference;
                if (userbutr != null)
                {
                    AppUser AppUserbutr = userbutr.AppUser;
                    if (AppUserbutr != null & task.TaskStakeholders.IndexOf(AppUserbutr) == -1)
                    {
                        AppUserbutr.BaseUserTaskTaskStakeholders.Add(task);
                    }
                }
            }

            // Роли и группы пока не обрабатываем

            //if (butr.GetType() == typeof(RoleTaskReference)) {
            //    RoleTaskReference rolebutr = (RoleTaskReference)butr;
            //    //AppUser AppUserbutr = rolebutr.AppUser;
            //    //if (ual.IndexOf(AppUserbutr) == -1) ual.Add(AppUserbutr);
            //}
            //if (butr.GetType() == typeof(GroupTaskReference)) {
            //    GroupTaskReference groupbutr = (GroupTaskReference)butr;
            //    //AppUser AppUserbutr = userbutr.AppUser;
            //    //if (ual.IndexOf(AppUserbutr) == -1) ual.Add(AppUserbutr);
            //}
        }