commit
This commit is contained in:
@@ -156,12 +156,14 @@
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.Runtime.Serialization">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.ServiceModel">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
@@ -25,7 +28,11 @@ using BS.Shared.Extensions;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using ChatController.ChatKlassen;
|
||||
using DevExpress.Office.Utils;
|
||||
using DevExpress.Pdf;
|
||||
using DevExpress.Pdf.Native;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BeWo.View
|
||||
{
|
||||
@@ -72,9 +79,6 @@ namespace BeWo.View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void GenerateCodeClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!GeneratetTexfield.Text.Equals("") && BeWoApp.Tenant != null && BeWoApp.Mandator.Apikey != null)
|
||||
@@ -202,52 +206,227 @@ namespace BeWo.View
|
||||
}
|
||||
}
|
||||
|
||||
//############################# Anderer Versuch
|
||||
private string ErmittleServerURL(string customerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
string url = "https://dict.ownchat.de/api/server/resolve/1/" + customerId;//customerId; //customerid == kundennummer
|
||||
|
||||
WebRequest request = WebRequest.Create(url);
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
|
||||
Stream dataStream = response.GetResponseStream();
|
||||
|
||||
StreamReader reader = new StreamReader(dataStream);
|
||||
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
|
||||
dataStream.Dispose();
|
||||
reader.Dispose();
|
||||
|
||||
dataStream.Close();
|
||||
reader.Close();
|
||||
|
||||
// string responseFromServer = ReadStreamForChatCode(response);
|
||||
|
||||
var definition = new { status = "", URL = "", SYNCTYPE = "" };
|
||||
|
||||
var jsondaten = JsonConvert.DeserializeAnonymousType(responseFromServer, definition);
|
||||
|
||||
string serverUrl = jsondaten.URL;
|
||||
response.Close();
|
||||
|
||||
return serverUrl;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int Lekomio(string customerId, string apikey)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
int Result = 0;
|
||||
|
||||
string serverUrl = ErmittleServerURL(customerId);
|
||||
|
||||
if (serverUrl == null)
|
||||
{
|
||||
return Result = 11;
|
||||
}
|
||||
else if (serverUrl.Equals(""))
|
||||
{
|
||||
return Result = 11;
|
||||
}
|
||||
|
||||
|
||||
// ab hier switch case
|
||||
var endurl = serverUrl + "/api/ownchat/createpdfmanual/" + apikey + "/" + customerId;
|
||||
|
||||
|
||||
Dictionary<string, string> postparameter = new Dictionary<string, string>();
|
||||
|
||||
postparameter.Add("username", "HAns");
|
||||
postparameter.Add("password", "Dito");
|
||||
|
||||
//neu | hinzufügen laut document
|
||||
postparameter.Add("chatcode", "yyAbrams");
|
||||
|
||||
string postdaten = "";
|
||||
int i = 0;
|
||||
foreach (var key in postparameter.Keys)
|
||||
{
|
||||
//hier noch chatcode übergeben
|
||||
postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(postparameter[key]) + "&";
|
||||
|
||||
}
|
||||
|
||||
WebRequest requesten = WebRequest.Create(endurl);
|
||||
|
||||
requesten.Method = "POST";
|
||||
requesten.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
byte[] daten = Encoding.ASCII.GetBytes(postdaten);
|
||||
|
||||
requesten.ContentLength = daten.Length;
|
||||
|
||||
try
|
||||
{
|
||||
Stream requestStream = requesten.GetRequestStream();
|
||||
|
||||
requestStream.Write(daten, 0, daten.Length);
|
||||
|
||||
requestStream.Close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK);
|
||||
|
||||
}
|
||||
|
||||
HttpWebResponse response = (HttpWebResponse) requesten.GetResponse();
|
||||
|
||||
|
||||
Stream ahh = new MemoryStream(); // = new Stream();
|
||||
|
||||
//response.GetResponseStream().CopyTo(ahh);
|
||||
|
||||
StreamReader reader = new StreamReader(ahh);
|
||||
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
|
||||
|
||||
if (responseFromServer.Contains("PDF"))
|
||||
{
|
||||
//################# Ab Hier Funktionsfähiger Code #############################
|
||||
//--------------------- Save In File ------------------------------------
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
|
||||
saveFileDialog1.Title = "PDF Speichern";
|
||||
saveFileDialog1.FileName = Path.GetFileName("ownChat-Kurzanleitung.pdf");
|
||||
saveFileDialog1.ShowDialog();
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
||||
Stream reqStr = response.GetResponseStream();
|
||||
|
||||
int bytesProcessed = 0;
|
||||
|
||||
Stream localStream = File.Create(saveFileDialog1.FileName);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
|
||||
do
|
||||
{
|
||||
// Read data (up to 1k) from the stream
|
||||
bytesRead = reqStr.Read(buffer, 0, buffer.Length);
|
||||
|
||||
// Write the data to the local file
|
||||
localStream.Write(buffer, 0, bytesRead);
|
||||
|
||||
// Increment total bytes processed
|
||||
bytesProcessed += bytesRead;
|
||||
|
||||
} while (bytesRead > 0);
|
||||
|
||||
response.Close();
|
||||
localStream.Close();
|
||||
reqStr.Close();
|
||||
|
||||
Process.Start(saveFileDialog1.FileName);
|
||||
|
||||
return 0;
|
||||
|
||||
//#################################################################################
|
||||
}
|
||||
else
|
||||
{
|
||||
var jsonDatentyp = JsonConvert.DeserializeObject<PdfChatHandoutDC>(responseFromServer);
|
||||
|
||||
return jsonDatentyp.Result;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
var handout = new PdfChatHandoutDC();
|
||||
handout.Result = 60;
|
||||
handout.File = e.Message;
|
||||
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
|
||||
private void ZeigePDF_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
StartWaiting();
|
||||
|
||||
var handout = ServiceFacade.DoOperationsServiceSync(r => r.GetHandOutPdfForChat(BeWoApp.Tenant, BeWoApp.Mandator.Apikey));
|
||||
|
||||
//var handout = ServiceFacade.DoOperationsServiceSync(r => r.GetHandOutPdfForChat("5473568546", "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"/*BeWoApp.Tenant, BeWoApp.Mandator.Apikey*/));
|
||||
var Result = Lekomio("5473568546", "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"/*BeWoApp.Tenant, BeWoApp.Mandator.Apikey*/);
|
||||
|
||||
|
||||
EndWaiting();
|
||||
|
||||
switch (handout.Result)
|
||||
switch (Result)
|
||||
{
|
||||
case 0:
|
||||
|
||||
using (WebClient wc = new WebClient())
|
||||
{
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
// wenn hier dann alles ok
|
||||
|
||||
saveFileDialog1.Title = "PDF Speichern";
|
||||
saveFileDialog1.FileName = Path.GetFileName("ownChat-Kurzanleitung.pdf");
|
||||
saveFileDialog1.ShowDialog();
|
||||
|
||||
wc.DownloadFile(handout.File, saveFileDialog1.FileName);//@"c:\temp\ownChatHandoutEmployee.pdf"
|
||||
|
||||
Process.Start(saveFileDialog1.FileName);
|
||||
}
|
||||
|
||||
break;
|
||||
case 11:
|
||||
MessageBox.Show("Kundennummer unbekannt.", "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Kundennummer unbekannt.", "Fehler", MessageBoxButton.OK);
|
||||
break;
|
||||
case 12:
|
||||
MessageBox.Show("Der API-Key ist falsch -> Auth-Error.", "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Der API-Key ist falsch -> Auth-Error.", "Fehler", MessageBoxButton.OK);
|
||||
break;
|
||||
case 13:
|
||||
MessageBox.Show("Es existiert kein API-Key für die angegebene Kundennummer.", "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Es existiert kein API-Key für die angegebene Kundennummer.", "Fehler", MessageBoxButton.OK);
|
||||
break;
|
||||
case 40:
|
||||
MessageBox.Show("Vorlage nicht gefunden.", "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Vorlage nicht gefunden.", "Fehler", MessageBoxButton.OK);
|
||||
break;
|
||||
case 41:
|
||||
MessageBox.Show("Ungültige Custom-Logo-URL.", "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Ungültige Custom-Logo-URL.", "Fehler", MessageBoxButton.OK);
|
||||
break;
|
||||
case 60:
|
||||
MessageBox.Show("Fehler: \n"+handout.File, "Fehler", MessageBoxButton.OK);
|
||||
MessageBox.Show("Fehler: \n" + "handout.File", "Fehler", MessageBoxButton.OK);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void RemoveCode_OnClick(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -133,6 +133,14 @@ namespace BeWo.View
|
||||
string s = NeuesPwBox.Password;
|
||||
|
||||
|
||||
//################ Foreach String Char if Kopie and paste was triggered ################
|
||||
|
||||
|
||||
|
||||
|
||||
//--> this block foreach Char
|
||||
//############################
|
||||
|
||||
if (s.Length < letztespw.Length)
|
||||
{
|
||||
retschalter = true;
|
||||
|
||||
@@ -30,6 +30,7 @@ using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.DataContracts.Reports;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
using DevExpress.Pdf;
|
||||
using Newtonsoft.Json;
|
||||
using Utils = BeWo.Service.Core.Utils;
|
||||
|
||||
@@ -3512,14 +3513,13 @@ namespace BeWo.Service.ServiceImplementations
|
||||
private string ReadStreamForChatCode(WebResponse response)
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
Stream dataStream = response.GetResponseStream();
|
||||
|
||||
StreamReader reader = new StreamReader(dataStream);
|
||||
|
||||
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
|
||||
|
||||
dataStream.Dispose();
|
||||
reader.Dispose();
|
||||
|
||||
@@ -4592,40 +4592,40 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
|
||||
#region TestBereich Multipart
|
||||
/* Bereich zum Testen Multiform Test gedönse
|
||||
using (MultipartFormDataContent multiPartContent = new MultipartFormDataContent())
|
||||
{
|
||||
Uri requestUri = new Uri(ChatDaten.ServerUrl + "/api/ownchat/createpdfmanual/");
|
||||
//Bereich zum Testen Multiform Test gedönse
|
||||
//using (MultipartFormDataContent multiPartContent = new MultipartFormDataContent())
|
||||
//{
|
||||
// Uri requestUri = new Uri(ChatDaten.ServerUrl + "/api/ownchat/createpdfmanual/");
|
||||
|
||||
//Links Content / Rechts name
|
||||
multiPartContent.Add(new StringContent(chatcode+""), "chatcode");
|
||||
multiPartContent.Add(new StringContent(login + ""), "login");
|
||||
multiPartContent.Add(new StringContent(password + ""), "password");
|
||||
multiPartContent.Add(new StringContent("https://support.bewoplaner.de/bewoplaner_logo_big.png"),"custom_logo_url");
|
||||
// Links Content / Rechts name
|
||||
// multiPartContent.Add(new StringContent(chatcode + ""), "chatcode");
|
||||
// multiPartContent.Add(new StringContent(login + ""), "login");
|
||||
// multiPartContent.Add(new StringContent(password + ""), "password");
|
||||
// multiPartContent.Add(new StringContent("https://support.bewoplaner.de/bewoplaner_logo_big.png"), "custom_logo_url");
|
||||
|
||||
httpRequest = new HttpRequestMessage();
|
||||
httpRequest.Method = HttpMethod.Post;
|
||||
httpRequest.RequestUri = requestUri;
|
||||
httpRequest.Content = multiPartContent;
|
||||
|
||||
httpRequest.Headers.Add("Token", apikey);
|
||||
httpRequest.Headers.Add("CustomerID", customerId);
|
||||
// httpRequest = new HttpRequestMessage();
|
||||
// httpRequest.Method = HttpMethod.Post;
|
||||
// httpRequest.RequestUri = requestUri;
|
||||
// httpRequest.Content = multiPartContent;
|
||||
|
||||
// httpRequest.Headers.Add("Token", apikey);
|
||||
// httpRequest.Headers.Add("CustomerID", customerId);
|
||||
|
||||
|
||||
HttpResponseMessage httpResponse = null;
|
||||
// HttpResponseMessage httpResponse = null;
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
||||
httpResponse = await httpClient.SendAsync(httpRequest, CancellationToken.None).ConfigureAwait(false);
|
||||
// HttpClient httpClient = new HttpClient();
|
||||
|
||||
// httpResponse = await httpClient.SendAsync(httpRequest, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
|
||||
string antwortResponse = await httpResponse.Content.ReadAsStringAsync();
|
||||
|
||||
var jsonDatentyp = JsonConvert.DeserializeObject<PdfChatHandoutDC>(antwortResponse);
|
||||
|
||||
return jsonDatentyp;
|
||||
}
|
||||
*/
|
||||
// string antwortResponse = await httpResponse.Content.ReadAsStringAsync();
|
||||
|
||||
// var jsonDatentyp = JsonConvert.DeserializeObject<PdfChatHandoutDC>(antwortResponse);
|
||||
|
||||
// return jsonDatentyp;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TestBereich Normal Post
|
||||
@@ -4665,22 +4665,81 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
#endregion
|
||||
|
||||
//alt get bereich
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Proxy = null;
|
||||
//############################
|
||||
Dictionary<string, string> postparameter = new Dictionary<string, string>();
|
||||
|
||||
postparameter.Add("username", "HAns");
|
||||
postparameter.Add("password", "Dito");
|
||||
|
||||
//neu | hinzufügen laut document
|
||||
postparameter.Add("chatcode", "yyAbrams");
|
||||
|
||||
string postdaten = "";
|
||||
int i = 0;
|
||||
foreach (var key in postparameter.Keys)
|
||||
{
|
||||
//hier noch chatcode übergeben
|
||||
postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(postparameter[key]) + "&";
|
||||
|
||||
}
|
||||
|
||||
WebRequest requesten = WebRequest.Create(endurl);
|
||||
|
||||
requesten.Method = "POST";
|
||||
requesten.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
byte[] daten = Encoding.ASCII.GetBytes(postdaten);
|
||||
|
||||
requesten.ContentLength = daten.Length;
|
||||
|
||||
try
|
||||
{
|
||||
Stream requestStream = requesten.GetRequestStream();
|
||||
|
||||
requestStream.Write(daten, 0, daten.Length);
|
||||
|
||||
requestStream.Close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK);
|
||||
|
||||
}
|
||||
|
||||
//response bereich | Verarbeiten
|
||||
HttpWebResponse response = (HttpWebResponse)requesten.GetResponse();
|
||||
//response.ContentType = "application/pdf";
|
||||
|
||||
//######################################################################
|
||||
|
||||
//alt get bereich
|
||||
//WebRequest request = WebRequest.Create(endurl);
|
||||
|
||||
//request.Method = WebRequestMethods.Http.Post;
|
||||
|
||||
//request.Credentials = CredentialCache.DefaultCredentials;
|
||||
//request.Proxy = null;
|
||||
|
||||
//WebResponse response = request.GetResponse();
|
||||
|
||||
using (Stream stream = response.GetResponseStream())
|
||||
{
|
||||
byte[] buffer = new byte[stream.Length];
|
||||
stream.Read(buffer, 0, buffer.Length);
|
||||
File.WriteAllBytes("foo.pdf", buffer);
|
||||
}
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
string responseFromServer = ReadStreamForChatCode(response);
|
||||
|
||||
if (responseFromServer.Contains("PDF"))
|
||||
{
|
||||
PdfChatHandoutDC hd = new PdfChatHandoutDC();
|
||||
hd.File = endurl;
|
||||
hd.File = responseFromServer;
|
||||
hd.Result = 0;
|
||||
|
||||
//hd.TestStream = dataStream;
|
||||
|
||||
return hd;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
@@ -12,6 +13,6 @@ namespace BS.Shared.DataContracts
|
||||
|
||||
[DataMember]
|
||||
public int Result { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user