Esempio n. 1
0
        public Hashtable SearchTivo(String _sSearchValue)
        {
            pdamxSearchKeyGen mxSearchKeyGen;

            String[] sMultiSearch;
            String[] sSearchValues;

            if (_sSearchValue == null)
            {
                return(null);
            }

            if (_sSearchValue.Trim().Length == 0)
            {
                return(null);
            }

            sMultiSearch = _sSearchValue.Split(';');
            if (sMultiSearch.Length == 0)
            {
                sMultiSearch    = new String[1];
                sMultiSearch[0] = _sSearchValue;
            }
            sSearchValues = new String[sMultiSearch.Length];

            mxSearchKeyGen = new pdamxSearchKeyGen();
            for (int i = 0; i < sMultiSearch.Length; i++)
            {
                mxSearchKeyGen.GenerateKey(sMultiSearch[i].Replace("\"", "").Replace(":", " - "));
                sSearchValues[i] = mxSearchKeyGen.StrongKey;
            }
            if (TivoRDMSSearch)
            {
                return(SearchTivoRDMSDB(sSearchValues));
            }
            else
            {
                return(SearchTivoXMLDB(sSearchValues));
            }
        }
Esempio n. 2
0
        public Hashtable GetTivoNowPlayingList(String _sSettopUrl, String _sCredentials, String _sTempDataFile)
        {
            String[] sAdvisoryList        = { "AL", "Language", "MV", "Mild Violence", "V", "Violence", "BN", "Brief Nudity", "N", "Nudity", "SC", "Strong Sexual Content", "GV", "Graphic Violence", "AC", "Adult Situations" };
            String[] sStarRatingList      = { "ONE", "*", "ONE POINT FIVE", "*½", "TWO", "**", "TWO POINT FIVE", "**½", "THREE", "***", "THREE POINT FIVE", "***½", "FOUR", "****", "FOUR POINT FIVE", "****½", "FIVE", "*****" };
            String[] sNetworAffiliateList = { "2", "CBS Affiliate", "4", "NBC Affiliate", "5", "Fox Affiliate", "7", "ABC Affiliate", "9", "MyNetworkTV Affiliate", "11", "CW Affiliate" };
            String   sNetworkAffiliate    = "";
            bool     bSeries5             = true;

            DateTimeFormatInfo timeFormat = new CultureInfo("en-US", false).DateTimeFormat;
            XPathNodeIterator  xpathINode;
            XPathNodeIterator  xpathINodeDetails;
            pdamxUrlReader     mxUrlReader;
            pdamxCrypter       mxCrypter;
            pdamxXMLReader     mxXMLReader;
            pdamxSearchKeyGen  mxSearchKeyGen;
            FileInfo           fiTempFileInfo;
            Hashtable          hResultSet = null;
            Hashtable          hRecord    = new Hashtable();
            String             sTempDataFile;

            String[] sCredentials;
            int      nRowCnt              = 0;
            int      nTotalChildren       = 0;
            int      nTivoItemCount       = 0;
            int      nEntriesRead         = 0;
            int      nSeries5StartPos     = 0;
            int      nSeries5NewStartPos  = 0;
            int      nScheduledRecordings = 0;
            long     lTotalRecordingTimeOfScheduledRecordings = 0;
            long     lTotalRecordingTimeOfTivoSuggestions     = 0;
            long     lTotalSStorageUsedByScheduledRecordings  = 0;
            long     lTotalStoragedUsedByTivoSuggestions      = 0;
            bool     bFirstPast = true;

            if (_sSettopUrl == null)
            {
                return(null);
            }

            if (_sCredentials == null)
            {
                return(null);
            }

            if (_sTempDataFile == null)
            {
                return(null);
            }

            if (_sSettopUrl.Length == 0)
            {
                return(null);
            }

            if (_sCredentials.Length == 0)
            {
                return(null);
            }

            if (_sTempDataFile.Length == 0)
            {
                return(null);
            }

            mxCrypter = new pdamxCrypter();
            if (_sCredentials.Contains(".edf"))
            {
                sCredentials = mxCrypter.DecryptFile(_sCredentials).Split('/');
            }
            else
            {
                sCredentials = _sCredentials.Split('/');
            }

            hResultSet    = new Hashtable();
            sTempDataFile = DateTime.Now.Millisecond + "-" + _sTempDataFile;
            while (bSeries5)
            {
                if (!_sSettopUrl.Contains("AnchorOffset") || _sSettopUrl.Contains("Container1"))
                {
                    bSeries5 = false;
                }
                if (bSeries5)
                {
                    _sSettopUrl         = _sSettopUrl.Replace("AnchorOffset=" + Convert.ToString(nSeries5StartPos), "AnchorOffset=" + Convert.ToString(nSeries5NewStartPos));
                    nSeries5NewStartPos = nSeries5NewStartPos + 50;
                }
                mxUrlReader = new pdamxUrlReader();
                mxUrlReader.AcceptInvalidSSLCertificate = true;
                mxUrlReader.UseCredentials = true;
                mxUrlReader.XMLFiltering   = true;
                mxUrlReader.UserCredentals = sCredentials;
                mxUrlReader.Url            = _sSettopUrl;
                mxUrlReader.WriteToFile    = sTempDataFile;

                if (mxUrlReader.OpenUrl() != null) // Temp file created successfully...
                {
                    mxXMLReader    = new pdamxXMLReader();
                    mxSearchKeyGen = new pdamxSearchKeyGen();
                    mxXMLReader.Open(sTempDataFile);
                    mxXMLReader.AddNamespace("tivo", "http://www.tivo.com/developer/calypso-protocol-1.6/");
                    if (mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:ItemCount") != null)
                    {
                        nTivoItemCount = Convert.ToInt32(mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:ItemCount"));
                    }

                    if (bSeries5)
                    {
                        nSeries5StartPos = Convert.ToInt32(mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:ItemStart"));
                    }
                    if (nTivoItemCount == 0)
                    {
                        break;
                    }
                    if (bFirstPast)
                    {
                        hResultSet.Add("Title", mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:Details/tivo:Title"));
                        if (Convert.ToInt32(mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:Details/tivo:TotalItems")) == 1)
                        {
                            fiTempFileInfo = new FileInfo(sTempDataFile);
                            fiTempFileInfo.Delete();
                            return(hResultSet);
                        }
                        hResultSet.Add("SortOrder", mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:SortOrder"));
                        hResultSet.Add("GlobalSort", mxXMLReader.GetNodeValue("/tivo:TiVoContainer/tivo:GlobalSort"));
                        hResultSet.Add("MediaKey", sCredentials[1]);
                        int nStartIdx = _sSettopUrl.IndexOf("//") + 2;
                        hResultSet.Add("SettopIP", _sSettopUrl.Substring(nStartIdx, _sSettopUrl.IndexOf(":", nStartIdx) - nStartIdx));
                        hResultSet.Add("SettopUrl", _sSettopUrl.Replace("&", "&amp;"));
                        bFirstPast = false;
                    }
                    xpathINode = mxXMLReader.GetNodePath("/tivo:TiVoContainer/tivo:Item/*");
                    while (xpathINode.MoveNext())
                    {
                        if (xpathINode.Current.Name.Equals("Details"))
                        {
                            hRecord           = new Hashtable();
                            nTotalChildren    = 0;
                            sNetworkAffiliate = "";
                            xpathINode.Current.MoveToFirstChild();
                            nEntriesRead++;

                            hRecord.Add("TivoSuggestion", "No");
                            do
                            {
                                if (xpathINode.Current.Name.Equals("Title"))
                                {
                                    mxSearchKeyGen.GenerateKey(xpathINode.Current.Value);
                                    hRecord.Add("Title", xpathINode.Current.Value);
                                    hRecord.Add("TitleStrongSearchKey", mxSearchKeyGen.StrongKey);
                                }
                                if (xpathINode.Current.Name.Equals("ProgramId"))
                                {
                                    hRecord.Add("ProgramId", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("EpisodeTitle"))
                                {
                                    mxSearchKeyGen.GenerateKey(xpathINode.Current.Value);
                                    hRecord.Add("EpisodeTitle", xpathINode.Current.Value);
                                    hRecord.Add("EpisodeStrongSearchKey", mxSearchKeyGen.StrongKey);
                                }
                                if (xpathINode.Current.Name.Equals("EpisodeNumber"))
                                {
                                    hRecord.Add("EpisodeNumber", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("Duration"))
                                {
                                    hRecord.Add("Duration", pdamxUtility.FormatMiliseconds(xpathINode.Current.Value));
                                    hRecord.Add("UFDuration", GetTimeInSeconds(pdamxUtility.FormatMiliseconds(xpathINode.Current.Value)));
                                }
                                if (xpathINode.Current.Name.Equals("CaptureDate"))
                                {
                                    hRecord.Add("RecordDate", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("Description"))
                                {
                                    hRecord.Add("Description", xpathINode.Current.Value.Replace(" Copyright Tribune Media Services, Inc.", ""));
                                }

                                if (xpathINode.Current.Name.Equals("SourceChannel"))
                                {
                                    hRecord.Add("Channel", xpathINode.Current.Value);
                                    for (int i = 0; i < sNetworAffiliateList.Length; i = i + 2)
                                    {
                                        if ((hRecord["Channel"].ToString().Equals(sNetworAffiliateList[i])) ||
                                            (hRecord["Channel"].ToString().Equals("70" + sNetworAffiliateList[i])) ||
                                            (hRecord["Channel"].ToString().Equals("7" + sNetworAffiliateList[i])))
                                        {
                                            sNetworkAffiliate = sNetworAffiliateList[i + 1];
                                            break;
                                        }
                                    }
                                    hRecord.Add("NetworkAffiliate", (sNetworkAffiliate.Length > 0 ? sNetworkAffiliate : "Satellite"));
                                }
                                if (xpathINode.Current.Name.Equals("SourceStation"))
                                {
                                    hRecord.Add("StationName", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("HighDefinition"))
                                {
                                    hRecord.Add("IsHDContent", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("InProgress"))
                                {
                                    hRecord.Add("IsRecording", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("SourceSize"))
                                {
                                    hRecord.Add("VidoeSize", pdamxUtility.FormatStorageSize(xpathINode.Current.Value));
                                    hRecord.Add("UFVidoeSize", xpathINode.Current.Value);
                                }

                                if (xpathINode.Current.Name.Equals("TotalItems"))
                                {
                                    nTotalChildren = Convert.ToInt32(xpathINode.Current.Value);
                                }
                            }while (xpathINode.Current.MoveToNext());
                            if (hRecord["IsRecording"] == null)
                            {
                                hRecord.Add("IsRecording", "No"); // Default if not assigned...
                            }
                            xpathINode.Current.MoveToParent();
                        }
                        if (xpathINode.Current.Name.Equals("Links"))
                        {
                            xpathINode.Current.MoveToFirstChild();
                            do
                            {
                                if (xpathINode.Current.Name.Equals("Content"))
                                {
                                    xpathINode.Current.MoveToFirstChild();
                                    do
                                    {
                                        if (xpathINode.Current.Name.Equals("Url"))
                                        {
                                            // Get entries in group...
                                            if (nTotalChildren > 0)
                                            {
                                                pdamxTivo mxTivoChildEntries  = new pdamxTivo();
                                                Hashtable hTivoChildrenRecord = mxTivoChildEntries.GetTivoNowPlayingList(xpathINode.Current.Value, _sCredentials, nTotalChildren + "-" + _sTempDataFile);
                                                int       nMaxChildrenRows    = Convert.ToInt32(hTivoChildrenRecord["ProcessCount"].ToString());
                                                for (int i = 0; i < nMaxChildrenRows;)
                                                {
                                                    if (nEntriesRead == nTivoItemCount)
                                                    {
                                                        Hashtable hChildRecord = (Hashtable)hTivoChildrenRecord[Convert.ToString(++i)];
                                                        hChildRecord.Remove("TivoSuggestion");
                                                        hChildRecord.Add("TivoSuggestion", "Yes");
                                                        lTotalStoragedUsedByTivoSuggestions  = lTotalStoragedUsedByTivoSuggestions + Convert.ToInt64(hChildRecord["UFVidoeSize"]);
                                                        lTotalRecordingTimeOfTivoSuggestions = lTotalRecordingTimeOfTivoSuggestions + Convert.ToInt64(GetTimeInSeconds(hChildRecord["Duration"].ToString()));
                                                        hResultSet.Add(Convert.ToString(++nRowCnt), hChildRecord);
                                                        nScheduledRecordings = nRowCnt - nTotalChildren;
                                                    }
                                                    else
                                                    {
                                                        Hashtable hChildRecord = (Hashtable)hTivoChildrenRecord[Convert.ToString(++i)];
                                                        lTotalSStorageUsedByScheduledRecordings  = lTotalSStorageUsedByScheduledRecordings + Convert.ToInt64(hChildRecord["UFVidoeSize"]);
                                                        lTotalRecordingTimeOfScheduledRecordings = lTotalRecordingTimeOfScheduledRecordings + Convert.ToInt64(GetTimeInSeconds(hChildRecord["Duration"].ToString()));
                                                        hResultSet.Add(Convert.ToString(++nRowCnt), hChildRecord);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                hRecord.Add("DownloadUrl", xpathINode.Current.Value);
                                            }
                                        }
                                    }while (xpathINode.Current.MoveToNext());
                                    xpathINode.Current.MoveToParent();
                                }
                                if (xpathINode.Current.Name.Equals("TiVoVideoDetails"))
                                {
                                    xpathINode.Current.MoveToFirstChild();
                                    do
                                    {
                                        if (xpathINode.Current.Name.Equals("Url"))
                                        {
                                            mxUrlReader.Url         = xpathINode.Current.Value;
                                            mxUrlReader.WriteToFile = "temp-" + sTempDataFile;

                                            if (mxUrlReader.OpenUrl() != null)
                                            {
                                                mxXMLReader = new pdamxXMLReader();
                                                mxXMLReader.Open("temp-" + sTempDataFile);
                                                mxXMLReader.AddNamespace("TvBusMarshalledStruct", "http://tivo.com/developer/xml/idl/TvBusMarshalledStruct");

                                                // Get credits...
                                                String sActorList = "";
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/program/vActor/*");
                                                while (xpathINodeDetails.MoveNext())
                                                {
                                                    String[] sActors = xpathINodeDetails.Current.Value.Split('|');
                                                    sActorList = sActorList + (sActorList.Length > 0 ? ";" : "") + sActors[1] + " " + sActors[0];
                                                }
                                                hRecord.Add("Credits", sActorList);

                                                // Get genres...
                                                String sGenreList = "";
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/program/vProgramGenre/*");
                                                while (xpathINodeDetails.MoveNext())
                                                {
                                                    sGenreList = sGenreList + (sGenreList.Length > 0 ? "," : "") + xpathINodeDetails.Current.Value.Replace("_", "");
                                                }
                                                hRecord.Add("Genre", sGenreList);

                                                // Get advisory...
                                                String sAdvisory = "";
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/program/vAdvisory/*");
                                                while (xpathINodeDetails.MoveNext())
                                                {
                                                    sAdvisory = sAdvisory + (sAdvisory.Length > 0 ? "," : "") + xpathINodeDetails.Current.Value.Replace("_", " ");
                                                }
                                                String[] sParentalRatingReason = sAdvisory.Split(',');
                                                String   sRatingAdvisoryAddon  = "";
                                                for (int j = 0; j < sParentalRatingReason.Length; j++)
                                                {
                                                    for (int i = 0; i < sAdvisoryList.Length; i = i + 2)
                                                    {
                                                        if (sParentalRatingReason[j].ToLower().Trim().Equals(sAdvisoryList[i + 1].ToLower()))
                                                        {
                                                            sRatingAdvisoryAddon = sRatingAdvisoryAddon + (sRatingAdvisoryAddon.Length > 0 ? ";" : "") + sAdvisoryList[i];
                                                        }
                                                    }
                                                }
                                                hRecord.Add("Advisory", sRatingAdvisoryAddon);

                                                // Get movie year...
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/program/movieYear");
                                                xpathINodeDetails.MoveNext();
                                                hRecord.Add("MovieYear", (xpathINodeDetails.Current.Name.Equals("movieYear") ? xpathINodeDetails.Current.Value : ""));

                                                // Get movie rating...
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/program/mpaaRating");
                                                xpathINodeDetails.MoveNext();
                                                if (xpathINodeDetails.Current.Name.Equals("mpaaRating"))
                                                {
                                                    hRecord.Add("ParentalRating", xpathINodeDetails.Current.Value.Replace("_", ""));
                                                }

                                                // Get tv rating...
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/tvRating");
                                                xpathINodeDetails.MoveNext();
                                                if (xpathINodeDetails.Current.Name.Equals("tvRating"))
                                                {
                                                    if (hRecord["ParentalRating"] == null)
                                                    {
                                                        hRecord.Add("ParentalRating", "TV-" + xpathINodeDetails.Current.Value.Replace("_", ""));
                                                    }
                                                    //                                                else
                                                    //                                                {
                                                    //                                                    String sParentalRating = hRecord["ParentalRating"].ToString() + ";" + "TV-" + xpathINodeDetails.Current.Value.Replace("_", "");
                                                    //                                                    hRecord.Remove("ParentalRating");
                                                    //                                                   hRecord.Add("ParentalRating", sParentalRating);
                                                    //                                              }
                                                }

                                                // Get star rating...
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/showing/program/starRating");
                                                xpathINodeDetails.MoveNext();
                                                String sStarRating = (xpathINodeDetails.Current.Name.Equals("starRating") ? xpathINodeDetails.Current.Value.Replace("_", " ") : "");
                                                for (int i = 0; i < sStarRatingList.Length; i = i + 2)
                                                {
                                                    if (sStarRatingList[i].Equals(sStarRating))
                                                    {
                                                        hRecord.Add("StarRating", sStarRatingList[i + 1]);
                                                        break;
                                                    }
                                                }
                                                // Get start time...
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/startTime");
                                                xpathINodeDetails.MoveNext();
                                                if (xpathINodeDetails.Current.Name.Equals("startTime"))
                                                {
                                                    hRecord.Add("Recorded", GetDate(xpathINodeDetails.Current.Value));
                                                    hRecord.Add("StartTime", GetDate(xpathINodeDetails.Current.Value) + " (" + GetTime(xpathINodeDetails.Current.Value) + ")");
                                                    //hRecord.Add("StartTime", xpathINodeDetails.Current.Value.Replace("T", " (").Replace("Z", ")").Replace("-", "/"));
                                                }

                                                // Get start time...
                                                xpathINodeDetails = mxXMLReader.GetNodePath("/TvBusMarshalledStruct:TvBusEnvelope/stopTime");
                                                xpathINodeDetails.MoveNext();
                                                if (xpathINodeDetails.Current.Name.Equals("stopTime"))
                                                {
                                                    hRecord.Add("StopTime", GetDate(xpathINodeDetails.Current.Value) + " (" + GetTime(xpathINodeDetails.Current.Value) + ")");
                                                }

                                                //hRecord.Add("StopTime", xpathINodeDetails.Current.Value.Replace("T", " (").Replace("Z", ")").Replace("-","/"));
                                            }
                                            fiTempFileInfo = new FileInfo("temp-" + sTempDataFile);
                                            fiTempFileInfo.Delete();
                                        }
                                    }while (xpathINode.Current.MoveToNext());
                                    xpathINode.Current.MoveToParent();
                                }
                            }while (xpathINode.Current.MoveToNext());
                            xpathINode.Current.MoveToParent();

                            if (hRecord["Title"] == null)
                            {
                                hRecord.Add("Title", "");
                            }
                            if (hRecord["ProgramId"] == null)
                            {
                                hRecord.Add("ProgramId", "");
                            }
                            if (hRecord["EpisodeTitle"] == null)
                            {
                                hRecord.Add("EpisodeTitle", "");
                            }
                            if (hRecord["EpisodeNumber"] == null)
                            {
                                hRecord.Add("EpisodeNumber", "");
                            }
                            if (hRecord["Duration"] == null)
                            {
                                hRecord.Add("Duration", "");
                            }
                            if (hRecord["Description"] == null)
                            {
                                hRecord.Add("Description", "");
                            }
                            if (hRecord["Channel"] == null)
                            {
                                hRecord.Add("Channel", "");
                            }
                            if (hRecord["StationName"] == null)
                            {
                                hRecord.Add("StationName", "");
                            }
                            if (hRecord["NetworkAffiliate"] == null)
                            {
                                hRecord.Add("NetworkAffiliate", "");
                            }
                            if (hRecord["IsHDContent"] == null)
                            {
                                hRecord.Add("IsHDContent", "");
                            }
                            if (hRecord["IsRecording"] == null)
                            {
                                hRecord.Add("IsRecording", "");
                            }
                            if (hRecord["VidoeSize"] == null)
                            {
                                hRecord.Add("VidoeSize", "");
                            }
                            if (hRecord["DownloadUrl"] == null)
                            {
                                hRecord.Add("DownloadUrl", "");
                            }
                            if (hRecord["Credits"] == null)
                            {
                                hRecord.Add("Credits", "");
                            }
                            if (hRecord["Genre"] == null)
                            {
                                hRecord.Add("Genre", "");
                            }
                            if (hRecord["Advisory"] == null)
                            {
                                hRecord.Add("Advisory", "");
                            }
                            if (hRecord["MovieYear"] == null)
                            {
                                hRecord.Add("MovieYear", "");
                            }
                            if (hRecord["ParentalRating"] == null)
                            {
                                hRecord.Add("ParentalRating", "");
                            }
                            if (hRecord["StarRating"] == null)
                            {
                                hRecord.Add("StarRating", "");
                            }
                            if (hRecord["StartTime"] == null)
                            {
                                hRecord.Add("StartTime", "");
                            }
                            if (hRecord["StopTime"] == null)
                            {
                                hRecord.Add("StopTime", "");
                            }
                            if (hRecord["TivoSuggestion"] == null)
                            {
                                hRecord.Add("TivoSuggestion", "");
                            }
                            if (hRecord["TitleStrongSearchKey"] == null)
                            {
                                hRecord.Add("TitleStrongSearchKey", "");
                            }
                            if (hRecord["EpisodeStrongSearchKey"] == null)
                            {
                                hRecord.Add("EpisodeStrongSearchKey", "");
                            }

                            if (nTotalChildren == 0)
                            {
                                lTotalSStorageUsedByScheduledRecordings  = lTotalSStorageUsedByScheduledRecordings + Convert.ToInt64(hRecord["UFVidoeSize"]);
                                lTotalRecordingTimeOfScheduledRecordings = lTotalRecordingTimeOfScheduledRecordings + Convert.ToInt64(GetTimeInSeconds(hRecord["Duration"].ToString()));
                                hResultSet.Add(Convert.ToString(++nRowCnt), hRecord);
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
                fiTempFileInfo = new FileInfo(sTempDataFile);
                fiTempFileInfo.Delete();
            }
            fiTempFileInfo = new FileInfo(sTempDataFile);
            fiTempFileInfo.Delete();
            if (nScheduledRecordings == 0) // Not set...
            {
                nScheduledRecordings = nRowCnt;
            }
            hResultSet.Add("ProcessCount", Convert.ToString(nRowCnt));
            hResultSet.Add("ScheduledRecordings", Convert.ToString(nScheduledRecordings));
            hResultSet.Add("TotalStoragedUsedByTivoSuggestions", pdamxUtility.FormatStorageSize(Convert.ToString(lTotalStoragedUsedByTivoSuggestions)));
            hResultSet.Add("TotalSStorageUsedByScheduledRecordings", pdamxUtility.FormatStorageSize(Convert.ToString(lTotalSStorageUsedByScheduledRecordings)));
            hResultSet.Add("TotalStorageUsed", pdamxUtility.FormatStorageSize(Convert.ToString(lTotalSStorageUsedByScheduledRecordings + lTotalStoragedUsedByTivoSuggestions)));
            hResultSet.Add("UFTotalStoragedUsedByTivoSuggestions", Convert.ToString(lTotalStoragedUsedByTivoSuggestions));
            hResultSet.Add("UFTotalSStorageUsedByScheduledRecordings", Convert.ToString(lTotalSStorageUsedByScheduledRecordings));
            hResultSet.Add("UFTotalStorageUsed", Convert.ToString(lTotalSStorageUsedByScheduledRecordings + lTotalStoragedUsedByTivoSuggestions));
            hResultSet.Add("TotalRecordingTimeOfTivoSuggestions", pdamxUtility.FormatSeconds(Convert.ToString(lTotalRecordingTimeOfTivoSuggestions)));
            hResultSet.Add("TotalRecordingTimeOfScheduledRecordings", pdamxUtility.FormatSeconds(Convert.ToString(lTotalRecordingTimeOfScheduledRecordings)));
            hResultSet.Add("TotalRecordingTime", pdamxUtility.FormatSeconds(Convert.ToString(lTotalRecordingTimeOfScheduledRecordings + lTotalRecordingTimeOfTivoSuggestions)));
            hResultSet.Add("UFTotalRecordingTimeOfTivoSuggestions", Convert.ToString(lTotalRecordingTimeOfTivoSuggestions));
            hResultSet.Add("UFTotalRecordingTimeOfScheduledRecordings", Convert.ToString(lTotalRecordingTimeOfScheduledRecordings));
            hResultSet.Add("UFTotalRecordingTime", Convert.ToString(lTotalRecordingTimeOfScheduledRecordings + lTotalRecordingTimeOfTivoSuggestions));
            return(hResultSet);
        }
Esempio n. 3
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();
        }
Esempio n. 4
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");
            }
        }
Esempio n. 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;
        }
Esempio n. 6
0
        public Hashtable SearchSchedule(String _sSearchValue, int _nSearchCatagory)
        {
            pdamxXMLReader    mxXMLReader = null;
            pdamxSearchKeyGen mxSearchKeyGen;;
            Hashtable         hResultSet;
            Hashtable         hRecord;
            XPathNodeIterator xpathINode = null;
            String            sSearchCriteria;

            String[] sMultiSearch;
            int      nCnt = 0;

            if (_nSearchCatagory != CATAGORY_BEYONDTV && _nSearchCatagory != CATAGORY_MCE && _nSearchCatagory != CATAGORY_ALL)
            {
                return(null);
            }

            if (_nSearchCatagory == CATAGORY_BEYONDTV && sBeyondTVchedule == "")
            {
                return(null);
            }

            if (_nSearchCatagory == CATAGORY_MCE && sMCESchedule == "")
            {
                return(null);
            }

            if (_nSearchCatagory == CATAGORY_BEYONDTV && sBeyondTVchedule == "")
            {
                return(null);
            }

            if (_nSearchCatagory == CATAGORY_ALL && (sMCESchedule == "" && sBeyondTVchedule == ""))
            {
                return(null);
            }

            sMultiSearch = _sSearchValue.Split(';');
            if (sMultiSearch.Length == 0)
            {
                sMultiSearch    = new String[1];
                sMultiSearch[0] = _sSearchValue;
            }
            mxXMLReader = new pdamxXMLReader();
            hResultSet  = new Hashtable();
            if (_nSearchCatagory == CATAGORY_BEYONDTV || _nSearchCatagory == CATAGORY_ALL)
            {
                mxSearchKeyGen = new pdamxSearchKeyGen();
                mxXMLReader.Open(sBeyondTVchedule);
                mxXMLReader.AddNamespace("sch", "http://www.pdamediax.com/btv");

                for (int i = 0; i < sMultiSearch.Length; i++)
                {
                    mxSearchKeyGen.GenerateKey(sMultiSearch[i].Replace("\"", "").Replace(":", " - "));
                    sSearchCriteria = "/sch:BeyondTV/sch:UpcomingRecordings/sch:Show[starts-with(sch:TitleStrongSearchKey,\"" + mxSearchKeyGen.StrongKey + "\")]"
                                      + " | /sch:BeyondTV/sch:UpcomingRecordings/sch:Show[starts-with(sch:EpisodeStrongSearchKey,\"" + mxSearchKeyGen.StrongKey + "\")]";

                    xpathINode = mxXMLReader.GetNodePath(sSearchCriteria);
                    while (xpathINode.MoveNext())
                    {
                        hRecord = new Hashtable();
                        xpathINode.Current.MoveToFirstChild();
                        if (xpathINode.Current.Name.Equals("Title"))
                        {
                            do
                            {
                                hRecord.Add(xpathINode.Current.Name, xpathINode.Current.Value);
                            }while (xpathINode.Current.MoveToNext());
                        }
                        hRecord.Add("Catagory", "BeyondTV");
                        hResultSet.Add(Convert.ToString(++nCnt), hRecord);
                    }
                }
            }
            if (_nSearchCatagory == CATAGORY_MCE || _nSearchCatagory == CATAGORY_ALL)
            {
                mxSearchKeyGen = new pdamxSearchKeyGen();
                mxXMLReader.Open(sMCESchedule);
                mxXMLReader.AddNamespace("sch", "http://www.pdamediax.com/mce");

                for (int i = 0; i < sMultiSearch.Length; i++)
                {
                    mxSearchKeyGen.GenerateKey(sMultiSearch[i].Replace("\"", "").Replace(":", " - "));
                    sSearchCriteria = "/sch:MCETV/sch:UpcomingRecordings/sch:Show[starts-with(sch:TitleStrongSearchKey,\"" + mxSearchKeyGen.StrongKey + "\")]"
                                      + " | /sch:MCETV/sch:UpcomingRecordings/sch:Show[starts-with(sch:EpisodeStrongSearchKey,\"" + mxSearchKeyGen.StrongKey + "\")]";

                    xpathINode = mxXMLReader.GetNodePath(sSearchCriteria);
                    while (xpathINode.MoveNext())
                    {
                        hRecord = new Hashtable();
                        xpathINode.Current.MoveToFirstChild();
                        if (xpathINode.Current.Name.Equals("Title"))
                        {
                            do
                            {
                                hRecord.Add(xpathINode.Current.Name, xpathINode.Current.Value);
                            }while (xpathINode.Current.MoveToNext());
                        }
                        hRecord.Add("Catagory", "MCE");
                        hResultSet.Add(Convert.ToString(++nCnt), hRecord);
                    }
                }
            }
            return(hResultSet);
        }