Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix

  • Loading branch information...
commit ce85038ba460f2657599a6796d5a17120f3f3688 1 parent 604c052
@swistaczek authored
View
32 czytnik-rss/RssGuy.Console/Program.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Media;
+
+/* Prosty czytnik RSS - C# demo */
+namespace RssGuy.Console
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ string[] feeds = new []
+ {
+ "http://rss.feedsportal.com/c/32739/f/530278/index.rss",
+ "http://gazeta.pl.feedsportal.com/c/32739/f/576250/index.rss",
+ "http://rss.gazeta.pl/pub/rss/kotek.xml"
+ };
+
+ System.Console.WriteLine("Rozpoczynam pobieranie źródeł ({0})", feeds.Length);
+ System.Console.WriteLine("Czekaj cierpliwie");
+ System.Console.WriteLine("------------------------------------------------------------------");
+
+ Runner.FeedRunner runner = new Runner.FeedRunner();
+ runner.Crawl(feeds);
+
+ System.Console.ReadLine();
+ }
+ }
+}
View
36 czytnik-rss/RssGuy.Console/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RssGuy.Console")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("RssGuy.Console")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("93556318-e070-4b0b-aa59-98ed56b55659")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
72 czytnik-rss/RssGuy.Console/RssGuy.Console.csproj
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RssGuy.Console</RootNamespace>
+ <AssemblyName>RssGuy.Console</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\RssGuy.Runner\RssGuy.Runner.csproj">
+ <Project>{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}</Project>
+ <Name>RssCrawler.Runner</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
93 czytnik-rss/RssGuy.Runner/FeedRunner.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Threading;
+using System.Xml;
+using System.Xml.Linq;
+using System.Media;
+
+/* Prosty czytnik RSS - C# demo */
+/* Worker odpowiedzialny za pobieranie feedów, w¹tek */
+namespace RssGuy.Runner
+{
+ public class FeedRunner
+ {
+ public int ArticleCount { get; set; }
+ private Mutex _mutex = new Mutex();
+
+ /* Metoda publiczna do processingu feedu */
+ public void Crawl(string[] feeds)
+ {
+ foreach (var feed in feeds)
+ {
+ var feedFetcher = new FeedFetcher(feed, this);
+ Console.WriteLine("Kolejka - pobieram: {0}", feed);
+ feedFetcher.ProcessFeed();
+ /*
+ * Mo¿emy te¿ zrobiæ w¹tek, zleciæ pobranie a potem spokojnie oczekiwac na wyniki w w¹tku:
+ * new Thread(feedFetcher.ProcessFeed).Start();
+ */
+ }
+ System.Console.WriteLine("------------------------------------------------------------------");
+ }
+
+
+ /* Metoda publiczna do zwiêkszania iloœci artyku³ów */
+ public void UpdateCount()
+ {
+ lock(_mutex)
+ {
+ ArticleCount++;
+ }
+ }
+ }
+
+ /* Klasa artyku³u */
+ public class Article
+ {
+ public string Title { get; set; }
+ public string Link { get; set; }
+ public string Description { get; set; }
+ }
+
+ /* Klasa workera pobieraj¹cego feed */
+ public class FeedFetcher
+ {
+ private FeedRunner Runner { get; set; }
+ private readonly string _feedUrl;
+
+ public FeedFetcher(string feedUrl, FeedRunner runner)
+ {
+ Runner = runner;
+ _feedUrl = feedUrl;
+ }
+
+ /* Wykorzystywanie WebRequest i obrabianie pliku */
+ public void ProcessFeed()
+ {
+ WebRequest request = WebRequest.Create(_feedUrl);
+ using (var response = request.GetResponse())
+ {
+ var xmlReader = XmlReader.Create(response.GetResponseStream());
+ XDocument document = XDocument.Load(xmlReader);
+
+ IEnumerable<Article> articles = document.Descendants("channel")
+ .Elements("item")
+ .Select(i => new Article { Title = i.Element("title").Value, Link = i.Element("link").Value});
+
+ /* Wyœwietlanie w pêtli wszystkich artyku³ów - boskie foreach! */
+ foreach (var article in articles)
+ {
+ Runner.UpdateCount();
+ Console.WriteLine("#{0} Artyku³: {1}", Runner.ArticleCount, article.Title);
+
+ }
+ System.Console.WriteLine("------------------------------------------------------------------");
+ SystemSounds.Exclamation.Play();
+ }
+ }
+
+ }
+}
View
36 czytnik-rss/RssGuy.Runner/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RssGuy.Runner")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("RssGuy.Runner")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1ffc2465-97af-4646-a7c5-a7ca5f08653a")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
66 czytnik-rss/RssGuy.Runner/RssGuy.Runner.csproj
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RssGuy.Runner</RootNamespace>
+ <AssemblyName>RssGuy.Runner</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="FeedRunner.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
26 czytnik-rss/rss-guy.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssGuy.Console", "RssGuy.Console\RssGuy.Console.csproj", "{8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssGuy.Runner", "RssGuy.Runner\RssGuy.Runner.csproj", "{631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8FECBD9D-A79E-4EC0-8AC9-B41BBDD92373}.Release|Any CPU.Build.0 = Release|Any CPU
+ {631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {631C2CAA-8AF6-42CD-8B21-8E99D3BCEE12}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Please sign in to comment.
Something went wrong with that request. Please try again.