//static void Main(string[] args)
        // {
        //     new RecordedTVStorageUsage();
        // }
        public RecordedTVStorageUsage()
        {
            TextWriter twWriter;
            String     sRecordedTVDrive;
            String     sRecordedTVStatFile;
            String     sRecordedTVFolder;
            String     sRecordedTVFolderList;

            String[]      sRecordedTVFileFilter;
            List <String> lFiles;
            Boolean       bLimitStatsToRecordedTVDrive = true;
            int           nTotalRecording      = 0;
            long          lTotalRecordedTVSize = 0;

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

            String machineInfoXMLTemplate =
                "\n   <MachineInfo>"
                + "\n     <Machine></Machine>"
                + "\n     <Platform></Platform>"
                + "\n     <Processors></Processors>"
                + "\n     <OSVersion></OSVersion>"
                + "\n     <IPAddress></IPAddress>"
                + "\n   </MachineInfo>";

            String driveXMLTemplate =
                "\n   <Drive>"
                + "\n     <DriveLetter></DriveLetter>"
                + "\n     <VolumeLabel></VolumeLabel>"
                + "\n     <DriveFormat></DriveFormat>"
                + "\n     <TotalStorage></TotalStorage>"
                + "\n     <TotalStorageFree></TotalStorageFree>"
                + "\n     <TotalStorageUsed></TotalStorageUsed>"
                + "\n     <UFTotalStorage></UFTotalStorage>"
                + "\n     <UFTotalStorageFree></UFTotalStorageFree>"
                + "\n     <UFTotalStorageUsed></UFTotalStorageUsed>"
                + "\n   </Drive>";

            String recordedDirectoryXMLTemplate =
                "\n   <RecordingDirectory>"
                + "\n     <Directory></Directory>"
                + "\n     <Files></Files>"
                + "\n     <TotalStorageUsed></TotalStorageUsed>"
                + "\n     <UFTotalStorageUsed></UFTotalStorageUsed>"
                + "\n   </RecordingDirectory>";

            // Load XML templates into memory...
            XMLWriter.LoadXMLTemplate("jobInfoXMLTemplate", jobInfoXMLTemplate);
            XMLWriter.LoadXMLTemplate("driveXMLTemplate", driveXMLTemplate);
            XMLWriter.LoadXMLTemplate("recordedDirectoryXMLTemplate", recordedDirectoryXMLTemplate);
            XMLWriter.LoadXMLTemplate("machineInfoXMLTemplate", machineInfoXMLTemplate);

            sRecordedTVDrive    = GetSettings("/RecordedTV/RecordedTVDrive");
            sRecordedTVStatFile = GetSettings("/RecordedTV/RecordedTVDriveStatFile");

            if (GetSettings("/RecordedTV/LimitStatsToRecordedTVDrive").ToLower() == "yes")
            {
                bLimitStatsToRecordedTVDrive = true;
            }

            // Create XML DB file...
            XMLWriter.Open(sRecordedTVStatFile);
            XMLWriter.RootNode  = "RecordedTV";
            XMLWriter.Namespace = "http://www.pdamediax.com/recordedtv";

            // System.Environment.Version;
            //System.Net.Dns.GetHostAddresses().GetValue

            //Write XML content to console stream or file...
            XMLWriter.CopyXMLTemplate("jobInfoXMLTemplate");
            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.Write(XMLWriter.GetXMLTemplate("jobInfoXMLTemplate"));

            XMLWriter.CopyXMLTemplate("machineInfoXMLTemplate");
            XMLWriter.SetXMLTemplateElement("machineInfoXMLTemplate", "Machine", System.Environment.MachineName);
            XMLWriter.SetXMLTemplateElement("machineInfoXMLTemplate", "OSVersion", System.Environment.OSVersion.ToString());
            XMLWriter.SetXMLTemplateElement("machineInfoXMLTemplate", "Platform", System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"));
            XMLWriter.SetXMLTemplateElement("machineInfoXMLTemplate", "Processors", System.Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"));

            IPAddress[] ipAddress  = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());
            String      sIpAddress = "";

            foreach (IPAddress ip in ipAddress)
            {
                if (ip.IsIPv6LinkLocal || ip.IsIPv6Multicast || ip.IsIPv6SiteLocal)
                {
                    continue;
                }
                if (ip.ToString().StartsWith("192."))
                {
                    continue;
                }
                sIpAddress = ip.ToString();
                break;
            }
            XMLWriter.SetXMLTemplateElement("machineInfoXMLTemplate", "IPAddress", sIpAddress);
            XMLWriter.Write(XMLWriter.GetXMLTemplate("machineInfoXMLTemplate"));

            foreach (DriveInfo drive in DriveInfo.GetDrives())
            {
                if (drive.IsReady)
                {
                    if (bLimitStatsToRecordedTVDrive && drive.Name.ToLower() != sRecordedTVDrive.ToLower())
                    {
                        continue;
                    }
                    XMLWriter.CopyXMLTemplate("driveXMLTemplate");
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "DriveLetter", drive.Name);
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "VolumeLabel", drive.VolumeLabel);
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "DriveFormat", drive.DriveFormat);
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "TotalStorage", pdamxUtility.FormatStorageSize(Convert.ToString(drive.TotalSize)));
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "TotalStorageFree", pdamxUtility.FormatStorageSize(Convert.ToString(drive.TotalFreeSpace)));
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "TotalStorageUsed", pdamxUtility.FormatStorageSize(Convert.ToString(drive.TotalSize - drive.TotalFreeSpace)));
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "UFTotalStorage", Convert.ToString(drive.TotalSize));
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "UFTotalStorageFree", Convert.ToString(drive.TotalFreeSpace));
                    XMLWriter.SetXMLTemplateElement("driveXMLTemplate", "UFTotalStorageUsed", Convert.ToString(drive.TotalSize - drive.TotalFreeSpace));
                    XMLWriter.Write(XMLWriter.GetXMLTemplate("driveXMLTemplate"));
                }
            }
            sRecordedTVFolder     = GetSettings("/RecordedTV/RecordedTVFolder");
            sRecordedTVFolderList = GetSettings("/RecordedTV/RecordedTVFolderList");
            sRecordedTVFileFilter = GetSettings("/RecordedTV/RecordedTVFileFilter").Split(';');
            lFiles = new List <String>();
            foreach (String sFilter in sRecordedTVFileFilter)
            {
                String[] sFiles = Directory.GetFiles(sRecordedTVFolder, "*." + sFilter);
                foreach (String sFile in sFiles)
                {
                    lFiles.Add(sFile);
                }
            }
            twWriter = new StreamWriter(sRecordedTVFolderList);
            twWriter.WriteLine("{\"RecordedFiles\":[");
            String sbuffer = "";

            foreach (String sFile in lFiles)
            {
                String   sIsHD  = "No";
                FileInfo fiInfo = new FileInfo(sFile);
                if (sbuffer != "")
                {
                    twWriter.WriteLine(sbuffer + ",");
                }
                if (fiInfo.Name.ToUpper().Contains("HD_") || fiInfo.Name.ToUpper().Contains("DT_") ||
                    fiInfo.Name.ToUpper().Contains("H_") || fiInfo.Name.ToUpper().Contains("HDP_"))
                {
                    sIsHD = "Yes";
                }
                if (fiInfo.Extension.ToUpper().Contains("TP"))
                {
                    sIsHD = "Yes";
                }
                sbuffer = "{\"FileName\":\"" + fiInfo.Name + "\","
                          + "\"Directory\":\"" + fiInfo.Directory.ToString().Replace("\\", "\\\\") + "\","
                          + "\"FileExt\":\"" + fiInfo.Extension + "\","
                          + "\"HD\":\"" + sIsHD + "\","
                          + "\"FileSize\":\"" + pdamxUtility.FormatStorageSize(Convert.ToString(fiInfo.Length)) + "\","
                          + "\"UnformattedFileSize\":\"" + Convert.ToString(fiInfo.Length) + "\","
                          + "\"CreateTm\":\"" + fiInfo.CreationTime + "\","
                          + "\"LastModifiedTm\":\"" + fiInfo.LastWriteTime + "\","
                          + "\"LastAccessTm\":\"" + fiInfo.LastAccessTime + "\"}";
                lTotalRecordedTVSize = lTotalRecordedTVSize + fiInfo.Length;
                nTotalRecording++;
            }
            if (sbuffer != "")
            {
                twWriter.WriteLine(sbuffer);
            }
            twWriter.WriteLine("]}");
            twWriter.Close();
            DirectoryInfo diDirectory = new DirectoryInfo(sRecordedTVFolder);

            XMLWriter.CopyXMLTemplate("recordedDirectoryXMLTemplate");
            XMLWriter.SetXMLTemplateElement("recordedDirectoryXMLTemplate", "Directory", diDirectory.FullName);
            XMLWriter.SetXMLTemplateElement("recordedDirectoryXMLTemplate", "Files", Convert.ToString(nTotalRecording));
            XMLWriter.SetXMLTemplateElement("recordedDirectoryXMLTemplate", "TotalStorageUsed", pdamxUtility.FormatStorageSize(Convert.ToString(lTotalRecordedTVSize)));
            XMLWriter.SetXMLTemplateElement("recordedDirectoryXMLTemplate", "UFTotalStorageUsed", Convert.ToString(lTotalRecordedTVSize));
            XMLWriter.Write(XMLWriter.GetXMLTemplate("recordedDirectoryXMLTemplate"));
            XMLWriter.Close();

            WriteEndofJobSummaryToFile = true;
            AddSummaryExtra("");
            AddSummaryExtra("Recorded TV Storage Usage Processing Summary");
            AddSummaryExtra("");
            AddSummaryExtra("  Number of Recordings:                " + nTotalRecording);
            AddSummaryExtra("  Total Storage Used       :           " + pdamxUtility.FormatStorageSize(Convert.ToString(lTotalRecordedTVSize)));
            PrintEndofJobSummary();
        }
