当前位置: 首页>>代码示例>>C#>>正文


C# RoleController.GetUsersByRoleName方法代码示例

本文整理汇总了C#中DotNetNuke.Security.Roles.RoleController.GetUsersByRoleName方法的典型用法代码示例。如果您正苦于以下问题:C# RoleController.GetUsersByRoleName方法的具体用法?C# RoleController.GetUsersByRoleName怎么用?C# RoleController.GetUsersByRoleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Security.Roles.RoleController的用法示例。


在下文中一共展示了RoleController.GetUsersByRoleName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddGroupOwnerNotification

        internal virtual Notification AddGroupOwnerNotification(string notificationTypeName, int tabId, int moduleId, RoleInfo group, UserInfo initiatingUser) 
        {
            var notificationType = NotificationsController.Instance.GetNotificationType(notificationTypeName);

            var tokenReplace = new GroupItemTokenReplace(group);
            
            var subject = Localization.GetString(notificationTypeName + ".Subject", Constants.SharedResourcesPath);
            var body = Localization.GetString(notificationTypeName + ".Body", Constants.SharedResourcesPath);
            subject = subject.Replace("[DisplayName]", initiatingUser.DisplayName);
            subject = subject.Replace("[ProfileUrl]", Globals.UserProfileURL(initiatingUser.UserID));
            subject = tokenReplace.ReplaceGroupItemTokens(subject);
            body = body.Replace("[DisplayName]", initiatingUser.DisplayName);
            body = body.Replace("[ProfileUrl]", Globals.UserProfileURL(initiatingUser.UserID));
            body = tokenReplace.ReplaceGroupItemTokens(body);
            var roleCreator = UserController.GetUserById(group.PortalID, group.CreatedByUserID);

            var roleOwners = new List<UserInfo>();

            var rc = new RoleController();
            foreach (UserInfo userInfo in rc.GetUsersByRoleName(group.PortalID, group.RoleName)) {
                var userRoleInfo = rc.GetUserRole(group.PortalID, userInfo.UserID, group.RoleID);
                if (userRoleInfo.IsOwner && userRoleInfo.UserID != group.CreatedByUserID)
                {
                    roleOwners.Add(UserController.GetUserById(group.PortalID, userRoleInfo.UserID));
                }
            }
            roleOwners.Add(roleCreator);
            


            //Need to add from sender details
            var notification = new Notification
            {
                NotificationTypeID = notificationType.NotificationTypeId,
                Subject = subject,
                Body = body,
                IncludeDismissAction = true,
                SenderUserID = initiatingUser.UserID,
                Context = String.Format("{0}:{1}:{2}:{3}", tabId, moduleId, group.RoleID, initiatingUser.UserID)
            };
            NotificationsController.Instance.SendNotification(notification, initiatingUser.PortalID, null, roleOwners);

            return notification;
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:44,代码来源:Notifications.cs

示例2: cmdSend_Click

        /// <summary>
        /// cmdSend_Click runs when the cmdSend Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdSend_Click( Object sender, EventArgs e )
        {
            try
            {
                ArrayList objRecipients = new ArrayList();
                RoleController objRoles = new RoleController();
                ListItem objListItem;

                // load all user emails based on roles selected
                foreach( ListItem objRole in chkRoles.Items )
                {
                    if( objRole.Selected )
                    {
                        foreach( UserInfo objUser in objRoles.GetUsersByRoleName( PortalId, objRole.Value ) )
                        {
                            if( objUser.Membership.Approved )
                            {
                                objListItem = new ListItem( objUser.Email, objUser.DisplayName );
                                if( ! objRecipients.Contains( objListItem ) )
                                {
                                    objRecipients.Add( objListItem );
                                }
                            }
                        }
                    }
                }

                // load emails specified in email distribution list
                if( !String.IsNullOrEmpty(txtEmail.Text) )
                {
                    string[] splitter = {";"};
                    Array arrEmail = txtEmail.Text.Split(splitter, StringSplitOptions.None);
                    foreach( string strEmail in arrEmail )
                    {
                        objListItem = new ListItem( strEmail, strEmail );
                        if( ! objRecipients.Contains( objListItem ) )
                        {
                            objRecipients.Add( objListItem );
                        }
                    }
                }

                // create object
                SendBulkEmail objSendBulkEMail = new SendBulkEmail( objRecipients, cboPriority.SelectedItem.Value, teMessage.Mode, PortalSettings.PortalAlias.HTTPAlias );
                objSendBulkEMail.Subject = txtSubject.Text;
                objSendBulkEMail.Body += teMessage.Text;
                if( ctlAttachment.Url.StartsWith( "FileID=" ) )
                {
                    int fileId = int.Parse( ctlAttachment.Url.Substring( 7 ) );
                    FileController objFileController = new FileController();
                    FileInfo objFileInfo = objFileController.GetFileById( fileId, PortalId );

                    objSendBulkEMail.Attachment = PortalSettings.HomeDirectoryMapPath + objFileInfo.Folder + objFileInfo.FileName;
                }
                objSendBulkEMail.SendMethod = cboSendMethod.SelectedItem.Value;
                objSendBulkEMail.SMTPServer = Convert.ToString( PortalSettings.HostSettings["SMTPServer"] );
                objSendBulkEMail.SMTPAuthentication = Convert.ToString( PortalSettings.HostSettings["SMTPAuthentication"] );
                objSendBulkEMail.SMTPUsername = Convert.ToString( PortalSettings.HostSettings["SMTPUsername"] );
                objSendBulkEMail.SMTPPassword = Convert.ToString( PortalSettings.HostSettings["SMTPPassword"] );
                objSendBulkEMail.Administrator = txtFrom.Text;
                objSendBulkEMail.Heading = Localization.GetString( "Heading", this.LocalResourceFile );

                // send mail
                if( optSendAction.SelectedItem.Value == "S" )
                {
                    objSendBulkEMail.Send();
                }
                else // ansynchronous uses threading
                {
                    Thread objThread = new Thread( new ThreadStart( objSendBulkEMail.Send ) );
                    objThread.Start();
                }

                // completed
                UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "MessageSent", this.LocalResourceFile ), ModuleMessageType.GreenSuccess );
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:90,代码来源:BulkEmail.ascx.cs

示例3: SendApprovalEmail

        private void SendApprovalEmail()
        {
            //string toAddress = string.Empty;
            int edittabid = -1;
            int editModuleId = -1;
            var objModules = new ModuleController();
            foreach (ModuleInfo mi in objModules.GetModulesByDefinition(PortalId, Utility.DnnFriendlyModuleName))
            {
                if (!mi.IsDeleted)
                {
                    var objTabs = new TabController();
                    if (!objTabs.GetTab(mi.TabID, mi.PortalID, false).IsDeleted)
                    {
                        edittabid = mi.TabID;
                        editModuleId = mi.ModuleID;
                        break;
                    }
                    continue;
                }
            }

            UserInfo ui = UserController.GetCurrentUserInfo();
            if (ui.Username != null)
            {
                var rc = new RoleController();

                ArrayList users = rc.GetUsersByRoleName(ui.PortalID, HostController.Instance.GetString(Utility.PublishEmailNotificationRole + PortalId));

                DotNetNuke.Entities.Portals.PortalSettings ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
                string linkUrl = Globals.NavigateURL(DisplayTabId, "", "VersionId=" + ItemVersionId.ToString(CultureInfo.InvariantCulture) + "&modid=" + _moduleId);
                string linksUrl = Globals.NavigateURL(edittabid, "", "&ctl=" + Utility.AdminContainer + "&mid=" + editModuleId.ToString(CultureInfo.InvariantCulture) + "&adminType=" + "VersionsList&_itemId=" + ItemId);

                //Now ask for the approriate subclass (which gets it from the correct resource file) the subject and body.
                string body = EmailApprovalBody;
                body = body.Replace("[ENGAGEITEMNAME]", _name);
                body = body.Replace("[ENGAGEITEMLINK]", linkUrl);
                body = body.Replace("[ENGAGEITEMSLINK]", linksUrl);

                string subject = EmailApprovalSubject;

                foreach (UserInfo u in users)
                {
                    Mail.SendMail(ps.Email, u.Email, "", subject, body, "", "HTML", "", "", "", "");
                }
            }
        }
开发者ID:ChrisHammond,项目名称:Engage-Publish,代码行数:46,代码来源:Item.cs

示例4: NotifyAssignedGroupOfAssignment

        // Emails

        #region NotifyAssignedGroupOfAssignment
        private void NotifyAssignedGroupOfAssignment()
        {
            RoleController objRoleController = new RoleController();
            string strAssignedRole = String.Format("{0}", objRoleController.GetRole(Convert.ToInt32(ddlAssigned.SelectedValue), PortalId).RoleName);
            string strLinkUrl = Utils.FixURLLink(DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "EditTask", "mid=" + ModuleId.ToString(), String.Format(@"&TaskID={0}", Request.QueryString["TaskID"])), PortalSettings.PortalAlias.HTTPAlias);

            string strSubject = "[" + Localization.GetString(String.Format("ddlStatusAdmin{0}.Text", ddlStatus.SelectedValue), LocalResourceFile) + "] " + String.Format(Localization.GetString("HelpDeskTicketAtHasBeenAssigned.Text", LocalResourceFile), Request.QueryString["TaskID"], PortalSettings.PortalAlias.HTTPAlias, strAssignedRole);
            string strBody = String.Format(Localization.GetString("ANewHelpDeskTicketHasBeenAssigned.Text", LocalResourceFile), Request.QueryString["TaskID"], txtDescription.Text);
            strBody = strBody + Environment.NewLine;
            strBody = strBody + String.Format(Localization.GetString("YouMaySeeStatusHere.Text", LocalResourceFile), strLinkUrl);

            // Get all users in the AssignedRole Role
            ArrayList colAssignedRoleUsers = objRoleController.GetUsersByRoleName(PortalId, strAssignedRole);

            foreach (UserInfo objUserInfo in colAssignedRoleUsers)
            {
                DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, objUserInfo.Email, "", strSubject, strBody, "", "HTML", "", "", "", "");
            }

            Log.InsertLog(Convert.ToInt32(Request.QueryString["TaskID"]), UserId, String.Format(Localization.GetString("AssignedTicketTo.Text", LocalResourceFile), UserInfo.DisplayName, strAssignedRole));
        }
