diff --git a/AlabusTransfer/AlabusTransfer.csproj b/AlabusTransfer/AlabusTransfer.csproj
new file mode 100644
index 0000000..6f8a972
--- /dev/null
+++ b/AlabusTransfer/AlabusTransfer.csproj
@@ -0,0 +1,86 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {42E33F05-D798-4F84-A594-12B713EC8AE7}
+ Exe
+ AlabusTransfer
+ AlabusTransfer
+ v4.8
+ 512
+ true
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+ ..\QW2021C\packages\System.Configuration.ConfigurationManager.6.0.0\lib\net461\System.Configuration.ConfigurationManager.dll
+
+
+
+
+
+
+ ..\QW2021C\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll
+
+
+ ..\QW2021C\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll
+
+
+ ..\QW2021C\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
\ No newline at end of file
diff --git a/AlabusTransfer/App.config b/AlabusTransfer/App.config
new file mode 100644
index 0000000..e01d5c6
--- /dev/null
+++ b/AlabusTransfer/App.config
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https://alabus.swiss-athletics.ch/rest/License/Athletica/ExportStammDataFull
+
+
+ 40307
+
+
+ Turicum18
+
+
+ E:\Software-Projekte\QW-Tool\QW2021C\Upload\transfer\
+
+
+ Data Source=shu00;Initial Catalog=qw2021_prod;User ID=sa;Password=*shu29
+
+
+ No
+
+
+ 1
+
+
+ .ZH.,.ZZ.
+
+
+
+
diff --git a/AlabusTransfer/Helper/Log.cs b/AlabusTransfer/Helper/Log.cs
new file mode 100644
index 0000000..63f8c9c
--- /dev/null
+++ b/AlabusTransfer/Helper/Log.cs
@@ -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);
+
+ }
+
+}
+
+
diff --git a/AlabusTransfer/Helper/clsdb.cs b/AlabusTransfer/Helper/clsdb.cs
new file mode 100644
index 0000000..ef76235
--- /dev/null
+++ b/AlabusTransfer/Helper/clsdb.cs
@@ -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;
+ }
+
+
+
+}
diff --git a/AlabusTransfer/Helper/zipHelper.cs b/AlabusTransfer/Helper/zipHelper.cs
new file mode 100644
index 0000000..e5c7501
--- /dev/null
+++ b/AlabusTransfer/Helper/zipHelper.cs
@@ -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);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/AlabusTransfer/Program.cs b/AlabusTransfer/Program.cs
new file mode 100644
index 0000000..21b25b4
--- /dev/null
+++ b/AlabusTransfer/Program.cs
@@ -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");
+
+ }
+ }
+
+
+}
+
+
diff --git a/AlabusTransfer/Properties/AssemblyInfo.cs b/AlabusTransfer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..6f3dc9f
--- /dev/null
+++ b/AlabusTransfer/Properties/AssemblyInfo.cs
@@ -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")]
diff --git a/AlabusTransfer/Properties/Settings.Designer.cs b/AlabusTransfer/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..cc1dddb
--- /dev/null
+++ b/AlabusTransfer/Properties/Settings.Designer.cs
@@ -0,0 +1,122 @@
+//------------------------------------------------------------------------------
+//
+// 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.
+//
+//------------------------------------------------------------------------------
+
+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;
+ }
+ }
+ }
+}
diff --git a/AlabusTransfer/Properties/Settings.settings b/AlabusTransfer/Properties/Settings.settings
new file mode 100644
index 0000000..7db0ad2
--- /dev/null
+++ b/AlabusTransfer/Properties/Settings.settings
@@ -0,0 +1,30 @@
+
+
+
+
+
+ https://alabus.swiss-athletics.ch/rest/License/Athletica/ExportStammDataFull
+
+
+ 40307
+
+
+ Turicum18
+
+
+ E:\Software-Projekte\QW-Tool\QW2021C\Upload\transfer\
+
+
+ Data Source=shu00;Initial Catalog=qw2021_prod;User ID=sa;Password=*shu29
+
+
+ No
+
+
+ 1
+
+
+ .ZH.,.ZZ.
+
+
+
\ No newline at end of file
diff --git a/AlabusTransfer/packages.config b/AlabusTransfer/packages.config
new file mode 100644
index 0000000..f3a5f79
--- /dev/null
+++ b/AlabusTransfer/packages.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/QW2021C.sln b/QW2021C.sln
index 4e7dbb3..e4c3695 100644
--- a/QW2021C.sln
+++ b/QW2021C.sln
@@ -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