public void ProcessSingleItem(Publication publication)
        {
            var id = _publications.CreateOrRetrieveId(publication);
            publication.Id = id;

            // Delayed write for nice formatting in output file - see dispose.
        }
        public void ProcessSingleItem(Entry entry, Publication publication)
        {
            _currentArticleId = _currentArticleId + 1;
            entry.Writer.Id = _writers.CreateOrRetrieveId(entry.Writer);
            entry.Id = _currentArticleId;
            entry.PublicationId = publication.Id;

            var entrySql = _sqlGen.GenerateSqlFor(entry);
            _writer.WriteLine(entrySql);
        }
        public void IndexSingleDirectory(string rootDirectory)
        {
            Console.WriteLine("Parsing files in " + rootDirectory);

            var publication = new Publication { Name = rootDirectory.Split('\\').Last().Trim() };

            OnPublicationParsed(publication);
            
            var files = Directory.GetFiles(rootDirectory);

            Console.WriteLine(files.Length + " files found.");
            for (var index = 0; index < files.Length; index++)
            {
                var file = files[index];
                var text = File.ReadAllText(file, Encoding.Unicode);
                var entry = _textFileDataParser.Parse(text);

                OnEntryParsed(entry, publication);

                Console.Write(index + 1 + " ");
            }
        }
示例#4
0
 public string GenerateSqlFor(Publication entry)
 {
     return string.Format("\n" + PublicationInsert,
         EncodeMySqlString(entry.Id.ToString()),
         EncodeMySqlString(entry.Name.TrimStart()));
 }
示例#5
0
 public string GenerateSqlFor(Publication entry)
 {
     return string.Format(PublicationInsert, 
         entry.Id.ToEscapedString(),
         entry.Name.TrimStart().ToEscapedString());
 }