using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iReaper.IndexBuilder.WWESource;
using System.Xml.Serialization;
using System.Collections;
using System.IO;
using System.Xml;
namespace iReaper.IndexBuilder{
class Program
{
[STAThread]
static void Main(string[] args)
{
ITask[] tasks = new ITask[] { new SyncTask(), new RawIndexParseTTask(), new LuceneIndexTask() };
for (int i = 0; i < tasks.Length; i++)
{
var task = tasks[i];
task.OnProgress += new EventHandler<ProgressEventArgs>(task_OnProgress);
task.Initialize();
task.Invoke();
}
}
static void task_OnProgress(object sender, ProgressEventArgs e)
{
Console.Write("\r" + e.Value);
}
static void BuildInfoXml(string src, string output)
{
XmlTextWriter writer = new XmlTextWriter(output, Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("Webcasts");
XmlDocument xml = new XmlDocument();
xml.Load(src);
XmlNodeList eventList = xml.SelectNodes("//Event");
int i = 0;
foreach (XmlNode nEvent in eventList)
{
if (nEvent.SelectSingleNode("LiveMeetingUrl") == null)
{
continue;
}
DateTime date = DateTime.Parse(nEvent.SelectSingleNode("Publish").InnerText);
string download = nEvent.SelectSingleNode("LiveMeetingUrl").InnerText;
string url = nEvent.SelectSingleNode("DetailUrl").InnerText;
string title = nEvent.SelectSingleNode("Title").InnerText;
string description = nEvent.SelectSingleNode("Description").InnerText;
string category = nEvent.SelectSingleNode("../../Category").InnerText;
XmlNode nAuthor = nEvent.SelectSingleNode(".//Author");
string author = null, authorTitle = null, resume = null;
if (nAuthor != null)
{
author = nAuthor.SelectSingleNode("Name").InnerText;
XmlNode nTitle = nAuthor.SelectSingleNode("Title");
authorTitle = nTitle == null ? null : nTitle.InnerText;
XmlNode nResume = nAuthor.SelectSingleNode("Introduce");
resume = nResume == null ? null : nResume.InnerText;
}
writer.WriteStartElement("R");
writer.WriteElementString("newsID", i.ToString());
writer.WriteElementString("headline", title);
writer.WriteElementString("description", description);
writer.WriteElementString("url", url);
// level
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "level");
writer.WriteAttributeString("attValue", "200");
writer.WriteEndElement();
// speaker
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "speaker");
writer.WriteAttributeString("attValue", author);
writer.WriteEndElement();
// title
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "title");
writer.WriteAttributeString("attValue", authorTitle);
writer.WriteEndElement();
// resume
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "resume");
writer.WriteAttributeString("attValue", resume);
writer.WriteEndElement();
// tech
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "tech");
writer.WriteAttributeString("attValue", category);
writer.WriteEndElement();
// tech
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "video");
writer.WriteAttributeString("attValue", download);
writer.WriteEndElement();
// date
writer.WriteStartElement("a");
writer.WriteAttributeString("attCatID", "date");
writer.WriteAttributeString("attValue", date.ToString());
writer.WriteEndElement();
writer.WriteEndElement();
i++;
}
writer.WriteEndElement();
writer.Close();
}
}
}
|