Update Alabus Transfer (Log, Mail)

This commit is contained in:
2022-03-14 18:22:30 +01:00
parent f37abea441
commit a784ff2300
14 changed files with 1736 additions and 57 deletions

View File

@@ -13,6 +13,22 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>E:\Software-Projekte\QW-Tool\QW2021C\AlabusTransfer\Publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +49,18 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>B2D3805DDB68949D8F04A76502815D29F892EBAE</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>AlabusTransfer_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
@@ -64,6 +92,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Helper\clsdb.cs" />
<Compile Include="Helper\clsMailClient.cs" />
<Compile Include="Helper\Log.cs" />
<Compile Include="Helper\zipHelper.cs" />
<Compile Include="Program.cs" />
@@ -75,6 +104,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="AlabusTransfer_TemporaryKey.pfx" />
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
@@ -82,5 +112,17 @@
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -34,6 +34,18 @@
<setting name="VereinFiler" serializeAs="String">
<value>.ZH.,.ZZ.</value>
</setting>
<setting name="mailserver" serializeAs="String">
<value>mail.shub.ch</value>
</setting>
<setting name="sender" serializeAs="String">
<value>qwtool@shub.ch</value>
</setting>
<setting name="empfaenger" serializeAs="String">
<value>qwtool@shub.ch</value>
</setting>
<setting name="cred" serializeAs="String">
<value>ToolQW*2022</value>
</setting>
</AlabusTransfer.Properties.Settings>
</userSettings>
</configuration>

View File

@@ -16,20 +16,24 @@ using System.Configuration;
using Convert = System.Convert;
public class Log
namespace AlabusTransfer.Helper
{
public void insert_entry(int loglevel, int userid, string description)
public class Log
{
clsDB db = new clsDB();
if (loglevel <= get_level()) db.insert_log(loglevel, userid, description);
}
public void insert_entry(int loglevel, int userid, string description)
{
clsDB db = new clsDB();
db.insert_log(1, userid, description);
}
private int get_level()
{
return Convert.ToInt32(AlabusTransfer.Properties.Settings.Default.LogLevel);
private int get_level()
{
return Convert.ToInt32(AlabusTransfer.Properties.Settings.Default.LogLevel);
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
using System.Net;
namespace AlabusTransfer.Helper
{
internal class clsMailClient
{
public void CreateTestMessage(string Betreff, string Nachricht)
{
var smtpClient = new SmtpClient(Properties.Settings.Default.mailserver)
{
Port = 587,
Credentials = new NetworkCredential(Properties.Settings.Default.sender, Properties.Settings.Default.cred),
EnableSsl = true,
};
smtpClient.Send(Properties.Settings.Default.sender, Properties.Settings.Default.empfaenger, Betreff, Nachricht);
}
}
}

View File

@@ -699,6 +699,34 @@ public class clsDB
}
//return 0;
}
public string get_importstatistik()
{
SqlConnection myConnection = new SqlConnection(this.Connectionstring);
SqlCommand myCommand = new SqlCommand("dbo.sp_import_statistik", myConnection);
myCommand.Parameters.Add("@fnkt", SqlDbType.Int, 4);
myCommand.Parameters[0].Value = 2;
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.CommandTimeout = 600;
SqlDataAdapter da = new SqlDataAdapter(myCommand);
dsdaten.Tables.Clear();
try
{
myConnection.Open();
da.Fill(dsdaten, "Daten");
//myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}
return dsdaten.Tables[0].Rows[0][0].ToString();
}

View File

@@ -12,17 +12,29 @@ namespace AlabusTransfer
{
internal class Program
{
static Helper.Log Log = new Helper.Log();
static void Main(string[] args)
{
Log.insert_entry(0, 0, "Start Alabus-Abgleich");
string url = Properties.Settings.Default.URL;
CallRestMethod(url);
Log.insert_entry(0, 0, "Ende Alabus-Abgleich");
clsDB db = new clsDB();
Helper.clsMailClient mc = new Helper.clsMailClient();
mc.CreateTestMessage("QW-Tool: Autom. Alabus-Import", db.get_importstatistik());
Log.insert_entry(0, 0, "Mail versandt");
}
static void CallRestMethod(string url)
{
//var wc = new WebClient();
//var data = wc.DownloadString(url);
Log.insert_entry(0, 0, "Start Alabus-Download");
string dbconnection = Properties.Settings.Default.QWToolConnectionstring;
String userName = Properties.Settings.Default.UID;
String passWord = Properties.Settings.Default.PWD;
@@ -41,6 +53,7 @@ namespace AlabusTransfer
webClient.DownloadFile(restUri, localTarget);
}
}
Log.insert_entry(0, 0, "Ende Alabus-Download");
unzip_file();
load_data();
@@ -48,6 +61,7 @@ namespace AlabusTransfer
static void unzip_file()/* TODO ERROR: Skipped SkippedTokensTrivia */
{
Log.insert_entry(0, 0, "Start Unzip");
string filename = "DataDownload.gz";
string targetFolder = Properties.Settings.Default.TransferPath;
filename = targetFolder + "\\" + filename;
@@ -71,19 +85,21 @@ namespace AlabusTransfer
dsathlete.WriteXml(targetFolder + "\\athlete.xml");
}
Log.insert_entry(0, 0, "Ende Unzipü");
}
static void load_data()
{
Log log = new Log();
log.insert_entry(2, 0, "Start load data");
Log.insert_entry(0, 0, "Start Data Load");
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");
Log.insert_entry(0, 0, "Ende Data Load");
db.Import_Statistik();
log.insert_entry(2, 0, "Statistik nachgeführt");
Log.insert_entry(0, 0, "Statistik nachgeführt");
}
}

View File

@@ -118,5 +118,53 @@ namespace AlabusTransfer.Properties {
this["VereinFiler"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("mail.shub.ch")]
public string mailserver {
get {
return ((string)(this["mailserver"]));
}
set {
this["mailserver"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("qwtool@shub.ch")]
public string sender {
get {
return ((string)(this["sender"]));
}
set {
this["sender"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("qwtool@shub.ch")]
public string empfaenger {
get {
return ((string)(this["empfaenger"]));
}
set {
this["empfaenger"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("ToolQW*2022")]
public string cred {
get {
return ((string)(this["cred"]));
}
set {
this["cred"] = value;
}
}
}
}

View File

@@ -26,5 +26,17 @@
<Setting Name="VereinFiler" Type="System.String" Scope="User">
<Value Profile="(Default)">.ZH.,.ZZ.</Value>
</Setting>
<Setting Name="mailserver" Type="System.String" Scope="User">
<Value Profile="(Default)">mail.shub.ch</Value>
</Setting>
<Setting Name="sender" Type="System.String" Scope="User">
<Value Profile="(Default)">qwtool@shub.ch</Value>
</Setting>
<Setting Name="empfaenger" Type="System.String" Scope="User">
<Value Profile="(Default)">qwtool@shub.ch</Value>
</Setting>
<Setting Name="cred" Type="System.String" Scope="User">
<Value Profile="(Default)">ToolQW*2022</Value>
</Setting>
</Settings>
</SettingsFile>