Beispiel #2
0
        public BuildMP3XMLDB()
        {
            pdamxAudioProperties mxAudioProperties;
            pdamxSearchKeyGen    mxSearchKeyGen;

            FileInfo           fiFileSummary;
            DirectoryInfo      diDirectoryInfo;
            DateTimeFormatInfo dtFormat         = new CultureInfo("en-US", false).DateTimeFormat;
            TimeSpan           tspAlbumPlayTime = new TimeSpan();

            bool bStart = true;

            int nGenreCnt             = 0;
            int nSongCnt              = 0;
            int nAlbumCnt             = 0;
            int nArtistWithMostTitles = 0;
            int nArtistTitleCnt       = 0;
            int nFilesProcessed       = 0;
            int nFilesRead            = 0;
            int nStartingRange        = 1000;
            int nIncrementIDsBy       = 1;

            long[,] lSubtotals;
            long lTitles             = 0;
            long lArtist             = 0;
            long lAlbums             = 0;
            long lPlayTime           = 0;
            long lArtistPlayTime     = 0;
            long lStorageUsage       = 0;
            long lAlbumStorageUsage  = 0;
            long lArtistStorageUsage = 0;

            long lArtistID = 1 * nStartingRange;
            long lAlbumID  = 3 * lArtistID;
            long lSongID   = 2 * lAlbumID;

            long lTotTitles                    = 0;
            long lTotArtist                    = 0;
            long lTotAlbums                    = 0;
            long lTotPlayTime                  = 0;
            long lTotStorageUsage              = 0;
            long lGenreWithMostTitles          = 0;
            long lGenreUsingMostStorage        = 0;
            long lLongestPlayingGenre          = 0;
            long lLongestPlaySongTitleArtistID = 0;
            long lLongestPlaySongTitleAlbumID  = 0;
            long lShorestPlaySongTitleArtistID = 0;
            long lShorestPlaySongTitleAlbumID  = 0;

            double dLongestPlayingSongTitle = 0;
            double dShorestPlayingSongTitle = 9999999999;

            String[] sGenre;
            String   sLongestPlaySongTitle            = "";
            String   sLongestPlaySongTitleArtist      = "";
            String   sLongestPlaySongTitleArtistAlbum = "";
            String   sShorestPlaySongTitle            = "";
            String   sShorestPlaySongTitleArtist      = "";
            String   sShorestPlaySongTitleArtistAlbum = "";
            String   sGenreWithMostTitles             = "";
            String   sGenreUsingMostStorage           = "";
            String   sLongestPlayingGenre             = "";
            String   sArtistWithMostTitles            = "";
            String   sPrevAlbum            = "";
            String   sPreviousArtist       = "";
            String   sSubTotalList         = "";
            String   sCatalogDirectory     = "";
            String   sMP3XMLDBFile         = "";
            String   sMP3XMLDBSummaryFile  = "";
            String   sRealPlayerServerUrl  = "";
            String   sMediaPlayerServerUrl = "";
            String   sGoogleSearchUrl      = "";
            String   sMSNBingSearchUrl     = "";

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

            String statisticsXMLTemplate =
                "\n   <Statistics>"
                + "\n     <Artist></Artist>"
                + "\n     <Albums></Albums>"
                + "\n     <SongTitles></SongTitles>"
                + "\n     <Genres></Genres>"
                + "\n     <PlayTime></PlayTime>"
                + "\n     <StorageUsage></StorageUsage>"
                + "\n     <UFPlayTime></UFPlayTime>"
                + "\n     <UFStorageUsage></UFStorageUsage>"
                + "\n     <GenreWMostTitles Genre=''></GenreWMostTitles>"
                + "\n     <GenreUsingMostStorage Genre=''></GenreUsingMostStorage>"
                + "\n     <LongestPlayingGenre Genre=''></LongestPlayingGenre>"
                + "\n     <ArtistWithMostTitles NumberOfSongs=''></ArtistWithMostTitles>"
                + "&[LongestPlaySongTitle]&"
                + "&[ShorestPlaySongTitle]&"
                + "\n     <StatisticsByGenre>"
                + "&[StatisticsByGenre]&"
                + "\n     </StatisticsByGenre>"
                + "\n   </Statistics>";

            String longestPlayingSongTitleXMLTemplate =
                "\n     <LongestPlayingSongTitle>"
                + "\n       <ArtistID></ArtistID>"
                + "\n       <AlbumID></AlbumID>"
                + "\n       <ArtistName></ArtistName>"
                + "\n       <AlbumTitle></AlbumTitle>"
                + "&[Song]&"
                + "\n     </LongestPlayingSongTitle>";

            String shorestPlayingSongTitleXMLTemplate =
                "\n     <ShorestPlayingSongTitle>"
                + "\n       <ArtistID></ArtistID>"
                + "\n       <AlbumID></AlbumID>"
                + "\n       <ArtistName></ArtistName>"
                + "\n       <AlbumTitle></AlbumTitle>"
                + "&[Song]&"
                + "\n     </ShorestPlayingSongTitle>";

            String statsByGenreXMLTemplate =
                "\n       <Category>"
                + "\n         <Genre></Genre>"
                + "\n         <Artist></Artist>"
                + "\n         <Albums></Albums>"
                + "\n         <SongTitles></SongTitles>"
                + "\n         <PlayTime></PlayTime>"
                + "\n         <StorageUsage></StorageUsage>"
                + "\n         <UFPlayTime></UFPlayTime>"
                + "\n         <UFStorageUsage></UFStorageUsage>"
                + "\n       </Category>";

            String artistXMLTemplate =
                "\n   <Artist>"
                + "\n     <ArtistID></ArtistID>"
                + "\n     <ArtistName></ArtistName>"
                + "\n     <NumberOfAlbums></NumberOfAlbums>"
                + "\n     <ArtistPlayTime></ArtistPlayTime>"
                + "\n     <ArtistStorageUsage></ArtistStorageUsage>"
                + "\n     <GoogleSearch></GoogleSearch>"
                + "\n     <BingSearch></BingSearch>"
                + "\n     <StrongSearchKey></StrongSearchKey>"
                + "\n     <WeakSearchKey></WeakSearchKey>"
                + "\n     <NumericSearchKey></NumericSearchKey>"
                + "\n     <NumericLowRangeSearchKey></NumericLowRangeSearchKey>"
                + "\n     <NumericHighRangeSearchKey></NumericHighRangeSearchKey>"
                + "&[Albums]&"
                + "\n   </Artist>";

            String albumXMLTemplate =
                "\n    <Album>"
                + "\n      <AlbumID></AlbumID>"
                + "\n      <AlbumTitle></AlbumTitle>"
                + "\n      <AlbumGenre></AlbumGenre>"
                + "\n      <NumberOfSongs></NumberOfSongs>"
                + "\n      <AlbumPlayTime></AlbumPlayTime>"
                + "\n      <AlbumStorageUsage></AlbumStorageUsage>"
                + "\n      <UFAlbumPlayTime></UFAlbumPlayTime>"
                + "\n      <UFAlbumStorageUsage></UFAlbumStorageUsage>"
                + "\n      <StrongSearchKey></StrongSearchKey>"
                + "\n      <WeakSearchKey></WeakSearchKey>"
                + "\n      <NumericSearchKey></NumericSearchKey>"
                + "\n      <NumericLowRangeSearchKey></NumericLowRangeSearchKey>"
                + "\n      <NumericHighRangeSearchKey></NumericHighRangeSearchKey>"
                + "&[Songs]&"
                + "\n    </Album>";

            String songXMLTemplate =
                "\n      <Song>"
                + "\n        <SongID></SongID>"
                + "\n        <SongTitle></SongTitle>"
                + "\n        <Genre></Genre>"
                + "\n        <Track></Track>"
                + "\n        <SongPlayTime></SongPlayTime>"
                + "\n        <Year></Year>"
                + "\n        <MediaType></MediaType>"
                + "\n        <MediaFormat></MediaFormat>"
                + "\n        <SampleBitRate></SampleBitRate>"
                + "\n        <BitRate></BitRate>"
                + "\n        <AudioChannels></AudioChannels>"
                + "\n        <FileName></FileName>"
                + "\n        <FileType></FileType>"
                + "\n        <FileLocation></FileLocation>"
                + "\n        <FileSize></FileSize>"
                + "\n        <FileLastModified></FileLastModified>"
                + "\n        <UFSongPlayTime></UFSongPlayTime>"
                + "\n        <UFFileSize></UFFileSize>"
                + "\n        <UFFileLastModified></UFFileLastModified>"
                + "\n        <RealHelexServerUrl></RealHelexServerUrl>"
                + "\n        <WindowsMediaServerUrl></WindowsMediaServerUrl>"
                + "\n        <StrongSearchKey></StrongSearchKey>"
                + "\n        <WeakSearchKey></WeakSearchKey>"
                + "\n        <NumericSearchKey></NumericSearchKey>"
                + "\n        <NumericLowRangeSearchKey></NumericLowRangeSearchKey>"
                + "\n        <NumericHighRangeSearchKey></NumericHighRangeSearchKey>"
                + "\n      </Song>";

            // Load XML templates into memory...
            XMLWriter.LoadXMLTemplate("jobInfoXMLTemplate", jobInfoXMLTemplate);
            XMLWriter.LoadXMLTemplate("statisticsXMLTemplate", statisticsXMLTemplate);
            XMLWriter.LoadXMLTemplate("longestPlayingSongTitleXMLTemplate", longestPlayingSongTitleXMLTemplate);
            XMLWriter.LoadXMLTemplate("shorestPlayingSongTitleXMLTemplate", shorestPlayingSongTitleXMLTemplate);
            XMLWriter.LoadXMLTemplate("statsByGenreXMLTemplate", statsByGenreXMLTemplate);
            XMLWriter.LoadXMLTemplate("artistXMLTemplate", artistXMLTemplate);
            XMLWriter.LoadXMLTemplate("albumXMLTemplate", albumXMLTemplate);
            XMLWriter.LoadXMLTemplate("songXMLTemplate", songXMLTemplate);

            // Configuration based on file name + Config.xml automatically loaded...
            // Get catalog directory...
            sCatalogDirectory = GetSettings("/Music/Catalog/ScanFolder");

            // Get MP3 XML DB file name...
            sMP3XMLDBFile = GetSettings("/Music/Catalog/LibraryFile");

            // Get MP3 XML summary file name...
            sMP3XMLDBSummaryFile = GetSettings("/Music/Catalog/SummaryFile");

            // Get HelexServer Url...
            sRealPlayerServerUrl = GetSettings("/Music/PlaybackServers/RealHelexServerUrl");

            // Get MediaServer Url...
            sMediaPlayerServerUrl = GetSettings("/Music/PlaybackServers/WindowsMediaServerUrl");

            // Get Google search Url...
            sGoogleSearchUrl = GetSettings("/Music/SearchEngines/GoodleUrl");

            // Get MSN Bing search Url...
            sMSNBingSearchUrl = GetSettings("/Music/SearchEngines/BingUrl");

            // Create XML DB file...
            XMLWriter.Open(sMP3XMLDBFile);
            XMLWriter.RootNode  = "MusicCatalog";
            XMLWriter.DTD       = "DTD/" + pdamxUtility.StripPath(sMP3XMLDBFile, true);
            XMLWriter.Namespace = "http://www.pdamediax.com/mp3xmldb";

            //Write XML content to console stream or file...
            XMLWriter.CopyXMLTemplate("jobInfoXMLTemplate");
            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.Write(XMLWriter.GetXMLTemplate("jobInfoXMLTemplate"));

            //Get List of MP3'S directories (by genre)..
            diDirectoryInfo = new DirectoryInfo(sCatalogDirectory);
            DirectoryInfo[] dirInfo = diDirectoryInfo.GetDirectories();
            lSubtotals = new long[dirInfo.Count(), 5];
            sGenre     = new String[dirInfo.Count()];
            XMLWriter.CopyXMLTemplate("artistXMLTemplate");
            XMLWriter.CopyXMLTemplate("albumXMLTemplate");
            mxSearchKeyGen = new pdamxSearchKeyGen();
            foreach (DirectoryInfo dir in dirInfo)
            {
                sGenre[nGenreCnt] = dir.Name;
                if (sGenre[nGenreCnt].ToLower().Equals("randb"))
                {
                    sGenre[nGenreCnt] = "R&amp;B";
                }
                FileInfo[] fileInfo = dir.GetFiles("*.mp3");
                Array.Sort <FileInfo>(fileInfo, delegate(FileInfo a, FileInfo b) { return(getSortName(a).CompareTo(getSortName(b))); });
                foreach (FileInfo file in fileInfo)
                {
                    nFilesRead++;
                    XMLWriter.CopyXMLTemplate("songXMLTemplate");

                    mxAudioProperties = new pdamxAudioProperties(file);

                    if (bStart)
                    {
                        sPrevAlbum      = stripSpeciallChars(mxAudioProperties.AlbumTitle);
                        sPreviousArtist = stripSpeciallChars(mxAudioProperties.Artist);
                        bStart          = false;
                    }
                    if (sPrevAlbum.ToLower() != stripSpeciallChars(mxAudioProperties.AlbumTitle.ToLower()))
                    {
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumID", Convert.ToString(lAlbumID));
                        mxSearchKeyGen.GenerateKey(sPrevAlbum);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "StrongSearchKey", mxSearchKeyGen.StrongKey);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "WeakSearchKey", mxSearchKeyGen.WeakKey);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumericSearchKey", mxSearchKeyGen.NumericKey);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumericLowRangeSearchKey", mxSearchKeyGen.NumericLowRangeKey);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumericHighRangeSearchKey", mxSearchKeyGen.NumericHighRangeKey);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumGenre", sGenre[nGenreCnt]);
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumberOfSongs", Convert.ToString(nSongCnt));
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumPlayTime", pdamxUtility.FormatSeconds(tspAlbumPlayTime.Duration().TotalSeconds.ToString()));
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumStorageUsage", pdamxUtility.FormatStorageSize(Convert.ToString(lAlbumStorageUsage)));
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "UFAlbumStorageUsage", Convert.ToString(lAlbumStorageUsage));
                        XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "UFAlbumPlayTime", tspAlbumPlayTime.Duration().TotalSeconds.ToString());
                        XMLWriter.InsertXMLAtTemplateElementMarker("artistXMLTemplate", "Albums", "albumXMLTemplate");
                        XMLWriter.CopyXMLTemplate("albumXMLTemplate");
                        sPrevAlbum = stripSpeciallChars(mxAudioProperties.AlbumTitle);
                        lAlbums++;
                        nAlbumCnt++;
                        lAlbumID           = lAlbumID + nIncrementIDsBy;
                        nSongCnt           = 0;
                        lAlbumStorageUsage = 0;
                        tspAlbumPlayTime   = new TimeSpan();
                    }
                    if ((sPreviousArtist.ToLower() != stripSpeciallChars(mxAudioProperties.Artist.ToLower())))
                    {
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "ArtistID", Convert.ToString(lArtistID));
                        mxSearchKeyGen.GenerateKey(sPreviousArtist);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "StrongSearchKey", mxSearchKeyGen.StrongKey);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "WeakSearchKey", mxSearchKeyGen.WeakKey);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "NumericSearchKey", mxSearchKeyGen.NumericKey);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "NumericLowRangeSearchKey", mxSearchKeyGen.NumericLowRangeKey);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "NumericHighRangeSearchKey", mxSearchKeyGen.NumericHighRangeKey);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "NumberOfAlbums", Convert.ToString(nAlbumCnt));
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "ArtistPlayTime", pdamxUtility.FormatSeconds(Convert.ToString(lArtistPlayTime)));
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "ArtistStorageUsage", pdamxUtility.FormatStorageSize(Convert.ToString(lArtistStorageUsage)));
                        XMLWriter.Write(XMLWriter.GetXMLTemplate("artistXMLTemplate"));
                        XMLWriter.CopyXMLTemplate("artistXMLTemplate");

                        // Artist with most song titles...
                        if (nArtistTitleCnt > nArtistWithMostTitles)
                        {
                            nArtistWithMostTitles = nArtistTitleCnt;
                            sArtistWithMostTitles = sPreviousArtist;
                        }
                        sPreviousArtist = stripSpeciallChars(mxAudioProperties.Artist);
                        lArtist++;
                        lArtistID           = lArtistID + nIncrementIDsBy;
                        nAlbumCnt           = 0;
                        nArtistTitleCnt     = 0;
                        lArtistPlayTime     = 0;
                        lArtistStorageUsage = 0;
                    }
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "SongID", Convert.ToString(lSongID));
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "RealHelexServerUrl", sRealPlayerServerUrl + "/" + sGenre[nGenreCnt] + "/" + mxAudioProperties.FileName);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "WindowsMediaServerUrl", sMediaPlayerServerUrl + "/" + sGenre[nGenreCnt] + "/" + mxAudioProperties.FileName);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "SongTitle", mxAudioProperties.Title);
                    XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "ArtistName", mxAudioProperties.Artist);
                    if (mxAudioProperties.Artist.Length == 0)
                    {
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "GoogleSearch", mxAudioProperties.Artist);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "BingSearch", mxAudioProperties.Artist);
                    }
                    else
                    {
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "GoogleSearch", sGoogleSearchUrl + mxAudioProperties.Artist);
                        XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "BingSearch", sMSNBingSearchUrl + mxAudioProperties.Artist);
                    }
                    mxSearchKeyGen.GenerateKey(mxAudioProperties.Title);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "StrongSearchKey", mxSearchKeyGen.StrongKey);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "WeakSearchKey", mxSearchKeyGen.WeakKey);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "NumericSearchKey", mxSearchKeyGen.NumericKey);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "NumericLowRangeSearchKey", mxSearchKeyGen.NumericLowRangeKey);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "NumericHighRangeSearchKey", mxSearchKeyGen.NumericHighRangeKey);
                    XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumTitle", mxAudioProperties.AlbumTitle);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "Track", mxAudioProperties.Track);
                    tspAlbumPlayTime = tspAlbumPlayTime.Add(mxAudioProperties.Duration);
                    lPlayTime        = lPlayTime + Convert.ToInt64(mxAudioProperties.DurationInSeconds);
                    lArtistPlayTime  = lArtistPlayTime + Convert.ToInt64(mxAudioProperties.DurationInSeconds);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "SongPlayTime", mxAudioProperties.PlayTimeFormatted);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "UFSongPlayTime", mxAudioProperties.PlayTimeUnformatted);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "Genre", mxAudioProperties.Genre);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "Year", mxAudioProperties.AlbumYear);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "SampleBitRate", mxAudioProperties.AudioSampleBitRate);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "BitRate", mxAudioProperties.AudioBitRate);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "AudioChannels", mxAudioProperties.AudioChannels);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "MediaType", mxAudioProperties.MediaType);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "MediaFormat", mxAudioProperties.MediaFormat);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "FileName", mxAudioProperties.FileName);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "FileType", mxAudioProperties.FileType);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "FileLocation", mxAudioProperties.FileLocation);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "FileSize", mxAudioProperties.FileSizeFormatted);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "UFFileSize", mxAudioProperties.FileSizeUnformatted);
                    lAlbumStorageUsage  = lAlbumStorageUsage + mxAudioProperties.FileSize;
                    lArtistStorageUsage = lArtistStorageUsage + mxAudioProperties.FileSize;
                    lStorageUsage       = lStorageUsage + mxAudioProperties.FileSize;
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "FileLastModified", mxAudioProperties.LastWriteTimeFormatted);
                    XMLWriter.SetXMLTemplateElement("songXMLTemplate", "UFFileLastModified", mxAudioProperties.LastWriteTimeUnformatted);
                    lTitles++;
                    lSongID = lSongID + nIncrementIDsBy;
                    nArtistTitleCnt++;
                    nSongCnt++;
                    XMLWriter.InsertXMLAtTemplateElementMarker("albumXMLTemplate", "Songs", "songXMLTemplate");

                    // Longest playing song title...
                    if (mxAudioProperties.DurationInSeconds > dLongestPlayingSongTitle)
                    {
                        dLongestPlayingSongTitle         = mxAudioProperties.DurationInSeconds;
                        sLongestPlaySongTitle            = XMLWriter.GetXMLTemplate("songXMLTemplate");
                        sLongestPlaySongTitleArtist      = mxAudioProperties.Artist;
                        sLongestPlaySongTitleArtistAlbum = mxAudioProperties.AlbumTitle;
                        lLongestPlaySongTitleArtistID    = lArtistID;
                        lLongestPlaySongTitleAlbumID     = lAlbumID;
                    }
                    // Shortest playing song title...
                    if (mxAudioProperties.DurationInSeconds < dShorestPlayingSongTitle)
                    {
                        dShorestPlayingSongTitle         = mxAudioProperties.DurationInSeconds;
                        sShorestPlaySongTitle            = XMLWriter.GetXMLTemplate("songXMLTemplate");
                        sShorestPlaySongTitleArtist      = mxAudioProperties.Artist;
                        sShorestPlaySongTitleArtistAlbum = mxAudioProperties.AlbumTitle;
                        lShorestPlaySongTitleArtistID    = lArtistID;
                        lShorestPlaySongTitleAlbumID     = lAlbumID;
                    }
                    nFilesProcessed++;
                }
                // Accumlate Sub-totals....
                lSubtotals[nGenreCnt, 0] = lArtist;
                lSubtotals[nGenreCnt, 1] = lAlbums;
                lSubtotals[nGenreCnt, 2] = lTitles;
                lSubtotals[nGenreCnt, 3] = lPlayTime;
                lSubtotals[nGenreCnt, 4] = lStorageUsage;

                // Reset count for next genre...
                lArtist       = 0;
                lAlbums       = 0;
                lTitles       = 0;
                lPlayTime     = 0;
                lStorageUsage = 0;
                nGenreCnt++;
            }
            mxSearchKeyGen.GenerateKey(sPrevAlbum);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "StrongSearchKey", mxSearchKeyGen.StrongKey);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "WeakSearchKey", mxSearchKeyGen.WeakKey);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumericSearchKey", mxSearchKeyGen.NumericKey);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumericLowRangeSearchKey", mxSearchKeyGen.NumericLowRangeKey);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumericHighRangeSearchKey", mxSearchKeyGen.NumericHighRangeKey);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumID", Convert.ToString(lAlbumID));
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumGenre", sGenre[nGenreCnt - 1]);
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "NumberOfSongs", Convert.ToString(nSongCnt));
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumPlayTime", pdamxUtility.FormatSeconds(tspAlbumPlayTime.Duration().TotalSeconds.ToString()));
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "AlbumStorageUsage", pdamxUtility.FormatStorageSize(Convert.ToString(lAlbumStorageUsage)));
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "UFAlbumStorageUsage", Convert.ToString(lAlbumStorageUsage));
            XMLWriter.SetXMLTemplateElement("albumXMLTemplate", "UFAlbumPlayTime", tspAlbumPlayTime.Duration().TotalSeconds.ToString());
            XMLWriter.InsertXMLAtTemplateElementMarker("artistXMLTemplate", "Albums", "albumXMLTemplate");
            XMLWriter.SetXMLTemplateElement("artistXMLTemplate", "NumberOfAlbums", Convert.ToString(nAlbumCnt));
            XMLWriter.Write(XMLWriter.GetXMLTemplate("artistXMLTemplate"));
            XMLWriter.Close();

            XMLWriter.Open(sMP3XMLDBSummaryFile);
            XMLWriter.RootNode  = "MusicCatalogSummary";
            XMLWriter.DTD       = "DTD/" + pdamxUtility.StripPath(sMP3XMLDBSummaryFile, true);
            XMLWriter.Namespace = "http://www.pdamediax.com/mp3xmldbsummary";
            XMLWriter.Write(XMLWriter.GetXMLTemplate("jobInfoXMLTemplate"));
            XMLWriter.CopyXMLTemplate("statisticsXMLTemplate");

            // Build by genre xml subtotal section...
            for (int i = 0; i < nGenreCnt; i++)
            {
                XMLWriter.CopyXMLTemplate("statsByGenreXMLTemplate");
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "Genre", sGenre[i]);
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "Artist", Convert.ToString(lSubtotals[i, 0]));
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "Albums", Convert.ToString(lSubtotals[i, 1]));
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "SongTitles", Convert.ToString(lSubtotals[i, 2]));
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "PlayTime", pdamxUtility.FormatSeconds(Convert.ToString(lSubtotals[i, 3])));
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "StorageUsage", pdamxUtility.FormatStorageSize(Convert.ToString(lSubtotals[i, 4])));
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "UFPlayTime", Convert.ToString(lSubtotals[i, 3]));
                XMLWriter.SetXMLTemplateElement("statsByGenreXMLTemplate", "UFStorageUsage", Convert.ToString(lSubtotals[i, 4]));
                XMLWriter.InsertXMLAtTemplateElementMarker("statisticsXMLTemplate", "StatisticsByGenre", "statsByGenreXMLTemplate");

                lTotArtist       = lTotArtist + lSubtotals[i, 0];
                lTotAlbums       = lTotAlbums + lSubtotals[i, 1];
                lTotTitles       = lTotTitles + lSubtotals[i, 2];
                lTotPlayTime     = lTotPlayTime + lSubtotals[i, 3];
                lTotStorageUsage = lTotStorageUsage + lSubtotals[i, 4];

                if (lSubtotals[i, 2] > lGenreWithMostTitles)
                {
                    lGenreWithMostTitles = lSubtotals[i, 2];
                    sGenreWithMostTitles = sGenre[i];
                }
                if (lSubtotals[i, 4] > lGenreUsingMostStorage)
                {
                    lGenreUsingMostStorage = lSubtotals[i, 4];
                    sGenreUsingMostStorage = sGenre[i];
                }
                if (lSubtotals[i, 3] > lLongestPlayingGenre)
                {
                    lLongestPlayingGenre = lSubtotals[i, 3];
                    sLongestPlayingGenre = sGenre[i];
                }
            }
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "Artist", Convert.ToString(lTotArtist));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "Albums", Convert.ToString(lTotAlbums));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "SongTitles", Convert.ToString(lTotTitles));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "Genres", Convert.ToString(nGenreCnt));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "PlayTime", pdamxUtility.FormatSeconds(Convert.ToString(lTotPlayTime)));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "StorageUsage", pdamxUtility.FormatStorageSize(Convert.ToString(lTotStorageUsage)));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "UFPlayTime", Convert.ToString(lTotPlayTime));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "UFStorageUsage", Convert.ToString(lTotStorageUsage));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "StatisticsByGenre", sSubTotalList);
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "ArtistWithMostTitles", sArtistWithMostTitles);
            XMLWriter.SetXMLTemplateElementAttribute("statisticsXMLTemplate", "ArtistWithMostTitles", "NumberOfSongs", Convert.ToString(nArtistWithMostTitles));
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "GenreWMostTitles", Convert.ToString(lGenreWithMostTitles));
            XMLWriter.SetXMLTemplateElementAttribute("statisticsXMLTemplate", "GenreWMostTitles", "Genre", sGenreWithMostTitles);
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "GenreUsingMostStorage", pdamxUtility.FormatStorageSize(Convert.ToString(lGenreUsingMostStorage)));
            XMLWriter.SetXMLTemplateElementAttribute("statisticsXMLTemplate", "GenreUsingMostStorage", "Genre", sGenreUsingMostStorage);
            XMLWriter.SetXMLTemplateElement("statisticsXMLTemplate", "LongestPlayingGenre", pdamxUtility.FormatSeconds(Convert.ToString(lLongestPlayingGenre)));
            XMLWriter.SetXMLTemplateElementAttribute("statisticsXMLTemplate", "LongestPlayingGenre", "Genre", sLongestPlayingGenre);
            XMLWriter.CopyXMLTemplate("longestPlayingSongTitleXMLTemplate");

            XMLWriter.SetXMLTemplateElement("longestPlayingSongTitleXMLTemplate", "ArtistID", Convert.ToString(lLongestPlaySongTitleArtistID));
            XMLWriter.SetXMLTemplateElement("longestPlayingSongTitleXMLTemplate", "AlbumID", Convert.ToString(lLongestPlaySongTitleAlbumID));
            XMLWriter.SetXMLTemplateElement("longestPlayingSongTitleXMLTemplate", "ArtistName", sLongestPlaySongTitleArtist);
            XMLWriter.SetXMLTemplateElement("longestPlayingSongTitleXMLTemplate", "AlbumTitle", sLongestPlaySongTitleArtistAlbum);
            XMLWriter.ReplactXMPTemplateElementMarker("longestPlayingSongTitleXMLTemplate", "Song", sLongestPlaySongTitle);
            XMLWriter.CopyXMLTemplate("shorestPlayingSongTitleXMLTemplate");

            XMLWriter.SetXMLTemplateElement("shorestPlayingSongTitleXMLTemplate", "ArtistID", Convert.ToString(lShorestPlaySongTitleArtistID));
            XMLWriter.SetXMLTemplateElement("shorestPlayingSongTitleXMLTemplate", "AlbumID", Convert.ToString(lShorestPlaySongTitleAlbumID));
            XMLWriter.SetXMLTemplateElement("shorestPlayingSongTitleXMLTemplate", "ArtistName", sShorestPlaySongTitleArtist);
            XMLWriter.SetXMLTemplateElement("shorestPlayingSongTitleXMLTemplate", "AlbumTitle", sShorestPlaySongTitleArtistAlbum);
            XMLWriter.ReplactXMPTemplateElementMarker("shorestPlayingSongTitleXMLTemplate", "Song", sShorestPlaySongTitle);
            XMLWriter.ReplactXMPTemplateElementMarker("statisticsXMLTemplate", "LongestPlaySongTitle", "longestPlayingSongTitleXMLTemplate");
            XMLWriter.ReplactXMPTemplateElementMarker("statisticsXMLTemplate", "ShorestPlaySongTitle", "shorestPlayingSongTitleXMLTemplate");
            XMLWriter.Write(XMLWriter.GetXMLTemplate("statisticsXMLTemplate"));
            XMLWriter.Close();


            // Job Summary...
            WriteEndofJobSummaryToFile = true;
            AddSummaryExtra("");
            AddSummaryExtra("Music Library (MP3's) Processing Summary");
            AddSummaryExtra("");
            AddSummaryExtra("  Music Directory:        " + diDirectoryInfo.FullName);
            AddSummaryExtra("");
            AddSummaryExtra("  Music files Read:       " + pdamxUtility.FormatNumber(nFilesRead));
            AddSummaryExtra("  Music files Processed:  " + pdamxUtility.FormatNumber(nFilesProcessed));
            AddSummaryExtra("  Storage Used:           " + pdamxUtility.FormatStorageSize(Convert.ToString(lTotStorageUsage)));
            AddSummaryExtra("  Total Playtime:         " + pdamxUtility.FormatSecondsInText(Convert.ToString(lTotPlayTime)));

            AddSummaryExtra("");
            AddSummaryExtra("  Number of Artist:       " + pdamxUtility.FormatNumber(Convert.ToInt32(lTotArtist)));
            AddSummaryExtra("  Number of Albums:       " + pdamxUtility.FormatNumber(Convert.ToInt32(lTotAlbums)));
            AddSummaryExtra("  Number of Titles:       " + pdamxUtility.FormatNumber(Convert.ToInt32(lTotTitles)));

            fiFileSummary = new FileInfo(sMP3XMLDBFile);
            AddSummaryExtra("");
            AddSummaryExtra("Music Library (MP3's) XML 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));

            fiFileSummary = new FileInfo(sMP3XMLDBSummaryFile);
            AddSummaryExtra("");
            AddSummaryExtra("Music Library (MP3's) XML Data File Summary 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();
        }
Beispiel #3
0
        virtual public void getRecordingInfo(BTVDispatcher.PVSPropertyBag rec, string xmlTemplate)
        {
            DateTimeFormatInfo timeFormat         = new CultureInfo("en-US", false).DateTimeFormat;
            pdamxSearchKeyGen  mxSearchKeyGen     = new pdamxSearchKeyGen();
            string             recordingInfo      = xmlTemplate;
            string             description        = "";
            string             episodeDescription = "";
            string             stationCallSign    = "";
            string             isHDBroadcast      = "";
            string             isEpisode          = "No";

            XMLWriter.CopyXMLTemplate(xmlTemplate);
            foreach (BTVDispatcher.PVSProperty prop in rec.Properties)
            {
                if (prop.Name == "DisplayTitle")
                {
                    mxSearchKeyGen.GenerateKey(prop.Value.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Title", prop.Value.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TitleStrongSearchKey", mxSearchKeyGen.StrongKey);
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TVGuideSearch", sTVGuideSearchUrl + prop.Value.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TVDotComSearch", sTVComSearchUrl + prop.Value.Trim());
                }
                if (prop.Name == "Channel")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Channel", prop.Value.Trim());
                }
                if (prop.Name == "StationName")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "StationName", prop.Value.Trim());
                }
                if (prop.Name == "StationCallsign")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "StationCallSign", prop.Value.Trim());
                    stationCallSign = prop.Value.Trim().ToUpper();
                }
                if (prop.Name == "Actors")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Actors", prop.Value.Trim());
                }
                if (prop.Name == "Credits")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Credits", prop.Value.Trim());
                }
                if (prop.Name == "Genre")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Genre", prop.Value.Trim());
                }
                if (prop.Name == "TargetStart")
                {
                    DateTime startTime = DateTime.FromFileTime(Convert.ToInt64(prop.Value.Trim()));
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TargetStartTime", startTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", timeFormat));
                }
                if (prop.Name == "ActualStart")
                {
                    DateTime startTime = DateTime.FromFileTime(Convert.ToInt64(prop.Value.Trim()));
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "ActualStartTime", startTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", timeFormat));
                }
                if (prop.Name == "ActualDuration")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "ActualDuration", pdamxUtility.FormatNanoseconds(prop.Value));
                }
                if (prop.Name == "TargetDuration")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "TargetDuration", pdamxUtility.FormatNanoseconds(prop.Value));
                }
                if (prop.Name == "Description")
                {
                    description = prop.Value.Trim();
                }
                if (prop.Name == "EpisodeDescription")
                {
                    episodeDescription = prop.Value.Trim();
                }

                if (prop.Name == "EpisodeTitle")
                {
                    mxSearchKeyGen.GenerateKey(prop.Value.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "EpisodeTitle", prop.Value.Trim());
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "EpisodeStrongSearchKey", mxSearchKeyGen.StrongKey);
                    //if (prop.Value.Trim() != "")
                    isEpisode = "Yes";
                }

                if (prop.Name == "OriginalAirDate")
                {
                    if (prop.Value.Trim() == "")
                    {
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", "");
                    }
                    else
                    {
                        DateTime startTime = new DateTime(Convert.ToInt32(prop.Value.Substring(0, 4)),
                                                          Convert.ToInt32(prop.Value.Substring(4, 2)),
                                                          Convert.ToInt32(prop.Value.Substring(6, 2)));
                        XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "OriginalAirDate", startTime.ToString("d", timeFormat));
                    }
                }
                if (prop.Name == "Rating")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Rating", prop.Value.Trim());
                }
                if (prop.Name == "MovieYear")
                {
                    XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "MovieYear", prop.Value.Trim());
                }
                if (prop.Name == "IsHD")
                {
                    isHDBroadcast = prop.Value;
                }
            }
            XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsEpisode", isEpisode);
            if (episodeDescription.Equals(""))
            {
                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Description", description.ToLower());
            }
            else
            {
                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "Description", episodeDescription);
            }
            if (stationCallSign.Equals("WCBS") | stationCallSign.Equals("WNBC")
                | stationCallSign.Equals("WNYW") | stationCallSign.Equals("WABC")
                | stationCallSign.Equals("WWOR") | stationCallSign.Equals("WPIX")
                | stationCallSign.Equals("WNET") | stationCallSign.Equals("WPXN"))
            {
                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDBroadcast", "Yes");
                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDRecording", "Yes");
            }
            else
            {
                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDBroadcast", (isHDBroadcast == "Y") ? "Yes" : "No");
                XMLWriter.SetXMLTemplateElement("recordingsXMLTemplate", "IsHDRecording", "No");
            }
        }
