Ejemplo n.º 1
0
 /// <summary>
 /// Constructs a <b>PublishException</b> for the given MvcRequest 
 /// and PublishRecord, with the specified message.
 /// </summary>
 /// <param name="request">The <b>MvcRequest</b> in which the exception occurred.</param>
 /// <param name="publishRecord">The <b>PublishRecord</b> in use at the time 
 ///			the exception occurred.</param>
 /// <param name="message">The error message to return.</param>
 public PublishException(
     MvcRequest request,
     PublishRecord publishRecord,
     string message)
     : base(message)
 {
     this.request = request;
     this.publishRecord = publishRecord;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a <b>PublishException</b> for the given TransitionContext 
 /// and PublishRecord, with the specified message.
 /// </summary>
 /// <param name="context">The <b>TransitionContext</b> in which the exception occurred.</param>
 /// <param name="publishRecord">The <b>PublishRecord</b> in use at the time 
 ///			the exception occurred.</param>
 /// <param name="message">The error message to return.</param>
 public PublishException(
     TransitionContext context,
     PublishRecord publishRecord,
     string message)
     : base(message)
 {
     this.context = context;
     this.publishRecord = publishRecord;
 }
        /// <summary>
        /// Constructs a <b>PublishedPageCollection</b> from the given data in XML
        /// format.
        /// </summary>
        /// <remarks>
        /// The format of the pagesXml parameter is:
        /// <pre>
        ///		<PublishedPages>
        ///			<Page startState="" publishedState="" key="" event="" path="" lastPublished="" />
        ///			...
        ///		</PublishedPages>
        /// </pre>
        /// </remarks>
        /// <param name="pagesXml">The <b>XmlDocument</b> containing the data to
        ///			populate the new <b>PublishedPageCollection</b> with.</param>
        public PublishedPageCollection(
            XmlDocument pagesXml)
        {
            if ((pagesXml != null) && (pagesXml.DocumentElement != null)) {
                XmlNodeList pages = pagesXml.DocumentElement.SelectNodes("Page");
                foreach (XmlNode pg in pages) {
                    long startState = long.Parse(pg.Attributes["startState"].Value);
                    long publishedState = long.Parse(pg.Attributes["publishedState"].Value);
                    string key = pg.Attributes["key"].Value;
                    string evnt = pg.Attributes["event"].Value;
                    string path = pg.Attributes["path"].Value;
                    string publisher = pg.Attributes["publisher"].Value;
                    int hits = int.Parse(pg.Attributes["hits"].Value);
                    DateTime? publishTime = DateTime.Parse(pg.Attributes["lastPublished"].Value);

                    PublishRecord pageRec = new PublishRecord(
                            key, startState, evnt, publishedState, path, publishTime, publisher);
                    pageRec.HitCount = hits;

                    Add(key, pageRec);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the <c>PublishRecord</c> for the target page of the given
        /// context.
        /// </summary>		
        /// <param name="key"></param>
        /// <param name="context">The <c>TransitionContext</c> to get the <c>PublishRecord</c> for.</param>
        /// <param name="publisher">The <c>ContentPublisher</c></param>
        /// <param name="addIfNotPresent">If <b>true</b> adds a new <b>PublishRecord</b> 
        ///		to the internal collection for the given context.</param>
        /// <returns>The <c>PublishRecord</c> for the target page of the given context.</returns>
        internal PublishRecord GetPublishRecord(
            string key,
            TransitionContext context,
            IContentPublisher publisher,
            bool addIfNotPresent)
        {
            PublishRecord pubRec = this.publishedPages[key];

            if ((pubRec == null) && addIfNotPresent) {
                pubRec = new PublishRecord(key,
                        context.StartState.Id,
                        context.StartEvent,
                        context.EndState.Id,
                        null,
                        null,
                        publisher.Name);
                this.publishedPages.Add(key, pubRec);
            }

            return pubRec;
        }
        /// <summary>
        /// Determines if the published content referenced by the given PublishRecord is expired.
        /// </summary>
        /// <param name="publishRecord">The PublishRecord to determine the expiration of.</param>
        /// <returns><b>True</b> if the given PublishRecord is expired, <b>false</b> if not.</returns>
        public virtual bool IsExpired(
            PublishRecord publishRecord)
        {
            #if (PUBLISH_TRACE)
            string msg = "Checking " + publishRecord.Key;
            if (publishRecord.LastPublished.HasValue) {
            msg += string.Format(" LastPublished: {0}, pageExpireTime: {1}, expired = {2}.",
                    publishRecord.LastPublished.Value, pageExpireTime, (publishRecord.LastPublished.Value.AddMinutes(pageExpireTime) < DateTime.Now));
            } else {
            msg += " - no LastPublished time.";
            }
            LogManager.GetCurrentClassLogger().Debug(msg);
            #endif

            return (!publishRecord.LastPublished.HasValue
                || (publishRecord.LastPublished.Value.AddMinutes(pageExpireTime) < DateTime.Now));
        }
 /// <summary>
 /// Adds the given <b>PublishRecord</b> to the collection with the specified
 /// key.
 /// </summary>
 /// <param name="key">The key to add the <b>PublishRecord</b> under.</param>
 /// <param name="pubRec">The <b>PublishRecord</b> to add to the collection.</param>
 internal void Add(
     string key,
     PublishRecord pubRec)
 {
     if (!pageHash.ContainsKey(key)) {
         pageHash.Add(key, pubRec);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Determines if the published content for the given <b>PublishRecord</b> is expired.
 /// </summary>
 /// <param name="publishRecord">The <b>PublishRecord</b> to check the expiration for.</param>
 /// <returns><b>True</b> if the content is expired, <b>false</b> if not.</returns>
 public virtual bool IsExpired(
     PublishRecord publishRecord)
 {
     return this.contentPublisher.IsExpired(publishRecord);
 }