示例#1
0
        public MCESchedule(string[] args)
        {
            pdamxBeyondTV      mxBeyondTV;
            DateTimeFormatInfo dtFormat = new CultureInfo("en-US", false).DateTimeFormat;
            pdamxSearchKeyGen  mxSearchKeyGen;
            FileInfo           fiFileSummary;
            Hashtable          hProgramInfo;

            int iNumberOfsActiveRecordings = 0;
            int iNumberOfUpCommingShows    = 0;

            String sBTVNetworkLicense     = "";
            String sBTVNetworkLicenseFile = "";
            String sBTVUserAccessFile     = "";
            String sWebGuideURL           = "";
            String sWebGuideFile          = "";
            String sXMLOutFile            = "";
            String sTVGuideSearchUrl      = "";
            String sTVComSearchUrl        = "";
            String spubDate = "";

            String rootXMLNodeTemplate =
                "&[JobInfo]&"
                + "\n   <ActiveRecordings>&[ActiveRecordings]&\n   </ActiveRecordings>"
                + "\n   <NextRecording>&[NextRecording]&\n   </NextRecording>"
                + "\n   <LastRecording>&[LastRecording]&\n   </LastRecording>"
                + "\n   <UpcomingRecordings NumberOfShows=''>&[UpcommingRecordings]&\n   </UpcomingRecordings>";

            String jobInfoXMLTemplate =
                "\n   <JobInfo>"
                + "\n      <Generated></Generated>"
                + "\n      <Generator></Generator>"
                + "\n      <Machine></Machine>"
                + "\n      <OS></OS>"
                + "\n      <OSVersion></OSVersion>"
                + "\n      <WebGuideServer>"
                + "\n         <WGHost></WGHost>"
                + "\n         <WGPort></WGPort>"
                + "\n         <WGVersion></WGVersion>"
                + "\n      </WebGuideServer>"
                + "\n   </JobInfo>";

            String recordingsXMLTemplate =
                "\n      <Show>"
                + "\n         <Title></Title>"
                + "\n         <EpisodeTitle></EpisodeTitle>"
                + "\n         <Description></Description>"
                + "\n         <Actors></Actors>"
                + "\n         <Credits></Credits>"
                + "\n         <Genre></Genre>"
                + "\n         <Channel></Channel>"
                + "\n         <StationCallSign></StationCallSign>"
                + "\n         <StationName></StationName>"
                + "\n         <TargetStartTime></TargetStartTime>"
                + "\n         <TargetDuration></TargetDuration>"
                + "\n         <ActualStartTime></ActualStartTime>"
                + "\n         <ActualDuration></ActualDuration>"
                + "\n         <OriginalAirDate></OriginalAirDate>"
                + "\n         <Rating></Rating>"
                + "\n         <MovieYear></MovieYear>"
                + "\n         <IsHDBroadcast></IsHDBroadcast>"
                + "\n         <IsHDRecording></IsHDRecording>"
                + "\n         <IsEpisode></IsEpisode>"
                + "\n         <TVGuideSearch></TVGuideSearch>"
                + "\n         <TVDotComSearch></TVDotComSearch>"
                + "\n         <TitleStrongSearchKey></TitleStrongSearchKey>"
                + "\n         <EpisodeStrongSearchKey></EpisodeStrongSearchKey>"
                + "\n      </Show>";

            // Load XML templates into memory...
            XMLWriter.LoadXMLTemplate("rootXMLNodeTemplate", rootXMLNodeTemplate);
            XMLWriter.LoadXMLTemplate("jobInfoXMLTemplate", jobInfoXMLTemplate);
            XMLWriter.LoadXMLTemplate("recordingsXMLTemplate", recordingsXMLTemplate);
            XMLWriter.CopyXMLTemplate("rootXMLNodeTemplate");
            XMLWriter.CopyXMLTemplate("jobInfoXMLTemplate");

            // Check if content should be written to a file...
            if (args.Length > 0)
            {
                sXMLOutFile = args[0];
            }

            // Configuration based on file name + Config.xml automatically loaded...
            // Get BeyondTV network license...
            sBTVNetworkLicenseFile = GetSettings("/MCETV/BeyondTV/License/NetworkLicense");

            if (sBTVNetworkLicenseFile.ToLower().Contains(".edf"))
            {
                sBTVNetworkLicense = Crypter.DecryptFile(sBTVNetworkLicenseFile);
            }
            else
            {
                sBTVNetworkLicense = sBTVNetworkLicenseFile;
            }

            // Get BeyondTV user account...
            sBTVUserAccessFile = GetSettings("/MCETV/BeyondTV/License/User");

            // Get WebGuide url...
            sWebGuideURL = GetSettings("/MCETV/WebGuide/Url");

            // Get WebGuide data file name...
            sWebGuideFile = GetSettings("/MCETV/WebGuide/TempDataFile");

            // Get sechdule output file name...
            if (sXMLOutFile.Length == 0) //Not overriden by file name passed to program...
            {
                if (GetSettings("/MCETV/Schedule/FileWriteEnabled").ToUpper().Equals("YES"))
                {
                    sXMLOutFile = GetSettings("/MCETV/Schedule/ScheduleFile");
                }
            }
            // Get Google search Url...
            sTVGuideSearchUrl = GetSettings("/MCETV/SearchEngines/TVGuideUrl");

            // Get MSN Bing search Url...
            sTVComSearchUrl = GetSettings("/MCETV/SearchEngines/TVCOMUrl");

            // Get TV schedule for MCE from WebGuide services...
            mxBeyondTV = new pdamxBeyondTV(sBTVNetworkLicense, sBTVUserAccessFile);
            getScheduleFromWebGuide(sWebGuideURL, sWebGuideFile);
            XMLReader.Open(sWebGuideFile);
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "WGVersion", XMLReader.GetNodeValue("/rss/channel/generator"));
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "WGHost", sWebGuideURL.Substring(sWebGuideURL.LastIndexOf("//") + 2, sWebGuideURL.LastIndexOf(":") - (sWebGuideURL.LastIndexOf("//") + 2)));
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "WGPort", sWebGuideURL.Substring(sWebGuideURL.LastIndexOf(":") + 1, sWebGuideURL.LastIndexOf(":", (sWebGuideURL.LastIndexOf("/") + 1) - (sWebGuideURL.LastIndexOf(":") + 1))));

            // Get Schedule Information...
            XMLReader.GetNodePath("/rss/channel/item/*");
            String sGenre           = "";
            String sTitle           = "";
            String sEpisodeTitle    = "";
            bool   bActiveRecording = false;

            XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
            while (XMLReader.MoveNext())
            {
                if (XMLReader.GetXPathNodeIterator().Current.Name.Equals("title"))
                {
                    sEpisodeTitle = "";
                    sTitle        = XMLReader.GetXPathNodeIterator().Current.Value;
                    if (sTitle.Contains(": \""))
                    {
                        int nStartIdx = sTitle.IndexOf(": \"") + 1;
                        sEpisodeTitle = sTitle.Substring(nStartIdx + 2, sTitle.Length - (nStartIdx + 3));
                        sTitle        = sTitle.Substring(0, sTitle.IndexOf(": \""));
                    }
                    if (iNumberOfUpCommingShows > 0)
                    {
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Genre", sGenre);
                        XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "UpcommingRecordings", "recordingsXMLTemplate");
                        if (bActiveRecording)
                        {
                            bActiveRecording = false;
                            XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "ActiveRecordings", "recordingsXMLTemplate");
                            iNumberOfsActiveRecordings++;
                        }
                        if ((iNumberOfUpCommingShows == 1) && (iNumberOfsActiveRecordings == 0))
                        {
                            XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "NextRecording", "recordingsXMLTemplate");
                        }
                        else if ((iNumberOfUpCommingShows == 2) && (XMLWriter.GetXMLTemplate("NextRecording") == null))
                        {
                            XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "NextRecording", "recordingsXMLTemplate");
                        }
                    }
                    sGenre = "";
                    XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
                    mxSearchKeyGen = new pdamxSearchKeyGen();
                    mxSearchKeyGen.GenerateKey(sTitle);
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Title", sTitle);
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TitleStrongSearchKey", mxSearchKeyGen.StrongKey);
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TVGuideSearch", sTVGuideSearchUrl + XMLReader.GetXPathNodeIterator().Current.Value);
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TVDotComSearch", sTVComSearchUrl + XMLReader.GetXPathNodeIterator().Current.Value);

                    if (sEpisodeTitle.Length > 0)
                    {
                        mxSearchKeyGen.GenerateKey(sEpisodeTitle);
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "EpisodeTitle", sEpisodeTitle);
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "EpisodeStrongSearchKey", mxSearchKeyGen.StrongKey);
                    }
                    iNumberOfUpCommingShows++;
                }
                if (XMLReader.GetXPathNodeIterator().Current.Name.Equals("description"))
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Description", XMLReader.GetXPathNodeIterator().Current.Value);
                }
                if (XMLReader.GetXPathNodeIterator().Current.Name.Equals("pubDate"))
                {
                    int result = DateTime.Compare(Convert.ToDateTime(XMLReader.GetXPathNodeIterator().Current.Value), System.DateTime.Now);
                    if (result < 0)
                    {
                        bActiveRecording = true;
                    }
                    spubDate = XMLReader.GetXPathNodeIterator().Current.Value;
                }
                if (XMLReader.GetXPathNodeIterator().Current.Name.Equals("dc:creator"))
                {
                    String sChannel         = XMLReader.GetXPathNodeIterator().Current.Value.Substring(0, XMLReader.GetXPathNodeIterator().Current.Value.IndexOf(" "));
                    String sStationCallSign = XMLReader.GetXPathNodeIterator().Current.Value.Substring(XMLReader.GetXPathNodeIterator().Current.Value.IndexOf(" ") + 1, (XMLReader.GetXPathNodeIterator().Current.Value.IndexOf("-") - 1) - XMLReader.GetXPathNodeIterator().Current.Value.IndexOf(" "));
                    String sStationName     = XMLReader.GetXPathNodeIterator().Current.Value.Substring(XMLReader.GetXPathNodeIterator().Current.Value.IndexOf("-") + 2, (XMLReader.GetXPathNodeIterator().Current.Value.Length - XMLReader.GetXPathNodeIterator().Current.Value.IndexOf("-")) - 2);

                    hProgramInfo = GetBTVProgramInfo(mxBeyondTV.SearchGuideAll(sTitle.Trim()), spubDate, sChannel);
                    if (hProgramInfo != null)
                    {
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Actors", (hProgramInfo["Actors"] != null ? hProgramInfo["Actors"].ToString() : ""));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Credits", (hProgramInfo["Credits"] != null ? hProgramInfo["Credits"].ToString() : ""));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Genre", (hProgramInfo["Genre"] != null ? hProgramInfo["Genre"].ToString() : ""));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TargetStartTime", DateTime.FromFileTime(Convert.ToInt64(hProgramInfo["Start"].ToString())).ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TargetDuration", pdamxUtility.FormatNanoseconds(hProgramInfo["Duration"].ToString()));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "ActualStartTime", DateTime.FromFileTime(Convert.ToInt64(hProgramInfo["Start"].ToString())).ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "ActualDuration", pdamxUtility.FormatNanoseconds(hProgramInfo["Duration"].ToString()));

                        if (hProgramInfo["OriginalAirDate"] == null)
                        {
                            XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", "");
                        }
                        else
                        {
                            if (hProgramInfo["OriginalAirDate"].ToString() == "")
                            {
                                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", "");
                            }
                            else
                            {
                                DateTime startTime = new DateTime(Convert.ToInt32(hProgramInfo["OriginalAirDate"].ToString().Substring(0, 4)),
                                                                  Convert.ToInt32(hProgramInfo["OriginalAirDate"].ToString().Substring(4, 2)),
                                                                  Convert.ToInt32(hProgramInfo["OriginalAirDate"].ToString().Substring(6, 2)));
                                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", startTime.ToString("d", dtFormat));
                            }
                        }
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", (hProgramInfo["OriginalAirDate"] != null ? hProgramInfo["OriginalAirDate"].ToString() : ""));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Rating", (hProgramInfo["Rating"] != null ? hProgramInfo["Rating"].ToString() : ""));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "MovieYear", (hProgramInfo["MovieYear"] != null ? hProgramInfo["MovieYear"].ToString() : ""));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDBroadcast", (hProgramInfo["IsHD"] != null ? (hProgramInfo["IsHD"].ToString() == "Y" ? "Yes" : "No") : "No"));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDRecording", "No");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsEpisode", (hProgramInfo["EpisodeDescription"] != null ? "Yes" : "No"));
                    }
                    else
                    {
                        DateTime startTime = Convert.ToDateTime(spubDate);
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Actors", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Credits", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Genre", sGenre);
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TargetStartTime", startTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TargetDuration", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "ActualStartTime", startTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "ActualDuration", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Rating", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "MovieYear", "");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDBroadcast", "No");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDRecording", "No");
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsEpisode", "No");
                    }
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Channel", sChannel.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "StationCallSign", sStationCallSign.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "StationName", sStationName.Trim());
                }
                if (XMLReader.GetXPathNodeIterator().Current.Name.Equals("category"))
                {
                    if (sGenre != "")
                    {
                        sGenre = sGenre + "/";
                    }
                    sGenre = sGenre + XMLReader.GetXPathNodeIterator().Current.Value.Trim();
                }
            }
            // Delete WebGuide data file...
            FileInfo fiTempFileInfo = new FileInfo(sWebGuideFile);

            fiTempFileInfo.Delete();

            // Get last recording...
            XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Genre", sGenre);
            XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "LastRecording", "recordingsXMLTemplate");

            //Write XML content to console stream or file...
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Generated", StartTime);
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Generator", Program);
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Machine", Machine);
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "OS", OS);
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "OSVersion", OSVersion);

            XMLWriter.SetXMLTemplateElementAttribute("rootXMLNodeTemplate", "UpcomingRecordings", "NumberOfShows", Convert.ToString(iNumberOfUpCommingShows));
            XMLWriter.ReplactXMPTemplateElementMarker("rootXMLNodeTemplate", "JobInfo", "jobInfoXMLTemplate");

            if (sXMLOutFile != "") //Write to file...
            {
                XMLWriter.Open(sXMLOutFile);
                XMLWriter.RootNode  = "MCETV";
                XMLWriter.DTD       = "DTD/" + pdamxUtility.StripPath(sXMLOutFile, true);
                XMLWriter.Namespace = "http://www.pdamediax.com/mce";
                XMLWriter.Write(XMLWriter.GetXMLTemplate("rootXMLNodeTemplate"));
                XMLWriter.Close();
            }
            else
            {
                Console.WriteLine(XMLWriter.GetXMLTemplate("rootXMLNodeTemplate"));
            }
            WriteEndofJobSummaryToFile = true;
            AddSummaryExtra("");
            AddSummaryExtra("MCE Scheduling Summary");
            AddSummaryExtra("");
            AddSummaryExtra("  Number of Up Comming Shows:  " + pdamxUtility.FormatNumber(iNumberOfUpCommingShows));
            AddSummaryExtra("  Number of Active Shows:      " + pdamxUtility.FormatNumber(iNumberOfsActiveRecordings));

            if (sXMLOutFile != "") //Write to file...
            {
                fiFileSummary = new FileInfo(sXMLOutFile);
                AddSummaryExtra("");
                AddSummaryExtra("MCE XML Schedule Data File Information");
                AddSummaryExtra("");
                AddSummaryExtra("  Name:      " + fiFileSummary.Name);
                AddSummaryExtra("  Location:  " + fiFileSummary.Directory);
                AddSummaryExtra("  Size:      " + pdamxUtility.FormatStorageSize(Convert.ToString(fiFileSummary.Length)));
                AddSummaryExtra("  Created:   " + fiFileSummary.LastWriteTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
            }
            PrintEndofJobSummary();
            return;
        }
