private void AddEntity(object param) { int paramValue = GetParam(param); switch (paramValue) { case 0: Contacts.Add(new Contact { ModelStateChanged = true }); break; case 1: Emails.Add(new EmailAddress { ModelStateChanged = true }); break; case 2: Phones.Add(new PhoneNumber { ModelStateChanged = true }); break; case 3: Mails.Add(new MailingAddress { ModelStateChanged = true }); break; default: break; } }
public void Init(List <pd_MailInfo> mail_list) { IsInit = true; if (Mails.Count > 0) { List <Mail> noexist = new List <Mail>(); foreach (var mail in Mails) { if (mail_list.Exists(m => m.mail_idx == mail.MailIdx) == false) { noexist.Add(mail); } } if (noexist.Count > 0) { noexist.ForEach(i => Mails.Remove(i)); } } foreach (var info in mail_list) { int index = Mails.FindIndex(mail => mail.MailIdx == info.mail_idx); if (index >= 0) { Mails[index].Data = info; } else { Mails.Add(new Mail(info)); } } OrderMailData(); }
private void Run(object obj) { while (Running) { try { using (var clientSocket = _socket.Accept()) { clientSocket.ReceiveTimeout = 200; try { var session = new FakeSmtpSession(clientSocket); session.ReceiveMail(); var mail = session.GetMail(); Mails.Add(mail); } catch (Exception) { // ignored } } } catch (SocketException exception) { if (!Running) { return; } throw; } } }
public ViewModel() { if (MailList.Count == 0) { //Mails = new List<Mail>(); Mails.Add(new Mail("*****@*****.**", "ALo alo", "123")); Mails.Add(new Mail("*****@*****.**", "ALo123 alo", "123123")); } }
public InboxViewModel() : base(new ImapClient(), client => client.Inbox) { #if DEBUG //if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { Mails.Add(new MailDataViewModel("Git of markdown-mail project") { Body = "walterlv started a discussion to lindexi's Merge Request.", }); Mails.Add(new MailDataViewModel("markdown-mail 项目版本管理") { Body = "walterlv 在 lindexi 的 Merge Request 中添加了一个讨论。", }); Mails.Add(new MailDataViewModel("markdown-mail 項目版本管理") { Body = "walterlv 在 lindexi 的 Merge Request 中添加了一個討論。", }); Mails.Add(new MailDataViewModel("マークダウンメールプロジェクトのバージョン管理") { Body = "walterlvさんがlindexiのMerge Requestのディスカッションに追加しました。", }); } #endif }
/// <summary> /// Sets pathes to required resources. /// Will also remove any existing resources from the current lists. /// </summary> /// <param name="PathStrings"></param> /// <param name="PathRooms"></param> /// <param name="PathObjects"></param> /// <param name="PathRoomTextures"></param> /// <param name="PathSounds"></param> /// <param name="PathMusic"></param> /// <param name="PathMails"></param> public void Init( string PathStrings, string PathRooms, string PathObjects, string PathRoomTextures, string PathSounds, string PathMusic, string PathMails) { this.StringsFolder = PathStrings; this.RoomsFolder = PathRooms; this.ObjectsFolder = PathObjects; this.RoomTexturesFolder = PathRoomTextures; this.WavFolder = PathSounds; this.MusicFolder = PathMusic; this.MailFolder = PathMails; string[] files; // already executed once? if (Initialized) { StringResources.Clear(); StringDictionaries.Clear(); Objects.Clear(); RoomTextures.Clear(); Rooms.Clear(); Wavs.Clear(); Music.Clear(); // detach mail listener so we don't delete them Mails.ListChanged -= OnMailsListChanged; // clear our objects Mails.Clear(); } // register string dictionaries for different servers if (Directory.Exists(StringsFolder)) { // get available files files = Directory.GetFiles(StringsFolder, '*' + FileExtensions.RSB); foreach (string s in files) { StringDictionaries.TryAdd(Path.GetFileName(s), null); } } else { Directory.CreateDirectory(StringsFolder); } // register objects if (Directory.Exists(ObjectsFolder)) { // get available files files = Directory.GetFiles(ObjectsFolder, '*' + FileExtensions.BGF); foreach (string s in files) { string filename = Path.GetFileName(s); if (!filename.StartsWith("grd")) { Objects.TryAdd(filename, null); } } } else { Directory.CreateDirectory(ObjectsFolder); } // register roomtextures if (Directory.Exists(RoomTexturesFolder)) { // get available files files = Directory.GetFiles(RoomTexturesFolder, "grd*" + FileExtensions.BGF); foreach (string s in files) { RoomTextures.TryAdd(Path.GetFileName(s), null); } } else { Directory.CreateDirectory(RoomTexturesFolder); } // register rooms if (Directory.Exists(RoomsFolder)) { // get available files files = Directory.GetFiles(RoomsFolder, '*' + FileExtensions.ROO); foreach (string s in files) { Rooms.TryAdd(Path.GetFileName(s), null); } } else { Directory.CreateDirectory(RoomsFolder); } // register wav sounds if (Directory.Exists(WavFolder)) { // get available files files = Directory.GetFiles(WavFolder, '*' + FileExtensions.OGG); foreach (string s in files) { Wavs.TryAdd(Path.GetFileName(s), null); } } else { Directory.CreateDirectory(WavFolder); } // register music if (Directory.Exists(MusicFolder)) { // get available files files = Directory.GetFiles(MusicFolder, '*' + FileExtensions.OGG); foreach (string s in files) { Music.TryAdd(Path.GetFileName(s), null); } } else { Directory.CreateDirectory(MusicFolder); } // load mails if (Directory.Exists(MailFolder)) { // read available mail files files = Directory.GetFiles(MailFolder, '*' + FileExtensions.XML); foreach (string s in files) { // create mail object Mail mail = new Mail(); // load values from xml mail.Load(s); #if !VANILLA && !OPENMERIDIAN // Fix timestamp if necessary and write out mail. if (!mail.IsTimestampUpdated) { mail.Timestamp += MeridianDate.CONVERTOFFSET; mail.IsTimestampUpdated = true; mail.Save(s); } #endif // add to list Mails.Add(mail); } } else { Directory.CreateDirectory(MailFolder); } // hookup mails listener to write/delete the files Mails.ListChanged += OnMailsListChanged; // forced GC collection Util.ForceMaximumGC(); // mark initialized Initialized = true; }
/// <summary> /// Sets pathes to required resources. /// Will also remove any existing resources from the current lists. /// </summary> /// <param name="PathStrings"></param> /// <param name="PathRooms"></param> /// <param name="PathObjects"></param> /// <param name="PathRoomTextures"></param> /// <param name="PathSounds"></param> /// <param name="PathMusic"></param> /// <param name="PathMails"></param> public void Init( string PathStrings, string PathRooms, string PathObjects, string PathRoomTextures, string PathSounds, string PathMusic, string PathMails) { this.StringsFolder = PathStrings; this.RoomsFolder = PathRooms; this.ObjectsFolder = PathObjects; this.RoomTexturesFolder = PathRoomTextures; this.WavFolder = PathSounds; this.MusicFolder = PathMusic; this.MailFolder = PathMails; string[] files; // already executed once? if (Initialized) { StringResources.Clear(); StringDictionaries.Clear(); Objects.Clear(); RoomTextures.Clear(); Rooms.Clear(); Wavs.Clear(); Music.Clear(); // detach mail listener so we don't delete them Mails.ListChanged -= OnMailsListChanged; // clear our objects Mails.Clear(); } // register string dictionaries for different servers if (Directory.Exists(StringsFolder)) { // get available files files = Directory.GetFiles(StringsFolder, '*' + FileExtensions.RSB); foreach (string s in files) { StringDictionaries.TryAdd(Path.GetFileName(s), null); } } // register objects if (Directory.Exists(ObjectsFolder)) { // get available files files = Directory.GetFiles(ObjectsFolder, '*' + FileExtensions.BGF); foreach (string s in files) { string filename = Path.GetFileName(s); if (!filename.StartsWith("grd")) { Objects.TryAdd(filename, null); } } } // register roomtextures if (Directory.Exists(RoomTexturesFolder)) { // get available files files = Directory.GetFiles(RoomTexturesFolder, "grd*" + FileExtensions.BGF); foreach (string s in files) { RoomTextures.TryAdd(Path.GetFileName(s), null); } } // register rooms if (Directory.Exists(RoomsFolder)) { // get available files files = Directory.GetFiles(RoomsFolder, '*' + FileExtensions.ROO); foreach (string s in files) { Rooms.TryAdd(Path.GetFileName(s), null); } } // register wav sounds if (Directory.Exists(WavFolder)) { // get available files files = Directory.GetFiles(WavFolder, '*' + FileExtensions.OGG); foreach (string s in files) { Wavs.TryAdd(Path.GetFileName(s), null); } } // register music if (Directory.Exists(MusicFolder)) { // get available files files = Directory.GetFiles(MusicFolder, '*' + FileExtensions.OGG); foreach (string s in files) { Music.TryAdd(Path.GetFileName(s), null); } } // load mails if (Directory.Exists(MailFolder)) { // read available mail files files = Directory.GetFiles(MailFolder, '*' + FileExtensions.XML); foreach (string s in files) { // create mail object Mail mail = new Mail(); // load values from xml mail.Load(s); // add to list Mails.Add(mail); } } // hookup mails listener to write/delete the files Mails.ListChanged += OnMailsListChanged; // forced GC collection GC.Collect(2); // mark initialized Initialized = true; }
private async void RetriveMessages(bool initialization = false) { _timer?.Stop(); using (var connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { connection.Connect(_config.Incoming.Host, _config.Incoming.Port); if (!connection.Connected) { Disconnect(); App.Current.Dispatcher.Invoke( delegate { DisplayDialog("Błąd", "Nie udało się nawiązać połączenia z serwerem"); } ); return; } Status = "Połączono"; StatusColor = Brushes.Green; StreamReader reader; StreamWriter writer; if (_config.Incoming.SSL) { var ssl = new SslStream(new NetworkStream(connection)); try { ssl.AuthenticateAsClient(_config.Incoming.Host); } catch { Disconnect(); App.Current.Dispatcher.Invoke( delegate { DisplayDialog("Błąd", "Wystąpił błąd z połączeniem SSL"); } ); return; } reader = new StreamReader(ssl); writer = new StreamWriter(ssl); } else { reader = new StreamReader(new NetworkStream(connection)); writer = new StreamWriter(new NetworkStream(connection)); } IsLoading = true; await Task.Run(() => { reader.ReadLine(); // Powitanie serwera // AUTHENTICATION mode writer.WriteLine($"USER {_config.Incoming.Username}"); writer.Flush(); reader.ReadLine(); // Potwierdzenie odbioru loginu writer.WriteLine($"PASS {_config.Incoming.Password}"); writer.Flush(); reader.ReadLine(); // potwierdzenie odbioru hasła // TRANSACTION mode writer.WriteLine("UIDL"); writer.Flush(); string strTemp; var line = 0; while ((strTemp = reader.ReadLine()) != null) { if (".".Equals(strTemp) || strTemp.IndexOf("-ERR") != -1) { break; } if (line != 0) { if (!Mails.Contains(new Mail(strTemp.Substring(0, strTemp.IndexOf(" ")), strTemp.Substring(strTemp.IndexOf(" ") + 1), false))) { System.Windows.Application.Current.Dispatcher.Invoke( delegate { Mails.Add(new Mail(strTemp.Substring(0, strTemp.IndexOf(" ")), strTemp.Substring(strTemp.IndexOf(" ") + 1), !initialization)); } ); AllMessagesCounter++; if (!initialization) { NewMessagesCounter++; } } } else { line++; } } writer.WriteLine("QUIT"); writer.Flush(); reader.ReadLine(); // Potwierdzenie rozłączenia sesji }); IsLoading = false; } _timer?.Start(); }
public void Send(string address, string message) { Mails.Add(new Mail(address, message)); }