本文整理汇总了C#中System.Logger.WriteToFile方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.WriteToFile方法的具体用法?C# Logger.WriteToFile怎么用?C# Logger.WriteToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Logger
的用法示例。
在下文中一共展示了Logger.WriteToFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
public static List<string> Search(string GameName, string Platform, int Retention, Logger LogInstance)
{
string ProviderClass = "Provider:NZBClub";
//Create URI
string XMLUri = "http://www.nzbclub.com/nzbfeed.aspx?q=" + GameName.Replace(" ", "%20") + "%20" + Platform.Replace(" ", "%20") + "&ig=2&st=5&sp=1&ns=1";
System.IO.Stream XMLStream;
WebResponse XMLResponse;
//Load the feed-xml
XmlDocument RSSXML;
WebRequest XMLRequest = WebRequest.Create(XMLUri);
try
{
LogInstance.WriteToFile(1, "Trying to get a response from " + XMLUri, ProviderClass);
XMLResponse = XMLRequest.GetResponse();
XMLStream = XMLResponse.GetResponseStream();
}
catch (Exception e)
{
LogInstance.WriteToFile(2, "Unable to connect to NZBClub.com. The error message returned was:\n" + e.Message, ProviderClass);
return null;
}
RSSXML = new XmlDocument();
RSSXML.Load(XMLStream);
//Read the contents
if (RSSXML.SelectNodes("rss/channel/item") == null)
return null;
List<string> Results = new List<string>();
foreach (XmlNode Node in RSSXML.SelectNodes("rss/channel/item"))
{
if (NZBClub.ReturnRetention(Node.SelectSingleNode("pubDate").InnerText) <= Retention)
{
string link = FreakOut.classes.Provider.NZBClub.ReturnURL(Node);
string title = Node.SelectSingleNode("title").InnerText;
Results.Add(title + ";" + link);
}
}
if (Results.Count != 0)
return Results;
else
return null;
}
示例2: Search
public static List<string> Search(string GameName, string nzbshash, int nzbsid, int Retention, Logger LogInstance)
{
//Create URI
string XMLUri = "http://nzbs.org/rss.php?type=5&i=" + nzbsid + "&h=" + nzbshash + "&q=" + GameName + "&dl=1&num=50&age=" + Retention;
System.IO.Stream XMLStream;
WebResponse XMLResponse;
//Load the feed-xml
XmlDocument RSSXML;
WebRequest XMLRequest = WebRequest.Create(XMLUri);
try
{
LogInstance.WriteToFile(1, "Trying to get a response from " + XMLUri, "Provider:NZBS.org");
XMLResponse = XMLRequest.GetResponse();
XMLStream = XMLResponse.GetResponseStream();
}
catch (Exception e)
{
LogInstance.WriteToFile(2, "Unable to connect to NZBS.org. The error message returned was:\n" + e.Message, "Provider:NZBS.org");
return null;
}
RSSXML = new XmlDocument();
RSSXML.Load(XMLStream);
//Read the contents
List<string> Results = new List<string>();
if (RSSXML.SelectNodes("rss/channel/item") == null)
return null;
foreach (XmlNode Node in RSSXML.SelectNodes("rss/channel/item"))
{
Results.Add(Node.SelectSingleNode("title").InnerText + ";" + Node.SelectSingleNode("link").InnerText);
}
return Results;
}
示例3: Search
public static List<string> Search(string GameName, string username, string apikey, int Retention, string Platform, Logger LogInstance)
{
string ProviderClass = "Provider:NZBMatrix";
//Determine the correct category for the given Platform
#region category
int catid = 0;
switch (Platform)
{
case "PC":
catid = 10;
break;
case "Playstation 2":
catid = 11;
break;
case "PSP":
catid = 12;
break;
case "Xbox":
catid = 13;
break;
case "Xbox 360":
catid = 14;
break;
case "Wii":
catid = 44;
break;
default:
catid = 0;
break;
}
#endregion
//Create URI
string XMLUri = "http://api.nzbmatrix.com/v1.1/search.php?search=" + GameName + "&num=50&username=" + username + "&apikey=" + apikey + "&age=" + Retention;
//Append catid if necessary
if (catid != 0)
XMLUri += "&catid=" + catid;
System.IO.Stream XMLStream;
WebResponse XMLResponse;
//Load the feed-xml
XmlDocument RSSXML;
StreamReader ErrorParser;
WebRequest XMLRequest = WebRequest.Create(XMLUri);
try
{
LogInstance.WriteToFile(1, "Trying to get a response from " + XMLUri, ProviderClass);
XMLResponse = XMLRequest.GetResponse();
XMLStream = XMLResponse.GetResponseStream();
ErrorParser = new StreamReader(XMLStream);
string Messages = ErrorParser.ReadToEnd();
string LogMessage = "Could not fetch the NZBMatrix-RSS due to the following error: \n";
switch (Messages)
{
case "error:invalid_login":
LogMessage += "error:invalid_login - There seems to be a problem with your username.";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:invalid_api":
LogMessage += "error:invalid_api - There seems to be a problem with your apikey.";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:invalid_nzbid":
LogMessage += "error:invalid_nzbid - Please post a bug report on github with this error message.";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:vip_only":
LogMessage += "error:vip_only - You do not have access to this feature (NZBMatrix VIP only).";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:disabled_account":
LogMessage += "error:disabled_account - Your account has been disabled by NZBMatrix.";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:no_nzb_found":
LogMessage += "error:no_nzb_found - Couldn't find a NZB-File. Problem probably on NZBMatrix' end.";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:no_search":
LogMessage += "error:no_search - Please post a bug report on github with this error message.";
LogInstance.WriteToFile(2, LogMessage, ProviderClass);
return null;
case "error:nothing_found":
LogMessage += "error:nothing_found - unable to get any results on your query.";
//.........这里部分代码省略.........