update neues Feature
This commit is contained in:
@@ -69,7 +69,7 @@ namespace ChatController
|
||||
|
||||
public ChatMainControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void InitMitChatdaten(ChatDatenUebergabe cdu)
|
||||
@@ -85,6 +85,7 @@ namespace ChatController
|
||||
view.Filter = UserFilter;
|
||||
|
||||
HorcheAlleGruppenNachrichten();
|
||||
LeseMessageInfoAusDatei();
|
||||
}
|
||||
|
||||
public AktuellerKontakt GetAktuellenKontakt()
|
||||
@@ -954,12 +955,12 @@ namespace ChatController
|
||||
Cursor = Cursors.Wait;
|
||||
|
||||
//StartWaiting();
|
||||
if (_isDesktopVersion)
|
||||
{
|
||||
var doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
|
||||
//if (_isDesktopVersion)
|
||||
//{
|
||||
// var doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
|
||||
|
||||
if (doSync)
|
||||
{
|
||||
// if (doSync)
|
||||
// {
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
@@ -969,29 +970,29 @@ namespace ChatController
|
||||
Clientlist.Items.Refresh();
|
||||
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor = Cursors.Arrow;
|
||||
// EndWaiting();
|
||||
if (OnClose != null)
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Cursor = Cursors.Arrow;
|
||||
// // EndWaiting();
|
||||
// if (OnClose != null)
|
||||
// {
|
||||
// OnClose();
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
// var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
|
||||
_kontaktlist = x;
|
||||
// _kontaktlist = x;
|
||||
|
||||
Clientlist.Items.Refresh();
|
||||
// Clientlist.Items.Refresh();
|
||||
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
// Cursor = Cursors.Arrow;
|
||||
//}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1000,5 +1001,46 @@ namespace ChatController
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region speichern sowie lesen der MessageSyncDatei / stylezwecke
|
||||
public void SpeichereMessageInfoInDatei()
|
||||
{
|
||||
List<KontaktlistBuilder> aa = new List<KontaktlistBuilder>();
|
||||
foreach (var kontakt in _kontaktlist)
|
||||
{
|
||||
if(kontakt.SetzeGelesen == 0 && !kontakt.ReceiveMs.Equals("")) {
|
||||
aa.Add(kontakt);
|
||||
}
|
||||
}
|
||||
|
||||
if(aa.Count>0)
|
||||
_chat.SpeichereTimeStampsInDatei(aa);
|
||||
}
|
||||
|
||||
public void LeseMessageInfoAusDatei()
|
||||
{
|
||||
List<KontaktlistBuilder> aa = new List<KontaktlistBuilder>();
|
||||
foreach (var kontakt in _kontaktlist)
|
||||
{
|
||||
aa.Add(kontakt);
|
||||
}
|
||||
|
||||
var liste = _chat.PruefeTimeStampsBeiStart(aa);
|
||||
|
||||
if(liste != null) {
|
||||
foreach (var kon in _kontaktlist)
|
||||
{
|
||||
foreach (var item in liste)
|
||||
{
|
||||
if (kon.GroupId == item.Key)
|
||||
{
|
||||
kon.SetzeGelesen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -1216,8 +1217,7 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//Neu
|
||||
|
||||
#region Synchronisation Veranlassen für Bewoplaner OwnChat Version
|
||||
//sync für alles und jeden
|
||||
//public bool DoSync = true;
|
||||
@@ -1370,5 +1370,160 @@ namespace ChatController.HauptKlassen
|
||||
//view.Filter = UserFilter;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//unter konstruktion
|
||||
#region pruefe letzten Konversations timestamp für design element
|
||||
|
||||
public Dictionary<int, DateTime> PruefeTimeStampsBeiStart(List<KontaktlistBuilder> kontaktliste)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt")))
|
||||
{
|
||||
Dictionary<string,string> merkdaten = new Dictionary<string, string>();
|
||||
|
||||
using (StreamReader sr = new StreamReader(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt"), true))
|
||||
{
|
||||
string line = "";
|
||||
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
var encodedTextBytes = Convert.FromBase64String(line);
|
||||
|
||||
string plainText = Encoding.UTF8.GetString(encodedTextBytes);
|
||||
|
||||
var plainarray = plainText.Split(';');
|
||||
|
||||
merkdaten.Add(plainarray[0], plainarray[1]);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, DateTime> rueckgabe = new Dictionary<int, DateTime>();
|
||||
|
||||
foreach (var kontakt in kontaktliste)
|
||||
{
|
||||
foreach (var daten in merkdaten)
|
||||
{
|
||||
var groupoid = Int32.Parse(daten.Key);
|
||||
|
||||
if (kontakt.GroupId == groupoid)
|
||||
{
|
||||
var datetime = DateTime.Parse(daten.Value);
|
||||
|
||||
if (kontakt.TimeStamp.Equals(datetime))
|
||||
{
|
||||
rueckgabe.Add(groupoid,datetime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rueckgabe.Count > 0)
|
||||
{
|
||||
return rueckgabe;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SpeichereTimeStampsInDatei( List<KontaktlistBuilder> kontaktliste )
|
||||
{
|
||||
try
|
||||
{
|
||||
//Hole alle aktuellen, schreibe ihre oid und den Timestamp der Aktuellen nachricht in eine Datei
|
||||
|
||||
if (!File.Exists(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt")))
|
||||
{
|
||||
using (
|
||||
StreamWriter sw =
|
||||
new StreamWriter(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt")))
|
||||
{
|
||||
|
||||
Encoding enc = new UTF8Encoding();
|
||||
|
||||
foreach (var kontakt in kontaktliste)
|
||||
{
|
||||
var text = kontakt.GroupId + ";" + kontakt.TimeStamp+";";
|
||||
var byt = enc.GetBytes(text);
|
||||
var bytes = Convert.ToBase64String(byt);
|
||||
|
||||
sw.WriteLine(bytes);
|
||||
}
|
||||
|
||||
File.SetAttributes(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt"),
|
||||
FileAttributes.ReadOnly);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
File.SetAttributes(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt"), FileAttributes.Normal);
|
||||
File.Delete(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt"));
|
||||
|
||||
using (
|
||||
StreamWriter sw = new StreamWriter(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt")))
|
||||
{
|
||||
|
||||
Encoding enc = new UTF8Encoding();
|
||||
|
||||
foreach (var kontakt in kontaktliste)
|
||||
{
|
||||
var text = kontakt.GroupId + ";" + kontakt.TimeStamp + ";";
|
||||
var byt = enc.GetBytes(text);
|
||||
var bytes = Convert.ToBase64String(byt);
|
||||
|
||||
sw.WriteLine(bytes);
|
||||
}
|
||||
|
||||
File.SetAttributes(Path.Combine(GetAndCreateUserAppDataPath(), "ownChatMessageSync.txt"),
|
||||
FileAttributes.ReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAndCreateUserAppDataPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
string localAppData = Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.LocalApplicationData);
|
||||
string companyFilePath
|
||||
= Path.Combine(localAppData, "beyondSoft");
|
||||
|
||||
if (!Directory.Exists(companyFilePath))
|
||||
Directory.CreateDirectory(companyFilePath);
|
||||
|
||||
string bewoFilePath
|
||||
= Path.Combine(companyFilePath, "OwnChat");
|
||||
|
||||
if (!Directory.Exists(bewoFilePath))
|
||||
Directory.CreateDirectory(bewoFilePath);
|
||||
|
||||
return bewoFilePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Fehler beim Anlegen des Anwendungsordners. Sie besitzen nicht die erforderlichen Rechte, bitte wenden Sie sich an Ihren Systemadministrator.\n" +
|
||||
ex.Message, "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ namespace ownChat
|
||||
private void MainWindow_OnClosed(object sender, EventArgs e)
|
||||
{
|
||||
_emojiView = null;
|
||||
ChatMainControl.SpeichereMessageInfoInDatei();
|
||||
// Environment.Exit(0);
|
||||
LoginMaske newLogin = new LoginMaske();
|
||||
newLogin.Show();
|
||||
|
||||
Reference in New Issue
Block a user