예제 #1
0
        /// <summary>
        ///     Returns instance of ObjectStore for a specific type name
        /// </summary>
        private static ObjectStore GetEventFromStore(string typeName)
        {
            Query q = ObjectStore.CreateQuery();

            q.AndWhere(ObjectStore.Columns.Name, typeName);
            q.AndWhere(ObjectStore.Columns.ContentType, "eventdetails/xml");
            return(ObjectStore.FetchByQuery(q));
        }
예제 #2
0
        public static void RemoveFeedData()
        {
            ObjectStoreCollection osc = new ObjectStoreCollection();
            Query q = ObjectStore.CreateQuery();

            q.AndWhere(ObjectStore.Columns.ContentType, "feed/xml");
            osc.LoadAndCloseReader(q.ExecuteReader());

            foreach (ObjectStore os in osc)
            {
                ObjectStore.Destroy(os.Id);
            }

            ZCache.RemoveCache("Feed-Objects");
        }
예제 #3
0
        /// <summary>
        /// Gets all the widgets from the ObjectStore (match ContentType = "xml/widget"
        /// </summary>
        /// <returns></returns>
        public static List <Widget> FetchAll()
        {
            List <Widget> the_Widgets = ZCache.Get <List <Widget> >(cacheKey);

            if (the_Widgets == null)
            {
                ObjectStoreCollection osc = new ObjectStoreCollection();
                Query oquery = ObjectStore.CreateQuery();
                oquery.AndWhere(ObjectStore.Columns.ContentType, "xml/widget");
                osc.LoadAndCloseReader(oquery.ExecuteReader());

                the_Widgets = new List <Widget>(osc.Count);
                foreach (ObjectStore os in osc)
                {
                    try
                    {
                        Widget widget = ObjectManager.ConvertToObject(os.Data, Type.GetType(os.Type)) as Widget;

                        if (widget != null)
                        {
                            the_Widgets.Add(widget);
                        }
                        else
                        {
                            Log.Warn("Widgets",
                                     "The widget of type {0} (Widget Id:{1}, ObjetStore id: {2}) could not be loaded. Please check with the widget developer for help",
                                     os.Type, os.Name, os.Id);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Widget",
                                  "An exception was raised invoking the following widget type {0}. Exception: {1} Details: {2}",
                                  os.Type, ex.Message, ex.StackTrace);
                    }
                }

                ZCache.InsertCache(cacheKey, the_Widgets, 120);
            }
            return(the_Widgets);
        }
예제 #4
0
        /// <summary>
        /// Deletes a widget.
        /// </summary>
        /// <param name="id"></param>
        public static void Delete(string id)
        {
            Query q = ObjectStore.CreateQuery();

            q.AndWhere(ObjectStore.Columns.Name, id);
            q.AndWhere(ObjectStore.Columns.ContentType, "xml/widget");
            ObjectStoreCollection osc = new ObjectStoreCollection();

            osc.LoadAndCloseReader(q.ExecuteReader());
            if (osc.Count > 1)
            {
                throw new Exception("More than one item matched id/name ");
            }
            else if (osc.Count > 0)
            {
                ObjectStore.Destroy(osc[0].Id);
            }


            Reset();
        }
예제 #5
0
        public static Dictionary <Guid, Feed> GetFeeds()
        {
            Dictionary <Guid, Feed> feeds = ZCache.Get <Dictionary <Guid, Feed> >("Feed-Objects");

            if (feeds == null)
            {
                feeds = new Dictionary <Guid, Feed>();
                ObjectStoreCollection osc = new ObjectStoreCollection();
                Query q = ObjectStore.CreateQuery();
                q.AndWhere(ObjectStore.Columns.ContentType, "feed/xml");
                osc.LoadAndCloseReader(q.ExecuteReader());

                foreach (ObjectStore os in osc)
                {
                    Feed feed = ObjectManager.ConvertToObject <Feed>(os.Data);
                    feeds.Add(feed.Id, feed);
                }

                ZCache.InsertCache("Feed-Objects", feeds, 300);
            }

            return(feeds);
        }