TT-Crawler hinzugefügt

This commit is contained in:
BlubbFish 2017-03-09 21:19:06 +00:00
commit e25069cd97
17 changed files with 1269 additions and 0 deletions

20
TT-Crawler.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TT-Crawler", "TT-Crawler\TT-Crawler.csproj", "{2E66D72B-7C9C-4BB5-AA51-C2686CBAF837}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E66D72B-7C9C-4BB5-AA51-C2686CBAF837}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E66D72B-7C9C-4BB5-AA51-C2686CBAF837}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E66D72B-7C9C-4BB5-AA51-C2686CBAF837}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E66D72B-7C9C-4BB5-AA51-C2686CBAF837}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

75
TT-Crawler/Crawler.cs Normal file
View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TT_Crawler.classes;
using TT_Crawler.classes.db;
namespace TT_Crawler
{
class Crawler
{
private bool HasNewPercent = false;
private int NewPercent = 0;
private bool HasNewStatus = false;
private string NewStatus = "";
private Log log;
private Games games;
public Crawler(Games games)
{
this.games = games;
}
public void arbeite()
{
this.NewStatus = "Beginne Downloads";
this.HasNewStatus = true;
this.log = new Log(games.getSize());
int i = 0;
while (games.hasNext())
{
threadNewPercent = ++i;
threadHasNewPercent = true;
Games.dbStruct a = games.next();
log.initEntry();
if (a.done)
{
log.addToEntry("Die PDF gibt es schon auf der Festplatte", Log.Error.Warn);
//this.refreshList();
log.setEntry(a.benum + ".pdf", a.benum);
continue;
}
Crawl cw = new Crawl(a.url, log);
log.addToEntry("Partie " + a.heim + " - " + a.gast + " am " + a.datum + " ausgewählt", Log.Error.Ok);
string pdf = cw.findGame(a.datum, a.heim, a.gast);
if (pdf != null)
{
log.addToEntry("Adresse der Spielberichtsseite gefunden: " + pdf, Log.Error.Ok);
Crawl f2 = new Crawl(pdf, log);
log.addToEntry("Datei " + Lib.link(pdf) + " geöffnet", Log.Error.Ok);
bool pdfo = f2.findPdf(a.benum.ToString());
if (pdfo)
log.addToEntry("PDF gefunden und im Ordner out unter dem Namen 00" + a.benum + ".pdf gespeichert.", Log.Error.Ok);
else
log.addToEntry("Spielbericht noch nicht freigegeben!", Log.Error.Falue);
}
else
{
log.addToEntry("Keine Adresse der Spielberichtsseite gefunden!", Log.Error.Falue);
}
a.done = true;
log.setEntry(a.benum + ".pdf", a.benum);
//this.refreshList();
//break;
}
threadNewStatus = "Liste Abgearbeitet";
threadHasNewStatus = true;
}
private void refreshList()
{
this.progress.Refresh();
Application.DoEvents();
}
}
}

