Exemplo n.º 1
0
        public List <dtoDisplayRepositoryItem> GetItemsWithPermissions(List <long> idItems, Int32 idCurrentPerson, RepositoryIdentifier identifier, liteRepositorySettings settings, String unknownUser, Boolean useCache = false)
        {
            String           key    = CacheKeys.UserViewOfPartialRepository(idCurrentPerson, identifier);
            ModuleRepository module = GetPermissions(identifier, idCurrentPerson);
            List <dtoDisplayRepositoryItem> rItems = lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <dtoDisplayRepositoryItem> >(key);

            if (rItems == null || !rItems.Any() || !useCache)
            {
                rItems = new List <dtoDisplayRepositoryItem>();
                List <dtoRepositoryItem> fItems = GetFullRepository(identifier, unknownUser, true);
                if (fItems == null)
                {
                    return(null);
                }

                List <dtoDisplayRepositoryItem> items = GetRepositoryItemsWithPermissions(settings, UC.CurrentUserID, identifier, fItems, module, module.Administration || module.ManageItems, module.Administration || module.ManageItems, false, false);
                if (items != null)
                {
                    rItems.AddRange(items);
                }
                if (useCache && rItems.Any())
                {
                    CacheHelper.AddToCache <List <dtoDisplayRepositoryItem> >(key, rItems, CacheExpiration._5minutes);
                }
            }
            return(GetItemsWithPermissions(idItems, rItems, settings, idCurrentPerson, module));
        }
Exemplo n.º 2
0
        private static T CreateChannel <T>() where T : class
        {
            string key = typeof(T).FullName;
            ServiceEndpointEntity fromCache = CacheHelper.GetFromCache <ServiceEndpointEntity>(key);


            if (fromCache == null)
            {
                Configuration configuration = null;


                configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                ServiceModelSectionGroup smsg = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");

                fromCache = GetEndpointEntity <T>(smsg);
                if (fromCache == null)
                {
                    throw new Exception("Invalid type" + typeof(T));
                }

                SetBindingParam(fromCache.ChannelBinding, smsg);
            }

            CacheHelper.AddToCache(key, fromCache);

            return(CreateChanel <T>(fromCache));
        }
Exemplo n.º 3
0
            public void Fill(ReportHelper.TableReport report)
            {
                var o        = (BlockModelCompareViewModel)_r;
                var cacheKey = o.ToJson().ComputeHash();

                report.DataSource = CacheHelper.AddToCache <DataSet>(() => { return(_r.ReportResult(o)); }, cacheKey);
                report.Parameters["ParameterModel1Name"].Value            = o.Model1Name;
                report.Parameters["ParameterModel2Name"].Value            = o.Model2Name;
                report.Parameters["ParameterGradeTonnageFieldName"].Value = o.GradeTonnageFieldName;
                report.Parameters["ParameterUserName"].Value = o.ReportExecutedByUserName;
            }
Exemplo n.º 4
0
        protected List <dtoRepositoryItem> GetFullRepository(RepositoryIdentifier identifier, String unknownUser, Boolean useCache = true)
        {
            String key = CacheKeys.Repository(identifier);
            List <dtoRepositoryItem> items = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <dtoRepositoryItem> >(key) : null;

            if (items == null || !items.Any())
            {
                items = GetRepositoryTree(identifier, unknownUser);
                if (items != null && useCache)
                {
                    CacheHelper.AddToCache <List <dtoRepositoryItem> >(key, items, CacheExpiration.Week);
                }
            }
            return(items);
        }