Beispiel #4
0
        public BTVSchedule(string [] args)
        {
            BTVLicenseManager.BTVLicenseManager btvLicenseManager;
            BTVGuideUpdater.BTVGuideUpdater     btvGuideUpdater;
            BTVDispatcher.BTVDispatcher         btvDispatcher;
            BTVScheduler.BTVScheduler           btvScheduler;

            DateTime           dtDateTime;
            DateTimeFormatInfo dtFormat = new CultureInfo("en-US", false).DateTimeFormat;
            FileInfo           fiFileSummary;

            int  iNumberOfUpCommingShows    = 0;
            int  iNumberOfsActiveRecordings = 0;
            int  iNumberOfNextShows         = 0;
            bool bAllNextShowsFound         = false;

            String sNetworkLicense     = "";
            String sNetworkLicenseFile = "";
            String sUserAccessFile     = "";
            String sUser     = "";
            String sPassword = "";

            String sAuthTicket = "";
            String sUpcomingRecsTotalDuration = "";
            String sXMLOutFile        = "";
            String sPreviousStartTime = "";

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


            String jobInfoXMLTemplate =
                "\n   <JobInfo>"
                + "\n      <Generated></Generated>"
                + "\n      <Generator></Generator>"
                + "\n      <Machine></Machine>"
                + "\n      <OS></OS>"
                + "\n      <OSVersion></OSVersion>"
                + "\n      <BTVServer>"
                + "\n         <Host></Host>"
                + "\n         <Port></Port>"
                + "\n         <Version></Version>"
                + "\n         <GuideUpdate>"
                + "\n            <GuideLastUpdateAttempt></GuideLastUpdateAttempt>"
                + "\n            <GuideNextUpdateAttempt></GuideNextUpdateAttempt>"
                + "\n            <GuideLastSuccessfulUpdate></GuideLastSuccessfulUpdate>"
                + "\n         </GuideUpdate>"
                + "\n      </BTVServer>"
                + "\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");

            // Test section...

            // pdamxBeyondTV mxBeyondTV = new pdamxBeyondTV(GetSettings("/BeyondTV/License/NetworkLicense"),
            //     GetSettings("/BeyondTV/License/User"));

            //mxBeyondTV.SearchGuide("Batman Beyond");
            //Console.ReadKey();
            //mxBeyondTV.GetProgramByEPGID("MV0068340000");

            // 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...
            sNetworkLicenseFile = GetSettings("/BeyondTV/License/NetworkLicense");

            if (sNetworkLicenseFile.ToLower().Contains(".edf"))
            {
                sNetworkLicense = Crypter.DecryptFile(sNetworkLicenseFile);
            }
            else
            {
                sNetworkLicense = sNetworkLicenseFile;
            }

            // Get BeyondTV user account...
            sUserAccessFile = GetSettings("/BeyondTV/License/User");
            String[] sAccess;
            if (sUserAccessFile.ToLower().Contains(".edf"))
            {
                sAccess = Crypter.DecryptFile(sUserAccessFile).Split('/');
            }
            else
            {
                sAccess = sUserAccessFile.Split('/');
            }
            sUser     = sAccess[0];
            sPassword = sAccess[1];

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

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

            // Log into BeyondTV Server ...
            try
            {
                btvLicenseManager = new BTVLicenseManager.BTVLicenseManager();
                BTVLicenseManager.PVSPropertyBag licenseInfo = btvLicenseManager.LogonRemote(sNetworkLicense, sUser, sPassword);
                foreach (BTVLicenseManager.PVSProperty prop in licenseInfo.Properties)
                {
                    if (prop.Name == "AuthTicket")
                    {
                        sAuthTicket = prop.Value;
                    }
                }
            }
            catch (Exception)
            {
                return;
            }
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Version", btvLicenseManager.GetVersionNumber());
            string url = btvLicenseManager.Url;

            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Host", url.Substring(url.LastIndexOf("//") + 2, url.LastIndexOf(":") - (url.LastIndexOf("//") + 2)));
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "Port", url.Substring(url.LastIndexOf(":") + 1, url.LastIndexOf(":", (url.LastIndexOf("/") + 1) - (url.LastIndexOf(":") + 1))));

            // Get guide information...
            btvGuideUpdater = new BTVGuideUpdater.BTVGuideUpdater();
            dtDateTime      = DateTime.FromFileTime(Convert.ToInt64(btvGuideUpdater.GetLastSuccessfulUpdate(sAuthTicket)));
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "GuideLastSuccessfulUpdate", dtDateTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
            dtDateTime = DateTime.FromFileTime(Convert.ToInt64(btvGuideUpdater.GetLastAttemptedUpdate(sAuthTicket)));
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "GuideLastUpdateAttempt", dtDateTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));
            dtDateTime = DateTime.FromFileTime(Convert.ToInt64(btvGuideUpdater.GetNextAttemptedUpdate(sAuthTicket)));
            XMLWriter.SetXMLTemplateElement("jobInfoXMLTemplate", "GuideNextUpdateAttempt", dtDateTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat));

            //Get active recordings...
            btvDispatcher = new BTVDispatcher.BTVDispatcher();
            BTVDispatcher.PVSPropertyBag[] activeRecs = btvDispatcher.GetActiveRecordings(sAuthTicket);
            foreach (BTVDispatcher.PVSPropertyBag rec in activeRecs)
            {
                XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
                getRecordingInfo(rec, "recordingsXMLTemplate");
                XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "ActiveRecordings", "recordingsXMLTemplate");
                iNumberOfsActiveRecordings++;
            }

            // Get upcoming recordings...
            btvScheduler = new BTVScheduler.BTVScheduler();
            BTVScheduler.PVSPropertyBag[] upcomingRecs = btvScheduler.GetUpcomingRecordings(sAuthTicket);
            foreach (BTVScheduler.PVSPropertyBag rec in upcomingRecs)
            {
                XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
                getRecordingInfo(rec, "recordingsXMLTemplate");
                XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "UpcommingRecordings", "recordingsXMLTemplate");

                if (bAllNextShowsFound) // Only contine to code below if all next shows haven't been processed...
                {
                    iNumberOfUpCommingShows++;
                    continue;
                }
                if (iNumberOfUpCommingShows >= iNumberOfsActiveRecordings) // Set next recordings (skip active recordings)...
                {
                    string startTime = "";
                    foreach (BTVScheduler.PVSProperty prop in rec.Properties)
                    {
                        if (prop.Name == "TargetStart")
                        {
                            DateTime dtStartTime = DateTime.FromFileTime(Convert.ToInt64(prop.Value.Trim()));
                            startTime = dtStartTime.ToString("MM/dd/yyyy (hh:mm:ss tt)", dtFormat);
                            break;
                        }
                    }
                    if ((startTime == sPreviousStartTime) ||
                        (iNumberOfUpCommingShows == iNumberOfsActiveRecordings))    // More then one show schedule at the same time...
                    {
                        XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
                        getRecordingInfo(rec, "recordingsXMLTemplate");
                        XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "NextRecording", "recordingsXMLTemplate");
                        sPreviousStartTime = startTime;
                        iNumberOfNextShows++;
                    }
                    else
