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; }
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&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(); }
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; }