public SchemaComponentsCacheDependency(int pollTime, string[] schemaUris) { timer = new Timer( new TimerCallback(CheckDependencyCallback), this, 0, pollTime); SchemaUris = schemaUris; IComponentFactory componentFactory = new ComponentFactory(); LastPublishDate = DateTime.Now; // TODO: get real last publish date (see line below) // LastPublishDate = componentFactory.LastPublished(schemaUris); }
private void CheckDependencyCallback(object sender) { IComponentFactory componentFactory = new ComponentFactory(); DateTime lastPublishedDate = DateTime.Now; // TODO: get real last publish date (see line below) // DateTime lastPublishedDate = componentFactory.LastPublished(SchemaUris); if (lastPublishedDate > LastPublishDate) { base.NotifyDependencyChanged(this, EventArgs.Empty); timer.Dispose(); } }
internal static IComponentFactory GetComponentFactory(Localization localization) { lock (_componentFactories) { IComponentFactory componentFactory; if (!_componentFactories.TryGetValue(localization.LocalizationId, out componentFactory)) { componentFactory = new ComponentFactory() { PublicationResolver = new PublicationResolver(localization) }; _componentFactories.Add(localization.LocalizationId, componentFactory); } return componentFactory; } }
internal static IComponentFactory GetComponentFactory(Localization localization) { lock (_componentFactories) { IComponentFactory componentFactory; if (!_componentFactories.TryGetValue(localization.LocalizationId, out componentFactory)) { IPublicationResolver publicationResolver = new PublicationResolver(localization); IFactoryCommonServices factoryCommonServices = new FactoryCommonServices(publicationResolver, _logger, _config, CreateCacheAgent()); componentFactory = new ComponentFactory( GetComponentPresentationFactory(localization), factoryCommonServices ); _componentFactories.Add(localization.LocalizationId, componentFactory); } return componentFactory; } }
protected List<Component> ParseUniverse(string extendedPropertyList) { this._logger.Debug("DD4TComponents > ParseUniverse >>>>>>>>"); this._logger.DebugFormat("extendedPropertyList = {0}", new object[] { extendedPropertyList }); List<Component> list = new List<Component>(); XmlDocument document = null; try { int num = this.Universe.itemssection.items.Count<item>(); } catch { return list; } this._logger.DebugFormat("Universe.itemssection.items.Count() = {0}", new object[] { this.Universe.itemssection.items.Count<item>() }); var provider = new DD4T.Providers.WCFServices.TridionComponentProvider(); foreach (item item in this.Universe.itemssection.items) { this._logger.InfoFormat("item = {0}", new object[] { item.id }); // fetch component content XML from DD4T component factory string componentUri; string templateUri; if(DD4TComponents.TryGetTcmUrisFromSecondId(item.id, out componentUri, out templateUri)) { this._logger.DebugFormat("Split secondid {0} into component ID {1} and template ID {2}", new object[] { item.id, componentUri, templateUri }); string xml = provider.GetContent(componentUri); if (!string.IsNullOrWhiteSpace(xml) && !string.IsNullOrEmpty(extendedPropertyList)) { try { document = new XmlDocument(); document.LoadXml(xml); // -------------------------------------------------------- // An example XML snippet of what we are trying to achieve // -------------------------------------------------------- // <item> // <key> // <string>[propName]</string> // </key> // <value> // <Field XPath="[propName]???" FieldType="Text"> // <Name>[propName]</Name> // <Values> // <string>abc</string> // <string>def</string> // <string>ghi</string> // </Values> // <NumericValues/> // <DateTimeValues/> // <LinkedComponentValues/> // <EmbeddedValues/> // <Keywords/> // </Field> // </value> // </item> // -------------------------------------------------------- // Loop through the extended ptrpoerty attribute list foreach (string propName in extendedPropertyList.Split(',')) { // Start to build the XML snippet (I'm cheating and using a StringBuilder!) StringBuilder sb = new StringBuilder(); sb.Append("<key><string>"); sb.Append(propName); sb.Append("</string></key><value><Field XPath=\""); sb.Append(propName); sb.Append("\" FieldType=\"Text\"><Name>"); sb.Append(propName); sb.Append("</Name><Values>"); // Try and find the actual attribute in the FredHopper item var attr = item.attribute.SingleOrDefault(a => a.name == propName); if (attr != null) { if (attr.value != null) { // Could be an array of values, so loop through foreach (var valueItem in attr.value) { // Belt and braces check to make sure this object isnt null if (valueItem != null) { // Double-check value if (!String.IsNullOrEmpty(valueItem.Value)) { sb.Append("<string>"); sb.Append(valueItem.Value); sb.Append("</string>"); } } } } } // Finally, close off the XML snippet sb.Append("</Values><NumericValues/><DateTimeValues/><LinkedComponentValues/><EmbeddedValues/><Keywords/></Field></value>"); // Create a new XML Node to import the XML snippet XmlNode xmlItem = document.CreateElement("item"); xmlItem.InnerXml = sb.ToString(); // Navigate to the relevant instertion point XmlNode fields = document.SelectSingleNode("/Component/Fields"); // Now insert the new node into the overall DD4T component XML fields.AppendChild(xmlItem); } xml = document.OuterXml; this._logger.DebugFormat("Final component Xml: {0}", new object[] { xml }); } catch (Exception exception) { this._logger.Error("Error adding extended details", exception); } } try { ComponentFactory factory = new ComponentFactory(); Component iComponentObject = (Component)factory.GetIComponentObject(xml); list.Add(iComponentObject); } catch (Exception exception2) { this._logger.Error("Error getting DD4T component", exception2); } } } return list; }