Winify – Blame information for rev 6
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | using System.Collections.Generic; |
2 | |||
3 | namespace Winify.Gotify |
||
4 | { |
||
5 | public class GotifyConnectionManager |
||
6 | { |
||
7 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
8 | |||
9 | private readonly List<GotifyConnection> _gotifyConnections; |
||
10 | |||
11 | #endregion |
||
12 | |||
13 | #region Constructors, Destructors and Finalizers |
||
14 | |||
15 | public GotifyConnectionManager() |
||
16 | { |
||
17 | _gotifyConnections = new List<GotifyConnection>(); |
||
18 | } |
||
19 | |||
20 | #endregion |
||
21 | |||
22 | #region Event Handlers |
||
23 | |||
24 | private static void Connection_GotifyNotification(object sender, GotifyNotificationEventArgs e) |
||
25 | { |
||
26 | var notification = new NotificationForm(e.Image, e.Notification.Title, e.Notification.Message, 5000); |
||
27 | notification.ShowDialog(); |
||
28 | } |
||
29 | |||
30 | #endregion |
||
31 | |||
32 | #region Public Methods |
||
33 | |||
6 | office | 34 | public void UpdateServers(Servers.Servers servers) |
4 | office | 35 | { |
36 | // Update connections. |
||
37 | var removeConnections = new List<GotifyConnection>(); |
||
38 | foreach (var gotifyConnection in _gotifyConnections) |
||
39 | { |
||
40 | gotifyConnection.GotifyNotification -= Connection_GotifyNotification; |
||
41 | gotifyConnection.Stop(); |
||
42 | gotifyConnection.Dispose(); |
||
43 | removeConnections.Add(gotifyConnection); |
||
44 | } |
||
45 | |||
46 | foreach (var connection in removeConnections) |
||
47 | { |
||
48 | _gotifyConnections.Remove(connection); |
||
49 | } |
||
50 | |||
51 | foreach (var server in servers.Server) |
||
52 | { |
||
53 | var connection = new GotifyConnection(); |
||
54 | connection.Start(server.Username, server.Password, server.Host, server.Port); |
||
55 | connection.GotifyNotification += Connection_GotifyNotification; |
||
56 | _gotifyConnections.Add(connection); |
||
57 | } |
||
58 | } |
||
59 | |||
60 | #endregion |
||
61 | } |
||
62 | } |