199
TT-Crawler/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,199 @@
namespace TT_Crawler
{
partial class Form1
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.open = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.progress = new System.Windows.Forms.ProgressBar();
this.dbasefile = new System.Windows.Forms.TextBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.statusFeld = new System.Windows.Forms.ToolStripStatusLabel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.statusBox = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.liste = new System.Windows.Forms.DataGridView();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.liste)).BeginInit();
this.SuspendLayout();
//
// openFileDialog
//
this.openFileDialog.Filter = "Dbase|*.dbf|Alle Dateien|*.*";
this.openFileDialog.RestoreDirectory = true;
//
// open
//
this.open.Location = new System.Drawing.Point(289, 19);
this.open.Name = "open";
this.open.Size = new System.Drawing.Size(75, 23);
this.open.TabIndex = 0;
this.open.Text = "Öffnen";
this.open.UseVisualStyleBackColor = true;
this.open.Click += new System.EventHandler(this.open_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.progress);
this.groupBox1.Controls.Add(this.dbasefile);
this.groupBox1.Controls.Add(this.open);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(372, 85);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Datenbank";
//
// progress
//
this.progress.Location = new System.Drawing.Point(6, 51);
this.progress.Name = "progress";
this.progress.Size = new System.Drawing.Size(358, 23);
this.progress.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.progress.TabIndex = 2;
//
// dbasefile
//
this.dbasefile.AcceptsReturn = true;
this.dbasefile.AllowDrop = true;
this.dbasefile.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.dbasefile.Location = new System.Drawing.Point(6, 19);
this.dbasefile.Name = "dbasefile";
this.dbasefile.ReadOnly = true;
this.dbasefile.Size = new System.Drawing.Size(277, 20);
this.dbasefile.TabIndex = 1;
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statusFeld});
this.statusStrip1.Location = new System.Drawing.Point(0, 464);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(844, 22);
this.statusStrip1.TabIndex = 2;
this.statusStrip1.Text = "statusStrip1";
//
// statusFeld
//
this.statusFeld.Name = "statusFeld";
this.statusFeld.Size = new System.Drawing.Size(0, 17);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.statusBox);
this.groupBox2.Location = new System.Drawing.Point(390, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(436, 85);
this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Status";
//
// statusBox
//
this.statusBox.BackColor = System.Drawing.SystemColors.Window;
this.statusBox.Cursor = System.Windows.Forms.Cursors.Arrow;
this.statusBox.Location = new System.Drawing.Point(6, 19);
this.statusBox.Multiline = true;
this.statusBox.Name = "statusBox";
this.statusBox.ReadOnly = true;
this.statusBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.statusBox.Size = new System.Drawing.Size(421, 55);
this.statusBox.TabIndex = 0;
this.statusBox.TabStop = false;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.liste);
this.groupBox3.Location = new System.Drawing.Point(12, 103);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(814, 357);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "groupBox3";
//
// liste
//
this.liste.AllowUserToAddRows = false;
this.liste.AllowUserToDeleteRows = false;
this.liste.AllowUserToOrderColumns = true;
this.liste.BackgroundColor = System.Drawing.SystemColors.Window;
this.liste.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.liste.Location = new System.Drawing.Point(6, 19);
this.liste.Name = "liste";
this.liste.ReadOnly = true;
this.liste.Size = new System.Drawing.Size(799, 329);
this.liste.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(844, 486);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "TT-Crawler";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.liste)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.Button open;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ProgressBar progress;
private System.Windows.Forms.TextBox dbasefile;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel statusFeld;
private System.Windows.Forms.GroupBox groupBox2;
public System.Windows.Forms.TextBox statusBox;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.DataGridView liste;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}

58
TT-Crawler/Form1.cs Normal file
View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TT_Crawler.classes;
using TT_Crawler.classes.db;
namespace TT_Crawler
{
public partial class Form1 : Form
{
private Dbase dbase;
public Form1()
{
InitializeComponent();
}
private void open_Click(object sender, System.EventArgs e)
{
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.dbasefile.Text = openFileDialog.FileName;
this.progress.Value = 0;
this.dbase = new Dbase(this.dbasefile.Text, this.statusFeld);
if (this.dbase.getError())
this.statusFeld.Text = "Fehler beim Lesen der DBase Datei";
else
{
this.statusFeld.Text = "DBase Datei gelesen, konvertiere...";
Games games = new Games(this.dbase,this.progress);
this.statusFeld.Text = "Datenbank kovertiert";
Crawler cw = new Crawler(games);
this.backgroundWorker1.RunWorkerAsync(cw);
this.liste.DataSource = games.getView();
while (true)
{
if (threadHasNewPercent)
{
this.progress.Value = threadNewPercent;
threadHasNewPercent = false;
this.progress.Refresh();
}
if (threadHasNewStatus)
{
this.statusFeld.Text = threadNewStatus;
threadHasNewStatus = false;
}
}
}
}
}
}
}

129
TT-Crawler/Form1.resx Normal file
View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>157, 17</value>
</metadata>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>273, 17</value>
</metadata>
</root>