//                    {
//                        if (iNumberOfUpCommingShows == iNumberOfsActiveRecordings)
//                        {
//                            XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
//                            getRecordingInfo(rec, XMLWriter, "recordingsXMLTemplate");
//                            XMLWriter.InsertXMLAtTemplateElementMarker("rootXMLNodeTemplate", "NextRecording", "recordingsXMLTemplate");
//                            sPreviousStartTime = startTime;
//                            iNumberOfNextShows++;
//                        }
//                        else
                    {
                        bAllNextShowsFound = true;     // All next shows found...
                    }
//                    }
                }
                iNumberOfUpCommingShows++;
            }

            // Get upcoming recordings duration...
            sUpcomingRecsTotalDuration = pdamxUtility.FormatNanoseconds(Convert.ToString(btvScheduler.GetUpcomingRecordingDuration(sAuthTicket)));

            // Get last recording...
            XMLWriter.CopyXMLTemplate("recordingsXMLTemplate");
            getRecordingInfo(btvScheduler.GetLastRecording(sAuthTicket), "recordingsXMLTemplate");
            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", "ActiveRecordings", "NumberOfShows", Convert.ToString(iNumberOfsActiveRecordings));
            XMLWriter.SetXMLTemplateElementAttribute("rootXMLNodeTemplate", "UpcomingRecordings", "NumberOfShows", Convert.ToString(iNumberOfUpCommingShows));
            XMLWriter.SetXMLTemplateElementAttribute("rootXMLNodeTemplate", "NextRecording", "NumberOfShows", Convert.ToString(iNumberOfNextShows));
            XMLWriter.SetXMLTemplateElementAttribute("rootXMLNodeTemplate", "UpcomingRecordings", "Duration", sUpcomingRecsTotalDuration);
            XMLWriter.ReplactXMPTemplateElementMarker("rootXMLNodeTemplate", "JobInfo", "jobInfoXMLTemplate");
            btvLicenseManager.Logoff(sAuthTicket);

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

            if (sXMLOutFile != "") //Write to file...
            {
                fiFileSummary = new FileInfo(sXMLOutFile);
                AddSummaryExtra("");
                AddSummaryExtra("BeyondTV 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;
        }
Beispiel #5
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;
        }
