//
        // GetImageFileName
        //
        // Will get the image file name representing the item
        //
        public static string GetImageFileName(int compiledTextFeedHash, Guid compiledTextFeedGuid, int compiledTextFeedItemHash, SlideShowImageSize imageSize, string templateDirectory, bool bypassCaches)
        {
            string fileName = ImageUtil.GetCompiledImageDirectory("TextFeed") + compiledTextFeedGuid.ToString() + "_" + compiledTextFeedItemHash.ToString() + "_" + ((int)imageSize).ToString() + ".jpg";

            if (!bypassCaches && MiscUtil.TTLFileExists(fileName, CompiledTextFeedItem.textFeedImageTTL))
            {
                return(fileName);
            }
            else
            {
                CompiledTextFeedItem compiledTextFeedItem = CompiledTextFeedItem.LoadForImage(compiledTextFeedItemHash, compiledTextFeedHash, compiledTextFeedGuid);

                Bitmap bitmap = compiledTextFeedItem.GenerateImage(fileName, imageSize, templateDirectory);

                return(fileName);
            }
        }
        //
        // Load
        //
        // Loads the object from the database, and if it doesn't exist, creates it
        static public CompiledTextFeedItem Load(int compiledTextFeedHash, Guid compiledTextFeedGuid, string title, string description, int compiledTextFeedItemHash)
        {
            CompiledTextFeedItem compiledTextFeedItem = new CompiledTextFeedItem();

            compiledTextFeedItem.compiledTextFeedHash = compiledTextFeedHash;
            compiledTextFeedItem.compiledTextFeedGuid = compiledTextFeedGuid;
            if ((title != null) || (description != null))
            {
                compiledTextFeedItem.compiledTextFeedItemHash = ((string)(title + description)).GetHashCode();
            }
            else
            {
                compiledTextFeedItem.compiledTextFeedItemHash = compiledTextFeedItemHash;
            }
            compiledTextFeedItem.compiledDate       = DateTime.Now;
            compiledTextFeedItem.imageGeneratedDate = DateTime.Now;

            using (PhotoMixQuery query = new PhotoMixQuery("SelectCompiledTextFeedItem"))
            {
                query.Parameters.Add("@CompiledTextFeedHash", SqlDbType.Int).Value = compiledTextFeedItem.compiledTextFeedHash;
                query.Parameters.Add("@CompiledTextFeedGuid", SqlDbType.UniqueIdentifier).Value = compiledTextFeedItem.compiledTextFeedGuid;
                query.Parameters.Add("@CompiledTextFeedItemHash", SqlDbType.Int).Value          = compiledTextFeedItem.compiledTextFeedItemHash;
                if ((title != null) || (description != null))
                {
                    query.Parameters.Add("@Title", SqlDbType.VarChar).Value         = String.IsNullOrEmpty(title) ? (Object)DBNull.Value : (Object)title;
                    query.Parameters.Add("@Description", SqlDbType.Text).Value      = String.IsNullOrEmpty(description) ? (Object)DBNull.Value : (Object)description;
                    query.Parameters.Add("@CompiledDate", SqlDbType.DateTime).Value = compiledTextFeedItem.compiledDate;
                }
                else
                {
                    query.Parameters.Add("@ImageGeneratedDate", SqlDbType.DateTime).Value = compiledTextFeedItem.imageGeneratedDate;
                }

                if (query.Reader.Read())
                {
                    compiledTextFeedItem.title              = query.Reader.IsDBNull(0) ? null : query.Reader.GetString(0);
                    compiledTextFeedItem.description        = query.Reader.IsDBNull(1) ? null : query.Reader.GetString(1);
                    compiledTextFeedItem.compiledDate       = query.Reader.IsDBNull(2) ? DateTime.MinValue : query.Reader.GetDateTime(2);
                    compiledTextFeedItem.imageGeneratedDate = query.Reader.IsDBNull(3) ? DateTime.MinValue : query.Reader.GetDateTime(3);
                }
            }

            return(compiledTextFeedItem);
        }
Exemplo n.º 3
0
        public override SlideShowItem CreateSlideShowItem(Hashtable compileCache, DateTime dateContext, bool bypassCaches)
        {
            RssChannel rssFeedChannel = (RssChannel)this.Channel;

            CompiledTextFeed compiledTextFeed;

            if (compileCache[rssFeedChannel.ChannelGuid] != null)
            {
                compiledTextFeed = (CompiledTextFeed)compileCache[rssFeedChannel.ChannelGuid];
            }
            else
            {
                compiledTextFeed = CompiledTextFeed.LoadForCompile(rssFeedChannel.RssFeedUrl, rssFeedChannel.ChannelImageUrl, rssFeedChannel.ChannelTitle, rssFeedChannel.RenderAd);
                compileCache[rssFeedChannel.ChannelGuid] = compiledTextFeed;
            }

            CompiledTextFeedItem compiledTextFeedItem;

            if (compileCache[rssFeedChannel.ChannelGuid + this.title + this.description] != null)
            {
                compiledTextFeedItem = (CompiledTextFeedItem)compileCache[rssFeedChannel.ChannelGuid + this.title + this.description];
            }
            else
            {
                compiledTextFeedItem = CompiledTextFeedItem.LoadForCompile(compiledTextFeed.CompiledTextFeedHash, compiledTextFeed.CompiledTextFeedGuid, this.title, this.description);
                compileCache[rssFeedChannel.ChannelGuid + this.title + this.description] = compiledTextFeedItem;
            }

            string url = Config.GetSetting("CompiledImageBaseUrl") + "textfeeditem.ashx?" +
                         "ch=" + compiledTextFeed.CompiledTextFeedHash +
                         "&cid=" + compiledTextFeed.CompiledTextFeedGuid +
                         "&tih=" + compiledTextFeedItem.CompiledTextFeedItemHash +
                         (bypassCaches ? "&bc=1" : "") +
                         "&<SIZE>";

            return(new SlideShowItem(this.ExpDate, this.PubDate, this.Channel.Name, url, true));
        }