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


C# Logger.WriteToFile方法代碼示例

本文整理匯總了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;
        }
開發者ID:henryford,項目名稱:FreakOut,代碼行數:48,代碼來源:NZBClub.cs

示例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;
        }
開發者ID:henryford,項目名稱:FreakOut,代碼行數:39,代碼來源:NZBSorg.cs

示例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.";
//.........這裏部分代碼省略.........
開發者ID:henryford,項目名稱:FreakOut,代碼行數:101,代碼來源:NZBMatrix.cs


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