當前位置: 首頁>>代碼示例>>C#>>正文


C# TvBusinessLayer.WaitForInsertPrograms方法代碼示例

本文整理匯總了C#中TvDatabase.TvBusinessLayer.WaitForInsertPrograms方法的典型用法代碼示例。如果您正苦於以下問題:C# TvBusinessLayer.WaitForInsertPrograms方法的具體用法?C# TvBusinessLayer.WaitForInsertPrograms怎麽用?C# TvBusinessLayer.WaitForInsertPrograms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TvDatabase.TvBusinessLayer的用法示例。


在下文中一共展示了TvBusinessLayer.WaitForInsertPrograms方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ThreadFunctionImportTVGuide


//.........這裏部分代碼省略.........
        //  stmt.Execute();
        //}

        int numChannels = 0, numPrograms = 0;
        string errors = "";

        try
        {
          if (param._importXML)
          {
            string fileName = folder + @"\tvguide.xml";
            Log.Write("plugin:xmltv importing " + fileName);

            XMLTVImport import = new XMLTVImport(10); // add 10 msec dely to the background thread
            import.Import(fileName, deleteBeforeImport, false);

            numChannels += import.ImportStats.Channels;
            numPrograms += import.ImportStats.Programs;

            if (import.ErrorMessage.Length != 0)
              errors += "tvguide.xml:" + import.ErrorMessage + "; ";
          }

          if (param._importLST)
          {
            string fileName = folder + @"\tvguide.lst";
            Log.Write("plugin:xmltv importing files in " + fileName);

            Encoding fileEncoding = Encoding.Default;
            streamIn = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            fileIn = new StreamReader(streamIn, fileEncoding, true);

            while (!fileIn.EndOfStream)
            {
              string tvguideFileName = fileIn.ReadLine();
              if (tvguideFileName.Length == 0) continue;

              if (!System.IO.Path.IsPathRooted(tvguideFileName))
              {
                // extend by directory
                tvguideFileName = System.IO.Path.Combine(folder, tvguideFileName);
              }

              Log.WriteFile(@"plugin:xmltv importing " + tvguideFileName);

              XMLTVImport import = new XMLTVImport(10); // add 10 msec dely to the background thread

              import.Import(tvguideFileName, deleteBeforeImport, false);

              numChannels += import.ImportStats.Channels;
              numPrograms += import.ImportStats.Programs;

              if (import.ErrorMessage.Length != 0)
                errors += tvguideFileName + ": " + import.ErrorMessage + "; ";
            }
          }

          setting = layer.GetSetting("xmlTvResultLastImport", "");
          setting.Value = DateTime.Now.ToString();
          setting.Persist();
          setting = layer.GetSetting("xmlTvResultChannels", "");
          setting.Value = numChannels.ToString();
          setting.Persist();
          setting = layer.GetSetting("xmlTvResultPrograms", "");
          setting.Value = numPrograms.ToString();
          setting.Persist();
          setting = layer.GetSetting("xmlTvResultStatus", "");
          setting.Value = errors;
          setting.Persist();
          Log.Write("Xmltv: imported {0} channels, {1} programs status:{2}", numChannels, numPrograms, errors);
        }
        catch (Exception ex)
        {
          Log.Error(@"plugin:xmltv import failed");
          Log.Write(ex);
        }

        setting = layer.GetSetting("xmlTvLastUpdate", "");
        setting.Value = param._importDate.ToString();
        setting.Persist();
        Log.Info("Xmltv: waiting for database to finish inserting imported programs.");
        layer.WaitForInsertPrograms();
      }
      finally
      {
        Log.WriteFile(@"plugin:xmltv import done");
        if (streamIn != null)
        {
          streamIn.Close();
          streamIn.Dispose();
        }
        if (fileIn != null)
        {
          fileIn.Close();
          fileIn.Dispose();
        }
        _workerThreadRunning = false;
        SetStandbyAllowed(true);
      }
    }
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:101,代碼來源:XmlTvImporter.cs


注:本文中的TvDatabase.TvBusinessLayer.WaitForInsertPrograms方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。