示例#1
0
 public void Save(long idTile, dtoEditTile item, String cssFile, String imagesFolder)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         ModuleDashboard.ActionType action = action = (idTile > 0) ? ModuleDashboard.ActionType.TileUnableToAdd : ModuleDashboard.ActionType.TileUnableToSave;
         if (item.Type == TileType.CombinedTags && item.IdTags.Count < 2)
         {
             View.DisplayMessage(View.IdTileCommunity, Service.ServiceModuleID(), idTile, action, ErrorMessageType.MissingTags);
         }
         else
         {
             Tile tile = null;
             try
             {
                 tile = Service.SaveTile(item);
                 if (tile != null)
                 {
                     action = (idTile > 0) ? ModuleDashboard.ActionType.TileSaved : ModuleDashboard.ActionType.TileAdded;
                 }
                 if (action == ModuleDashboard.ActionType.TileAdded)
                 {
                     View.RedirectToEdit(View.IdTileCommunity, Service.ServiceModuleID(), tile.Id, action);
                 }
                 else
                 {
                     View.DisplayMessage(View.IdTileCommunity, Service.ServiceModuleID(), idTile, action);
                 }
                 if (tile != null)
                 {
                     View.LoadCssAndImages(ExtractIconsCss(cssFile, tile.ImageCssClass), ExtractTileImages(imagesFolder, tile.ImageUrl), true);
                 }
             }
             catch (TileException ex)
             {
                 View.DisplayMessage(View.IdTileCommunity, Service.ServiceModuleID(), idTile, action, ex.ErrorType);
             }
             catch (Exception ex)
             {
                 View.DisplayMessage(View.IdTileCommunity, Service.ServiceModuleID(), idTile, action);
             }
         }
     }
 }
示例#2
0
        public void InitView(dtoEditTile tile, String cssFile, String imagesFolder)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                List <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> items = CurrentManager.GetAllLanguages().OrderByDescending(l => l.isDefault).ThenBy(l => l.Name).Select(l =>
                                                                                                                                                                                   new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                {
                    IdLanguage = l.Id, LanguageCode = l.Code, LanguageName = l.Name
                }).ToList();

                items.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                {
                    IdLanguage = 0, LanguageCode = View.GetDefaultLanguageCode(), LanguageName = View.GetDefaultLanguageName(), IsMultiLanguage = true
                });
                View.CurrentType = tile.Type;
                View.LoadTranslations(items, items.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                View.LoadCssAndImages(ExtractIconsCss(cssFile, tile.ImageCssClass), ExtractTileImages(imagesFolder, tile.ImageUrl), true);
            }
        }
        public void InitView(Boolean add, long idTile, DashboardType dashboardType, Int32 idContainerCommunity)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || p == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                Int32           idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0;
                ModuleDashboard permissions     = ModuleDashboard.CreatePortalmodule(p.TypeID);
                List <TileType> availableTypes  = null;
                dtoEditTile     tile            = null;
                View.IdTile = idTile;
                if (add)
                {
                    availableTypes = Service.GetTileTypesAvailable(dashboardType);
                    tile           = new dtoEditTile();
                    tile.Status    = AvailableStatus.Draft;
                    tile.Type      = availableTypes.FirstOrDefault();
                }
                else
                {
                    if (View.PreloadFromAdd)
                    {
                        View.DisplayTileAdded();
                    }
                    tile            = Service.GetEditTile(idTile);
                    idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity;
                }
                View.IdTileCommunity = idTileCommunity;
                if (dashboardType == DashboardType.Community)
                {
                    View.IdContainerCommunity = idContainerCommunity;
                    if (idTileCommunity < 0)
                    {
                        idTileCommunity = UserContext.CurrentCommunityID;
                    }
                    if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles))
                    {
                        permissions = Service.GetPermission(idTileCommunity);
                    }
                }
                else
                {
                    idContainerCommunity      = 0;
                    View.IdContainerCommunity = 0;
                }
                if ((tile == null && (idTile > 0 || !add)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual))
                {
                    View.DisplayUnknownTile();
                    if (!permissions.ManageTiles)
                    {
                        View.DisplayNoPermission(idContainerCommunity, CurrentIdModule);
                    }
                    else
                    {
                        View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep));
                    }
                }
                else
                {
                    if (permissions.ManageTiles)
                    {
                        if (tile != null && tile.Id > 0)
                        {
                            View.AllowVirtualUndelete = (tile.Deleted == BaseStatusDeleted.Manual);
                            View.AllowVirtualDelete   = (tile.Deleted == BaseStatusDeleted.None);
                            View.AllowDisable         = (tile.Deleted == BaseStatusDeleted.None && tile.Status == AvailableStatus.Available);
                            View.AllowEnable          = (tile.Deleted == BaseStatusDeleted.None && tile.Status != AvailableStatus.Available);
                            View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), tile.Id, ModuleDashboard.ActionType.TileStartEditing);
                        }
                        else
                        {
                            View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileStartAdding);
                        }

                        View.AllowSave = (tile.Deleted == BaseStatusDeleted.None);
                        View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep));
                        switch (tile.Type)
                        {
                        case TileType.CommunityTag:
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title);
                            break;

                        case TileType.CombinedTags:
                            Language dLanguage = CurrentManager.GetDefaultLanguage();
                            List <lm.Comol.Core.Tag.Domain.liteTagItem>             items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList();
                            List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags  = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>()
                            {
                                Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id)
                            }).ToList();
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, tags, availableTypes);
                            break;

                        case TileType.CommunityType:
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id));
                            break;

                        default:
                            View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, availableTypes);
                            break;
                        }
                    }
                    else
                    {
                        View.DisplayNoPermission(idContainerCommunity, CurrentIdModule);
                    }
                }
            }
        }