开发者ID:roman-yagodin,项目名称:R7.HelpDesk,代码行数:24,代码来源:EditTask.ascx.cs

示例5: GiveTranslatorRoleEditRights

        /// <summary>
        /// Gives the translator role edit rights.
        /// </summary>
        /// <param name="localizedTab">The localized tab.</param>
        /// <param name="users">The users.</param>
        public void GiveTranslatorRoleEditRights(TabInfo localizedTab, Dictionary<int, UserInfo> users)
        {
            var roleCtrl = new RoleController();
            var permissionCtrl = new PermissionController();
            ArrayList permissionsList = permissionCtrl.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT");

            string translatorRoles =
                PortalController.GetPortalSetting(
                    string.Format("DefaultTranslatorRoles-{0}", localizedTab.CultureCode), localizedTab.PortalID, "");
            foreach (string translatorRole in translatorRoles.Split(';'))
            {
                if (users != null)
                {
                    foreach (UserInfo translator in roleCtrl.GetUsersByRoleName(localizedTab.PortalID, translatorRole))
                    {
                        users[translator.UserID] = translator;
                    }
                }

                if (permissionsList != null && permissionsList.Count > 0)
                {
                    var translatePermisison = (PermissionInfo)permissionsList[0];
                    string roleName = translatorRole;
                    RoleInfo role = TestableRoleController.Instance.GetRole(localizedTab.PortalID,
                                                                            r => r.RoleName == roleName);
                    if (role != null)
                    {
                        TabPermissionInfo perm =
                            localizedTab.TabPermissions.Where(
                                tp => tp.RoleID == role.RoleID && tp.PermissionKey == "EDIT").SingleOrDefault();
                        if (perm == null)
                        {
                            //Create Permission
                            var tabTranslatePermission = new TabPermissionInfo(translatePermisison)
                                {
                                    RoleID = role.RoleID,
                                    AllowAccess = true,
                                    RoleName = roleName
                                };
                            localizedTab.TabPermissions.Add(tabTranslatePermission);
                            UpdateTab(localizedTab);
                        }
                    }
                }
            }
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:51,代码来源:TabController.cs

示例6: NotifyAssignedGroupOfComment

        // Emails

        #region NotifyAssignedGroupOfComment
        private void NotifyAssignedGroupOfComment(string strComment)
        {
            RoleController objRoleController = new RoleController();
            string strDescription = GetDescriptionOfTicket();

            // Send to Administrator Role
            string strAssignedRole = "Administrators";
            int intRole = GetAssignedRole();
            if (intRole > -1)
            {
                strAssignedRole = String.Format("{0}", objRoleController.GetRole(intRole, PortalId).RoleName);
            }
            else
            {
                strAssignedRole = GetAdminRole();
            }

            string strLinkUrl = Utils.FixURLLink(DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "EditTask", "mid=" + ModuleID.ToString(), String.Format(@"&TaskID={0}", TaskID)), PortalSettings.PortalAlias.HTTPAlias);

            string strSubject = String.Format(Localization.GetString("HelpDeskTicketAtHasBeenupdated.Text", LocalResourceFile), Request.QueryString["TaskID"], PortalSettings.PortalAlias.HTTPAlias);
            string strBody = String.Format(Localization.GetString("HelpDeskTicketHasBeenupdated.Text", LocalResourceFile), Request.QueryString["TaskID"], strDescription);
            strBody = strBody + Environment.NewLine + Environment.NewLine;
            strBody = strBody + Localization.GetString("Comments.Text", LocalResourceFile) + Environment.NewLine;
            strBody = strBody + strComment;
            strBody = strBody + Environment.NewLine + Environment.NewLine;
            strBody = strBody + String.Format(Localization.GetString("YouMaySeeFullStatusHere.Text", LocalResourceFile), strLinkUrl);

            // Get all users in the AssignedRole Role
            ArrayList colAssignedRoleUsers = objRoleController.GetUsersByRoleName(PortalId, strAssignedRole);

            foreach (UserInfo objUserInfo in colAssignedRoleUsers)
            {
                DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, objUserInfo.Email, "", strSubject, strBody, "", "HTML", "", "", "", "");
            }

            Log.InsertLog(Convert.ToInt32(Request.QueryString["TaskID"]), UserId, String.Format(Localization.GetString("SentCommentTo.Text", LocalResourceFile), UserInfo.DisplayName, strAssignedRole));
        }