Beispiel #6
0
        public TivoNowPlaying()
        {
            pdamxTivo mxTivo;
            Hashtable hResultSet;
            FileInfo  fiFileInfo;
            String    sNowPlayingFile;
            String    sSettopName = "";

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

            String summaryXMLTemplate =
                "\n    <Summary>"
                + "\n      <SettopName></SettopName>"
                + "\n      <SettopIP></SettopIP>"
                + "\n      <SettopUrl></SettopUrl>"
                + "\n      <MediaKey></MediaKey>"
                + "\n      <ScheduledRecordings></ScheduledRecordings>"
                + "\n      <TotalItems></TotalItems>"
                + "\n      <GlobalSort></GlobalSort>"
                + "\n      <SortOrder></SortOrder>"
                + "\n      <TotalStorageUsed></TotalStorageUsed>"
                + "\n      <TotalStoragedUsedByTivoSuggestions></TotalStoragedUsedByTivoSuggestions>"
                + "\n      <TotalSStorageUsedByScheduledRecordings></TotalSStorageUsedByScheduledRecordings>"
                + "\n      <TotalRecordingTime></TotalRecordingTime>"
                + "\n      <TotalRecordingTimeOfTivoSuggestions></TotalRecordingTimeOfTivoSuggestions>"
                + "\n      <TotalRecordingTimeOfScheduledRecordings></TotalRecordingTimeOfScheduledRecordings>"
                + "\n      <UFTotalStorageUsed></UFTotalStorageUsed>"
                + "\n      <UFTotalStoragedUsedByTivoSuggestions></UFTotalStoragedUsedByTivoSuggestions>"
                + "\n      <UFTotalSStorageUsedByScheduledRecordings></UFTotalSStorageUsedByScheduledRecordings>"
                + "\n      <UFTotalRecordingTime></UFTotalRecordingTime>"
                + "\n      <UFTotalRecordingTimeOfTivoSuggestions></UFTotalRecordingTimeOfTivoSuggestions>"
                + "\n      <UFTotalRecordingTimeOfScheduledRecordings></UFTotalRecordingTimeOfScheduledRecordings>"
                + "\n    </Summary>";

            String showXMLTemplate =
                "\n    <Show>"
                + "\n      <Title></Title>"
                + "\n      <ProgramId></ProgramId>"
                + "\n      <EpisodeTitle></EpisodeTitle>"
                + "\n      <EpisodeNumber></EpisodeNumber>"
                + "\n      <Description></Description>"
                + "\n      <Credits></Credits>"
                + "\n      <Genre></Genre>"
                + "\n      <MovieYear></MovieYear>"
                + "\n      <Channel></Channel>"
                + "\n      <StationName></StationName>"
                + "\n      <NetworkAffiliate></NetworkAffiliate>"
                + "\n      <PlayTime></PlayTime>"
                + "\n      <UFPlayTime></UFPlayTime>"
                + "\n      <ParentalRating></ParentalRating>"
                + "\n      <Advisory></Advisory>"
                + "\n      <StarRating></StarRating>"
                + "\n      <IsHDContent></IsHDContent>"
                + "\n      <IsRecording></IsRecording>"
                + "\n      <Recorded></Recorded>"
                + "\n      <StartTime></StartTime>"
                + "\n      <StopTime></StopTime>"
                + "\n      <TivoSuggestion></TivoSuggestion>"
                + "\n      <VidoeSize></VidoeSize>"
                + "\n      <UFVidoeSize></UFVidoeSize>"
                + "\n      <DownloadUrl></DownloadUrl>"
                + "\n      <SearchAll>All</SearchAll>"
                + "\n      <TitleStrongSearchKey></TitleStrongSearchKey>"
                + "\n      <EpisodeStrongSearchKey></EpisodeStrongSearchKey>"
                + "\n    </Show>";

            // Load XML templates into memory...
            XMLWriter.LoadXMLTemplate("jobInfoXMLTemplate", jobInfoXMLTemplate);
            XMLWriter.LoadXMLTemplate("summaryXMLTemplate", summaryXMLTemplate);
            XMLWriter.LoadXMLTemplate("showXMLTemplate", showXMLTemplate);

            sNowPlayingFile = GetSettings("/Tivo/NowPlayingFile");
            mxTivo          = new pdamxTivo();

            hResultSet = mxTivo.GetTivoNowPlayingList(GetSettings("/Tivo/TivoBoxUrl").Replace("Container=", "Container1="),
                                                      GetSettings("/Tivo/Credentals"),
                                                      GetSettings("/Tivo/TempDataFile"));

            if (hResultSet != null)
            {
                /*
                 * if (hResultSet.Count > 0)
                 * {
                 *  Hashtable hRecord = (Hashtable)hResultSet["1"];
                 *  if (hRecord != null)
                 *  {
                 *      if (hRecord["Title"] != null)
                 *          sSettopName = hRecord["Title"].ToString();
                 *  }
                 * }
                 * */
                if (hResultSet["Title"] != null)
                {
                    sSettopName = hResultSet["Title"].ToString();
                }
            }
            hResultSet = mxTivo.GetTivoNowPlayingList(GetSettings("/Tivo/TivoBoxUrl"),
                                                      GetSettings("/Tivo/Credentals"),
                                                      GetSettings("/Tivo/TempDataFile"));

            if (hResultSet != null)
            {
                if (hResultSet.Count > 0)
                {
                    XMLWriter.Open("result-" + GetSettings("/Tivo/TempDataFile"));
                    XMLWriter.RootNode  = "TivoNowPlaying";
                    XMLWriter.Namespace = "http://www.pdamediax.com/tivonowplaying";

                    XMLWriter.CopyXMLTemplate("jobInfoXMLTemplate");
                    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.Write(XMLWriter.GetXMLTemplate("jobInfoXMLTemplate"));

                    XMLWriter.CopyXMLTemplate("summaryXMLTemplate");
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "SettopName", sSettopName);
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "SettopIP", hResultSet["SettopIP"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "SettopUrl", hResultSet["SettopUrl"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "MediaKey", hResultSet["MediaKey"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "ScheduledRecordings", hResultSet["ScheduledRecordings"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalItems", hResultSet["ProcessCount"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "GlobalSort", hResultSet["GlobalSort"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "SortOrder", hResultSet["SortOrder"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalStorageUsed", hResultSet["TotalStorageUsed"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalStoragedUsedByTivoSuggestions", hResultSet["TotalStoragedUsedByTivoSuggestions"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalSStorageUsedByScheduledRecordings", hResultSet["TotalSStorageUsedByScheduledRecordings"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "UFTotalStorageUsed", hResultSet["UFTotalStorageUsed"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "UFTotalStoragedUsedByTivoSuggestions", hResultSet["UFTotalStoragedUsedByTivoSuggestions"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "UFTotalSStorageUsedByScheduledRecordings", hResultSet["UFTotalSStorageUsedByScheduledRecordings"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalRecordingTime", hResultSet["TotalRecordingTime"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalRecordingTimeOfTivoSuggestions", hResultSet["TotalRecordingTimeOfTivoSuggestions"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "TotalRecordingTimeOfScheduledRecordings", hResultSet["TotalRecordingTimeOfScheduledRecordings"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "UFTotalRecordingTime", hResultSet["UFTotalRecordingTime"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "UFTotalRecordingTimeOfTivoSuggestions", hResultSet["UFTotalRecordingTimeOfTivoSuggestions"].ToString());
                    XMLWriter.SetXMLTemplateElement("summaryXMLTemplate", "UFTotalRecordingTimeOfScheduledRecordings", hResultSet["UFTotalRecordingTimeOfScheduledRecordings"].ToString());
                    XMLWriter.Write(XMLWriter.GetXMLTemplate("summaryXMLTemplate"));

                    int nMaxRows = Convert.ToInt32(hResultSet["ProcessCount"].ToString());
                    XMLWriter.Write("\n  <ShowList>");
                    for (int nRowCnt = 0; nRowCnt < nMaxRows;)
                    {
                        XMLWriter.CopyXMLTemplate("showXMLTemplate");
                        Hashtable hRecord = (Hashtable)hResultSet[Convert.ToString(++nRowCnt)];
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Title", hRecord["Title"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "ProgramId", hRecord["ProgramId"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "EpisodeTitle", hRecord["EpisodeTitle"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "EpisodeNumber", hRecord["EpisodeNumber"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Description", hRecord["Description"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Credits", hRecord["Credits"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Genre", hRecord["Genre"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "MovieYear", hRecord["MovieYear"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Channel", hRecord["Channel"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "StationName", hRecord["StationName"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "NetworkAffiliate", hRecord["NetworkAffiliate"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "PlayTime", hRecord["Duration"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "UFPlayTime", hRecord["UFDuration"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "ParentalRating", hRecord["ParentalRating"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Advisory", hRecord["Advisory"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "StarRating", hRecord["StarRating"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "IsHDContent", hRecord["IsHDContent"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "IsRecording", hRecord["IsRecording"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "Recorded", hRecord["Recorded"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "StartTime", hRecord["StartTime"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "StopTime", hRecord["StopTime"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "TivoSuggestion", hRecord["TivoSuggestion"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "VidoeSize", hRecord["VidoeSize"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "UFVidoeSize", hRecord["UFVidoeSize"].ToString());


                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "DownloadUrl", hRecord["DownloadUrl"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "TitleStrongSearchKey", hRecord["TitleStrongSearchKey"].ToString());
                        XMLWriter.SetXMLTemplateElement("showXMLTemplate", "EpisodeStrongSearchKey", hRecord["EpisodeStrongSearchKey"].ToString());
                        XMLWriter.Write(XMLWriter.GetXMLTemplate("showXMLTemplate"));
                    }
                    XMLWriter.Write("\n  </ShowList>");
                    XMLWriter.Close();
                    File.Copy("result-" + GetSettings("/Tivo/TempDataFile"), sNowPlayingFile, true);
                    fiFileInfo = new FileInfo("result-" + GetSettings("/Tivo/TempDataFile"));
                    fiFileInfo.Delete();
                }
            }
        }