AlabusImport hinzugefügt
This commit is contained in:
94
AlabusTransfer/Program.cs
Normal file
94
AlabusTransfer/Program.cs
Normal file
@@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user