开发者ID:roman-yagodin,项目名称:R7.HelpDesk,代码行数:40,代码来源:Comments.ascx.cs

示例7: Recipients

        /// <summary>All bulk mail recipients, derived from role names and individual adressees </summary>
        /// <returns>List of userInfo objects, who receive the bulk mail </returns>
        /// <remarks>user.Email used for sending, other properties might be used for TokenReplace</remarks>
        public List<UserInfo> Recipients()
        {
            EnsureNotDisposed();

            var userList = new List<UserInfo>();
            var keyList = new List<string>();
            var roleController = new RoleController();
            
            foreach (string roleName in _addressedRoles)
            {
                string role = roleName;
                var roleInfo = TestableRoleController.Instance.GetRole(_portalSettings.PortalId, r => r.RoleName == role);

                foreach (UserInfo objUser in roleController.GetUsersByRoleName(_portalSettings.PortalId, roleName))
                {
                    UserInfo user = objUser;
                    ProfileController.GetUserProfile(ref user);
                    var userRole = roleController.GetUserRole(_portalSettings.PortalId, objUser.UserID, roleInfo.RoleID);
                    //only add if user role has not expired and effectivedate has been passed
                    if ((userRole.EffectiveDate <= DateTime.Now || Null.IsNull(userRole.EffectiveDate)) && (userRole.ExpiryDate >= DateTime.Now || Null.IsNull(userRole.ExpiryDate)))
                    {
                        ConditionallyAddUser(objUser, ref keyList, ref userList);
                    }
                }
            }
            
            foreach (UserInfo objUser in _addressedUsers)
            {
                ConditionallyAddUser(objUser, ref keyList, ref userList);
            }
            
            return userList;
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:36,代码来源:SendTokenizedBulkEmail.cs

示例8: SendEmail

        // Email

        #region SendEmail
        private void SendEmail(string TaskID)
        {
            try
            {
                HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

                HelpDesk_Task objHelpDesk_Tasks = (from HelpDesk_Tasks in objHelpDeskDALDataContext.HelpDesk_Tasks
                                                           where HelpDesk_Tasks.TaskID == Convert.ToInt32(TaskID)
                                                           select HelpDesk_Tasks).FirstOrDefault();

                string strPasswordLinkUrl = Utils.FixURLLink(DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "EditTask", "mid=" + ModuleId.ToString(), String.Format(@"&TaskID={0}&TP={1}", TaskID, objHelpDesk_Tasks.TicketPassword)), PortalSettings.PortalAlias.HTTPAlias);
                string strLinkUrl = Utils.FixURLLink(DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "EditTask", "mid=" + ModuleId.ToString(), String.Format(@"&TaskID={0}", TaskID)), PortalSettings.PortalAlias.HTTPAlias);
                string strSubject = String.Format(Localization.GetString("NewHelpDeskTicketCreated.Text", LocalResourceFile), TaskID);
                string strBody = "";

                if (Convert.ToInt32(txtUserID.Text) != UserId || UserId == -1)
                {
                    if (UserId == -1)
                    {
                        // Anonymous user has created a ticket
                        strBody = String.Format(Localization.GetString("ANewHelpDeskTicket.Text", LocalResourceFile), TaskID); ;
                    }
                    else
                    {
                        // Admin has created a Ticket on behalf of another user
                        strBody = String.Format(Localization.GetString("HasCreatedANewHelpDeskTicket.Text", LocalResourceFile), UserInfo.DisplayName, TaskID, PortalSettings.PortalAlias.HTTPAlias); ;
                    }

                    strBody = strBody + Environment.NewLine;
                    strBody = strBody + String.Format(Localization.GetString("YouMaySeeStatusHere.Text", LocalResourceFile), strPasswordLinkUrl);

                    string strEmail = txtEmail.Text;

                    // If userId is not -1 then get the Email
                    if (Convert.ToInt32(txtUserID.Text) > -1)
                    {
                        strEmail = //UserController.GetUser(PortalId, Convert.ToInt32(txtUserID.Text), false).Email
							UserController.GetUserById(PortalId, Convert.ToInt32(txtUserID.Text)).Email;
                    }

                    DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, strEmail, "", strSubject, strBody, "", "HTML", "", "", "", "");

                    // Get Admin Role
                    string strAdminRoleID = GetAdminRole();
                    // User is an Administrator
                    if (UserInfo.IsInRole(strAdminRoleID) || UserInfo.IsInRole("Administrators") || UserInfo.IsSuperUser)
                    {
                        // If Ticket is assigned to any group other than unassigned notify them
                        if (Convert.ToInt32(ddlAssignedAdmin.SelectedValue) > -1)
                        {
                            NotifyAssignedGroup(TaskID);
                        }
                    }
                    else
                    {
                        // This is not an Admin so Notify the Admins
                        strSubject = String.Format(Localization.GetString("NewHelpDeskTicketCreatedAt.Text", LocalResourceFile), TaskID, PortalSettings.PortalAlias.HTTPAlias);
                        strBody = String.Format(Localization.GetString("ANewHelpDeskTicketCreated.Text", LocalResourceFile), TaskID, txtDescription.Text);
                        strBody = strBody + Environment.NewLine;
                        strBody = strBody + String.Format(Localization.GetString("YouMaySeeStatusHere.Text", LocalResourceFile), strLinkUrl);

                        // Get all users in the Admin Role
                        RoleController objRoleController = new RoleController();
                        ArrayList colAdminUsers = objRoleController.GetUsersByRoleName(PortalId, GetAdminRole());

                        foreach (UserInfo objUserInfo in colAdminUsers)
                        {
                            DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, objUserInfo.Email, "", strSubject, strBody, "", "HTML", "", "", "", "");
                        }
                    }
                }
                else
                {
                    // A normal ticket has been created
                    strSubject = String.Format(Localization.GetString("NewHelpDeskTicketCreatedAt.Text", LocalResourceFile), TaskID, PortalSettings.PortalAlias.HTTPAlias);
                    strBody = String.Format(Localization.GetString("ANewHelpDeskTicketCreated.Text", LocalResourceFile), TaskID, txtDescription.Text);
                    strBody = strBody + Environment.NewLine;
                    strBody = strBody + String.Format(Localization.GetString("YouMaySeeStatusHere.Text", LocalResourceFile), strLinkUrl);

                    // Get all users in the Admin Role
                    RoleController objRoleController = new RoleController();
                    ArrayList colAdminUsers = objRoleController.GetUsersByRoleName(PortalId, GetAdminRole());

                    foreach (UserInfo objUserInfo in colAdminUsers)
                    {
                        DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, objUserInfo.Email, "", strSubject, strBody, "", "HTML", "", "", "", "");
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }

        }
开发者ID:roman-yagodin,项目名称:R7.HelpDesk,代码行数:98,代码来源:View.ascx.cs


注:本文中的DotNetNuke.Security.Roles.RoleController.GetUsersByRoleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。