示例#4
0
        public void InitView(long idTile, DashboardType dashboardType, Int32 idContainerCommunity)
        {
            Person p = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (UserContext.isAnonymous || p == null)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                Int32           idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0;
                ModuleDashboard permissions     = ModuleDashboard.CreatePortalmodule(p.TypeID);
                dtoEditTile     tile            = Service.GetEditTile(idTile);
                idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity;
                if (dashboardType == DashboardType.Community)
                {
                    View.IdContainerCommunity = idContainerCommunity;
                    if (idTileCommunity < 0)
                    {
                        idTileCommunity = UserContext.CurrentCommunityID;
                    }
                    if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles))
                    {
                        permissions = Service.GetPermission(idTileCommunity);
                    }
                }
                else
                {
                    idContainerCommunity      = 0;
                    View.IdContainerCommunity = 0;
                }
                if ((tile == null && (idTile > 0)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual))
                {
                    View.DisplayUnknownTile();
                }
                if (permissions.ManageTiles)
                {
                    View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView);
                    View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep));


                    List <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> languages = CurrentManager.GetAllLanguages().OrderByDescending(l => l.isDefault).ThenBy(l => l.Name).Select(l =>
                                                                                                                                                                                           new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                    {
                        IdLanguage = l.Id, LanguageCode = l.Code, LanguageName = l.Name
                    }).ToList();

                    languages.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem()
                    {
                        IdLanguage = 0, LanguageCode = View.GetDefaultLanguageCode(), LanguageName = View.GetDefaultLanguageName(), IsMultiLanguage = true
                    });

                    switch (tile.Type)
                    {
                    case TileType.CommunityTag:
                        View.LoadTile(tile, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;

                    case TileType.CombinedTags:
                        Language dLanguage = CurrentManager.GetDefaultLanguage();
                        List <lm.Comol.Core.Tag.Domain.liteTagItem>             items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList();
                        List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags  = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>()
                        {
                            Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id)
                        }).ToList();
                        View.LoadTile(tile, tags, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;

                    case TileType.CommunityType:
                        View.LoadTile(tile, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id), languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;

                    default:
                        View.LoadTile(tile, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList());
                        break;
                    }
                    View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView);
                }
                else
                {
                    View.DisplayNoPermission(idContainerCommunity, CurrentIdModule);
                }
            }
        }