개정판 a6e5055d
Markus.Service.StationController DataBaseView 추가
Change-Id: I16b9c78a690e2ae8f804bf35c8787a9c97fea157
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/TotalStatusViewModel.cs | ||
---|---|---|
54 | 54 |
} |
55 | 55 |
} |
56 | 56 |
|
57 |
public TotalStatusViewModel()
|
|
58 |
{
|
|
59 |
}
|
|
57 |
public TotalStatusViewModel() |
|
58 |
{ |
|
59 |
} |
|
60 | 60 |
|
61 |
// 진행률에 변화가 있을때 이벤트가 발생
|
|
62 |
private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
63 |
{
|
|
64 |
}
|
|
61 |
// 진행률에 변화가 있을때 이벤트가 발생 |
|
62 |
private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) |
|
63 |
{ |
|
64 |
} |
|
65 | 65 |
|
66 |
// 일이 모두 마쳤을때 수행되어야할 코드
|
|
67 |
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
68 |
{
|
|
69 |
}
|
|
66 |
// 일이 모두 마쳤을때 수행되어야할 코드 |
|
67 |
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
|
68 |
{ |
|
69 |
} |
|
70 | 70 |
|
71 |
// BackgroundWorker에서 수행할 일을 정의. |
|
72 |
private async void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) |
|
71 |
// BackgroundWorker에서 수행할 일을 정의. |
|
72 |
private async void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) |
|
73 |
{ |
|
74 |
while (IsAcitve) |
|
73 | 75 |
{ |
74 |
while (IsAcitve) |
|
76 |
System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); |
|
77 |
|
|
78 |
if (!IsLoading) |
|
75 | 79 |
{ |
76 |
System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3));
|
|
80 |
IsLoading = true;
|
|
77 | 81 |
|
78 |
if (!IsLoading)
|
|
82 |
try
|
|
79 | 83 |
{ |
80 |
IsLoading = true; |
|
81 |
|
|
82 |
try |
|
83 |
{ |
|
84 | 84 |
|
85 |
List<ConvertItem> newitems = new List<ConvertItem>();
|
|
85 |
List<ConvertItem> newitems = new List<ConvertItem>(); |
|
86 | 86 |
|
87 |
foreach (var client in App.StationClientList) |
|
87 |
foreach (var client in App.StationClientList) |
|
88 |
{ |
|
89 |
if (await SimplePingAsync(client.Endpoint.Address.ToString())) |
|
88 | 90 |
{ |
89 |
if (await SimplePingAsync(client.Endpoint.Address.ToString()))
|
|
91 |
try
|
|
90 | 92 |
{ |
91 |
try |
|
92 |
{ |
|
93 |
var items = await client.AliveConvertListAsync(); |
|
94 |
newitems.AddRange(items); |
|
95 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping"); |
|
96 |
|
|
97 |
if (items.Count() == 0) |
|
98 |
{ |
|
99 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero."); |
|
100 |
} |
|
101 |
} |
|
102 |
catch (Exception ex) |
|
93 |
var items = await client.AliveConvertListAsync(); |
|
94 |
newitems.AddRange(items); |
|
95 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping"); |
|
96 |
|
|
97 |
if (items.Count() == 0) |
|
103 | 98 |
{ |
104 |
System.Diagnostics.Trace.TraceError($"{client.Endpoint.Address} {ex.Message}");
|
|
99 |
System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
|
|
105 | 100 |
} |
106 | 101 |
} |
107 |
else
|
|
102 |
catch (Exception ex)
|
|
108 | 103 |
{ |
109 |
System.Diagnostics.Trace.TraceError($"{client.Endpoint.Address} ping Error");
|
|
104 |
System.Diagnostics.Trace.TraceError($"{client.Endpoint.Address} {ex.Message}");
|
|
110 | 105 |
} |
111 | 106 |
} |
112 |
|
|
113 |
}
|
|
114 |
catch (Exception ex)
|
|
115 |
{
|
|
107 |
else |
|
108 |
{
|
|
109 |
System.Diagnostics.Trace.TraceError($"{client.Endpoint.Address} ping Error");
|
|
110 |
}
|
|
116 | 111 |
} |
117 | 112 |
|
118 |
IsLoading = false; |
|
113 |
} |
|
114 |
catch (Exception ex) |
|
115 |
{ |
|
116 |
System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
119 | 117 |
} |
120 | 118 |
|
119 |
IsLoading = false; |
|
121 | 120 |
} |
121 |
|
|
122 | 122 |
} |
123 |
} |
|
123 | 124 |
|
124 | 125 |
|
125 |
private void LogWrite(string log, bool IsError) |
|
126 |
private void LogWrite(string log, bool IsError) |
|
127 |
{ |
|
128 |
if (IsError) |
|
126 | 129 |
{ |
127 |
if (IsError) |
|
128 |
{ |
|
129 |
System.Diagnostics.Trace.Fail(log); |
|
130 |
} |
|
131 |
else |
|
132 |
{ |
|
133 |
System.Diagnostics.Trace.TraceInformation(log); |
|
134 |
} |
|
130 |
System.Diagnostics.Trace.Fail(log); |
|
131 |
} |
|
132 |
else |
|
133 |
{ |
|
134 |
System.Diagnostics.Trace.TraceInformation(log); |
|
135 | 135 |
} |
136 |
} |
|
136 | 137 |
|
137 | 138 |
|
138 |
public static async Task<bool> SimplePingAsync(string uri)
|
|
139 |
{
|
|
140 |
bool result = false;
|
|
139 |
public static async Task<bool> SimplePingAsync(string uri) |
|
140 |
{ |
|
141 |
bool result = false; |
|
141 | 142 |
|
142 |
try |
|
143 |
try |
|
144 |
{ |
|
145 |
using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient()) |
|
143 | 146 |
{ |
144 |
using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient()) |
|
145 |
{ |
|
146 |
Client.Timeout = new TimeSpan(0, 5, 0); |
|
147 |
Client.Timeout = new TimeSpan(0, 5, 0); |
|
147 | 148 |
|
148 |
var message = await Client.GetAsync(uri);
|
|
149 |
var message = await Client.GetAsync(uri); |
|
149 | 150 |
|
150 |
System.Net.HttpStatusCode StatusCode = message.StatusCode;
|
|
151 |
System.Net.HttpStatusCode StatusCode = message.StatusCode; |
|
151 | 152 |
|
152 |
switch (StatusCode)
|
|
153 |
{
|
|
153 |
switch (StatusCode) |
|
154 |
{ |
|
154 | 155 |
|
155 |
case System.Net.HttpStatusCode.Accepted: |
|
156 |
case System.Net.HttpStatusCode.OK: |
|
157 |
result = true; |
|
158 |
break; |
|
159 |
} |
|
156 |
case System.Net.HttpStatusCode.Accepted: |
|
157 |
case System.Net.HttpStatusCode.OK: |
|
158 |
result = true; |
|
159 |
break; |
|
160 | 160 |
} |
161 | 161 |
} |
162 |
catch (Exception ex) |
|
163 |
{ |
|
164 |
result = false; |
|
165 |
} |
|
166 |
|
|
167 |
return result; |
|
168 | 162 |
} |
169 |
|
|
170 |
public override void Loaded() |
|
163 |
catch (Exception ex) |
|
171 | 164 |
{ |
172 |
base.Loaded(); |
|
165 |
result = false; |
|
166 |
System.Diagnostics.Debug.WriteLine(ex.ToString()); |
|
167 |
} |
|
173 | 168 |
|
174 |
if (!App.IsDesignMode) |
|
175 |
{ |
|
176 |
backgroundWorker = new BackgroundWorker(); |
|
177 |
backgroundWorker.DoWork += backgroundWorker_DoWork; |
|
178 |
backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; |
|
179 |
backgroundWorker.WorkerReportsProgress = false; |
|
180 |
backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
169 |
return result; |
|
170 |
} |
|
181 | 171 |
|
182 |
backgroundWorker.RunWorkerAsync();
|
|
183 |
}
|
|
184 |
}
|
|
172 |
public override void Loaded()
|
|
173 |
{
|
|
174 |
base.Loaded();
|
|
185 | 175 |
|
186 |
public override void Closed()
|
|
176 |
if (!App.IsDesignMode)
|
|
187 | 177 |
{ |
188 |
if (backgroundWorker != null) |
|
189 |
{ |
|
190 |
backgroundWorker.DoWork -= backgroundWorker_DoWork; |
|
191 |
backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted; |
|
192 |
backgroundWorker.WorkerReportsProgress = false; |
|
193 |
backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
178 |
backgroundWorker = new BackgroundWorker(); |
|
179 |
backgroundWorker.DoWork += backgroundWorker_DoWork; |
|
180 |
backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; |
|
181 |
backgroundWorker.WorkerReportsProgress = false; |
|
182 |
backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
194 | 183 |
|
195 |
backgroundWorker.Dispose(); |
|
196 |
} |
|
184 |
backgroundWorker.RunWorkerAsync(); |
|
185 |
} |
|
186 |
} |
|
197 | 187 |
|
198 |
base.Closed(); |
|
188 |
public override void Closed() |
|
189 |
{ |
|
190 |
if (backgroundWorker != null) |
|
191 |
{ |
|
192 |
backgroundWorker.DoWork -= backgroundWorker_DoWork; |
|
193 |
backgroundWorker.RunWorkerCompleted -= backgroundWorker_RunWorkerCompleted; |
|
194 |
backgroundWorker.WorkerReportsProgress = false; |
|
195 |
backgroundWorker.ProgressChanged -= new ProgressChangedEventHandler(backgroundWorker_ProgressChanged); |
|
196 |
|
|
197 |
backgroundWorker.Dispose(); |
|
199 | 198 |
} |
199 |
|
|
200 |
base.Closed(); |
|
200 | 201 |
} |
202 |
} |
|
201 | 203 |
} |
내보내기 Unified diff