Ejemplo n.º 1
0
        /// <summary>
        /// Write 'it' to document XML.
        /// </summary>
        /// <param name="iterDoc">XML document</param>
        /// <param name="iterArticles">XML articles node </param>        
        /// <param name="it">Node info</param>
        /// <param name="sourcePath">Resource source directory</param>
        /// <param name="documentPath">Resource target directory</param>
        /// <param name="documentPath"
        private void CreateOutputArticleToonDocToXml(XmlDocument iterDoc, XmlElement iterArticles, ToonDirInfo it, string sourcePath, string documentPath) {
            if (log.IsDebugEnabled) log.Debug("CreateOutputArticleToonDocToXml start");
            XmlElement iterArticle = iterDoc.CreateElement("article");
            XmlElement iterArticleMetadata = iterDoc.CreateElement("metadata");
            XmlElement iterArticleContent = iterDoc.CreateElement("content");
            DateTime toonDateToUse;

            if (it.UseComputedCreateDate == 1) {
                toonDateToUse = it.ComputedCreatedDate;
            }
            else {
                toonDateToUse = it.CreateDate;
            }

            string dtStr = String.Format("{0:dd/MM/yyyy}", toonDateToUse);
            string title = "Caricatura " + dtStr;
            string urlTitle = "Caricatura_" + dtStr;
            string legacyUrl = "";

            urlTitle = urlTitle.Replace('/', '_').ToLower().ToString();
            legacyUrl = "/Bancomedios/Imagenes/caricaturas2/" + it.FileName;

            XmlElement properties = iterDoc.CreateElement("properties");
            properties.SetAttribute("indexable", "1");
            properties.SetAttribute("urltitle", urlTitle);
            properties.SetAttribute("legacyurl", legacyUrl);
            properties.SetAttribute("title", title);
            properties.SetAttribute("createdate", String.Format("{0:yyyy/MM/dd HH:mm:ss}", toonDateToUse));
            properties.SetAttribute("modifieddate", String.Format("{0:yyyy/MM/dd HH:mm:ss}", toonDateToUse));
            iterArticleMetadata.AppendChild(properties);

            iterArticle.AppendChild(iterArticleMetadata);
            iterArticle.AppendChild(iterArticleContent);
            iterArticle.SetAttribute("articleid", it.IdArticle);

            string filter = "";
            filter = GlobalConstants.ARTICLE_HISTORICAL_TOON_GALLERY;
            CreateOutputArticleSectionsDocToXml(iterDoc, iterArticleMetadata, toonDateToUse, filter);

            var item = iterDoc.CreateElement("component");
            item.SetAttribute("name", GlobalConstants.IMAGE_NAME_TOON);
            iterArticleContent.AppendChild(item);

            var itemChild = iterDoc.CreateElement("file");
            string fileName = it.FileName;
            fileName = CopyImageToZip(sourcePath, documentPath, fileName, it);
            itemChild.SetAttribute("path", DocumentImageDir + fileName);
            item.AppendChild(itemChild);
            iterArticles.AppendChild(iterArticle);
            if (log.IsDebugEnabled) log.Debug("CreateOutputArticleToonDocToXml end");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads toon info not actually being processed.
        /// </summary>
        private void LoadToonInfo() {
            string sql = "";

            sql = "select * from toondir where processed = 0 order by ComputedCreatedDate desc ";
            if (log.IsDebugEnabled) {
                log.Debug("LoadToonInfo Start");
            }
            _toonList.Clear();

            HandleDatabase hdb = new HandleDatabase(_sitemapConnStr);
            hdb.Open();

            SqlTransaction transaction = hdb.BeginTransaction("LoadToonInfo");
            SqlDataReader rdr = hdb.ExecSelectSQLStmtAsReader(transaction, sql);
            while (rdr.Read()) {
                ToonDirInfo toonInfo = new ToonDirInfo();
                toonInfo.IdArticle = rdr["idArticle"].ToString();
                toonInfo.FileName = rdr["filename"].ToString();
				
                var dtCreate = Convert.ToDateTime(rdr["CreateDate"]);
                var dtUpdate = Convert.ToDateTime(rdr["UpdateDate"]);
                var dtComputeCreatedDate = Convert.ToDateTime(rdr["ComputedCreatedDate"]);

                toonInfo.CreateDate = dtCreate;
                toonInfo.UpdateDate = dtUpdate;
                toonInfo.Processed = Convert.ToInt32(rdr["processed"].ToString());
                toonInfo.Id = Convert.ToInt32(rdr["id"].ToString());
                toonInfo.ComputedCreatedDate = dtComputeCreatedDate;
                toonInfo.UseComputedCreateDate = (int)rdr["UseComputedCreateDate"];
                _toonList.Add(toonInfo);
            }
            rdr.Close();
            transaction.Commit();
            hdb.Close();
            if (log.IsDebugEnabled) {
                log.Debug("LoadToonInfo End");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This actually copies the image from source directory to target directory. Applies to Toon Directory images.
        /// </summary>
        /// <param name="srcDir">Image source folder to gather</param>
        /// <param name="targetDir">Image target folder to copy to</param>
        /// <param name="fileName">File name of image.</param>
        /// <param name="info">A toon directory info record</param>
        /// <returns>If 'fileName' has been changed due to non-ascii characters in it, it is returned like so, 
        /// otherwise, it is returned as such.</returns>
        private string CopyImageToZip(string srcDir, string targetDir, string fileName, ToonDirInfo info) {
            string line = "";
            string rslt = "";

            var sourceFile = srcDir + @"\" + fileName;
            rslt = fileName;
            if (log.IsDebugEnabled) {
                log.Debug("CopyImageToZip(string srcDir, string targetDir, string fileName, ToonDirInfo info) Start");
            }
            line = "Using parameters srcDir=[" + srcDir + "], targetDir=[" + targetDir + "], fileName=[" + fileName + "], info idsitemap=[" + info.Id + "]";
            if (log.IsDebugEnabled) {
                log.Debug(line);
            }
            if (!File.Exists(sourceFile)) {
                if (log.IsWarnEnabled) {
                    log.Warn("Document image for TOON id=[" + info.Id + "], sourceFile=[" + sourceFile + "] does not exist");
                }
                rslt = "";
            }
            else {
                rslt = ConfigureImageName(fileName, targetDir, srcDir);
            }
            if (log.IsDebugEnabled) {
                log.Debug("CopyImageToZip(string srcDir, string targetDir, string fileName, ToonDirInfo info) End");
            }
            return rslt;
        }