21
TT-Crawler/Program.cs Normal file
View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace TT_Crawler
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("TT-Crawler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TT-Crawler")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("7383b3ab-a018-40e1-9c86-c22e167e0288")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:2.0.50727.4927
//
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
// der Code neu generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TT_Crawler.Properties
{
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TT_Crawler.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TT_Crawler.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" 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>{2E66D72B-7C9C-4BB5-AA51-C2686CBAF837}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TT_Crawler</RootNamespace>
<AssemblyName>TT-Crawler</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
</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>
</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.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="classes\Crawl.cs" />
<Compile Include="classes\db\Dbase.cs" />
<Compile Include="classes\db\Games.cs" />
<Compile Include="classes\Lib.cs" />
<Compile Include="classes\Log.cs" />
<Compile Include="Crawler.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</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>

152
TT-Crawler/classes/Crawl.cs Normal file
View File

@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;
namespace TT_Crawler.classes
{
class Crawl
{
private string inh;
private string date;
private Log log;
public Crawl(string file, Log log)
{
WebClient wClient = new WebClient();
this.inh = wClient.DownloadString(file);
if (inh.Equals(""))
{
Console.WriteLine(this.log.addToEntry("Fehler beim Aufruf der Seite " + Lib.link(file), Log.Error.Falue));
}
this.log = log;
}
public string findGame(DateTime datum, string heim, string gast)
{
string date = datum.ToString("dd.MM.yyyy");
var tmp_c = this.inh.Substring(this.inh.IndexOf("<div id=\"content-row2\">") + 10);
tmp_c = tmp_c.Substring(tmp_c.IndexOf("<table"));
tmp_c = tmp_c.Substring(0, tmp_c.IndexOf("</table>"));
string[] tmp = tmp_c.Split(new String[] {"<tr"},StringSplitOptions.None);
for (int i = 2; i < tmp.Length; i++)
{
string[] tmp1 = tmp[i].Split(new String[] { "</td>" }, StringSplitOptions.None);
if (!tmp1[1].Substring(tmp1[1].LastIndexOf(">") + 1).Trim().Equals("&nbsp;"))
this.date = tmp1[1].Substring(tmp1[1].LastIndexOf(">") + 1).Trim();
if (this.date == date)
{
if (this.verg(tmp1[4].Substring(tmp1[4].LastIndexOf(">") + 1).Trim(), heim))
{
if (this.verg(tmp1[5].Substring(tmp1[5].LastIndexOf(">") + 1).Trim(), gast))
{
string url = tmp1[6].Substring(tmp1[6].LastIndexOf("href") + 6).Trim();
url = "http://wttv.click-tt.de"+url.Substring(0, url.IndexOf("\""));
string ret = url.Replace("&amp;", "&");
if (ret.Equals(""))
return null;
else
return ret;
}
}
}
}
return null;
}
public bool findPdf(string name)
{
if (this.inh.IndexOf("Spielbericht durch Staffelleiter genehmigt.") == 0)
return false;
string url = this.inh.Substring(this.inh.IndexOf("Spielbericht durch Staffelleiter genehmigt."));
url = url.Substring(url.IndexOf("href=\"") + 6);
url = url.Substring(0, url.IndexOf("\""));
url = "http://wttv.click-tt.de" + url.Replace("&amp;", "&");
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
string addr = myHttpWebResponse.ResponseUri.AbsoluteUri;
WebClient wClient = new WebClient();
if(!Directory.Exists("out"))
new DirectoryInfo("out").Create();
wClient.DownloadFile(addr,"out\\00"+name+".pdf");
return true;
}
private bool verg(string s1, string s2)
{
s1 = s1.Replace("&nbsp;", " ").Trim();
s2 = s2.Replace("&nbsp;", " ").Trim();
if (s1.Equals(s2))
return true;
s1 = this.ed(s1);
s1 = this.ed(s2);
if (s1.Equals(s2))
return true;
float p = this.GetSimilarity(s1, s2);
if(p >= 0.45)
Console.WriteLine(this.log.addToEntry("ClickTT: \""+s1+"\", TT-Datenbank: \""+s2+"\", Unterschied: "+(p*100)+"%",Log.Error.Ok));
if (p >= 0.99)
return true;
return false;
}
private string ed(string s)
{
s = s.ToLower();
s = s.Replace(" ", " ");
s = s.Replace("blau-weiß", "bw");
s = Regex.Replace(s, "<.*?>", string.Empty);
return s;
}
/**
* An improvement on capturing similarity between strings
* By Thanh Dao
* www.codeproject.com
**/
private int ComputeDistance(string s, string t)
{
int n = s.Length;
int m = t.Length;
int[,] distance = new int[n + 1, m + 1]; // matrix
int cost = 0;
if (n == 0) return m;
if (m == 0) return n;
//init1
for (int i = 0; i <= n; distance[i, 0] = i++) ;
for (int j = 0; j <= m; distance[0, j] = j++) ;
//find min distance
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cost = (t.Substring(j - 1, 1) ==
s.Substring(i - 1, 1) ? 0 : 1);
distance[i, j] = Min3(distance[i - 1, j] + 1,
distance[i, j - 1] + 1,
distance[i - 1, j - 1] + cost);
}
}
return distance[n, m];
}
private int Min3(int p, int p_2, int p_3)
{
p = Math.Min(p, p_2);
return Math.Min(p,p_3);
}
private float GetSimilarity(string string1, string string2)
{
float dis = ComputeDistance(string1, string2);
float maxLen = string1.Length;
if (maxLen < string2.Length)
maxLen = string2.Length;
if (maxLen == 0.0F)
return 1.0F;
else
return 1.0F - dis / maxLen;
}
}
}

15
TT-Crawler/classes/Lib.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TT_Crawler.classes
{
class Lib
{
public static string link(string url)
{
return url;
}
}
}

