AlabusImport hinzugefügt

master
Stefan Hutter 4 years ago
parent 9215ce0675
commit d9895bdfad

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{42E33F05-D798-4F84-A594-12B713EC8AE7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AlabusTransfer</RootNamespace>
<AssemblyName>AlabusTransfer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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.Configuration" />
<Reference Include="System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\QW2021C\packages\System.Configuration.ConfigurationManager.6.0.0\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Net" />
<Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\QW2021C\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Permissions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\QW2021C\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\QW2021C\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Helper\clsdb.cs" />
<Compile Include="Helper\Log.cs" />
<Compile Include="Helper\zipHelper.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="AlabusTransfer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<AlabusTransfer.Properties.Settings>
<setting name="URL" serializeAs="String">
<value>https://alabus.swiss-athletics.ch/rest/License/Athletica/ExportStammDataFull</value>
</setting>
<setting name="UID" serializeAs="String">
<value>40307</value>
</setting>
<setting name="PWD" serializeAs="String">
<value>Turicum18</value>
</setting>
<setting name="TransferPath" serializeAs="String">
<value>E:\Software-Projekte\QW-Tool\QW2021C\Upload\transfer\</value>
</setting>
<setting name="QWToolConnectionstring" serializeAs="String">
<value>Data Source=shu00;Initial Catalog=qw2021_prod;User ID=sa;Password=*shu29</value>
</setting>
<setting name="NoDownload" serializeAs="String">
<value>No</value>
</setting>
<setting name="LogLevel" serializeAs="String">
<value>1</value>
</setting>
<setting name="VereinFiler" serializeAs="String">
<value>.ZH.,.ZZ.</value>
</setting>
</AlabusTransfer.Properties.Settings>
</userSettings>
</configuration>

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using Convert = System.Convert;
public class Log
{
public void insert_entry(int loglevel, int userid, string description)
{
clsDB db = new clsDB();
if (loglevel <= get_level()) db.insert_log(loglevel, userid, description);
}
private int get_level()
{
return Convert.ToInt32(AlabusTransfer.Properties.Settings.Default.LogLevel);
}
}

@ -0,0 +1,705 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Configuration;
public class clsDB
{
public string Connectionstring = "";
public DataSet dsdaten = new DataSet();
private SqlDataAdapter dadaten;
public clsDB()
{
// Me.Connectionstring = Get_Connectionstring(parcoursnr)
if (this.Connectionstring == "")
this.Connectionstring = Get_Connectionstring();
}
public string Get_Connectionstring()
{
return AlabusTransfer.Properties.Settings.Default.QWToolConnectionstring;
}
public string Get_Option(int onr)
{
try
{
SqlConnection sqlconnect = new SqlConnection();
DataSet ds = new DataSet();
ds.Tables.Clear();
sqlconnect.ConnectionString = this.Connectionstring;
sqlconnect.Open();
SqlDataAdapter da = new SqlDataAdapter("", sqlconnect);
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = sqlconnect;
sqlcmd.CommandType = CommandType.Text;
sqlcmd.CommandText = "Select * from optionen where optionnr=" + onr.ToString();
// sqlcmd.CommandText = "Select * from optionen where mandantnr=" + mandantnr.ToString + " and optionnr=" + onr.ToString
da.SelectCommand = sqlcmd;
da.Fill(ds, "Daten");
// If ds.Tables(0).Rows.Count = 0 Then
// sqlcmd.CommandText = "Select * from optionen where mandantnr=1 and optionnr=" + onr.ToString
// da.Fill(ds, "Daten")
// End If
return ds.Tables[0].Rows[0]["Inhalt"].ToString();
}
catch (Exception ex)
{
return "";
}
}
public DataSet Get_Tabledata(int sqlscriptnumber, string vereinnr, int userid)
{
Get_Tabledata("Select sqlscript from sqlqueries where sqlscriptnumber=" + sqlscriptnumber.ToString(),false,true);
string sql = dsdaten.Tables[0].Rows[0][0].ToString();
dsdaten.Tables.Clear();
sql = sql.Replace("@vereinnr", vereinnr);
sql = sql.Replace("@userid", userid.ToString());
Get_Tabledata(sql, false, true);
return dsdaten;
}
public DataSet Get_Tabledata(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
{
SqlConnection sqlconnect = new SqlConnection();
DataSet ds = new DataSet();
ds.Tables.Clear();
sqlconnect.ConnectionString = this.Connectionstring;
sqlconnect.Open();
SqlDataAdapter da = new SqlDataAdapter("", sqlconnect);
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = sqlconnect;
if (StoredProc == true)
{
sqlcmd.CommandType = CommandType.StoredProcedure;
if (Tablename.IndexOf("@@Mandantnr@@") > 0)
Tablename = Tablename.Replace("@@Mandantnr@@", "");
sqlcmd.CommandText = Tablename;
}
else
{
sqlcmd.CommandType = CommandType.Text;
sqlcmd.CommandText = "Select * from " + Tablename;
}
if (is_SQL_String == true)
sqlcmd.CommandText = Tablename;
// sqlcmd.CommandType = CommandType.StoredProcedure
// sqlcmd.CommandText = "Berufsliste"
da.SelectCommand = sqlcmd;
da.Fill(dsdaten, "Daten");
sqlconnect.Close();
return dsdaten;
}
public void Get_Tabledata(string tablename, string wherestatement = "", string SQL = "", string args = "", bool SP = false, DataTable SP_Params = null/* TODO Change to default(_) if this is not a reference type */)
{
if (SP == true)
{
}
try
{
dsdaten.Clear();
dsdaten.Tables.Clear();
dadaten = new SqlDataAdapter(SQL, this.Connectionstring);
if (SP == true)
{
SqlCommand sqlcmd = new SqlCommand();
SqlConnection sqlconnect = new SqlConnection();
sqlconnect.ConnectionString = this.Connectionstring;
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.CommandText = tablename;
foreach (DataRow r in SP_Params.Rows)
{
sqlcmd.Parameters.Add(r["Paramname"].ToString(), SqlDbType.VarChar);
sqlcmd.Parameters[sqlcmd.Parameters.Count - 1].Value = r["Paramvalue"];
}
sqlcmd.Connection = sqlconnect;
try
{
dadaten.SelectCommand = sqlcmd;
dadaten.Fill(dsdaten, tablename);
return;
}
catch (Exception ex)
{
sqlconnect.Open();
sqlcmd.ExecuteNonQuery();
sqlconnect.Close();
}
}
if (SQL != "")
{
SQL = SQL.Replace("&ARGS&", args);
dadaten = new SqlDataAdapter(SQL, this.Connectionstring);
}
else
dadaten = new SqlDataAdapter("select * from [" + tablename + "] " + wherestatement, this.Connectionstring);
dadaten.Fill(dsdaten, tablename);
}
catch (Exception ex)
{
int a = 1;
}
}
public void Get_Tabeldata_for_Update(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
{
dsdaten.Clear();
dsdaten.Tables.Clear();
dadaten = new SqlDataAdapter(Tablename, this.Connectionstring);
dadaten.Fill(dsdaten, Tablename);
}
public void Update_Tabeldata()
{
SqlCommandBuilder cb = new SqlCommandBuilder(dadaten);
dadaten.Update(dsdaten, dsdaten.Tables[0].TableName);
}
public DataTable Get_Menu(string Menutype, bool loggedoffmenu)
{
SqlConnection SQLconnect = new SqlConnection();
DataSet ds = new DataSet();
ds.Tables.Clear();
SQLconnect.ConnectionString = this.Connectionstring;
SQLconnect.Open();
SqlDataAdapter da = new SqlDataAdapter("", SQLconnect);
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = SQLconnect;
sqlcmd.CommandType = CommandType.Text;
clsDB dh = new clsDB();
// ds = dh.Get_Tabledata("Select Mandanttype from mandant where mandantnr=" + mandantnr.ToString, False, True)
// Dim mandanttyp As Integer
// mandanttyp = ds.Tables(0).Rows(0).Item(0)
// ds.Tables.Clear()
// If Get_Option(11, mandantnr) = "1/2" And
// Menutype = 3 Then
// sqlcmd.CommandText = "Select * from web_menu where mandanttype>=" + mandanttyp.ToString + " and aktiv=1 and menutext<>'Schüler' and ( menutype=10 or menutype=1 or menutype = " + Menutype.ToString + ") order by menutype, sort"
// Else
if (loggedoffmenu==true)
{
sqlcmd.CommandText = "Select * from web_menu where aktiv=1 and ( menutype=100 or menutype=1 or menutype = " + Menutype.ToString() + ") order by menutype, sort";
}
else
{
sqlcmd.CommandText = "Select * from web_menu where aktiv=1 and ( menutype <> 100 and menutype=10 or menutype=1 or menutype = " + Menutype.ToString() + ") order by menutype, sort";
}
// End If
da.SelectCommand = sqlcmd;
da.Fill(ds, "Daten");
sqlcmd.Dispose();
SQLconnect.Close();
return ds.Tables[0];
}
public void add_user()
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("add_user", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
//return null;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
//return 0;
}
public void generate_password(string usernr, int pwgen)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("Generate_Password", myConnection);
myCommand.Parameters.Add(new SqlParameter("@usernr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, usernr));
myCommand.Parameters.Add(new SqlParameter("@nurpw", SqlDbType.Int, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, pwgen));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
//return null;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
//return 0;
}
public void insert_log(int loglevel, int userid, string description)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("sp_insert_logentry", myConnection);
myCommand.Parameters.Add(new SqlParameter("@userid", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, userid));
myCommand.Parameters.Add(new SqlParameter("@entrydescription", SqlDbType.VarChar, 4096, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, description));
myCommand.Parameters.Add(new SqlParameter("@level", SqlDbType.VarChar, 4096, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, loglevel));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
//return null;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
//return 0;
}
public void add_new_mannschaft(string verein, string usernr)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("add_mannschaft", myConnection);
myCommand.Parameters.Add(new SqlParameter("@vereinnr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, verein));
myCommand.Parameters.Add(new SqlParameter("@usernr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, usernr));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
//return null;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
//return 0;
}
public int Add_New_Teilnehmer(string vereinnr, string usernr)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("add_Teilnehmer", myConnection);
myCommand.Parameters.Add(new SqlParameter("@vereinnr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, vereinnr));
myCommand.Parameters.Add(new SqlParameter("@usernr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, usernr));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
return 0;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
return 0;
}
public int Check_Teilnehmer(string vereinnr, string usernr)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("chk_Teilnehmer", myConnection);
myCommand.Parameters.Add(new SqlParameter("@vereinnr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, vereinnr));
myCommand.Parameters.Add(new SqlParameter("@usernr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, usernr));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
return 0;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
return 0;
}
public int Add_Athlet(string Vereinnr, int Athlete_id, string user)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("add_athlet", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add(new SqlParameter("@vereinnr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, Vereinnr));
myCommand.Parameters.Add(new SqlParameter("@athletid", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, Athlete_id));
myCommand.Parameters.Add(new SqlParameter("@usernr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, user));
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
return 0;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
return 0;
}
public void Add_Nicht_angemeldete_Teilnehmer(string vereinnr, string usernr)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("add_all_Teilnehmer", myConnection);
myCommand.Parameters.Add(new SqlParameter("@vereinnr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, vereinnr));
myCommand.Parameters.Add(new SqlParameter("@usernr", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, usernr));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
}
public void truncate_table(string tablename)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("truncate table " + tablename, myConnection);
myCommand.CommandType = CommandType.Text;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
}
public string migrate_taf_resultate(string ortnr, string deldata)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("[dbo].[Migrate_TAF_Import]", myConnection);
// if (deldata == "False") ortnr = "0";
myCommand.Parameters.Add(new SqlParameter("@ortnr", SqlDbType.Int, 3, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, ortnr));
myCommand.Parameters.Add(new SqlParameter("@return", SqlDbType.Int, 3, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
myCommand.Parameters.Add(new SqlParameter("@statistics", SqlDbType.VarChar, 8096, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, ""));
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
return myCommand.Parameters["@statistics"].Value.ToString();
}
catch (Exception ex)
{
return "Fehler:"+ex.Message;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
}
public void update_verein(string targetfolder)
{
truncate_table("base_account_import");
String Filter = AlabusTransfer.Properties.Settings.Default.VereinFiler;
string[] filters = Filter.Split(',');
Get_Tabeldata_for_Update ("Select * from base_account_import",false,true);
DataSet verein = new DataSet();
verein.ReadXml(targetfolder + "\\verein.xml");
foreach (DataRow r in verein.Tables[0].Rows)
{
DataRow rn = dsdaten.Tables[0].NewRow();
Boolean useit;
useit = false;
foreach(var filt in filters)
{
if (r["accountcode"].ToString().IndexOf(filt) > 0) useit = true;
}
if (useit == true)
{
rn["account_code"] = r["accountCode"];
rn["account_name"] = r["accountName"];
rn["account_short"] = r["accountShort"];
rn["account_type"] = r["accountType"];
rn["lg"] = r["lg"];
dsdaten.Tables[0].Rows.Add(rn);
}
}
Update_Tabeldata();
}
public string get_unicode(string inputstring, DataTable unicodes)
{
string res = "";
string res1 = "";
char[] characters = inputstring.ToCharArray();
foreach (char c in characters)
{
res1 = "";
foreach (DataRow r in unicodes.Rows)
{
int ascii = (int)c;
if (ascii == Convert.ToInt32(r[0]))
{
res1 = r[1].ToString();
}
}
if (res1=="")
{
res = res + c.ToString();
}
else
{
res = res + res1;
}
}
return res;
}
public void update_athlete(string targetfolder)
{
dsdaten.Tables.Clear();
Get_Tabledata("Select * from charconvert", false, true);
DataTable unicodes = new DataTable();
unicodes = dsdaten.Tables[0].Copy();
dsdaten.Tables.Clear();
String Filter = AlabusTransfer.Properties.Settings.Default.VereinFiler;
string[] filters = Filter.Split(',');
DataSet athlete = new DataSet();
athlete.ReadXml(targetfolder + "\\athlete.xml");
foreach (DataRow r in athlete.Tables[0].Rows)
{
Boolean useit;
useit = false;
foreach (var filt in filters)
{
if (r["accountcode"].ToString().IndexOf(filt) > 0) useit = true;
}
if (useit == true)
{
Get_Tabeldata_for_Update("Select * from base_athlete where license=" + r["license"].ToString(), false, true);
if (dsdaten.Tables[0].Rows.Count == 0)
{
DataRow rn = dsdaten.Tables[0].NewRow();
//string a = "";
//ASCIIEncoding ascii = new ASCIIEncoding();
//Byte[] bytes = ascii.GetBytes(r["Lastname"].ToString());
//String decoded = ascii.GetString(bytes);
//if (decoded.IndexOf("o?in") > -1)
//{
// decoded = decoded.Replace("o?in", "ošin");
// r["Lastname"] = decoded;
//}
r["lastname"] = get_unicode(r["lastname"].ToString(),unicodes);
r["firstname"] = get_unicode(r["firstname"].ToString(),unicodes);
rn["lastname"] = r["lastname"];
rn["firstname"] = r["firstname"];
rn["birth_date"] = r["birthdate"].ToString().Substring(3,2)+"."+ r["birthdate"].ToString().Substring(0, 2) + "."+r["birthdate"].ToString().Substring(6, 4);
rn["sex"] = r["sex"];
rn["nationality"] = r["nationality"];
rn["account_code"] = r["accountcode"];
rn["second_account_code"] = r["secondaccountcode"];
rn["account_info"] = r["lastKnownAccountInfo"];
rn["license_Paid"] = r["licensepaid"];
rn["license_Cat"] = r["licensecat"];
rn["license"] = r["license"];
dsdaten.Tables[0].Rows.Add(rn);
Update_Tabeldata();
}
else
{
DataRow rn = dsdaten.Tables[0].NewRow();
//string a = "";
//ASCIIEncoding ascii = new ASCIIEncoding();
//Byte[] bytes = ascii.GetBytes(r["Lastname"].ToString());
//String decoded = ascii.GetString(bytes);
//if (decoded.IndexOf("o?in")>-1)
//{
// decoded = decoded.Replace("o?in", "ošin");
// r["Lastname"] = decoded;
//}
if (r["License"].ToString() == "173471")
{
string a = "";
}
r["lastname"] = get_unicode(r["lastname"].ToString(),unicodes);
r["firstname"] = get_unicode(r["firstname"].ToString(),unicodes);
dsdaten.Tables[0].Rows[0]["lastname"] = r["lastname"];
dsdaten.Tables[0].Rows[0]["firstname"] = r["firstname"];
dsdaten.Tables[0].Rows[0]["birth_date"] = r["birthdate"].ToString().Substring(3, 2) + "." + r["birthdate"].ToString().Substring(0, 2) + "." + r["birthdate"].ToString().Substring(6, 4); ;
dsdaten.Tables[0].Rows[0]["sex"] = r["sex"];
dsdaten.Tables[0].Rows[0]["nationality"] = r["nationality"];
dsdaten.Tables[0].Rows[0]["account_code"] = r["accountcode"];
dsdaten.Tables[0].Rows[0]["second_account_code"] = r["secondaccountcode"];
dsdaten.Tables[0].Rows[0]["account_info"] = r["lastKnownAccountInfo"];
dsdaten.Tables[0].Rows[0]["license_paid"] = r["licensepaid"];
dsdaten.Tables[0].Rows[0]["license_cat"] = r["licensecat"];
//dsdaten.Tables[0].AcceptChanges();
Update_Tabeldata();
}
}
}
}
public DataSet Get_Reportdata(string Orte, string U1012, string erdgas, string vierkampf, int ortnr)
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("dbo.res_resultate_aufbereiten", myConnection);
myCommand.Parameters.Add("@orte", SqlDbType.VarChar, 1024);
myCommand.Parameters.Add("@U10U12", SqlDbType.VarChar, 1);
if (vierkampf == "J")
{
myCommand.Parameters.Add("@resqw", SqlDbType.Int, 4);
myCommand.Parameters.Add("@resew", SqlDbType.Int, 4);
myCommand.Parameters.Add("@resortnr", SqlDbType.Int, 4);
myCommand.Parameters[4].Value = ortnr;
myCommand.Parameters[3].Value = 0;
myCommand.Parameters[2].Value = 1;
}
if (erdgas == "J")
{
myCommand.Parameters.Add("@resqw", SqlDbType.Int, 4);
myCommand.Parameters.Add("@resew", SqlDbType.Int, 4);
myCommand.Parameters.Add("@resortnr", SqlDbType.Int, 4);
myCommand.Parameters[4].Value = ortnr;
myCommand.Parameters[3].Value = 1;
myCommand.Parameters[2].Value = 0;
}
myCommand.Parameters[0].Value = Orte;
myCommand.Parameters[1].Value = U1012;
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.CommandTimeout = 600;
SqlDataAdapter da = new SqlDataAdapter(myCommand);
try
{
myConnection.Open();
da.Fill(dsdaten, "Daten");
//myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
return dsdaten;
}
public void Insert_Disziplin_select(int ortnr)
{
}
public void Import_Statistik()
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("sp_import_statistik", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
//return null;
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
//return 0;
}
}

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Web;
namespace AlabusTransfer.Helper
{
public class zipHelper
{
public void Decompress(FileInfo fileToDecompress)
{
using (FileStream originalFileStream = fileToDecompress.OpenRead())
{
string currentFileName = fileToDecompress.FullName;
string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);
using (FileStream decompressedFileStream = File.Create(newFileName))
{
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
{
decompressionStream.CopyTo(decompressedFileStream);
Console.WriteLine("Decompressed: {0}", fileToDecompress.Name);
}
}
}
}
}
}

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using System.Configuration;
namespace AlabusTransfer
{
internal class Program
{
static void Main(string[] args)
{
string url = Properties.Settings.Default.URL;
CallRestMethod(url);
}
static void CallRestMethod(string url)
{
//var wc = new WebClient();
//var data = wc.DownloadString(url);
string dbconnection = Properties.Settings.Default.QWToolConnectionstring;
String userName = Properties.Settings.Default.UID;
String passWord = Properties.Settings.Default.PWD;
Uri restUri = new Uri(url);
string localTarget = Properties.Settings.Default.TransferPath + "DataDownload.gz";
// String userName = "40307";
// String passWord = "Turicum18";
string noDownload = Properties.Settings.Default.NoDownload;
if (noDownload != "YES")
{
string credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(userName + ":" + passWord));
using (var webClient = new WebClient())
{
webClient.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
webClient.DownloadFile(restUri, localTarget);
}
}
unzip_file();
load_data();
}
static void unzip_file()/* TODO ERROR: Skipped SkippedTokensTrivia */
{
string filename = "DataDownload.gz";
string targetFolder = Properties.Settings.Default.TransferPath;
filename = targetFolder + "\\" + filename;
string extension;
extension = System.IO.Path.GetExtension(filename);
if (extension == ".gz")
{
Helper.zipHelper csh = new Helper.zipHelper();
var fi = new System.IO.FileInfo(filename);
csh.Decompress(fi);
System.Data.DataSet DS = new System.Data.DataSet();
string fn;
fn = System.IO.Path.GetFileNameWithoutExtension(filename);
DS.ReadXml(targetFolder + "\\" + fn);
System.Data.DataSet dsverein = new System.Data.DataSet();
dsverein.Tables.Add(DS.Tables["account"].Copy());
System.Data.DataSet dsathlete = new System.Data.DataSet();
dsathlete.Tables.Add(DS.Tables["athlete"].Copy());
dsverein.WriteXml(targetFolder + "\\verein.xml");
dsathlete.WriteXml(targetFolder + "\\athlete.xml");
}
}
static void load_data()
{
Log log = new Log();
log.insert_entry(2, 0, "Start load data");
clsDB db = new clsDB();
string targetFolder = Properties.Settings.Default.TransferPath;
db.update_verein(targetFolder);
db.update_athlete(targetFolder);
log.insert_entry(2, 0, "Ende load data");
db.Import_Statistik();
log.insert_entry(2, 0, "Statistik nachgeführt");
}
}
}

@ -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 einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("AlabusTransfer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AlabusTransfer")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("42e33f05-d798-4f84-a594-12b713ec8ae7")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,122 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AlabusTransfer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.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;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://alabus.swiss-athletics.ch/rest/License/Athletica/ExportStammDataFull")]
public string URL {
get {
return ((string)(this["URL"]));
}
set {
this["URL"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("40307")]
public string UID {
get {
return ((string)(this["UID"]));
}
set {
this["UID"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Turicum18")]
public string PWD {
get {
return ((string)(this["PWD"]));
}
set {
this["PWD"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\Software-Projekte\\QW-Tool\\QW2021C\\Upload\\transfer\\")]
public string TransferPath {
get {
return ((string)(this["TransferPath"]));
}
set {
this["TransferPath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=shu00;Initial Catalog=qw2021_prod;User ID=sa;Password=*shu29")]
public string QWToolConnectionstring {
get {
return ((string)(this["QWToolConnectionstring"]));
}
set {
this["QWToolConnectionstring"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("No")]
public string NoDownload {
get {
return ((string)(this["NoDownload"]));
}
set {
this["NoDownload"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1")]
public string LogLevel {
get {
return ((string)(this["LogLevel"]));
}
set {
this["LogLevel"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(".ZH.,.ZZ.")]
public string VereinFiler {
get {
return ((string)(this["VereinFiler"]));
}
set {
this["VereinFiler"] = value;
}
}
}
}

@ -0,0 +1,30 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="AlabusTransfer.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="URL" Type="System.String" Scope="User">
<Value Profile="(Default)">https://alabus.swiss-athletics.ch/rest/License/Athletica/ExportStammDataFull</Value>
</Setting>
<Setting Name="UID" Type="System.String" Scope="User">
<Value Profile="(Default)">40307</Value>
</Setting>
<Setting Name="PWD" Type="System.String" Scope="User">
<Value Profile="(Default)">Turicum18</Value>
</Setting>
<Setting Name="TransferPath" Type="System.String" Scope="User">
<Value Profile="(Default)">E:\Software-Projekte\QW-Tool\QW2021C\Upload\transfer\</Value>
</Setting>
<Setting Name="QWToolConnectionstring" Type="System.String" Scope="User">
<Value Profile="(Default)">Data Source=shu00;Initial Catalog=qw2021_prod;User ID=sa;Password=*shu29</Value>
</Setting>
<Setting Name="NoDownload" Type="System.String" Scope="User">
<Value Profile="(Default)">No</Value>
</Setting>
<Setting Name="LogLevel" Type="System.String" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="VereinFiler" Type="System.String" Scope="User">
<Value Profile="(Default)">.ZH.,.ZZ.</Value>
</Setting>
</Settings>
</SettingsFile>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Configuration.ConfigurationManager" version="6.0.0" targetFramework="net48" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net48" />
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net48" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net48" />
</packages>

@ -1,15 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
# Visual Studio Version 16
VisualStudioVersion = 16.0.31613.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QW2021C", "QW2021C.csproj", "{1FC10A94-F028-4DB2-AD48-F0F18234A4A2}"
EndProject
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "QWDB2021", "..\QWDB2021\QWDB2021.sqlproj", "{462FDF0F-C822-41D2-AFD5-40629F20B7B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransferStammdaten", "..\TransferStammdaten\TransferStammdaten.csproj", "{C5194EF7-C2E5-4711-B224-DD1CD9183079}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlabusTransfer", "..\AlabusTransfer\AlabusTransfer.csproj", "{42E33F05-D798-4F84-A594-12B713EC8AE7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlabusTransfer", "AlabusTransfer\AlabusTransfer.csproj", "{42E33F05-D798-4F84-A594-12B713EC8AE7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -27,10 +25,6 @@ Global
{462FDF0F-C822-41D2-AFD5-40629F20B7B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{462FDF0F-C822-41D2-AFD5-40629F20B7B9}.Release|Any CPU.Build.0 = Release|Any CPU
{462FDF0F-C822-41D2-AFD5-40629F20B7B9}.Release|Any CPU.Deploy.0 = Release|Any CPU
{C5194EF7-C2E5-4711-B224-DD1CD9183079}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5194EF7-C2E5-4711-B224-DD1CD9183079}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5194EF7-C2E5-4711-B224-DD1CD9183079}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5194EF7-C2E5-4711-B224-DD1CD9183079}.Release|Any CPU.Build.0 = Release|Any CPU
{42E33F05-D798-4F84-A594-12B713EC8AE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42E33F05-D798-4F84-A594-12B713EC8AE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42E33F05-D798-4F84-A594-12B713EC8AE7}.Release|Any CPU.ActiveCfg = Release|Any CPU

Loading…
Cancel
Save