You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
5.2 KiB
150 lines
5.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Net;
|
|
using System.IO;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
|
|
namespace OnDoc_Paketversand
|
|
{
|
|
internal class Program
|
|
{
|
|
private static string connectionstring { get; set; } = "";
|
|
private static DataSet dsdaten = new DataSet();
|
|
private static DataTable SP_Parameters = new DataTable();
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
run();
|
|
}
|
|
|
|
public static void InitLogging()
|
|
{
|
|
|
|
|
|
Get_Tabledata("Select * from nlog_parameter WHERE ID=4", false, true);
|
|
Logging.Logging.IntLogLevel = dsdaten.Tables[0].Rows[0]["LogLevel"].ToString();
|
|
Logging.Logging.IntUserID = dsdaten.Tables[0].Rows[0]["LogUserID"].ToString();
|
|
Logging.Logging.connectionstring = Properties.Settings.Default.LogConnectionstring;
|
|
Logging.Logging.init_logger();
|
|
|
|
}
|
|
|
|
private static void run(){
|
|
connectionstring = Properties.Settings.Default.Connectionstring;
|
|
Console.WriteLine(connectionstring);
|
|
|
|
string URLBase = Properties.Settings.Default.RESTURI + "api/Send_Versandstrasse?paketid=";
|
|
Console.WriteLine(URLBase);
|
|
Get_Tabledata("Select id,paket from ondoc_versandstrasse_paket where versendet=0 and geloescht=0 and aktiv=1 order by versandoption", false, true);
|
|
foreach (System.Data.DataRow dr in dsdaten.Tables[0].Rows)
|
|
{
|
|
Console.WriteLine("PaketID:"+ dr[0].ToString());
|
|
string jsonstring = dr[1].ToString();
|
|
string URL = URLBase+ dr[0].ToString();
|
|
WebRequest request;
|
|
var data = Encoding.UTF8.GetBytes(jsonstring);
|
|
request = WebRequest.Create(URL);
|
|
request.ContentLength = data.Length;
|
|
request.ContentType = "application/json";
|
|
request.Method = "POST";
|
|
request.Headers["Authorization"] = "Bearer " + Properties.Settings.Default.APIKey;
|
|
string response;
|
|
try
|
|
{
|
|
|
|
using (Stream requestStream = request.GetRequestStream())
|
|
{
|
|
requestStream.Write(data, 0, data.Length);
|
|
requestStream.Close();
|
|
|
|
using (Stream responseStream = request.GetResponse().GetResponseStream())
|
|
{
|
|
using (var reader = new StreamReader(responseStream))
|
|
{
|
|
response = reader.ReadToEnd();
|
|
}
|
|
if (response.ToString().Contains("archiviert"))
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
catch { }
|
|
|
|
}
|
|
}
|
|
private static DataTable Get_Tabledata(string Tablename, bool StoredProc = false, bool is_SQL_String = false, DataTable sp_params = null)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (sp_params == null && SP_Parameters.Rows.Count > 0)
|
|
{
|
|
sp_params = SP_Parameters.Copy();
|
|
}
|
|
|
|
SqlConnection sqlconnect = new SqlConnection();
|
|
DataSet ds = new DataSet();
|
|
ds.Tables.Clear();
|
|
dsdaten.Tables.Clear();
|
|
|
|
|
|
sqlconnect.ConnectionString = connectionstring;
|
|
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;
|
|
try
|
|
{
|
|
foreach (DataRow r in sp_params.Rows)
|
|
{
|
|
sqlcmd.Parameters.Add(r["Paramname"].ToString(), SqlDbType.VarChar);
|
|
sqlcmd.Parameters[sqlcmd.Parameters.Count - 1].Value = r["Paramvalue"].ToString();
|
|
}
|
|
}
|
|
catch { };
|
|
|
|
}
|
|
else
|
|
{
|
|
sqlcmd.CommandType = CommandType.Text;
|
|
sqlcmd.CommandText = "Select * from " + Tablename;
|
|
}
|
|
if (is_SQL_String == true)
|
|
sqlcmd.CommandText = Tablename;
|
|
da.SelectCommand = sqlcmd;
|
|
sqlconnect.Open();
|
|
da.Fill(dsdaten, "Daten1");
|
|
sqlconnect.Close();
|
|
|
|
return dsdaten.Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|