public static Feed AddFeed(Feed feed) { if (feed.Name == null) { throw new Exception("Must give the feed a name"); } if (feed.Id == Guid.Empty) { feed.Id = Guid.NewGuid(); } if (feed.RequestInterval == 0) { feed.RequestInterval = 60; } if (feed.Document == null) { feed.ReLoad(); } ObjectStore os = new ObjectStore(); os.UniqueId = feed.Id; os.Name = "Feed: " + feed.Name; os.Data = ObjectManager.ConvertToString(feed); os.ContentType = "feed/xml"; os.Type = typeof(Feed).FullName; os.Save(); ZCache.RemoveCache("Feed-Objects"); return(feed); }
/// <summary> /// Creates an empty Widget for the given type /// </summary> /// <param name="type"></param> /// <returns></returns> public static Widget Create(Type type) { Widget widget = Activator.CreateInstance(type) as Widget; widget.Id = Guid.NewGuid(); widget.Order = Widgets.FetchByLocation(WidgetLocation.Queue).Count + 1; // Get default values if any were configured. NameValueCollection defaultValues = widget.GetDefaults(); if (defaultValues != null && defaultValues.Count > 0) { widget.SetValues(HttpContext.Current, widget.GetDefaults()); } ObjectStore os = new ObjectStore(); os.ContentType = "xml/widget"; string the_Type = type.AssemblyQualifiedName; os.Type = the_Type.Substring(0, the_Type.IndexOf(", Version=")); os.Data = ObjectManager.ConvertToString(widget); os.Name = widget.Id.ToString(); os.UniqueId = widget.Id; os.Save(); Reset(); return(widget); }
public static Feed AddFeed(Feed feed) { if (feed.Name == null) throw new Exception("Must give the feed a name"); if (feed.Id == Guid.Empty) feed.Id = Guid.NewGuid(); if (feed.RequestInterval == 0) feed.RequestInterval = 60; if(feed.Document == null) feed.ReLoad(); ObjectStore os = new ObjectStore(); os.UniqueId = feed.Id; os.Name = "Feed: " + feed.Name; os.Data = ObjectManager.ConvertToString(feed); os.ContentType = "feed/xml"; os.Type = typeof (Feed).FullName; os.Save(); ZCache.RemoveCache("Feed-Objects"); return feed; }
/// <summary> /// Creates an empty Widget for the given type /// </summary> /// <param name="type"></param> /// <returns></returns> public static Widget Create(Type type) { Widget widget = Activator.CreateInstance(type) as Widget; widget.Id = Guid.NewGuid(); widget.Order = Widgets.FetchByLocation(WidgetLocation.Queue).Count + 1; // Get default values if any were configured. NameValueCollection defaultValues = widget.GetDefaults(); if (defaultValues != null && defaultValues.Count > 0) widget.SetValues(HttpContext.Current, widget.GetDefaults()); ObjectStore os = new ObjectStore(); os.ContentType = "xml/widget"; string the_Type = type.AssemblyQualifiedName; os.Type = the_Type.Substring(0, the_Type.IndexOf(", Version=")); os.Data = ObjectManager.ConvertToString(widget); os.Name = widget.Id.ToString(); os.UniqueId = widget.Id; os.Save(); Reset(); return widget; }
private static void Save(Widget widget, bool resetCache) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.Name, widget.Id.ToString()); os.Data = ObjectManager.ConvertToString(widget); os.Save(); if (resetCache) { Reset(); } }
private static void UpdateFeed(Feed feed, bool resetCache) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.UniqueId, feed.Id); os.Data = ObjectManager.ConvertToString(feed); os.Version++; os.Save(); if (resetCache) { ZCache.RemoveCache("Feed-Objects"); } }
/// <summary> /// Saves an EventDetails to the ObjectStore /// </summary> /// <param name="ed"></param> public static void Save(EventDetails ed) { ed.Xml = ObjectManager.ConvertToString(ed.Event); ObjectStore os = GetEventFromStore(ed.EventType); os.Name = ed.EventType; os.ContentType = "eventdetails/xml"; os.Data = ObjectManager.ConvertToString(ed); os.Type = ed.GetType().ToString(); os.Save(GraffitiUsers.Current.Name); ResetCache(); }
public static void Save(object objectToSave, string name) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.Name, name); os.Data = ConvertToString(objectToSave); if (!os.IsLoaded) { os.ContentType = "xml/serialization"; os.Name = name; os.Type = objectToSave.GetType().FullName; os.Version++; } os.Save(); ZCache.RemoveCache("object-" + name); ZCache.InsertCache("object-" + name, objectToSave, 120); }