Exemplo n.º 5
0
        public List <dtoCommunityTags> CacheGetUserCommunitiesAssociation(Int32 idUser, List <Int32> idCommunities, TagType type, Boolean useCache)
        {
            List <dtoCommunityTags> links = null;

            links = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <dtoCommunityTags> >(CacheKeys.UserCommunitiesTags(idUser, type)) : null;
            if (links == null || !links.Any())
            {
                links = GetUserCommunitiesAssociation(idCommunities, type);
                if (useCache)
                {
                    CacheHelper.AddToCache <List <dtoCommunityTags> >(CacheKeys.UserCommunitiesTags(idUser, type), links, CacheExpiration._12hours);
                }
            }
            return(links);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get all tags available
        /// </summary>
        /// <param name="type">type of tag to load</param>
        /// <param name="useCache">retrieve from cache or from DB</param>
        /// <returns></returns>
        public List <liteTagItem> CacheGetTags(TagType type, Boolean useCache)
        {
            List <liteTagItem> tags = null;

            tags = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <liteTagItem> >(CacheKeys.Tags(type)) : null;

            if (tags == null || !tags.Any())
            {
                tags = (from t in Manager.GetIQ <liteTagItem>() where t.Deleted == BaseStatusDeleted.None select t).ToList();
                Manager.DetachList(tags);
                if (useCache)
                {
                    CacheHelper.AddToCache <List <liteTagItem> >(CacheKeys.Tags(type), tags, CacheExpiration.Week);
                }
            }
            return(tags);
        }
Exemplo n.º 7
0
        /// <summary>
        ///  Get all available tiles for a dashboard
        /// </summary>
        /// <param name="idDashboard"></param>
        /// <param name="useCache"></param>
        /// <returns></returns>
        private List <liteDashboardTileAssignment> CacheGetDashBoardTiles(long idDashboard, Boolean useCache = true)
        {
            List <liteDashboardTileAssignment> tiles = null;

            tiles = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <liteDashboardTileAssignment> >(CacheKeys.DashboardTiles(idDashboard)) : null;
            if (tiles == null || !tiles.Any())
            {
                tiles = (from t in Manager.GetIQ <liteDashboardTileAssignment>()
                         where t.Deleted == BaseStatusDeleted.None && t.IdDashboard == idDashboard && t.Status == AvailableStatus.Available
                         select t).ToList().Where(t => t.Tile != null && t.Tile.Status == AvailableStatus.Available).OrderBy(t => t.Tile.Type).ThenBy(t => t.DisplayOrder).ToList();
                Manager.DetachList(tiles);
                if (useCache)
                {
                    CacheHelper.AddToCache <List <liteDashboardTileAssignment> >(CacheKeys.DashboardTiles(idDashboard), tiles, CacheExpiration.Day);
                }
            }
            return(tiles);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get all association between tag and communities
        /// </summary>
        /// <param name="useCache">retrieve from cache or from DB</param>
        /// <returns></returns>
        public List <liteCommunityTag> CacheGetCommunityAssociation(Boolean useCache)
        {
            List <liteCommunityTag> links = null;

            links = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <liteCommunityTag> >(CacheKeys.AllCommunityTags) : null;

            if (links == null || !links.Any())
            {
                links = (from t in Manager.GetIQ <liteCommunityTag>()
                         where t.Deleted == BaseStatusDeleted.None && t.Tag != null && t.Tag.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available
                         select t).ToList();
                Manager.DetachList(links);
                if (useCache)
                {
                    CacheHelper.AddToCache <List <liteCommunityTag> >(CacheKeys.AllCommunityTags, links, CacheExpiration.Day);
                }
            }
            return(links);
        }
Exemplo n.º 9
0
        private List <liteDashboardSettings> LoadingSettingsGetForAllCommunity(Boolean useCache = true)
        {
            List <liteDashboardSettings> settings = null;

            settings = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <liteDashboardSettings> >(CacheKeys.Dashboard(DashboardType.AllCommunities)) : null;

            if (settings == null || !settings.Any())
            {
                settings = (from t in Manager.GetIQ <liteDashboardSettings>() where t.Deleted == BaseStatusDeleted.None && t.Active && t.Type == DashboardType.AllCommunities select t).ToList();
                if (settings != null && settings.Any())
                {
                    Manager.DetachList(settings);
                }
                if (settings != null && useCache)
                {
                    CacheHelper.AddToCache <List <liteDashboardSettings> >(CacheKeys.Dashboard(DashboardType.AllCommunities), settings, CacheExpiration.Week);
                }
            }
            return(settings);
        }
Exemplo n.º 10
0
        public List <liteDashboardSettings> LoadingSettingsGetAll(DashboardType type, Int32 idCommunity, Boolean useCache = true)
        {
            List <liteDashboardSettings> settings = null;
            String cacheKey = "";

            switch (type)
            {
            case DashboardType.AllCommunities:
            case DashboardType.Portal:
                cacheKey = CacheKeys.Dashboard(type);
                break;

            case DashboardType.Community:
                settings = LoadingSettingsGetForCommunity(idCommunity, useCache);
                if (settings == null)
                {
                    cacheKey = CacheKeys.Dashboard(DashboardType.AllCommunities);
                }
                break;
            }
            if (type != DashboardType.Community || settings == null)
            {
                settings = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <liteDashboardSettings> >(cacheKey) : null;
            }

            if (settings == null || !settings.Any())
            {
                settings = (from t in Manager.GetIQ <liteDashboardSettings>() where t.Active && t.Deleted == BaseStatusDeleted.None select t).ToList();
                if (settings != null && settings.Any())
                {
                    Manager.DetachList(settings);
                }

                if (settings != null && useCache)
                {
                    CacheHelper.AddToCache <List <liteDashboardSettings> >(cacheKey, settings, CacheExpiration.Week);
                }
            }
            return(settings);
        }
Exemplo n.º 11
0
        public List <dtoFolderSize> GetRepositoryAvailabilityInfo(String filePath, liteRepositorySettings settings, Int32 idCurrentUser, RepositoryType type, Int32 idCommunity, ModuleRepository permissions, List <dtoDisplayRepositoryItem> treeItems, Boolean useCache = true)
        {
            String key = CacheKeys.UserSizeOfRepository(idCurrentUser, type, idCommunity);
            List <dtoFolderSize> fItems = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <dtoFolderSize> >(key) : null;

            if (fItems == null || !fItems.Any())
            {
                fItems = new List <dtoFolderSize>();
                List <liteRepositoryItem> items = GetQuery(type, idCommunity).ToList();
                fItems.Add(GetRepositoryAvailabilityInfo(filePath, (settings != null && settings.DiskSpace != null) ? settings.DiskSpace : null, items, GetAllItems(treeItems.AsQueryable(), i => (i.Type != ItemType.Folder || i.FolderType == FolderType.standard))));

                foreach (dtoDisplayRepositoryItem folder in treeItems.Where(f => f.Type == ItemType.Folder))
                {
                    fItems.AddRange(GetFolderAvailabilityInfo(fItems[0], fItems[0], folder, items));
                }
                if (fItems != null)
                {
                    CacheHelper.AddToCache <List <dtoFolderSize> >(key, fItems, CacheExpiration.Day);
                }
            }
            return(fItems);
        }
Exemplo n.º 12
0
        public liteDashboardSettings DashboardSettingsGet(DashboardType type, Int32 idCommunity = -1, Boolean useCache = true)
        {
            liteDashboardSettings settings = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <liteDashboardSettings>(CacheKeys.CurrentDashboardSettings(UC.CurrentUserID, idCommunity)) : null;

            if (settings == null)
            {
                litePerson p = Manager.Get <litePerson>(UC.CurrentUserID);
                if (p != null)
                {
                    switch (type)
                    {
                    case DashboardType.Portal:
                        settings = GetPortalSettings(p, useCache);
                        if (settings != null && useCache)
                        {
                            CacheHelper.AddToCache <liteDashboardSettings>(CacheKeys.CurrentDashboardSettings(p.Id, 0), (liteDashboardSettings)settings.Clone(), CacheExpiration.Week);
                        }
                        break;

                    case DashboardType.Community:
                        settings = GetCommunitySettings(p, idCommunity, useCache);
                        if (settings != null && useCache)
                        {
                            CacheHelper.AddToCache <liteDashboardSettings>(CacheKeys.CurrentDashboardSettings(p.Id, idCommunity), (liteDashboardSettings)settings.Clone(), CacheExpiration.Week);
                        }
                        break;

                    case DashboardType.AllCommunities:
                        settings = GetCommonCommunitySettings(p, useCache);
                        if (settings != null && useCache)
                        {
                            CacheHelper.AddToCache <liteDashboardSettings>(CacheKeys.CurrentDashboardSettings(p.Id, -1), (liteDashboardSettings)settings.Clone(), CacheExpiration.Week);
                        }
                        break;
                    }
                }
            }
            return(settings);
        }
Exemplo n.º 13
0
            public void Fill(ReportHelper.TableReport report)
            {
                var o        = (AssayReportViewModel)_r;
                var cacheKey = string.Format("{0}-{1}", o.ProjectID, o.ReportName);
                var ds       = CacheHelper.AddToCache <DataSet>(() => { return(_r.ReportResult(o)); }, cacheKey, CacheHelper.DefaultTimeout);

                report.DataSource = ds;
                report.Parameters["ParameterProjectID"].Value = o.ProjectID;
                report.Parameters["ParameterUserName"].Value  = o.ReportExecutedByUserName;

                var tr1 = new XRTableRow {
                    Name = "tr1"
                };

                tr1.Cells.AddRange((from k in ds.Tables[0].Columns.Cast <DataColumn>() select new XRTableCell {
                    Name = k.ColumnName, Text = k.ColumnName
                }).ToArray());
                var h = new XRTable {
                    Name = "h", LocationF = new DevExpress.Utils.PointFloat(0F, 0F), SizeF = new System.Drawing.SizeF(600.0000F, 25F), KeepTogether = true
                };

                h.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { tr1 });
                report.Bands["Detail"].Controls.Add(h);

                var tr2 = new XRTableRow {
                    Name = "tr2"
                };

                tr2.Cells.AddRange((from k in ds.Tables[0].Columns.Cast <DataColumn>() select new XRTableCell {
                    Name = string.Format("{0}_data", k.ColumnName), Text = string.Format("[{0}]", k.ColumnName)
                }).ToArray());
                var t = new XRTable {
                    Name = "t", LocationF = new DevExpress.Utils.PointFloat(0F, 0F), SizeF = new System.Drawing.SizeF(600.0000F, 25F), KeepTogether = true
                };

                t.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { tr2 });
                ((DetailReportBand)report.Bands["DetailReport"]).Bands["DetailBand"].Controls.Add(t);
            }
