cb
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
<Compile Include="ChatMainControl.xaml.cs">
|
||||
<DependentUpon>ChatMainControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Data\OwnChatApi.cs" />
|
||||
<Compile Include="HauptKlassen\Chat.cs" />
|
||||
<Compile Include="HauptKlassen\ChatEmoji.cs" />
|
||||
<Compile Include="LoginControl.xaml.cs">
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ChatController.ChatKlassen
|
||||
public ImageSource Image { get; private set; }
|
||||
public DateTime TimeStamp { get; set; }
|
||||
public long GroupId { get; set; }
|
||||
public long? CustomerPersonOid { get; set; }
|
||||
public long? CustomerOid { get; set; }
|
||||
|
||||
|
||||
public AktuellerKontakt(KontaktlistBuilder kontakt)
|
||||
@@ -25,7 +25,7 @@ namespace ChatController.ChatKlassen
|
||||
Image = kontakt.Image;
|
||||
TimeStamp = kontakt.TimeStamp;
|
||||
Name = kontakt.Name;
|
||||
CustomerPersonOid = kontakt.CustomerPersonOid;
|
||||
CustomerOid = kontakt.CustomerOid;
|
||||
GroupId = kontakt.GroupId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ namespace ChatController.ChatKlassen
|
||||
public DateTime TimeStamp { get; set; }
|
||||
public long GroupId { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public long? CustomerPersonOid { get; set; }
|
||||
public long? CustomerOid { get; set; }
|
||||
|
||||
public KontaktlistBuilder(string name, ImageSource image, string lastMs, DateTime timestamp, long groupid,long? customerPersonOid,bool onlyEmployee, int userCount)
|
||||
public KontaktlistBuilder(string name, ImageSource image, string lastMs, DateTime timestamp, long groupid,long? customerOid, bool onlyEmployee, int userCount)
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
@@ -122,14 +122,14 @@ namespace ChatController.ChatKlassen
|
||||
Image = image;
|
||||
TimeStamp = timestamp;
|
||||
GroupId = groupid;
|
||||
CustomerPersonOid = customerPersonOid;
|
||||
CustomerOid = customerOid;
|
||||
SetzeGelesen = 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (CustomerPersonOid != null)
|
||||
if (CustomerOid != null)
|
||||
{
|
||||
_kontaktChatColor = new BrushConverter().ConvertFromString("#3B7799") as SolidColorBrush;
|
||||
}else if (onlyEmployee && userCount > 2)
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace ChatController
|
||||
public Thread AlleKontakteThread;
|
||||
public bool AlleNachrichtenThreadBool = true;
|
||||
private double? AlleNachrichtenCount = null;
|
||||
|
||||
private List<String> createdTempFiles = new List<String>();
|
||||
|
||||
private Dictionary<String, Action<string>> menuItemName2Callback = new Dictionary<string, Action<string>>();
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace ChatController
|
||||
{
|
||||
var kontakt = (AktuellerKontakt)AktChatUserList.Items[0];
|
||||
|
||||
if (kontakt.CustomerPersonOid == null)
|
||||
if (kontakt.CustomerOid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -177,8 +177,21 @@ namespace ChatController
|
||||
|
||||
ChatListBox.ItemsSource = x;
|
||||
|
||||
ChatListBox.Items.MoveCurrentToLast();
|
||||
ChatListBox.ScrollIntoView(ChatListBox.Items.CurrentItem);
|
||||
//ChatListBox.Items.MoveCurrentToLast();
|
||||
//ChatListBox.ScrollIntoView(ChatListBox.Items.CurrentItem);
|
||||
|
||||
if (VisualTreeHelper.GetChildrenCount(ChatListBox) > 0)
|
||||
{
|
||||
Border border = (Border)VisualTreeHelper.GetChild(ChatListBox, 0);
|
||||
ScrollViewer scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0);
|
||||
scrollViewer.ScrollToBottom();
|
||||
}
|
||||
|
||||
//if (ChatListBox.Items.Count > 0)
|
||||
//{
|
||||
// ChatListBox.SelectedIndex = ChatListBox.Items.Count - 1;
|
||||
// ChatListBox.ScrollIntoView(ChatListBox.SelectedItem);
|
||||
//}
|
||||
|
||||
ChatListBox.ContextMenu = _chat.ErstelleKontextMenue();
|
||||
SetContextHandler();
|
||||
@@ -186,6 +199,8 @@ namespace ChatController
|
||||
|
||||
HorcheAktivNachNachrichten();
|
||||
Cursor = Cursors.Arrow;
|
||||
|
||||
|
||||
disableKontaktNachrichtenThread = false;
|
||||
// EndWaiting();
|
||||
}
|
||||
@@ -335,7 +350,7 @@ namespace ChatController
|
||||
|
||||
//prüfe ob dokumentation erlaubt
|
||||
var kontakt = (AktuellerKontakt)AktChatUserList.Items[0];
|
||||
if (kontakt.CustomerPersonOid == null && ChatListBox.ContextMenu.Items.Count > 3)
|
||||
if (kontakt.CustomerOid == null && ChatListBox.ContextMenu.Items.Count > 3)
|
||||
{
|
||||
var contextItems = ChatListBox.ContextMenu.Items;
|
||||
var ContextItemSpeichernUnter = (MenuItem)contextItems[3];
|
||||
@@ -643,6 +658,8 @@ namespace ChatController
|
||||
var kontakt = (AktuellerKontakt) o;
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
|
||||
if (!disableKontaktNachrichtenThread)
|
||||
{
|
||||
_schaueNachMs = _chat.SchaueNachNeuenNachrichten(kontakt);
|
||||
@@ -673,7 +690,7 @@ namespace ChatController
|
||||
{
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(2000);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -785,7 +802,7 @@ namespace ChatController
|
||||
private void Chat_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Cursor = Cursors.Wait;
|
||||
StartWaiting();
|
||||
|
||||
var chatItems = ChatListBox.SelectedItems;
|
||||
|
||||
if (chatItems.Count > 0)
|
||||
@@ -796,7 +813,8 @@ namespace ChatController
|
||||
|
||||
if (item != null && item.ImageSources != null)
|
||||
{
|
||||
_chat.ShowPicture(item);
|
||||
StartWaiting();
|
||||
_chat.ShowPicture(item, EndWaiting);
|
||||
}
|
||||
else if(item != null && item.Dokpfad != null)
|
||||
{
|
||||
@@ -805,12 +823,10 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
|
||||
EndWaiting();
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
else
|
||||
{
|
||||
EndWaiting();
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
@@ -842,25 +858,41 @@ namespace ChatController
|
||||
}
|
||||
|
||||
private void LoadDokument(string link, String filename)
|
||||
{
|
||||
string path = @"c:\temp\" + filename;
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
webClient.DownloadFile(link, path);
|
||||
}
|
||||
StartWaiting();
|
||||
|
||||
if (File.Exists(path))
|
||||
string path = Path.Combine(Path.GetTempPath(), filename);
|
||||
createdTempFiles.Add(path);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
webClient.DownloadFile(link, path);
|
||||
}
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Process.Start(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
Process.Start(path);
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
EndWaiting();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1023,5 +1055,21 @@ namespace ChatController
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void DeleteTempFiles()
|
||||
{
|
||||
foreach (var file in createdTempFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(file))
|
||||
File.Delete(file);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
110
ChatController/Data/OwnChatApi.cs
Normal file
110
ChatController/Data/OwnChatApi.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using ChatController.Klassen;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ChatController.Data
|
||||
{
|
||||
public class OwnChatApi
|
||||
{
|
||||
private static String serverUrl;
|
||||
private static String apiKey;
|
||||
private static String tenant;
|
||||
|
||||
public static long GetMaximumAllowedFileUploadSize(string apikey, string customerid)
|
||||
{
|
||||
var endurl = serverUrl + "/api/ownchat/uploadmaxsize";// + apikey + "/" + customerid;
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
request.Headers["Token"] = apikey;
|
||||
request.Headers["CustomerID"] = customerid;
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Proxy = null;
|
||||
|
||||
using (WebResponse response = request.GetResponse())
|
||||
{
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
var definiti = new {file_upload_max_size = ""};
|
||||
|
||||
var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
||||
|
||||
return Convert.ToInt64(jsonDatentyp.file_upload_max_size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private UserMessages GetMessages(long groupId)
|
||||
{
|
||||
|
||||
var endurl = serverUrl + "/api/chat/messages?groupid=" + groupId;
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = apiKey;
|
||||
request.Headers["CustomerID"] = tenant;
|
||||
|
||||
using (WebResponse response = request.GetResponse())
|
||||
{
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
if (!String.IsNullOrEmpty(responseFromServer))
|
||||
{
|
||||
var jsonDaten = JsonConvert.DeserializeObject<UserMessages>(responseFromServer);
|
||||
return jsonDaten;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ChatGruppenDaten GetAllChatGroups()
|
||||
{
|
||||
var endurl = serverUrl + "/api/chat/groups";
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = apiKey;
|
||||
request.Headers["CustomerID"] = tenant;
|
||||
|
||||
using (WebResponse response = request.GetResponse())
|
||||
{
|
||||
string responseFromServer = ReadStream(response);
|
||||
return JsonConvert.DeserializeObject<ChatGruppenDaten>(responseFromServer);
|
||||
}
|
||||
}
|
||||
|
||||
private static string ReadStream(WebResponse response)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Stream dataStream = response.GetResponseStream())
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(dataStream))
|
||||
{
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
|
||||
return responseFromServer;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// MessageBox.Show(e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace ChatController.HauptKlassen
|
||||
#region Gruppen In Kontaktliste Wandler
|
||||
public IOrderedEnumerable<KontaktlistBuilder> GroupklassenInChatKontakteUmwandler()
|
||||
{
|
||||
foreach (var kontakt in ChatDaten.Groupconect.Response)
|
||||
foreach (var kontakt in ChatDaten.AlleGruppen.Response)
|
||||
{
|
||||
foreach (var value in kontakt.Value)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace ChatController.HauptKlassen
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
}
|
||||
|
||||
long? isCustomer = null;
|
||||
long? customerOid = null;
|
||||
bool isC = false;
|
||||
bool isE = false;
|
||||
foreach (var user in value.Users)
|
||||
@@ -100,9 +100,10 @@ namespace ChatController.HauptKlassen
|
||||
//oid des
|
||||
if (user.Oid != ChatDaten.Userid)
|
||||
{
|
||||
if (!user.Is_Employee)
|
||||
if (!user.Is_Employee && !String.IsNullOrEmpty(user.Userid_Manage))
|
||||
{
|
||||
isCustomer = user.Oid;
|
||||
|
||||
customerOid = Int64.Parse(user.Userid_Manage.Substring(1));
|
||||
isC = true;
|
||||
}
|
||||
}
|
||||
@@ -115,7 +116,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
//null steht für employee
|
||||
Kontaktliste.Add(new KontaktlistBuilder(value.Name, AvatarToImageSourceConverter(value.Avatar,isE,isC),
|
||||
message, timeformated, value.Oid, isCustomer,value.Onlyemployees,value.Users.Length));
|
||||
message, timeformated, value.Oid, customerOid, value.Onlyemployees,value.Users.Length));
|
||||
|
||||
if(lastMS != null && lastMS.Timestamp != null && lastMS.Timestamp.Date != null) {
|
||||
TimeSpan span = (DateTime.Parse(lastMS.Timestamp.Date) - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
@@ -335,7 +336,6 @@ namespace ChatController.HauptKlassen
|
||||
bix.UriSource = new Uri(link);
|
||||
bix.CacheOption = BitmapCacheOption.OnDemand;
|
||||
bix.EndInit();
|
||||
|
||||
|
||||
return bix;
|
||||
}
|
||||
@@ -356,42 +356,40 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = ChatDaten.AuthToken;
|
||||
request.Headers["CustomerID"] = ChatDaten.Kundennummer;
|
||||
request.Proxy = null;
|
||||
|
||||
|
||||
// Get the response.
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
//verarbeite hier zu json
|
||||
if (!responseFromServer.Equals(""))
|
||||
using (WebResponse response = request.GetResponse())
|
||||
{
|
||||
_userMessages = null;
|
||||
//################# Deserialisierung mit Json ###############################
|
||||
var jsonDaten = JsonConvert.DeserializeObject<UserMessages>(responseFromServer);
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse) response).StatusDescription;
|
||||
|
||||
_userMessages = jsonDaten;
|
||||
|
||||
if (_userMessages.Response.HasMorePages == true)
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
//verarbeite hier zu json
|
||||
if (!responseFromServer.Equals(""))
|
||||
{
|
||||
_nextPage = _userMessages.Response.NextPage;
|
||||
_hasNextPage = true;
|
||||
_userMessages = null;
|
||||
//################# Deserialisierung mit Json ###############################
|
||||
var jsonDaten = JsonConvert.DeserializeObject<UserMessages>(responseFromServer);
|
||||
|
||||
_userMessages = jsonDaten;
|
||||
|
||||
if (_userMessages.Response.HasMorePages == true)
|
||||
{
|
||||
_nextPage = _userMessages.Response.NextPage;
|
||||
_hasNextPage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasNextPage = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasNextPage = false;
|
||||
// MessageBox.Show("Keine Daten Vorhanden.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// MessageBox.Show("Keine Daten Vorhanden.");
|
||||
}
|
||||
|
||||
response.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -549,8 +547,7 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = ChatDaten.AuthToken;
|
||||
request.Headers["CustomerID"] = ChatDaten.Kundennummer;
|
||||
request.Proxy = null;
|
||||
|
||||
|
||||
// Get the response.
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
@@ -601,8 +598,6 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
public bool SchaueNachNeuenNachrichten(AktuellerKontakt kontakt)
|
||||
{
|
||||
TimeSpan lastTs = DateTime.UtcNow.TimeOfDay;
|
||||
|
||||
TimeSpan span = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
long timespan = System.Convert.ToInt64(span.TotalSeconds);
|
||||
//long timespan = //lastTs.TotalSeconds;
|
||||
@@ -615,7 +610,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
if (kontakt != null)
|
||||
{
|
||||
var newMsCount = SendeTimestamp(kontakt.GroupId, timespan);
|
||||
var newMsCount = SendOwnChatNewsRequest(kontakt.GroupId, timespan);
|
||||
|
||||
if (_oldMessageCount == null)
|
||||
{
|
||||
@@ -638,7 +633,7 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
private double? SendeTimestamp(long groupId,long lastStamp)
|
||||
private double? SendOwnChatNewsRequest(long groupId, long lastStamp)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -649,15 +644,14 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = ChatDaten.AuthToken;
|
||||
request.Headers["CustomerID"] = ChatDaten.Kundennummer;
|
||||
request.Proxy = null;
|
||||
|
||||
|
||||
// Get the response.
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
|
||||
|
||||
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
var jsonDaten = JsonConvert.DeserializeObject<MessageCounter>(responseFromServer);
|
||||
@@ -681,7 +675,10 @@ namespace ChatController.HauptKlassen
|
||||
long unixTime = System.Convert.ToInt64(span.TotalSeconds);
|
||||
|
||||
var x = SendeTimestampForEach(0, unixTime);
|
||||
|
||||
if (x > 0)
|
||||
{
|
||||
lastTimeStamp = unixTime;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -751,7 +748,7 @@ namespace ChatController.HauptKlassen
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
}
|
||||
|
||||
long? isCustomer = null;
|
||||
long? customerOid = null;
|
||||
bool isC = false;
|
||||
bool isE = false;
|
||||
foreach (var user in value.Users)
|
||||
@@ -759,9 +756,9 @@ namespace ChatController.HauptKlassen
|
||||
//oid des
|
||||
if (user.Oid != ChatDaten.Userid)
|
||||
{
|
||||
if (!user.Is_Employee)
|
||||
if (!user.Is_Employee && !String.IsNullOrEmpty(user.Userid_Manage))
|
||||
{
|
||||
isCustomer = user.Oid;
|
||||
customerOid = Int64.Parse(user.Userid_Manage.Substring(1));
|
||||
isC = true;
|
||||
}
|
||||
|
||||
@@ -776,7 +773,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
//null steht für employee
|
||||
Kontakt.Add(new KontaktlistBuilder(value.Name, AvatarToImageSourceConverter(value.Avatar,isE,isC),
|
||||
message, timeformated, value.Oid, isCustomer, value.Onlyemployees, value.Users.Length));
|
||||
message, timeformated, value.Oid, customerOid, value.Onlyemployees, value.Users.Length));
|
||||
|
||||
if (lastMS != null && lastMS.Timestamp != null && lastMS.Timestamp.Date != null) {
|
||||
TimeSpan span = (DateTime.Parse(lastMS.Timestamp.Date) - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
|
||||
@@ -815,7 +812,6 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = ChatDaten.AuthToken;
|
||||
request.Headers["CustomerID"] = ChatDaten.Kundennummer;
|
||||
//((HttpWebRequest) request).KeepAlive = false;
|
||||
|
||||
// Get the response.
|
||||
WebResponse response = request.GetResponse();
|
||||
@@ -854,7 +850,7 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
string username = "";
|
||||
|
||||
foreach (var daten in ChatDaten.Userconect.Response)
|
||||
foreach (var daten in ChatDaten.AngemeldeterUser.Response)
|
||||
{
|
||||
username = daten.Value.Firstname + " " + daten.Value.Lastname;
|
||||
}
|
||||
@@ -870,9 +866,7 @@ namespace ChatController.HauptKlassen
|
||||
MessageBox.Show(e.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private HttpWebRequest requesten;
|
||||
|
||||
|
||||
public async void SendMessage(string message, long groupId)
|
||||
{
|
||||
try
|
||||
@@ -1232,7 +1226,7 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Fehler");
|
||||
//MessageBox.Show(e.Message, "Fehler");
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -1630,13 +1624,177 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPicture(ChatMessage curItem)
|
||||
public void ShowPicture(ChatMessage curItem, Action downloadCompletedCallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var webClient = new WebClient();
|
||||
webClient.DownloadDataCompleted += DownoaldKomplett;
|
||||
webClient.DownloadDataCompleted += (s, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
using (Form form = new Form())
|
||||
{
|
||||
using (var ms = new MemoryStream(e.Result))
|
||||
{
|
||||
System.Drawing.Image Img = System.Drawing.Image.FromStream(ms);
|
||||
|
||||
|
||||
using (System.Drawing.Bitmap dImg = new System.Drawing.Bitmap(Img))
|
||||
{
|
||||
using (MemoryStream mss = new MemoryStream())
|
||||
{
|
||||
short orient = 0;
|
||||
int orientationId = 0x0112;
|
||||
|
||||
if (Img.PropertyIdList.Contains(orientationId))
|
||||
{
|
||||
PropertyItem item = Img.GetPropertyItem(orientationId);
|
||||
|
||||
orient = BitConverter.ToInt16(item.Value, 0);
|
||||
|
||||
dImg.SetPropertyItem(item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
var x = OrientationToFlipType(orient.ToString());
|
||||
|
||||
dImg.RotateFlip(x);
|
||||
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
form.ClientSize = dImg.Size;
|
||||
//form.MinimumSize = new Size(180, 180);
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
using (var pb = new PictureBox())
|
||||
{
|
||||
pb.Dock = DockStyle.Fill;
|
||||
pb.Image = dImg;
|
||||
|
||||
pb.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
|
||||
form.Controls.Add(pb);
|
||||
|
||||
downloadCompletedCallback?.Invoke();
|
||||
|
||||
form.ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
//form.Size = dImg.Size; //imgbit
|
||||
//form.MinimumSize = new Size(180, 180);
|
||||
|
||||
//#region Screen Size-ing
|
||||
|
||||
//int width = 0;
|
||||
//int height = 0;
|
||||
//int targetwidth =
|
||||
// (int) Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 1.25);
|
||||
|
||||
|
||||
////Querformat
|
||||
//if (dImg.Height < dImg.Width)
|
||||
//{
|
||||
|
||||
// float factor = (float) dImg.Height / targetwidth;
|
||||
|
||||
// height = targetwidth;
|
||||
|
||||
// width = (int) Math.Round(dImg.Width / factor);
|
||||
|
||||
//}
|
||||
//else // Hochformat
|
||||
//{
|
||||
// float factor = (float) dImg.Width / targetwidth;
|
||||
|
||||
// width = targetwidth;
|
||||
|
||||
// height = (int) Math.Round(dImg.Height / factor);
|
||||
|
||||
//}
|
||||
|
||||
//if (dImg.Width < targetwidth)
|
||||
//{
|
||||
// width = dImg.Width;
|
||||
// height = dImg.Height;
|
||||
//}
|
||||
|
||||
|
||||
//int targetheight =
|
||||
// (int) Math.Round(System.Windows.SystemParameters.PrimaryScreenHeight / 1.25);
|
||||
|
||||
|
||||
////Querformat
|
||||
//if (dImg.Height < dImg.Width)
|
||||
//{
|
||||
|
||||
// float factor = (float) dImg.Width / targetheight;
|
||||
|
||||
// width = targetheight;
|
||||
|
||||
// height = (int) Math.Round(dImg.Height / factor);
|
||||
|
||||
//}
|
||||
//else // Hochformat
|
||||
//{
|
||||
// float factor = (float) dImg.Height / targetheight;
|
||||
|
||||
// height = targetheight;
|
||||
|
||||
// width = (int) Math.Round(dImg.Width / factor);
|
||||
|
||||
//}
|
||||
|
||||
//if (dImg.Height < targetheight)
|
||||
//{
|
||||
// width = dImg.Width;
|
||||
// height = dImg.Height;
|
||||
//}
|
||||
|
||||
|
||||
//if (width < 150 || height < 150)
|
||||
//{
|
||||
// width = 150;
|
||||
// height = 150;
|
||||
//}
|
||||
|
||||
//#endregion
|
||||
|
||||
//form.MaximumSize = new Size(width, height);
|
||||
|
||||
|
||||
//form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
//form.MaximizeBox = false;
|
||||
|
||||
//form.Text = "ownChat";
|
||||
//form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
//PictureBox pb = new PictureBox();
|
||||
//pb.Dock = DockStyle.Fill;
|
||||
//pb.Image = dImg; //imgbit
|
||||
|
||||
//pb.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
|
||||
//form.Controls.Add(pb);
|
||||
//form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception edf)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + edf.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
|
||||
};
|
||||
webClient.DownloadDataAsync(new Uri(curItem.OriginalImage));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1644,149 +1802,6 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
private void DownoaldKomplett(object sender, DownloadDataCompletedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Form form = new Form())
|
||||
{
|
||||
MemoryStream ms = new MemoryStream(e.Result);
|
||||
System.Drawing.Image Img = System.Drawing.Image.FromStream(ms);
|
||||
|
||||
|
||||
using (System.Drawing.Bitmap dImg = new System.Drawing.Bitmap(Img))
|
||||
{
|
||||
using (MemoryStream mss = new MemoryStream())
|
||||
{
|
||||
short orient = 0;
|
||||
int orientationId = 0x0112;
|
||||
|
||||
if (Img.PropertyIdList.Contains(orientationId))
|
||||
{
|
||||
PropertyItem item = Img.GetPropertyItem(orientationId);
|
||||
|
||||
orient = BitConverter.ToInt16(item.Value, 0);
|
||||
|
||||
dImg.SetPropertyItem(item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
var x = OrientationToFlipType(orient.ToString());
|
||||
|
||||
dImg.RotateFlip(x);
|
||||
|
||||
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
form.Size = dImg.Size;//imgbit
|
||||
form.MinimumSize = new Size(180,180);
|
||||
|
||||
#region Screen Size-ing
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int targetwidth = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 1.25);
|
||||
|
||||
|
||||
//Querformat
|
||||
if (dImg.Height < dImg.Width)
|
||||
{
|
||||
|
||||
float factor = (float)dImg.Height / targetwidth;
|
||||
|
||||
height =targetwidth;
|
||||
|
||||
width = (int)Math.Round(dImg.Width / factor);
|
||||
|
||||
}
|
||||
else // Hochformat
|
||||
{
|
||||
float factor = (float)dImg.Width / targetwidth;
|
||||
|
||||
width = targetwidth;
|
||||
|
||||
height = (int)Math.Round(dImg.Height / factor);
|
||||
|
||||
}
|
||||
|
||||
if (dImg.Width < targetwidth)
|
||||
{
|
||||
width = dImg.Width;
|
||||
height = dImg.Height;
|
||||
}
|
||||
|
||||
|
||||
int targetheight = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenHeight / 1.25);
|
||||
|
||||
|
||||
//Querformat
|
||||
if (dImg.Height < dImg.Width)
|
||||
{
|
||||
|
||||
float factor = (float)dImg.Width / targetheight;
|
||||
|
||||
width = targetheight;
|
||||
|
||||
height = (int)Math.Round(dImg.Height / factor);
|
||||
|
||||
}
|
||||
else // Hochformat
|
||||
{
|
||||
float factor = (float)dImg.Height / targetheight;
|
||||
|
||||
height = targetheight;
|
||||
|
||||
width = (int)Math.Round(dImg.Width / factor);
|
||||
|
||||
}
|
||||
|
||||
if (dImg.Height < targetheight)
|
||||
{
|
||||
width = dImg.Width;
|
||||
height = dImg.Height;
|
||||
}
|
||||
|
||||
|
||||
if (width < 150 || height < 150)
|
||||
{
|
||||
width = 150;
|
||||
height = 150;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
form.MaximumSize = new Size(width, height);
|
||||
|
||||
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
form.MaximizeBox = false;
|
||||
|
||||
form.Text = "ownChat";
|
||||
form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
PictureBox pb = new PictureBox();
|
||||
pb.Dock = DockStyle.Fill;
|
||||
pb.Image = dImg;//imgbit
|
||||
|
||||
pb.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
|
||||
form.Controls.Add(pb);
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
ms.Dispose();
|
||||
ms.Close();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception edf)
|
||||
{
|
||||
MessageBox.Show("Fehler: " + edf.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Synchronisation Veranlassen für Bewoplaner OwnChat Version
|
||||
@@ -1850,8 +1865,8 @@ namespace ChatController.HauptKlassen
|
||||
var endurl = ChatDaten.ServerUrl + "/api/ownchat/uploadmaxsize";// + apikey + "/" + customerid;
|
||||
|
||||
WebRequest request = WebRequest.Create(endurl);
|
||||
requesten.Headers["Token"] = apikey;
|
||||
requesten.Headers["CustomerID"] = customerid;
|
||||
request.Headers["Token"] = apikey;
|
||||
request.Headers["CustomerID"] = customerid;
|
||||
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Proxy = null;
|
||||
@@ -1960,16 +1975,16 @@ namespace ChatController.HauptKlassen
|
||||
message = Path.GetFileName(value.LastMessage.File);
|
||||
}
|
||||
|
||||
long? isCustomer = null;
|
||||
long? customerOid = null;
|
||||
bool isC = false;
|
||||
bool isE = false;
|
||||
foreach (var user in value.Users)
|
||||
{
|
||||
if (user.Oid != ChatDaten.Userid)
|
||||
if (user.Oid != ChatDaten.Userid && !String.IsNullOrEmpty(user.Userid_Manage))
|
||||
{
|
||||
if (!user.Is_Employee)
|
||||
{
|
||||
isCustomer = user.Oid;
|
||||
customerOid = Int64.Parse(user.Userid_Manage.Substring(1));
|
||||
isC = true;
|
||||
}
|
||||
}
|
||||
@@ -1982,7 +1997,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
Kontaktliste.Add(new KontaktlistBuilder(value.Name,
|
||||
AvatarToImageSourceConverter(value.Avatar,isE,isC),
|
||||
message, timestamp, value.Oid, isCustomer, value.Onlyemployees, value.Users.Length));
|
||||
message, timestamp, value.Oid, customerOid, value.Onlyemployees, value.Users.Length));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace ChatController.HauptKlassen
|
||||
private bool _gruppeholenverbindungsaufbauOK = false;
|
||||
|
||||
private AuthentifizierungsDaten _serverconect;
|
||||
private UserDaten _userconect;
|
||||
private ChatGruppenDaten _groupconect;
|
||||
private UserDaten _angemeldeterUser;
|
||||
private ChatGruppenDaten _alleGruppen;
|
||||
|
||||
private bool showMessageBox = true;
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
long maxUploadSize = GetMaiximumAllowedFileUploadSize(_authToken,_kundennummer);
|
||||
|
||||
ChatDatenUebergabe ubergabe = new ChatDatenUebergabe(_serverconect, _userconect, _groupconect, _serverUrl, _authToken, _userid, _kundennummer,_apikey, maxUploadSize);
|
||||
ChatDatenUebergabe ubergabe = new ChatDatenUebergabe(_serverconect, _angemeldeterUser, _alleGruppen, _serverUrl, _authToken, _userid, _kundennummer,_apikey, maxUploadSize);
|
||||
|
||||
return ubergabe;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ namespace ChatController.HauptKlassen
|
||||
_userid = datev.Value.Oid;
|
||||
}
|
||||
|
||||
_userconect = jsonDaten;
|
||||
_angemeldeterUser = jsonDaten;
|
||||
|
||||
_ownchatVerbindungsaufbauOK = true;
|
||||
}
|
||||
@@ -327,24 +327,25 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Headers["Token"] = _authToken;
|
||||
request.Headers["CustomerID"] = _kundennummer;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
if (!responseFromServer.Equals(""))
|
||||
using (WebResponse response = request.GetResponse())
|
||||
{
|
||||
var jsonDaten = JsonConvert.DeserializeObject<ChatGruppenDaten>(responseFromServer);
|
||||
|
||||
_groupconect = jsonDaten;
|
||||
|
||||
_gruppeholenverbindungsaufbauOK = true;
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse) response).StatusDescription;
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
if (!responseFromServer.Equals(""))
|
||||
{
|
||||
var jsonDaten = JsonConvert.DeserializeObject<ChatGruppenDaten>(responseFromServer);
|
||||
|
||||
_alleGruppen = jsonDaten;
|
||||
|
||||
_gruppeholenverbindungsaufbauOK = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
response.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -386,6 +387,7 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
public long GetMaiximumAllowedFileUploadSize(string token, string customerid)
|
||||
{
|
||||
long maxsize = 0;
|
||||
try
|
||||
{
|
||||
var endurl = _serverUrl + "/api/ownchat/uploadmaxsize";// + apikey + "/" + customerid;
|
||||
@@ -397,24 +399,28 @@ namespace ChatController.HauptKlassen
|
||||
request.Credentials = CredentialCache.DefaultCredentials;
|
||||
request.Proxy = null;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
using (WebResponse response = request.GetResponse())
|
||||
{
|
||||
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse)response).StatusDescription;
|
||||
// Display the status.
|
||||
var statusResponse = ((HttpWebResponse) response).StatusDescription;
|
||||
|
||||
string responseFromServer = ReadStream(response);
|
||||
string responseFromServer = ReadStream(response);
|
||||
|
||||
var definiti = new { file_upload_max_size = "" };
|
||||
var definiti = new {file_upload_max_size = ""};
|
||||
|
||||
var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
||||
var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
||||
maxsize = Convert.ToInt64(jsonDatentyp.file_upload_max_size);
|
||||
|
||||
|
||||
return Convert.ToInt64(jsonDatentyp.file_upload_max_size);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return maxsize;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace ChatController.Klassen
|
||||
public class ChatDatenUebergabe
|
||||
{
|
||||
private AuthentifizierungsDaten _serverconect { get; set; }
|
||||
private UserDaten _userconect { get; set; }
|
||||
private ChatGruppenDaten _groupconect { get; set; }
|
||||
private UserDaten _angemeldeterUser { get; set; }
|
||||
private ChatGruppenDaten _alleGruppen { get; set; }
|
||||
|
||||
private string _serverUrl { get; set; }
|
||||
private string _authToken { get; set; }
|
||||
@@ -19,11 +19,11 @@ namespace ChatController.Klassen
|
||||
private string _apikey { get; set; }
|
||||
private long _maxUploadSize { get; set; }
|
||||
|
||||
public ChatDatenUebergabe(AuthentifizierungsDaten serverConect, UserDaten userConect, ChatGruppenDaten groupConect, string serverUrl, string authToken, long? userid, string kundennummer, string apikey,long maxUploadSize)
|
||||
public ChatDatenUebergabe(AuthentifizierungsDaten serverConect, UserDaten angemeldeterUser, ChatGruppenDaten alleGruppen, string serverUrl, string authToken, long? userid, string kundennummer, string apikey,long maxUploadSize)
|
||||
{
|
||||
_serverconect = serverConect;
|
||||
_userconect = userConect;
|
||||
_groupconect = groupConect;
|
||||
_angemeldeterUser = angemeldeterUser;
|
||||
_alleGruppen = alleGruppen;
|
||||
|
||||
_serverUrl = serverUrl;
|
||||
_authToken = authToken;
|
||||
@@ -45,27 +45,27 @@ namespace ChatController.Klassen
|
||||
}
|
||||
}
|
||||
|
||||
public UserDaten Userconect
|
||||
public UserDaten AngemeldeterUser
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userconect;
|
||||
return _angemeldeterUser;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_userconect = value;
|
||||
_angemeldeterUser = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ChatGruppenDaten Groupconect
|
||||
public ChatGruppenDaten AlleGruppen
|
||||
{
|
||||
get
|
||||
{
|
||||
return _groupconect;
|
||||
return _alleGruppen;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_groupconect = value;
|
||||
_alleGruppen = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace ChatController.Klassen
|
||||
public LastMessageTimeStamp Timestamp { get; set; }
|
||||
public long CreatedAt { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public string UserIdManage { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string UserPicture { get; set; }
|
||||
public string GroupId { get; set; }
|
||||
@@ -44,6 +45,7 @@ namespace ChatController.Klassen
|
||||
public class GroupUsers
|
||||
{
|
||||
public long Oid { get; set; }
|
||||
public string Userid_Manage { get; set; }
|
||||
public string Firstname { get; set; }
|
||||
public string Lastname { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user