61
TT-Crawler/classes/Log.cs Normal file
View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TT_Crawler.classes
{
class Log
{
private logEntry[] entrys;
public enum Error : int
{
Falue,
Warn,
Ok,
None,
}
public struct logEntry
{
public int id;
public Error state;
public string file;
public DateTime date;
public string head_err;
public string data;
}
private int index = -1;
public Log(int length)
{
this.entrys = new logEntry[length];
}
public string addToEntry(string text, Error fail)
{
if (fail == Error.Falue)
this.entrys[this.index].state = fail;
else if (fail == Error.Warn && this.entrys[this.index].state == Error.Ok)
this.entrys[this.index].state = fail;
if (fail == Error.Warn || this.entrys[this.index].state == Error.Falue)
this.entrys[this.index].head_err += text;
this.entrys[this.index].data += text+"\n";
return text;
}
public void initEntry()
{
this.index++;
this.entrys[this.index].head_err = "";
this.entrys[this.index].state = Error.Ok;
this.entrys[this.index].data = "";
}
public void setEntry(string file, int id)
{
this.entrys[this.index].id = id;
this.entrys[this.index].date = DateTime.Now;
this.entrys[this.index].file = file;
}
public logEntry getEntry()
{
return this.entrys[index];
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.Odbc;
using System.Data;
namespace TT_Crawler.classes.db
{
class Dbase
{
private bool err = false;
private ToolStripStatusLabel status;
private DataTable data;
public Dbase(string file, ToolStripStatusLabel status)
{
this.status = status;
this.err = this.open(file);
}
public bool getError()
{
return this.err;
}
private bool open(string file)
{
if (!File.Exists(file))
return true;
string dir = file.Substring(0, file.LastIndexOf("\\"));
file = file.Substring(file.LastIndexOf("\\") + 1);
OdbcConnection odbc = new OdbcConnection();
odbc.ConnectionString = @"DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=" + dir + ";DefaultDir=" + dir + ";DriverId=533;MaxBufferSize=2048;PageTimeout=5";
odbc.Open();
OdbcCommand oCmd = odbc.CreateCommand();
oCmd.CommandText = "SELECT * FROM " + file;
this.data = new DataTable();
this.data.Load(oCmd.ExecuteReader());
odbc.Close();
return false;
}
public DataTable getTable()
{
return this.data;
}
}
}

View File

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;
using System.IO;
namespace TT_Crawler.classes.db
{
class Games
{
public struct dbStruct
{
public string url;
public DateTime datum;
public string heim;
public string gast;
public int benum;
public bool done;
}
private dbStruct[] db;
private int index = 0;
private Dbase dbase;
private ProgressBar p;
public Games(Dbase dbase, ProgressBar p)
{
this.dbase = dbase;
this.p = p;
this.load();
}
private void load()
{
DataTable a = this.dbase.getTable();
p.Maximum = a.Rows.Count;
this.db = new dbStruct[a.Rows.Count];
int i = 0;
foreach (DataRow myRow in a.Rows)
{
db[i].url = (string)myRow["URL"];
db[i].datum = (DateTime)myRow["DATUM"];
db[i].heim = (string)myRow["HEIM"];
db[i].gast = (string)myRow["GAST"];
db[i].benum = (int)((double)myRow["BERICHTNR"]);
db[i].done = File.Exists("out\\00" + db[i].benum + ".pdf");
i++;
}
}
public dbStruct next()
{
return this.db[this.index++];
}
public bool hasNext()
{
if (this.db.Length <= this.index)
return false;
return true;
}
public void entryDone(int i)
{
db[this.index].done = true;
}
public int getSize()
{
return this.db.Length;
}
public DataTable getView()
{
DataTable a = new DataTable();
DataColumn myDataColumn;
DataRow myDataRow;
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "PDF";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = true;
a.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Heim";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = false;
a.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Gast";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = false;
a.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.DateTime");
myDataColumn.ColumnName = "Datum";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = false;
a.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Status";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = false;
a.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Fehler";
myDataColumn.ReadOnly = true;
myDataColumn.Unique = false;
a.Columns.Add(myDataColumn);
foreach(dbStruct row in db)
{
myDataRow = a.NewRow();
myDataRow["PDF"] = row.benum+".pdf";
myDataRow["Heim"] = row.heim;
myDataRow["Gast"] = row.gast;
myDataRow["Datum"] = row.datum;
if (row.done)
myDataRow["Status"] = "100%";
else
myDataRow["Status"] = "0%";
myDataRow["Fehler"] = "Kein Fehler";
a.Rows.Add(myDataRow);
}
return a;
}
}
}