Exemplo n.º 14
0
        public List <dtoDisplayRepositoryItem> GetAvailableRepositoryItems(
            liteRepositorySettings settings,
            Int32 idCurrentPerson,
            RepositoryIdentifier identifier,
            String unknownUser,
            Dictionary <FolderType, String> fTranslations,
            Dictionary <ItemType, String> iTranslations,
            ModuleRepository permissions,
            Boolean forAdmin   = false,
            Boolean alsoHidden = false,
            Boolean onlyFolder = false,
            Boolean useCache   = true)
        {
            String key = CacheKeys.UserViewOfRepository(idCurrentPerson, identifier, onlyFolder);
            List <dtoDisplayRepositoryItem> results = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <dtoDisplayRepositoryItem> >(key) : null;

            if (results == null || !results.Any())
            {
                results = new List <dtoDisplayRepositoryItem>();
                List <dtoRepositoryItem> fItems = GetFullRepository(identifier, unknownUser, useCache);
                if (fItems == null)
                {
                    return(null);
                }
                List <dtoDisplayRepositoryItem> items = GetRepositoryItemsWithPermissions(settings, UC.CurrentUserID, identifier, fItems, permissions, forAdmin, alsoHidden, onlyFolder, useCache);
                results.AddRange(items);
                if (permissions.Administration || permissions.ManageItems || permissions.DeleteMyFiles)
                {
                    results.Add(GetRecycleBinFolder(fTranslations[FolderType.recycleBin], items));
                }

                if (results != null && useCache)
                {
                    CacheHelper.AddToCache <List <dtoDisplayRepositoryItem> >(key, results, CacheExpiration.Day);
                }
            }
            return(results);
        }
Exemplo n.º 15
0
        private liteUserDashboardSettings UserDashboardSettingsGet(Int32 idUser, Boolean useCache = true, Int32 idCommunity = -1, liteDashboardSettings settings = null)
        {
            liteUserDashboardSettings userSettings = null;

            userSettings = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <liteUserDashboardSettings>(CacheKeys.UserSettings(idUser, idCommunity)) : null;

            if (userSettings == null)
            {
                userSettings = (from t in Manager.GetIQ <liteUserDashboardSettings>() where t.Deleted == BaseStatusDeleted.None && t.IdPerson == idUser && t.IdCommunity == idCommunity select t).Skip(0).Take(1).FirstOrDefault();
                if (userSettings == null && idCommunity > 0)
                {
                    userSettings = (from t in Manager.GetIQ <liteUserDashboardSettings>() where t.Deleted == BaseStatusDeleted.None && t.IdPerson == idUser && t.IdCommunity == -1 select t).Skip(0).Take(1).FirstOrDefault();
                }
                if (userSettings != null)
                {
                    Manager.Detach(userSettings);
                }
                if (userSettings != null && useCache)
                {
                    CacheHelper.AddToCache <liteUserDashboardSettings>(CacheKeys.UserSettings(idUser, idCommunity), userSettings, CacheExpiration.Week);
                }
            }
            return(userSettings);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Get all available tiles for user and dashboard
        /// </summary>
        /// <param name="idUser"></param>
        /// <param name="idDashboard"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public List <dtoLiteTile> TilesGetForUser(Int32 idUser, long idDashboard, TileType type, Boolean useCache = true)
        {
            List <dtoLiteTile> results = null;

            try
            {
                results = (useCache) ? lm.Comol.Core.DomainModel.Helpers.CacheHelper.Find <List <dtoLiteTile> >(CacheKeys.DashboardUserTiles(idDashboard, idUser, type)) : null;
                if (results == null || !results.Any())
                {
                    List <liteDashboardTileAssignment> tAssignments = CacheGetDashBoardTiles(idDashboard);
                    List <dtoLiteTile> aTiles = null;
                    switch (type)
                    {
                    case TileType.CombinedTags:
                        aTiles = tAssignments.Where(t => t.Tile != null && (t.Tile.Type == TileType.CommunityTag || t.Tile.Type == TileType.CombinedTags || t.Tile.Type == TileType.DashboardUserDefined)).Select(t => new dtoLiteTile()
                        {
                            DisplayOrder = t.DisplayOrder, Tile = t.Tile
                        }).ToList();
                        break;

                    case TileType.CommunityTag:
                        aTiles = tAssignments.Where(t => t.Tile != null && t.Tile.Type == TileType.CommunityTag).Select(t => new dtoLiteTile()
                        {
                            DisplayOrder = t.DisplayOrder, Tile = t.Tile
                        }).ToList();
                        break;

                    case TileType.Module:
                        aTiles = tAssignments.Where(t => t.Tile != null && (t.Tile.Type == TileType.Module || t.Tile.Type == TileType.UserDefined)).Select(t => new dtoLiteTile()
                        {
                            DisplayOrder = t.DisplayOrder, Tile = t.Tile
                        }).ToList();
                        break;

                    default:
                        aTiles = tAssignments.Where(t => t.Tile != null && t.Tile.Type == type).Select(t => new dtoLiteTile()
                        {
                            DisplayOrder = t.DisplayOrder, Tile = t.Tile
                        }).ToList();
                        break;
                    }
                    if (aTiles != null)
                    {
                        switch (type)
                        {
                        case TileType.Module:
                            break;

                        default:
                            List <lm.Comol.Core.Tag.Domain.dtoCommunityTags> tLinks = null;
                            switch (type)
                            {
                            case TileType.CommunityType:
                                List <Int32> idTypes = (from s in Manager.GetIQ <liteSubscriptionInfo>() where s.IdPerson == idUser && s.IdRole > -1 select s.Community.IdTypeOfCommunity).Distinct().ToList();

                                results = aTiles.Where(a => a.HasAnyCommunityType(idTypes)).ToList();

                                break;

                            case TileType.CommunityTag:
                            case TileType.CombinedTags:
                                List <Int32> idCommunities = (from s in Manager.GetIQ <liteSubscriptionInfo>() where s.IdPerson == idUser && s.IdRole > -1 select s.IdCommunity).ToList();
                                tLinks = Service.CacheGetUserCommunitiesAssociation(idUser, idCommunities, (type == TileType.Module) ? Tag.Domain.TagType.Module : Tag.Domain.TagType.Community, true);
                                if (idCommunities.Except(tLinks.Select(t => t.IdCommunity).ToList()).Any())
                                {
                                    tLinks = Service.CacheGetUserCommunitiesAssociation(idUser, idCommunities, (type == TileType.Module) ? Tag.Domain.TagType.Module : Tag.Domain.TagType.Community, false);
                                }
                                results = aTiles.Where(a => a.Tile.Type == TileType.CommunityTag && a.Tile.GetAvailableIdTags().Count == 1 && tLinks.Where(l => l.HasTag(a.Tile.GetAvailableIdTags().FirstOrDefault())).Any()).ToList();
                                if (type == TileType.CombinedTags)
                                {
                                    results.AddRange(aTiles.Where(a => a.Tile.Type == TileType.CombinedTags && a.Tile.GetAvailableIdTags().Count > 1 && tLinks.Where(l => l.HasTags(a.Tile.GetAvailableIdTags())).Any()).ToList());
                                    results.AddRange(aTiles.Where(a => a.Tile.Type == TileType.DashboardUserDefined && a.Tile.NavigateUrl != "").ToList());
                                }
                                break;
                            }
                            break;
                        }
                        results = results.OrderBy(i => i.DisplayOrder).ToList();
                        if (useCache)
                        {
                            CacheHelper.AddToCache <List <dtoLiteTile> >(CacheKeys.DashboardUserTiles(idDashboard, idUser, type), results, CacheExpiration._12hours);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(results);
        }