Пример #1
0
        /// <summary>
        /// Create the MXF file.
        /// </summary>
        /// <returns>An error message if the process fails; null otherwise.</returns>
        public static string Process()
        {
            string clearReply = WMCUtility.Run("clear series data", "CLEARSERIES");

            if (clearReply != null)
            {
                Logger.Instance.Write("<e> " + clearReply);
            }

            actualFileName = Path.Combine(RunParameters.DataDirectory, "TVGuide.mxf");

            try
            {
                Logger.Instance.Write("Deleting any existing version of output file");
                File.SetAttributes(actualFileName, FileAttributes.Normal);
                File.Delete(actualFileName);
            }
            catch (IOException e)
            {
                Logger.Instance.Write("File delete exception: " + e.Message);
            }

            if (RunParameters.Instance.WMCImportName != null)
            {
                importName = RunParameters.Instance.WMCImportName;
            }

            if (importName == null)
            {
                importName = "EPG Collector";
            }
            importReference = importName.Replace(" ", string.Empty);
            Logger.Instance.Write("Import name set to '" + importName + "'");

            Logger.Instance.Write("Creating output file: " + actualFileName);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            settings.NewLineOnAttributes = false;
            if (!OutputFile.UseUnicodeEncoding)
            {
                settings.Encoding = new UTF8Encoding();
            }
            else
            {
                settings.Encoding = new UnicodeEncoding();
            }
            settings.CloseOutput = true;

            try
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(actualFileName, settings))
                {
                    xmlWriter.WriteStartDocument();

                    xmlWriter.WriteStartElement("MXF");
                    xmlWriter.WriteAttributeString("xmlns", "sql", null, "urn:schemas-microsoft-com:XML-sql");
                    xmlWriter.WriteAttributeString("xmlns", "xsi", null, @"http://www.w3.org/2001/XMLSchema-instance");

                    xmlWriter.WriteStartElement("Assembly");
                    xmlWriter.WriteAttributeString("name", "mcepg");
                    xmlWriter.WriteAttributeString("version", "6.0.6000.0");
                    xmlWriter.WriteAttributeString("cultureInfo", "");
                    xmlWriter.WriteAttributeString("publicKey", "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9");
                    xmlWriter.WriteStartElement("NameSpace");
                    xmlWriter.WriteAttributeString("name", "Microsoft.MediaCenter.Guide");

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Lineup");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Channel");
                    xmlWriter.WriteAttributeString("parentFieldName", "lineup");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Service");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "ScheduleEntry");
                    xmlWriter.WriteAttributeString("groupName", "ScheduleEntries");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Keyword");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "KeywordGroup");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Person");
                    xmlWriter.WriteAttributeString("groupName", "People");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "ActorRole");
                    xmlWriter.WriteAttributeString("parentFieldName", "program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "DirectorRole");
                    xmlWriter.WriteAttributeString("parentFieldName", "program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "WriterRole");
                    xmlWriter.WriteAttributeString("parentFieldName", "program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "HostRole");
                    xmlWriter.WriteAttributeString("parentFieldName", "program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "GuestActorRole");
                    xmlWriter.WriteAttributeString("parentFieldName", "program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "ProducerRole");
                    xmlWriter.WriteAttributeString("parentFieldName", "program");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "GuideImage");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Affiliate");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "SeriesInfo");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Season");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Assembly");
                    xmlWriter.WriteAttributeString("name", "mcstore");
                    xmlWriter.WriteAttributeString("version", "6.0.6000.0");
                    xmlWriter.WriteAttributeString("cultureInfo", "");
                    xmlWriter.WriteAttributeString("publicKey", "0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9");
                    xmlWriter.WriteStartElement("NameSpace");
                    xmlWriter.WriteAttributeString("name", "Microsoft.MediaCenter.Store");

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "Provider");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Type");
                    xmlWriter.WriteAttributeString("name", "UId");
                    xmlWriter.WriteAttributeString("parentFieldName", "target");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Providers");
                    xmlWriter.WriteStartElement("Provider");
                    xmlWriter.WriteAttributeString("id", "provider1");
                    xmlWriter.WriteAttributeString("name", importReference);
                    xmlWriter.WriteAttributeString("displayName", importName);
                    xmlWriter.WriteAttributeString("copyright", "");
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("With");
                    xmlWriter.WriteAttributeString("provider", "provider1");

                    xmlWriter.WriteStartElement("Keywords");
                    processKeywords(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("KeywordGroups");
                    processKeywordGroups(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("GuideImages");
                    processGuideImages(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("People");
                    processPeople(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("SeriesInfos");
                    processSeries(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Seasons");
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Programs");
                    processPrograms(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Affiliates");
                    processAffiliates(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("Services");
                    processServices(xmlWriter);
                    xmlWriter.WriteEndElement();

                    processSchedules(xmlWriter);

                    xmlWriter.WriteStartElement("Lineups");
                    processLineUps(xmlWriter);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();

                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
            catch (XmlException ex1)
            {
                return(ex1.Message);
            }
            catch (IOException ex2)
            {
                return(ex2.Message);
            }

            string reply = runImportUtility(actualFileName);

            if (reply != null)
            {
                return(reply);
            }

            if (RunParameters.Instance.Options.Contains("CREATEBRCHANNELS"))
            {
                OutputFileBladeRunner.Process(actualFileName);
            }

            if (RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                OutputFileAreaRegionChannels.Process(actualFileName);
            }

            return(null);
        }
Пример #2
0
        internal static string Process(string fileName)
        {
            try
            {
                Logger.Instance.Write("Deleting any existing version of output file");
                File.SetAttributes(fileName, FileAttributes.Normal);
                File.Delete(fileName);
            }
            catch (IOException e)
            {
                Logger.Instance.Write("File delete exception: " + e.Message);
            }

            Logger.Instance.Write("Creating output file: " + fileName);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            settings.NewLineOnAttributes = false;
            if (!OutputFile.UseUnicodeEncoding)
            {
                settings.Encoding = new UTF8Encoding();
            }
            else
            {
                settings.Encoding = new UnicodeEncoding();
            }
            settings.CloseOutput = true;

            if (RunParameters.Instance.DebugIDs.Contains("IGNOREXMLCHARS"))
            {
                settings.CheckCharacters = false;
            }

            try
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(fileName, settings))
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement("tv");

                    xmlWriter.WriteAttributeString("generator-info-name", Assembly.GetCallingAssembly().GetName().Name
                                                   + "/" + Assembly.GetCallingAssembly().GetName().Version.ToString());

                    foreach (TVStation tvStation in TVStation.StationCollection)
                    {
                        if (!tvStation.Excluded && tvStation.EPGCollection.Count != 0)
                        {
                            processStationHeader(xmlWriter, tvStation);
                        }
                    }

                    foreach (TVStation tvStation in TVStation.StationCollection)
                    {
                        if (!tvStation.Excluded && tvStation.EPGCollection.Count != 0)
                        {
                            processStationEPG(xmlWriter, tvStation);
                        }
                    }

                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();

                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
            catch (XmlException ex1)
            {
                return(ex1.Message);
            }
            catch (IOException ex2)
            {
                return(ex2.Message);
            }

            if (RunParameters.Instance.Options.Contains("CREATEBRCHANNELS"))
            {
                OutputFileBladeRunner.Process(fileName);
            }

            if (RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                OutputFileAreaRegionChannels.Process(fileName);
            }

            return(null);
        }