Exemplo n.º 1
0
        private void initUserSelectorListView()
        {
            List <Guid> users = null;

            switch (TargetEntityType)
            {
            case EntityType.Contact:
                var contact = Global.DaoFactory.GetContactDao().GetByID(TargetContactID);
                if (contact.IsShared == false)
                {
                    users = CRMSecurity.GetAccessSubjectGuidsTo(contact);
                }
                break;

            case EntityType.Opportunity:
                var deal = Global.DaoFactory.GetDealDao().GetByID(TargetEntityID);
                if (CRMSecurity.IsPrivate(deal))
                {
                    users = CRMSecurity.GetAccessSubjectGuidsTo(deal);
                }
                break;

            case EntityType.Case:
                var caseItem = Global.DaoFactory.GetCasesDao().GetByID(TargetEntityID);
                if (CRMSecurity.IsPrivate(caseItem))
                {
                    users = CRMSecurity.GetAccessSubjectGuidsTo(caseItem);
                }
                break;
            }



            //init userSelectorListView
            if (users == null)
            {
                RegisterClientScriptHelper.DataHistoryView(Page, null);
            }
            else
            {
                List <UserInfo> UserList     = null;
                List <Guid>     UserListGuid = new List <Guid>();

                //with admins
                var admins = CoreContext.UserManager.GetUsersByGroup(Constants.GroupAdmin.ID).ToList();
                admins.AddRange(WebItemSecurity.GetProductAdministrators(ProductEntryPoint.ID).ToList());
                admins = admins.Distinct().ToList();

                admins.AddRange(from u in users
                                where !CoreContext.UserManager.IsUserInGroup(u, Constants.GroupAdmin.ID) && !WebItemSecurity.IsProductAdministrator(ProductEntryPoint.ID, u)
                                select CoreContext.UserManager.GetUsers(u));

                UserList     = admins.SortByUserName();
                UserListGuid = UserList.ConvertAll(n => n.ID).Where(g => g != SecurityContext.CurrentAccount.ID).ToList();

                RegisterClientScriptHelper.DataHistoryView(Page, UserListGuid);
            }
        }
Exemplo n.º 2
0
        private void initUserSelectorListView()
        {
            List <Guid> users = null;

            switch (TargetEntityType)
            {
            case EntityType.Contact:
                var contact = Global.DaoFactory.GetContactDao().GetByID(TargetContactID);
                if (contact.ShareType == ShareType.None)
                {
                    users = CRMSecurity.GetAccessSubjectGuidsTo(contact);
                }
                break;

            case EntityType.Opportunity:
                var deal = Global.DaoFactory.GetDealDao().GetByID(TargetEntityID);
                if (CRMSecurity.IsPrivate(deal))
                {
                    users = CRMSecurity.GetAccessSubjectGuidsTo(deal);
                }
                break;

            case EntityType.Case:
                var caseItem = Global.DaoFactory.GetCasesDao().GetByID(TargetEntityID);
                if (CRMSecurity.IsPrivate(caseItem))
                {
                    users = CRMSecurity.GetAccessSubjectGuidsTo(caseItem);
                }
                break;
            }


            //init userSelectorListView
            if (users == null)
            {
                RegisterClientScriptHelper.DataHistoryView(Page, null);
            }
            else
            {
                users = users.Where(g => g != SecurityContext.CurrentAccount.ID).ToList();
                RegisterClientScriptHelper.DataHistoryView(Page, users);
            }
        }