示例#2
0
        public BuildExVideoXMLDB()
        {
            DateTimeFormatInfo dtFormat      = new CultureInfo("en-US", false).DateTimeFormat;
            Hashtable          hSearchResult = null;
            FileInfo           fiFileInfo;
            pdamxXMLReader     mxXMLVideoXMLDBReader;
            pdamxXMLReader     mxXMLExBackupVideoXMLDBReader = null;
            pdamxXMLWriter     mxExVidoeXMLDBWriter;
            pdamxBeyondTV      mxBeyondTV;
            XPathNodeIterator  xpathINode;
            String             sExVideoXMLDBLibraryFile = "";
            String             sVideoXMLDBLibraryFile   = "";
            String             sExVideoXMLDBBackupFile  = "";
            String             sBTVNetworkLicenseFile   = "";
            String             sBTVUserAccessFile       = "";
            String             sBTVNetworkLicense       = "";
            String             sPrevTitle = "";

            int nNumberOfMoviesRead              = 0;
            int nNumberOfMovieEntriesSkipped     = 0;
            int nNumberOfMoviesFoundInGuide      = 0;
            int nNumberOfMoviesFoundInExArchive  = 0;
            int nNumberOfMovieEntryWrittened     = 0;
            int nNumberOfMoviesNotFound          = 0;
            int nNumberOfArchiveEntriesWrittened = 0;

            bool bExVideoXMLDBBackupFound = false;

            String jobInfoXMLTemplate =
                "\n   <JobInfo>"
                + "\n      <Generated></Generated>"
                + "\n      <Generator></Generator>"
                + "\n       <Machine></Machine>"
                + "\n      <OS></OS>"
                + "\n      <OSVersion></OSVersion>"
                + "\n   </JobInfo>";

            String movieXMLTemplate =
                "\n   <Movie>"
                + "\n     <Title></Title>"
                + "\n     <Description></Description>"
                + "\n     <Credits></Credits>"
                + "\n     <MovieYear></MovieYear>"
                + "\n     <ParentalRating></ParentalRating>"
                + "\n   </Movie>";

            String summaryXMLTemplate =
                "\n   <Summary>"
                + "\n     <MoviesRead></MoviesRead>"
                + "\n     <EntriesWrittened></EntriesWrittened>"
                + "\n     <EntriesFoundInBTVGuide></EntriesFoundInBTVGuide>"
                + "\n     <EntriesFoundedInArchive></EntriesFoundedInArchive>"
                + "\n     <EntriesNotFound></EntriesNotFound>"
                + "\n     <EntriesSkipped></EntriesSkipped>"
                + "\n     <ArchiveEntriesWrittened></ArchiveEntriesWrittened>"
                + "\n   </Summary>";

            // Get file names...
            sExVideoXMLDBLibraryFile = GetSettings("/Video/Catalog/ExVideoXMLDBLibraryFile");
            sVideoXMLDBLibraryFile   = GetSettings("/Video/Catalog/VideoXMLDBLibraryFile");

            // If file created once today then don't create a second time...
            FileInfo fiVideoInfo = new FileInfo(sExVideoXMLDBLibraryFile);

            if (fiVideoInfo.Exists)
            {
                bool bBypassDateCheck = false;
                if (GetSettings("/Video/Catalog/IgnoreDateCheck") != null)
                {
                    if (GetSettings("/Video/Catalog/IgnoreDateCheck").ToLower().Equals("true"))
                    {
                        bBypassDateCheck = true;
                    }
                }
                if (!bBypassDateCheck)
                {
                    DateTime dtOfFile = fiVideoInfo.LastWriteTime;
                    if (dtOfFile.ToString("MM/dd/yyyy", dtFormat).Equals(DateTime.Now.ToString("MM/dd/yyyy", dtFormat)))
                    {
                        return;
                    }
                }
            }
            sExVideoXMLDBBackupFile = GetSettings("/Video/Catalog/BackupFile");
            sBTVNetworkLicenseFile  = GetSettings("/Video/BeyondTV/License/NetworkLicense");
            if (sBTVNetworkLicenseFile.ToLower().Contains(".edf"))
            {
                sBTVNetworkLicense = Crypter.DecryptFile(sBTVNetworkLicenseFile);
            }
            else
            {
                sBTVNetworkLicense = sBTVNetworkLicenseFile;
            }

            // Get BeyondTV user account...
            sBTVUserAccessFile = GetSettings("/Video/BeyondTV/License/User");

            // Backup Extended Video Libarary XML Data file...
            bExVideoXMLDBBackupFound = BackupExVXMLDataFile(sExVideoXMLDBLibraryFile, sExVideoXMLDBBackupFile);

            try
            {
                mxXMLVideoXMLDBReader = new pdamxXMLReader();
                mxXMLVideoXMLDBReader.Open(sVideoXMLDBLibraryFile);
                mxXMLVideoXMLDBReader.AddNamespace("vxmldb", "http://www.pdamediax.com/videoxmldb");

                mxBeyondTV = new pdamxBeyondTV(sBTVNetworkLicense, sBTVUserAccessFile);

                if (bExVideoXMLDBBackupFound)
                {
                    mxXMLExBackupVideoXMLDBReader = new pdamxXMLReader();
                    mxXMLExBackupVideoXMLDBReader.Open(sExVideoXMLDBBackupFile);
                    mxXMLExBackupVideoXMLDBReader.AddNamespace("exvxmldb", "http://www.pdamediax.com/exvideoxmldb");
                }
                mxExVidoeXMLDBWriter = new pdamxXMLWriter();
                mxExVidoeXMLDBWriter.LoadXMLTemplate("jobInfoXMLTemplate", jobInfoXMLTemplate);
                mxExVidoeXMLDBWriter.LoadXMLTemplate("movieXMLTemplate", movieXMLTemplate);
                mxExVidoeXMLDBWriter.LoadXMLTemplate("summaryXMLTemplate", summaryXMLTemplate);

                mxExVidoeXMLDBWriter.RootNode  = "VideoCatalog";
                mxExVidoeXMLDBWriter.Namespace = "http://www.pdamediax.com/exvideoxmldb";
                mxExVidoeXMLDBWriter.Open("result-" + Program + ".xml");

                // Write XML content to console stream or file...
                mxExVidoeXMLDBWriter.CopyXMLTemplate("jobInfoXMLTemplate");
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Generated", StartTime);
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Generator", Program);
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Machine", Machine);
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "OS", OS);
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "OSVersion", OSVersion);
                mxExVidoeXMLDBWriter.Write(mxExVidoeXMLDBWriter.GetXMLTemplate("jobInfoXMLTemplate"));

                mxExVidoeXMLDBWriter.Write("\n  <MoviesCatalog>");

                // Write archive entries...
                if (bExVideoXMLDBBackupFound)
                {
                    xpathINode = mxXMLExBackupVideoXMLDBReader.GetNodePath("/exvxmldb:VideoCatalog/exvxmldb:MoviesCatalog/*");
                    xpathINode.MoveNext();
                    xpathINode.Current.MoveToParent();
                    xpathINode.Current.MoveToFirstChild();

                    do
                    {
                        if (xpathINode.Current.Name.Equals("Movie"))
                        {
                            String sTitle       = "";
                            String sMovieYear   = "";
                            String sDescription = "";
                            String sCredits     = "";
                            String sRating      = "";

                            xpathINode.Current.MoveToFirstChild();
                            do
                            {
                                if (xpathINode.Current.Name.Equals("Title"))
                                {
                                    sTitle = xpathINode.Current.Value;
                                }

                                if (xpathINode.Current.Name.Equals("MovieYear"))
                                {
                                    sMovieYear = xpathINode.Current.Value;
                                }

                                if (xpathINode.Current.Name.Equals("Description"))
                                {
                                    sDescription = xpathINode.Current.Value;
                                }

                                if (xpathINode.Current.Name.Equals("Credits"))
                                {
                                    sCredits = xpathINode.Current.Value;
                                }

                                if (xpathINode.Current.Name.Equals("ParentalRating"))
                                {
                                    sRating = xpathINode.Current.Value;
                                }
                            }while (xpathINode.Current.MoveToNext());
                            mxExVidoeXMLDBWriter.CopyXMLTemplate("movieXMLTemplate");
                            mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "Title", sTitle);
                            mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "Description", sDescription);
                            mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "Credits", sCredits);
                            mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "MovieYear", sMovieYear);
                            mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "ParentalRating", sRating);
                            if (sMovieYear != null && sRating != null)
                            {
                                if (sMovieYear != "" && sRating != "")
                                {
                                    mxExVidoeXMLDBWriter.Write(mxExVidoeXMLDBWriter.GetXMLTemplate("movieXMLTemplate"));
                                    nNumberOfArchiveEntriesWrittened++;
                                    nNumberOfMovieEntryWrittened++;
                                }
                            }
                            xpathINode.Current.MoveToParent();
                        }
                    }while (xpathINode.Current.MoveToNext());
                }
                xpathINode = mxXMLVideoXMLDBReader.GetNodePath("/vxmldb:VideoCatalog/vxmldb:MoviesCatalog/*");
                xpathINode.MoveNext();
                xpathINode.Current.MoveToParent();
                xpathINode.Current.MoveToFirstChild();

                do
                {
                    if (xpathINode.Current.Name.Equals("Movie"))
                    {
                        String sTitle       = "";
                        String sMovieYear   = "";
                        String sDescription = "";
                        String sCredits     = "";

                        xpathINode.Current.MoveToFirstChild();
                        nNumberOfMoviesRead++;
                        do
                        {
                            if (xpathINode.Current.Name.Equals("Title"))
                            {
                                sTitle = xpathINode.Current.Value;
                            }

                            if (xpathINode.Current.Name.Equals("MovieYear"))
                            {
                                sMovieYear = xpathINode.Current.Value;
                            }

                            if (xpathINode.Current.Name.Equals("Description"))
                            {
                                sDescription = xpathINode.Current.Value;
                            }

                            if (xpathINode.Current.Name.Equals("Credits"))
                            {
                                sCredits = xpathINode.Current.Value;
                            }
                        }while (xpathINode.Current.MoveToNext());

                        if ((sMovieYear.Trim().Length == 0) || (sCredits.Trim().Length == 0) ||
                            (sDescription.Trim().Length == 0))
                        {
                            hSearchResult = null;
                            if (!sTitle.Equals(sPrevTitle))
                            {
                                bool bSkipEntry = false;
                                if (bExVideoXMLDBBackupFound)
                                {
                                    if ((hSearchResult = GetArchiveProgramInfo(mxXMLExBackupVideoXMLDBReader, sTitle)) != null)
                                    {
                                        bSkipEntry = true;
                                        nNumberOfMoviesFoundInExArchive++;
                                    }
                                }
                                if (hSearchResult == null)
                                {
                                    if ((hSearchResult = GetBTVProgramInfo(mxBeyondTV.SearchGuideAll(sTitle), sTitle)) != null)
                                    {
                                        nNumberOfMoviesFoundInGuide++;
                                    }
                                }

                                if (!bSkipEntry)
                                {
                                    if (hSearchResult != null)
                                    {
                                        String sRating = (hSearchResult["Rating"] != null ? hSearchResult["Rating"].ToString() : (hSearchResult["ParentalRating"] != null ? hSearchResult["ParentalRating"].ToString() : ""));
                                        sMovieYear = (hSearchResult["MovieYear"] != null ? hSearchResult["MovieYear"].ToString() : "");

                                        mxExVidoeXMLDBWriter.CopyXMLTemplate("movieXMLTemplate");
                                        mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "Title", sTitle);
                                        mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "Description", (hSearchResult["EpisodeDescription"] != null ? hSearchResult["EpisodeDescription"].ToString() : (hSearchResult["Description"] != null ? hSearchResult["Description"].ToString() : "")));
                                        mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "Credits", (hSearchResult["Actors"] != null ? hSearchResult["Actors"].ToString() : (hSearchResult["Credits"] != null ? hSearchResult["Credits"].ToString() : "")));
                                        mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "MovieYear", (hSearchResult["MovieYear"] != null ? hSearchResult["MovieYear"].ToString() : ""));
                                        mxExVidoeXMLDBWriter.SetXMLTemplateElement("movieXMLTemplate", "ParentalRating", (hSearchResult["Rating"] != null ? hSearchResult["Rating"].ToString() : (hSearchResult["ParentalRating"] != null ? hSearchResult["ParentalRating"].ToString() : "")));

                                        if (sMovieYear != "" && sRating != "")
                                        {
                                            mxExVidoeXMLDBWriter.Write(mxExVidoeXMLDBWriter.GetXMLTemplate("movieXMLTemplate"));
                                            nNumberOfMovieEntryWrittened++;
                                        }
                                    }
                                    else
                                    {
                                        nNumberOfMoviesNotFound++;
                                    }
                                }
                                sPrevTitle = sTitle;
                            }
                            else
                            {
                                nNumberOfMovieEntriesSkipped++;
                            }
                        }
                        else
                        {
                            nNumberOfMovieEntriesSkipped++;
                        }
                        xpathINode.Current.MoveToParent();
                    }
                }while (xpathINode.Current.MoveToNext());

                mxExVidoeXMLDBWriter.Write("\n  </MoviesCatalog>");
                mxExVidoeXMLDBWriter.CopyXMLTemplate("summaryXMLTemplate");
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "MoviesRead", Convert.ToString(nNumberOfMoviesRead));
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "EntriesWrittened", Convert.ToString(nNumberOfMovieEntryWrittened));
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "EntriesFoundInBTVGuide", Convert.ToString(nNumberOfMoviesFoundInGuide));
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "EntriesFoundedInArchive", Convert.ToString(nNumberOfMoviesFoundInExArchive));
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "EntriesNotFound", Convert.ToString(nNumberOfMoviesNotFound));
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "EntriesSkipped", Convert.ToString(nNumberOfMovieEntriesSkipped));
                mxExVidoeXMLDBWriter.SetXMLTemplateElement("summaryXMLTemplate", "ArchiveEntriesWrittened", Convert.ToString(nNumberOfArchiveEntriesWrittened));
                mxExVidoeXMLDBWriter.Write(mxExVidoeXMLDBWriter.GetXMLTemplate("summaryXMLTemplate"));
                mxExVidoeXMLDBWriter.Close();
                File.Copy("result-" + Program + ".xml", sExVideoXMLDBLibraryFile, true);
                fiFileInfo = new FileInfo("result-" + Program + ".xml");
                fiFileInfo.Delete();

                // Job Summary...
                WriteEndofJobSummaryToFile = true;
                AddSummaryExtra("");
                AddSummaryExtra("Extended Video Library Processing Summary");
                AddSummaryExtra("");
                AddSummaryExtra("  Movie Video Entries:                " + pdamxUtility.FormatNumber(nNumberOfMoviesRead));
                AddSummaryExtra("  --- Movie Video Entries Not Found:  " + pdamxUtility.FormatNumber(nNumberOfMoviesNotFound));
                AddSummaryExtra("  --- Movie Video Entries Skipped  :  " + pdamxUtility.FormatNumber(nNumberOfMovieEntriesSkipped));
                AddSummaryExtra("");
                AddSummaryExtra("  Movie Video Entrie's Info Writtened:  " + pdamxUtility.FormatNumber(nNumberOfMovieEntryWrittened));
                AddSummaryExtra("  --- BTV Guide Search Hits:            " + pdamxUtility.FormatNumber(nNumberOfMoviesFoundInGuide));
                AddSummaryExtra("  --- Archive Search Hits:              " + pdamxUtility.FormatNumber(nNumberOfMoviesFoundInExArchive));
                AddSummaryExtra("  --- Archive Entries Writtened:        " + pdamxUtility.FormatNumber(nNumberOfArchiveEntriesWrittened));
                PrintEndofJobSummary();
            }
            catch (Exception e)
            {
                Console.WriteLine("BuildExVideoXMLDB Error: " + e.Message);
                Console.ReadKey();
                return;
            }
        }