示例#1
0
 public void BulkInsert(dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize, List <Dictionary <Int32, String> > toInsert)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         ModuleTags.ActionType action = ModuleTags.ActionType.GenericError;
         List <Dictionary <Int32, String> > notInserted = new List <Dictionary <int, string> >();
         List <TagItem> tags = ServiceTags.BulkInsert(TagType.Community, (idCommunity == 0), idCommunity, toInsert, notInserted);
         if (tags.Any())
         {
             if (notInserted.Any())
             {
                 action = (filters.ForOrganization) ? ModuleTags.ActionType.AddedBulkTagsToOrganizationWithDuplicates : ModuleTags.ActionType.AddedBulkTagsToPortalWithDuplicates;
                 View.DisplayMessage(action, notInserted.Select(i => i[0]).ToList());
             }
             else
             {
                 action = (filters.ForOrganization) ? ModuleTags.ActionType.AddedBulkTagsToOrganization : ModuleTags.ActionType.AddedBulkTagsToPortal;
                 View.DisplayMessage(action);
             }
         }
         else
         {
             action = (filters.ForOrganization) ? ModuleTags.ActionType.UnableToAddBulkTagsToOrganization : ModuleTags.ActionType.UnableToAddBulkTagsToPortal;
             View.DisplayMessage(action);
         }
         View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, action);
         LoadTags(filters, idCommunity, 0, pageSize);
     }
 }
示例#2
0
 public void VirtualDelete(long idTag, Boolean delete, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         ModuleTags.ActionType action = (delete) ? ModuleTags.ActionType.VirtualDelete : ModuleTags.ActionType.VirtualUndelete;
         TagItem item = ServiceTags.VirtualDelete(idTag, delete);
         if (item == null)
         {
             action = (delete) ? ModuleTags.ActionType.UnableToDelete : ModuleTags.ActionType.UnableToUndelete;
         }
         View.DisplayMessage(action);
         View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, idTag, action);
         LoadTags(filters, idCommunity, 0, pageSize);
     }
 }
示例#3
0
 public void SetStatus(long idTag, lm.Comol.Core.Dashboard.Domain.AvailableStatus status, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         ModuleTags.ActionType action = (status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available) ? ModuleTags.ActionType.EnableTag : ModuleTags.ActionType.DisableTag;
         TagItem item = ServiceTags.SetStatus(idTag, status);
         if (item == null || item.Status != status)
         {
             action = (status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available) ? ModuleTags.ActionType.UnableToEnableTag : ModuleTags.ActionType.UnableToDisableTag;
         }
         View.DisplayMessage(action);
         View.SendUserAction((filters.ForOrganization) ? idCommunity : 0, CurrentIdModule, idTag, action);
         LoadTags(filters, idCommunity, 0, pageSize);
     }
 }
 public void ApplyTags(List <dtoBulkCommunityForTags> items, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         ModuleTags.ActionType action = ModuleTags.ActionType.BulkTagsUnasigned;
         if (items.Any())
         {
             List <dtoBulkCommunityForTags> cTags = View.CurrentAssignedTags;
             if (ServiceTags.ApplyTagsToCommunities(items))
             {
                 action    = ModuleTags.ActionType.BulkTagsAssigned;
                 pageIndex = (filters.WithoutTags) ? ((pageIndex > 0) ? pageIndex - 1 : pageIndex) : pageIndex;
                 foreach (dtoBulkCommunityForTags item in items)
                 {
                     dtoBulkCommunityForTags current = cTags.Where(c => c.IdCommunity == item.IdCommunity).FirstOrDefault();
                     if (current != null)
                     {
                         current.IdSelectedTags = item.IdSelectedTags;
                     }
                 }
                 View.CurrentAssignedTags = cTags;
                 filters             = RecalcDefaultFilters(filters);
                 View.CurrentFilters = filters;
                 LoadCommunities(idCommunity, filters, pageIndex, pageSize, ModuleTags.ActionType.BulkTagsUpdateListAferTagsAssignment);
             }
         }
         else
         {
             action = ModuleTags.ActionType.BulkTagsNoSelection;
         }
         View.DisplayMessage(action);
         View.SendUserAction(idCommunity, CurrentIdModule, action);
     }
 }
        public void ApplyTags(List <Int32> idCommunities, List <long> tags, Boolean applyToAll, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                ModuleTags.ActionType action = ModuleTags.ActionType.BulkTagsUnasigned;
                View.CurrentAssignedTags = new List <dtoBulkCommunityForTags>();
                pageIndex = (filters.WithoutTags) ? ((pageIndex > 0) ? pageIndex - 1 : pageIndex) : pageIndex;
                if (applyToAll)
                {
                    List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityForTags> communities = ServiceCommunities.GetCommunitiesForBulkTagsManage(UserContext.CurrentUserID, filters);
                    if (communities != null)
                    {
                        idCommunities = communities.Select(c => c.Id).ToList();
                    }
                }

                if (idCommunities.Any())
                {
                    List <dtoBulkCommunityForTags> cTags = View.CurrentAssignedTags;
                    if (ServiceTags.ApplyTagsToCommunities(idCommunities, tags).Count > 0)
                    {
                        action = ModuleTags.ActionType.BulkTagsAssigned;

                        foreach (Int32 id in idCommunities)
                        {
                            dtoBulkCommunityForTags current = cTags.Where(c => c.IdCommunity == id).FirstOrDefault();
                            if (current != null)
                            {
                                current.IdSelectedTags = tags;
                            }
                        }
                        View.CurrentAssignedTags = cTags;
                        if (applyToAll)
                        {
                            filters = ServiceCommunities.GetDefaultFilters(CurrentManager.GetLitePerson(UserContext.CurrentUserID), CommunityManagement.CommunityAvailability.All, true);
                        }
                        else
                        {
                            filters = RecalcDefaultFilters(filters);
                        }
                        View.CurrentFilters = filters;
                        View.DeselectAll();
                        LoadCommunities(idCommunity, filters, pageIndex, pageSize, ModuleTags.ActionType.BulkTagsUpdateListAferTagsAssignment);
                    }
                    else
                    {
                        LoadCommunities(idCommunity, pageIndex, pageSize);
                    }
                }
                else
                {
                    action = ModuleTags.ActionType.BulkTagsNoSelection;
                }
                View.DisplayMessage(action);
                View.SendUserAction(idCommunity, CurrentIdModule, ModuleTags.ActionType.NoPermissionForBulkTagsAssign);
            }
        }
        private void LoadCommunities(Int32 idCommunity, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, Int32 pageIndex, Int32 pageSize, ModuleTags.ActionType action, Boolean firstLoad = false)
        {
            List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityForTags> items = ServiceCommunities.GetCommunitiesForBulkTagsManage(UserContext.CurrentUserID, filters);
            Int32 itemsCount = (items == null ? 0 : items.Count);

            PagerBase pager = new PagerBase();

            pager.PageSize  = pageSize;
            pager.Count     = (itemsCount > 0) ? itemsCount - 1 : 0;
            pager.PageIndex = pageIndex;
            View.Pager      = pager;
            if (items != null)
            {
                if (firstLoad && itemsCount == 0)
                {
                    View.HideFilters();
                }
                else if (itemsCount == 0 && ServiceTags.GetCommunitiesWithNoTags() == 0)
                {
                    View.HideFilters();
                }
                View.LoadCommunities(GenerateItems(filters, items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(), itemsCount > pageSize));
                View.SendUserAction(idCommunity, CurrentIdModule, action);
            }
            else
            {
                View.DisplayErrorFromDB();
            }
        }