Beispiel #1
0
        private void ProcessRoleGroups(ExportImportJob importJob, ImportDto importDto,
                                       IEnumerable <ExportRoleGroup> otherRoleGroups)
        {
            var changedGroups   = new List <RoleGroupItem>();
            var portalId        = importJob.PortalId;
            var localRoleGroups = CBO.FillCollection <ExportRoleGroup>(DataProvider.Instance().GetAllRoleGroups(portalId, DateUtils.GetDatabaseUtcTime().AddYears(1), null));

            foreach (var other in otherRoleGroups)
            {
                if (CheckCancelled(importJob))
                {
                    return;
                }
                var createdBy  = Util.GetUserIdByName(importJob, other.CreatedByUserID, other.CreatedByUserName);
                var modifiedBy = Util.GetUserIdByName(importJob, other.LastModifiedByUserID, other.LastModifiedByUserName);
                var local      = localRoleGroups.FirstOrDefault(t => t.RoleGroupName == other.RoleGroupName);

                if (local != null)
                {
                    other.LocalId = local.RoleGroupID;
                    switch (importDto.CollisionResolution)
                    {
                    case CollisionResolution.Ignore:
                        Result.AddLogEntry("Ignored role group", other.RoleGroupName);
                        break;

                    case CollisionResolution.Overwrite:
                        var roleGroup = new RoleGroupInfo(local.RoleGroupID, portalId, false)
                        {
                            RoleGroupName = other.RoleGroupName,
                            Description   = other.Description,
                        };
                        RoleController.UpdateRoleGroup(roleGroup, false);
                        changedGroups.Add(new RoleGroupItem(roleGroup.RoleGroupID, createdBy, modifiedBy));
                        DataCache.ClearCache(string.Format(DataCache.RoleGroupsCacheKey, local.RoleGroupID));
                        Result.AddLogEntry("Updated role group", other.RoleGroupName);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(importDto.CollisionResolution.ToString());
                    }
                }
                else
                {
                    var roleGroup = new RoleGroupInfo()
                    {
                        PortalID      = portalId,
                        RoleGroupName = other.RoleGroupName,
                        Description   = other.Description,
                    };
                    other.LocalId = RoleController.AddRoleGroup(roleGroup);
                    changedGroups.Add(new RoleGroupItem(roleGroup.RoleGroupID, createdBy, modifiedBy));
                    Result.AddLogEntry("Added role group", other.RoleGroupName);
                }
            }
            if (changedGroups.Count > 0)
            {
                RefreshRecordsUserIds(changedGroups);
            }
        }
        public HttpResponseMessage SaveRoleGroup(RoleGroupDto roleGroupDto)
        {
            try
            {
                Validate(roleGroupDto);

                var roleGroup = roleGroupDto.ToRoleGroupInfo();
                roleGroup.PortalID = PortalId;

                if (roleGroup.RoleGroupID < Null.NullInteger)
                {
                    try
                    {
                        RoleController.AddRoleGroup(roleGroup);
                    }
                    catch
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                           Localization.GetString("DuplicateRoleGroup", Components.Constants.LocalResourcesFile)));
                    }
                }
                else
                {
                    try
                    {
                        RoleController.UpdateRoleGroup(roleGroup);
                    }
                    catch
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                           Localization.GetString("DuplicateRoleGroup", Components.Constants.LocalResourcesFile)));
                    }
                }

                roleGroup = RoleController.GetRoleGroups(PortalId).Cast <RoleGroupInfo>()
                            .FirstOrDefault(r => r.RoleGroupName == roleGroupDto.Name?.Trim());

                return(Request.CreateResponse(HttpStatusCode.OK, RoleGroupDto.FromRoleGroupInfo(roleGroup)));
            }
            catch (ArgumentException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #3
0
        public void btGo_Click(object sender, EventArgs e)
        {
            //Setup Child Page - Main View/Activity
            TabInfo tab = CreatePage(PortalSettings.ActiveTab, PortalId, TabId, "Group Activity", false);

            //Add Module to Child Page
            int groupViewModuleId = AddModule(tab, PortalId, "Social Groups", "ContentPane");
            int journalModuleId   = AddModule(tab, PortalId, "Journal", "ContentPane");
            int consoleId         = AddModule(tab, PortalId, "Console", "RightPane");

            var mc = new ModuleController();

            ModuleInfo groupConsoleModule = mc.GetModule(consoleId, tab.TabID);
            TabInfo    memberTab          = CreatePage(PortalSettings.ActiveTab, PortalId, tab.TabID, "Members", false);

            mc.CopyModule(groupConsoleModule, memberTab, "RightPane", true);

            ModuleInfo groupViewModule = mc.GetModule(groupViewModuleId, tab.TabID);

            mc.CopyModule(groupViewModule, memberTab, "ContentPane", true);
            AddModule(memberTab, PortalId, "DotNetNuke.Modules.MemberDirectory", "ContentPane");


            //List Settings
            var modules = new ModuleController();

            modules.UpdateTabModuleSetting(TabModuleId, Constants.GroupLoadView, GroupMode.List.ToString());
            modules.UpdateTabModuleSetting(TabModuleId, Constants.GroupViewPage, tab.TabID.ToString(CultureInfo.InvariantCulture));

            //Default Social Groups
            var defaultGroup = RoleController.GetRoleGroupByName(PortalId, Constants.DefaultGroupName);
            var groupId      = -2;

            if (defaultGroup != null)
            {
                groupId = defaultGroup.RoleGroupID;
            }
            else
            {
                var groupInfo = new RoleGroupInfo();
                groupInfo.PortalID      = PortalId;
                groupInfo.RoleGroupName = Constants.DefaultGroupName;
                groupInfo.Description   = Constants.DefaultGroupName;
                groupId = RoleController.AddRoleGroup(groupInfo);
            }
            modules.UpdateTabModuleSetting(TabModuleId, Constants.DefaultRoleGroupSetting, groupId.ToString());

            Response.Redirect(Request.RawUrl);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// BindGroups gets the role Groups from the Database and binds them to the DropDown
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]    01/05/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void BindGroups()
        {
            ArrayList arrGroups = RoleController.GetRoleGroups(PortalId);
            bool      bFound    = false;

            foreach (RoleGroupInfo roleGroup in arrGroups)
            {
                if (roleGroup.RoleGroupName.StartsWith(GroupRole))
                {
                    cboRoleGroups.Items.Add(new ListItem(roleGroup.RoleGroupName, roleGroup.RoleGroupID.ToString()));
                    bFound = true;
                }
            }

            // If the Group "DBH" is not found, then we will add
            if (!bFound)
            {
                var objRoleGroupInfo = new RoleGroupInfo();
                objRoleGroupInfo.PortalID = PortalId;
                //objRoleGroupInfo.RoleGroupID = RoleGroupID;
                objRoleGroupInfo.RoleGroupName = GroupRole;
                objRoleGroupInfo.Description   = "Department of Beaches and Harbors Security Group Role";
                try
                {
                    RoleController.AddRoleGroup(objRoleGroupInfo);
                }
                catch
                {
                    Skin.AddModuleMessage(this, Localization.GetString("DuplicateRoleGroup", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                }

                arrGroups = RoleController.GetRoleGroups(PortalId);

                foreach (RoleGroupInfo roleGroup in arrGroups)
                {
                    if (roleGroup.RoleGroupName.StartsWith(GroupRole))
                    {
                        cboRoleGroups.Items.Add(new ListItem(roleGroup.RoleGroupName, roleGroup.RoleGroupID.ToString()));
                    }
                }
            }

            //Determine there is parameter of Request
            if (this.Request.QueryString["RoleGroupID"] != null)
            {
                cboRoleGroups.SelectedValue = this.Request.QueryString["RoleGroupID"].ToString();
            }
        }
Beispiel #5
0
        /// <summary>
        /// cmdUpdate_Click runs when the update 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 cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    RoleGroupInfo objRoleGroupInfo = new RoleGroupInfo();
                    objRoleGroupInfo.PortalID      = PortalId;
                    objRoleGroupInfo.RoleGroupID   = RoleGroupID;
                    objRoleGroupInfo.RoleGroupName = txtRoleGroupName.Text;
                    objRoleGroupInfo.Description   = txtDescription.Text;

                    if (RoleGroupID == -1)
                    {
                        try
                        {
                            RoleController.AddRoleGroup(objRoleGroupInfo);
                        }
                        catch
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateRoleGroup", this.LocalResourceFile), ModuleMessageType.RedError);
                            return;
                        }
                        Response.Redirect(Globals.NavigateURL(TabId, ""));
                    }
                    else
                    {
                        RoleController.UpdateRoleGroup(objRoleGroupInfo);
                        Response.Redirect(Globals.NavigateURL(TabId, "", "RoleGroupID=" + RoleGroupID.ToString()));
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }