Exemplo n.º 1
0
        public static ThematicApplicationCached FromId(IfyContext context, int id)
        {
            var app = new ThematicApplicationCached(context);

            app.Id = id;
            app.Load();
            return(app);
        }
Exemplo n.º 2
0
        public static ThematicApplicationCached FromUidAndIndex(IfyContext context, string identifier, string index)
        {
            var app = new ThematicApplicationCached(context);

            app.UId   = identifier;
            app.Index = index;
            app.Load();
            return(app);
        }
Exemplo n.º 3
0
        public static ThematicApplicationCached FromUidAndDomain(IfyContext context, string identifier, int domainid)
        {
            var app = new ThematicApplicationCached(context);

            app.UId      = identifier;
            app.DomainId = domainid;
            app.Load();
            return(app);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Synchronize WPS services
        /// </summary>
        /// <param name="context"></param>
        /// <param name="appcached"></param>
        public static void SyncWpsServices(IfyContext context, ThematicApplicationCached appcached)
        {
            context.LogDebug(context, string.Format("Sync WPS app : {0}/{1}", appcached.Index, appcached.UId));

            //get app self url
            var feed  = ThematicAppCachedFactory.GetOwsContextAtomFeed(appcached.TextFeed);
            var entry = feed.Items.First();

            SyncWpsServices(context, entry);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates or update the cached app
        /// </summary>
        /// <returns>The or update.</returns>
        /// <param name="entry">Entry.</param>
        /// <param name="domainid">Domainid.</param>
        public ThematicApplicationCached CreateOrUpdateCachedApp(OwsContextAtomEntry entry, int domainid, string index = null)
        {
            var appCategory = entry.Categories.FirstOrDefault(l => l.Label == "App");

            if (appCategory == null)
            {
                return(null);
            }

            var identifier = GetIdentifierFromFeed(entry);
            var appcached  = new ThematicApplicationCached(context);

            appcached.UId = identifier;

            if (index != null)
            {
                appcached.Index = index;
            }
            else
            {
                appcached.DomainId = domainid;
            }

            try
            {
                appcached.Load();
            }
            catch (Exception) { }

            var feed = new OwsContextAtomFeed();

            feed.Items = new List <OwsContextAtomEntry> {
                entry
            };

            appcached.Index      = index;
            appcached.Feed       = feed;
            appcached.TextFeed   = System.Text.RegularExpressions.Regex.Replace(GetOwsContextAtomFeedAsString(feed), @"\p{Cs}", "");
            appcached.Searchable = System.Text.RegularExpressions.Regex.Replace(GetSearchableTextFromAtomEntry(entry), @"\p{Cs}", "");
            appcached.LastUpdate = entry.LastUpdatedTime.DateTime;
            if (appcached.DomainId == 0 && domainid > 0)
            {
                appcached.DomainId = domainid;
            }
            appcached.Store();

            return(appcached);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Refreshs the cached app.
        /// </summary>
        /// <param name="feed">Feed.</param>
        /// <param name="index">Index.</param>
        /// <param name="uid">Uid.</param>
        /// <param name="domainId">Domain identifier.</param>
        public void RefreshCachedApp(OwsContextAtomFeed feed, string index, string uid, int domainId)
        {
            var entry       = feed.Items.First <OwsContextAtomEntry>();
            var appCategory = entry.Categories.FirstOrDefault(l => l.Label == "App");

            if (appCategory == null)
            {
                return;
            }

            var appcached = new ThematicApplicationCached(context);

            appcached.UId = uid;

            if (index != null)
            {
                appcached.Index = index;
            }
            else
            {
                appcached.DomainId = domainId;
            }

            try
            {
                appcached.Load();
            }
            catch (Exception) { }

            appcached.Index      = index;
            appcached.Feed       = feed;
            appcached.TextFeed   = GetOwsContextAtomFeedAsString(feed);
            appcached.Searchable = GetSearchableTextFromAtomEntry(entry);
            appcached.LastUpdate = entry.LastUpdatedTime.DateTime == DateTime.MinValue ? DateTime.UtcNow : entry.LastUpdatedTime.DateTime;
            if (appcached.DomainId == 0 && domainId > 0)
            {
                appcached.DomainId = domainId;
            }
            appcached.Store();

            return;
        }