프로젝트

일반

사용자정보

개정판 1ae729e4

ID1ae729e493a9e9a23d51cbaabb29993365c56ce6
상위 60723dc9
하위 a34f58f6

김태성이(가) 5년 이상 전에 추가함

contoller Richtextbox 추가
서비스 안정화

Change-Id: I1a18f9d1f9b0aaed92d4e22df779b46c4e8958e0

차이점 보기:

ConvertService/ServiceBase/Markus.Service.Convert/ConvertService.cs
207 207
                        /// 작은 사이즈의 컨버팅
208 208
                        await Task.Factory.StartNew(new Action(() =>
209 209
                        {
210
                            gMarkusPDF.Dispose();
210 211
                            result = gSaveTask.SaveFile(saveitem);
211 212

  
212 213
                        }), TaskCreationOptions.LongRunning);
ConvertService/ServiceBase/Markus.Service.DataBase/ConvertDatabase.cs
239 239
                                        x =>
240 240
                                        //projectList.Contains(x.PROJECT_NO) && x.RECONVERTER < 2 &&
241 241
                                         x.RECONVERTER < 2 &&
242
                                        (x.STATUS == (int)StatusCodeType.None || x.STATUS == (int)StatusCodeType.FileError && x.STATUS == (int)StatusCodeType.Error))
242
                                        (x.STATUS == (int)StatusCodeType.None || x.STATUS == (int)StatusCodeType.FileError || x.STATUS == (int)StatusCodeType.Error))
243 243
                                    .GroupBy(x=>x.DOCUMENT_ID).Select(x => x.FirstOrDefault())
244 244
                                    .Take(TakeCount);
245 245

  
......
276 276
        /// <param name="aliveItems"></param>
277 277
        /// <param name="TakeCount"></param>
278 278
        /// <returns></returns>
279
        public int SetCleanUpItem(string convertID)
279
        public int SetCleanUpItem(string convertID,int ReConvert)
280 280
        {
281 281
            int result = 0;
282 282

  
......
288 288
            {
289 289
                var item = items.First();
290 290

  
291
                item.RECONVERTER = item.RECONVERTER + 1;
291
                item.RECONVERTER = item.RECONVERTER + ReConvert;
292 292
                item.CREATE_DATETIME = DateTime.Now;
293 293
                item.START_DATETIME = null;
294 294
                item.END_DATETIME = null;
ConvertService/ServiceBase/Markus.Service.Extensions/Exntensions/SytemNet.cs
18 18
        /// </summary>
19 19
        /// <param name="strUri"></param>
20 20
        /// <returns></returns>
21
        public static bool Ping(string strUri)
21
        public static async Task<bool> PingAsync(string strUri)
22 22
        {
23 23
            bool result = false;
24 24

  
......
33 33
                {
34 34
                    using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
35 35
                    {
36
                        Client.Timeout = new TimeSpan(0, 0, 10);
36
                        Client.Timeout = new TimeSpan(0, 1,0);
37 37

  
38
                        var task = Client.GetAsync(uri);
38
                        var message = await Client.GetAsync(uri);
39 39

  
40
                        if (!task.IsFaulted)
40
                        System.Net.Http.HttpResponseMessage responseMessage = message;
41
                        System.Net.HttpStatusCode StatusCode = responseMessage.StatusCode;
42
                        switch (StatusCode)
41 43
                        {
42
                            System.Net.Http.HttpResponseMessage responseMessage = task.Result;
43
                            System.Net.HttpStatusCode StatusCode = responseMessage.StatusCode;
44
                            switch (StatusCode)
45
                            {
46 44

  
47
                                case System.Net.HttpStatusCode.Accepted:
48
                                case System.Net.HttpStatusCode.OK:
49
                                    result = true;
50
                                    break;
51
                            }
45
                            case System.Net.HttpStatusCode.Accepted:
46
                            case System.Net.HttpStatusCode.OK:
47
                                result = true;
48
                                break;
52 49
                        }
53 50
                    }
54 51
                }
ConvertService/ServiceBase/Markus.Service.Station/ServiceStation.cs
15 15
using System.Linq;
16 16
using System.Runtime.InteropServices;
17 17
using System.ServiceModel;
18
using System.ServiceModel.Channels;
19
using System.ServiceModel.Dispatcher;
18 20
using System.ServiceProcess;
19 21
using System.Text;
20 22
using System.Threading.Tasks;
......
175 177
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
176 178
        {
177 179
     
178
            System.Diagnostics.Debug.WriteLine("timer : " + e?.SignalTime);
179
            try
180
            {
181
                if (!IsReleaseItems)
182
                {
183
                    ReleaseItems();
184
                }
185

  
186
                if ((DateTime.Now - logTime) >= new TimeSpan(0, 5, 0))
187
                {
188
                    logTime = DateTime.Now;
189
                    logger.Info("StationService Alive Check");
190
                }
191
            }
192
            catch (Exception ex)
193
            {
194
                logger.Error("Timer Error " ,ex);
195
            }
180
            //System.Diagnostics.Debug.WriteLine("timer : " + e?.SignalTime);
181
            //try
182
            //{
183
            //    if (!IsReleaseItems)
184
            //    {
185
            //        ReleaseItems();
186
            //    }
187

  
188
            //    if ((DateTime.Now - logTime) >= new TimeSpan(0, 5, 0))
189
            //    {
190
            //        logTime = DateTime.Now;
191
            //        logger.Info("StationService Alive Check");
192
            //    }
193
            //}
194
            //catch (Exception ex)
195
            //{
196
            //    logger.Error("Timer Error " ,ex);
197
            //}
196 198

  
197
            System.Threading.Thread.SpinWait(1000);
199
            //System.Threading.Thread.SpinWait(1000);
198 200

  
199
            timer.Start();
201
            //timer.Start();
200 202
        }
201 203

  
202 204
        /// <summary>
......
215 217
                {
216 218
                    //if (IsDataBaseWaitingList(1))
217 219
                    //{
218
                        System.Diagnostics.Debug.WriteLine("ReleaseItems start");
219
                        ReflashSubServiceAsync();
220
                    System.Diagnostics.Debug.WriteLine("ReleaseItems start");
221
                    ReflashSubServiceAsync();
222

  
223
                    if (StationServiceList.All(x => x.IsOnline))
224
                    {
220 225
                        CleanUpDataBaseItems();
221 226
                        setDataBaseWaitingList();
222
                        System.Diagnostics.Debug.WriteLine("ReleaseItems end");
227
                    }
228
                    else
229
                    {
230
                        System.Diagnostics.Debug.WriteLine("Service Any Offline");
231
                    }
232

  
233
                    System.Diagnostics.Debug.WriteLine("ReleaseItems end");
223 234
                    //}
224 235
                }
225 236
            }
......
359 370
            logger.Info("Start ServiceStation");
360 371
            var autoEvent = new System.Threading.AutoResetEvent(false);
361 372

  
362
            stateTimer = new System.Threading.Timer(new System.Threading.TimerCallback(TimerCallBack), null, 0, 10000);
373
            stateTimer = new System.Threading.Timer(new System.Threading.TimerCallback(TimerCallBack), null, 0, 500);
363 374
            //timer = new System.Timers.Timer(new TimeSpan(0, 0, 0, 10).TotalMilliseconds);
364 375
            //timer.Elapsed += Timer_Elapsed;
365 376
            //timer.AutoReset = true;
......
370 381

  
371 382
        System.Threading.Timer stateTimer;
372 383
        DateTime logTime;
384
        DateTime ReleaseTime;
373 385

  
374 386
        private void TimerCallBack(object state)
375 387
        {
......
377 389
            //stateTimer.Change(-1, -1);
378 390
            try
379 391
            {
380
                if (!IsReleaseItems)
392
               
393
                if ((DateTime.Now - ReleaseTime) >= new TimeSpan(0, 0,15))
381 394
                {
382
                    ReleaseItems();
395
                    if (!IsReleaseItems)
396
                    {
397
                        ReleaseItems();
398
                    }
399
                    ReleaseTime = DateTime.Now;
383 400
                }
401
              
384 402

  
385 403
                if ((DateTime.Now - logTime) >= new TimeSpan(0, 5, 0))
386 404
                {
......
388 406
                    logger.Info("StationService Alive Check");
389 407
                }
390 408

  
409

  
391 410
            }
392 411
            catch (Exception ex)
393 412
            {
394 413
                logger.Error("Timer Error ", ex);
395 414
            }
396
            System.Threading.Thread.SpinWait(100000);
397
            stateTimer.Change(0, 10000);
415

  
416
            ///System.Threading.Thread.SpinWait(100000);
417
            //stateTimer.Change(0, 10000);
398 418
        }
399 419

  
400 420
        public void SetServiceList(List<string> serviceList)
......
411 431

  
412 432
                        if (prop != null)
413 433
                        {
414
                            BasicHttpBinding myBinding = new BasicHttpBinding();
434
                            BasicHttpBinding httpbinding = new BasicHttpBinding();
435
                            httpbinding.CloseTimeout = new TimeSpan(0, 10, 0);
436
                            httpbinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
437
                            httpbinding.SendTimeout = new TimeSpan(0, 10, 0);
438
                            httpbinding.OpenTimeout = new TimeSpan(0, 10, 0);
439

  
415 440
                            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate(prop.SERVICE_ADDRESS));
416
                            var StationServiceClient = new WcfClient.StationServiceTask.StationServiceClient(myBinding, myEndpoint);
441
                            var StationServiceClient = new WcfClient.StationServiceTask.StationServiceClient(httpbinding, myEndpoint);
417 442
                        
418 443
                       
419 444
                                //var items = StationServiceClient.AliveConvertList();
......
438 463
        {
439 464
            try
440 465
            {
441
                timer.Stop();
466
                if (timer != null)
467
                {
468
                    timer.Stop();
469
                }
470

  
442 471
                StopWcfService();
443 472
                Stopprocess();
444 473

  
ConvertService/ServiceBase/Markus.Service.Station/ServiceStation.ini
27 27

  
28 28
# 설정된 Resolution으로 강제 변환
29 29
# 기본 = 0
30
USE_RESOLUTION = 300
30
USE_RESOLUTION = 100
31 31

  
32 32
# 상태 저장 간격(페이지당 상태 저장 간각)
33 33
# 기본 5
ConvertService/ServiceBase/Markus.Service.Station/StationService/ServiceStationTask.cs
127 127
        /// </summary>
128 128
        public void setDataBaseWaitingList()
129 129
        {
130
            List<EntityModel.CONVERTER_DOC> convertItems = new List<EntityModel.CONVERTER_DOC>();
131

  
130 132
            using (DataBase.ConvertDatabase database = new DataBase.ConvertDatabase(MarkusDBConnectionString))
131 133
            {
132
                var convertItems = database.GetWaitConvertItems(this.RunProjectList, StationServiceList.Where(x=>x.IsOnline).Sum(f=>f.Properties.PROCESS_COUNT));
134
                convertItems = database.GetWaitConvertItems(this.RunProjectList, StationServiceList.Where(x=>x.IsOnline).Sum(f=>f.Properties.PROCESS_COUNT)).ToList();
135
            }
133 136

  
134
                foreach (var convert in convertItems)
135
                {
136
                    //ReflashSubService();
137
            foreach (var convert in convertItems)
138
            {
139
                //ReflashSubService();
137 140

  
138
                    if (convert.STATUS > (int)StatusCodeType.None)
141
                if (convert.STATUS > (int)StatusCodeType.None)
142
                {
143
                    using (DataBase.ConvertDatabase database = new DataBase.ConvertDatabase(MarkusDBConnectionString))
139 144
                    {
140
                        database.SetCleanUpItem(convert.ID);
145
                        database.SetCleanUpItem(convert.ID,1);
141 146
                    }
142

  
143
                    PassConvertItem(convert.PROJECT_NO, convert.ID,convert.DOCUMENT_ID);
144 147
                }
148

  
149
                PassConvertItem(convert.PROJECT_NO, convert.ID,convert.DOCUMENT_ID);
145 150
            }
151
          
146 152
        }
147 153

  
148 154
        public bool IsDataBaseWaitingList(int overListCount)
......
175 181
            {
176 182
                try
177 183
                {
178
                    subservice.IsOnline = SytemNet.Ping(subservice.Properties.SERVICE_ADDRESS);
184
                    subservice.IsOnline = await SytemNet.PingAsync(subservice.Properties.SERVICE_ADDRESS);
179 185

  
180 186
                    if (subservice.IsOnline)
181 187
                    {
......
268 274

  
269 275
                    try
270 276
                    {
271
                        for (int i = convertItems.Count - 1; i >= 0; --i)
277
                        if (convertItems.Count() > 0)
272 278
                        {
273
                            if (argumentList.Count(x => x == convertItems[i].ConvertID) == 0)
279
                            for (int i = convertItems.Count - 1; i >= 0; --i)
274 280
                            {
275
                                AliveConvertQueue.RemoveAt(i);
281
                                if (argumentList.Count(x => x == convertItems[i].ConvertID) == 0)
282
                                {
283
                                    AliveConvertQueue.RemoveAt(i);
284
                                }
276 285
                            }
277 286
                        }
278 287
                    }
......
307 316
                    {
308 317
                        if (aliveItems.Count(x => x.ConvertID == item.ID) == 0)
309 318
                        {
310
                            database.SetCleanUpItem(item.ID);
319
                            database.SetCleanUpItem(item.ID,0);
311 320
                        }
312 321
                    }
313 322
                }
......
379 388

  
380 389
                if (IsStation)
381 390
                {
382
                    if (!IsReleaseItems)
383
                    {
384
                        System.Diagnostics.Debug.WriteLine("ConvertFinish ReleaseItems call");
385
                        ReleaseItems();
386
                    }
391
                    //if (!IsReleaseItems)
392
                    //{
393
                    //    System.Diagnostics.Debug.WriteLine("ConvertFinish ReleaseItems call");
394
                    //    ReleaseItems();
395
                    //}
387 396
                }
388 397
                else
389 398
                {
ConvertService/ServiceBase/Markus.Service.Station/StationService/ServiceStationWCF.cs
18 18
    /// web service 목록
19 19
    /// </summary>
20 20
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
21
    //[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)]
21
    //[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IncludeExceptionDetailInFaults = true)]
22 22
    public partial class ServiceStation : IStationService
23 23
    {
24 24
        /// <summary>
ConvertService/ServiceBase/Markus.Service.StationController/AppInit.cs
38 38
               foreach (var item in serviceUri.Split(','))
39 39
                {
40 40

  
41
                    BasicHttpBinding myBinding = new BasicHttpBinding();
41
                    BasicHttpBinding httpbinding = new BasicHttpBinding();
42
                    httpbinding.CloseTimeout = new TimeSpan(0, 10, 0);
43
                    httpbinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
44
                    httpbinding.SendTimeout = new TimeSpan(0, 10, 0);
45
                    httpbinding.OpenTimeout = new TimeSpan(0, 10, 0);
46

  
47

  
42 48
                    EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate(item));
43
                    var StationClient = new StationServiceClient(myBinding, myEndpoint);
49
                    var StationClient = new StationServiceClient(httpbinding, myEndpoint);
44 50

  
45 51
                    StationClientList.Add(StationClient);
46 52
                }
ConvertService/ServiceBase/Markus.Service.StationController/Behaviors/RichTextBoxBehaviors.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Controls;
8
using System.Windows.Documents;
9

  
10
namespace Markus.Service.StationController.Behaviors
11
{
12
    public class RichTextBoxBehaviors : DependencyObject
13
    {
14
        public static FlowDocument GetDocument(DependencyObject obj)
15
        {
16
            return (FlowDocument)obj.GetValue(DocumentProperty);
17
        }
18
        public static void SetDocument(DependencyObject obj, FlowDocument value)
19
        {
20
            obj.SetValue(DocumentProperty, value);
21
        }
22

  
23
        public static readonly DependencyProperty DocumentProperty = DependencyProperty.RegisterAttached("Document", typeof(FlowDocument), typeof(RichTextBoxBehaviors),
24
                                                                    new FrameworkPropertyMetadata(null, new PropertyChangedCallback(DocumentPropertyChanged)) { BindsTwoWayByDefault = true });
25

  
26
        private static void DocumentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
27
        {
28
            var richTextBox = (RichTextBox)d;
29

  
30
            //richTextBox.Document.Dispatcher.InvokeAsync(() =>
31
            //{
32
            //    if (e.NewValue != null)
33
            //    {
34
            //        var doc = (e.NewValue == null) ? new FlowDocument() : (FlowDocument)e.NewValue;
35

  
36
            //        if (richTextBox.Document == null)
37
            //        {
38
            //            richTextBox.Document = new FlowDocument();
39
            //        }
40

  
41
            //        richTextBox.Document.Blocks doc.Blocks
42
            //    }
43
            //});
44
        }
45

  
46
        public FlowDocument Document
47
        {
48
            get { return (FlowDocument)GetValue(DocumentProperty); }
49
            set { SetValue(DocumentProperty, value); }
50
        }
51
    }
52
}
ConvertService/ServiceBase/Markus.Service.StationController/Controls/ITraceTextSink.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Diagnostics;
5

  
6
namespace Markus.Service.Controls
7
{
8
	interface ITraceTextSink
9
	{
10
		void Fail(string msg);
11
		void Event(string msg, TraceEventType eventType);
12
	}
13
}
ConvertService/ServiceBase/Markus.Service.StationController/Controls/TraceDocument.xaml
1
<FlowDocument  x:Class="Markus.Service.Controls.TraceDocument"
2
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
               FontSize="12" FontFamily="Courier New" PageWidth="10000"  Loaded="Document_Loaded" Unloaded="Document_Unloaded">
5
    <FlowDocument.Resources>
6
        <Style TargetType="{x:Type Run}" x:Key="Information">
7
            <Setter Property="Foreground" Value="Black"/>
8
            <Setter Property="FontWeight" Value="Normal"/>
9
        </Style>
10
        <Style TargetType="{x:Type Run}" x:Key="Error">
11
            <Setter Property="Foreground" Value="Red"/>
12
            <Setter Property="FontWeight" Value="Bold"/>
13
        </Style>
14
        <Style TargetType="{x:Type Run}" x:Key="Warning">
15
            <Setter Property="Foreground" Value="Red"/>
16
            <Setter Property="FontWeight" Value="Normal"/>
17
        </Style>
18
        <Style TargetType="{x:Type Run}" x:Key="Fail">
19
            <Setter Property="Foreground" Value="Fuchsia"/>
20
            <Setter Property="FontWeight" Value="Bold"/>
21
        </Style>
22
    </FlowDocument.Resources>
23
    <Paragraph>
24
        
25
    </Paragraph>
26
</FlowDocument>
ConvertService/ServiceBase/Markus.Service.StationController/Controls/TraceDocument.xaml.cs
1
using System.Windows.Controls;
2
using System.Windows;
3
using System.Windows.Media;
4
using System.Windows.Documents;
5
using System.Diagnostics;
6
using System.Windows.Controls.Primitives;
7

  
8
namespace Markus.Service.Controls
9
{
10
    public partial class TraceDocument : FlowDocument, ITraceTextSink
11
    {
12
        private delegate void AppendTextDelegate(string msg, string style);
13

  
14
        private TraceListener _listener;
15

  
16
        public TraceDocument()
17
        {
18
            AutoAttach = true;
19
            InitializeComponent();
20
        }
21

  
22
        public bool AutoAttach { get; set; }
23

  
24
        public void Event(string msg, TraceEventType eventType)
25
        {
26
            Append(msg, eventType.ToString());
27
        }
28

  
29
        public void Fail(string msg)
30
        {
31
            Append(msg, "Fail");
32
        }
33

  
34
        private void Append(string msg, string style)
35
        {
36
            if (Dispatcher.CheckAccess())
37
            {
38
                Debug.Assert(Blocks.LastBlock != null);
39
                Debug.Assert(Blocks.LastBlock is Paragraph);
40
                var run = new Run(msg);
41

  
42
                run.Style = (Style)(Resources[style]);
43
                if (run.Style == null)
44
                    run.Style = (Style)(Resources["Information"]);
45

  
46
                ((Paragraph)Blocks.LastBlock).Inlines.Add(run);
47

  
48
                ScrollParent(this);
49
            }
50
            else
51
            {
52
                Dispatcher.Invoke(new AppendTextDelegate(Append), msg, style);
53
            }
54
        }
55

  
56
        private static void ScrollParent(FrameworkContentElement element)
57
        {
58
            if (element != null)
59
            {
60
                if (element.Parent is TextBoxBase)
61
                    ((TextBoxBase)element.Parent).ScrollToEnd();
62

  
63
                else if (element.Parent is ScrollViewer)
64
                    ((ScrollViewer)element.Parent).ScrollToEnd();
65

  
66
                else
67
                    ScrollParent(element.Parent as FrameworkContentElement);
68
            }
69
        }
70

  
71
        private void Document_Loaded(object sender, RoutedEventArgs e)
72
        {
73
            if (AutoAttach && _listener == null)
74
            {
75
                _listener = new TraceTextSource(this);
76
                Trace.Listeners.Add(_listener);
77
            }
78
        }
79

  
80
        private void Document_Unloaded(object sender, RoutedEventArgs e)
81
        {
82
            if (_listener != null)
83
            {
84
                Trace.Listeners.Remove(_listener);
85
                _listener.Dispose();
86
                _listener = null;
87
            }
88
        }
89
    }
90
}
ConvertService/ServiceBase/Markus.Service.StationController/Controls/TraceTextSource.cs
1
using System;
2
using System.Diagnostics;
3

  
4
namespace Markus.Service.Controls
5
{
6
    class TraceTextSource : TraceListener
7
    {
8
        public ITraceTextSink Sink { get; private set; }
9
        private bool _fail;
10
        private TraceEventType _eventType = TraceEventType.Information;
11

  
12
        public TraceTextSource(ITraceTextSink sink)
13
        {
14
            Debug.Assert(sink != null);
15
            Sink = sink;
16
        }
17

  
18
        public override void Fail(string message)
19
        {
20
            _fail = true;
21
            base.Fail(message);
22
        }
23

  
24
        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
25
        {
26
            //_eventType = eventType;
27
           // base.TraceEvent(eventCache, source, eventType, id, message);
28
        }
29

  
30
        public override void Write(string message)
31
        {
32
            if (IndentLevel > 0)
33
                message = message.PadLeft(IndentLevel + message.Length, '\t');
34

  
35
            if (_fail)
36
                Sink.Fail(message);
37

  
38
            else
39
                Sink.Event(message, _eventType);
40

  
41
            _fail = false;
42
            _eventType = TraceEventType.Information;
43
        }
44

  
45
        public override void WriteLine(string message)
46
        {
47
            Write(message + "\n");
48
        }
49
    }
50
}
ConvertService/ServiceBase/Markus.Service.StationController/Markus.Service.StationController.csproj
138 138
    </ApplicationDefinition>
139 139
    <Compile Include="AppInit.cs" />
140 140
    <Compile Include="AppDefine.cs" />
141
    <Compile Include="Behaviors\RichTextBoxBehaviors.cs" />
141 142
    <Compile Include="Behaviors\StatusTypeSet.cs" />
143
    <Compile Include="Controls\ITraceTextSink.cs" />
144
    <Compile Include="Controls\TraceDocument.xaml.cs">
145
      <DependentUpon>TraceDocument.xaml</DependentUpon>
146
    </Compile>
147
    <Compile Include="Controls\TraceTextSource.cs" />
142 148
    <Compile Include="Data\NavigationItem.cs" />
143 149
    <Compile Include="Extensions\ConvertItemChangeValue.cs" />
144 150
    <Compile Include="Extensions\GetStatusTypeEnums.cs" />
......
161 167
    <Compile Include="Views\SettingsView.xaml.cs">
162 168
      <DependentUpon>SettingsView.xaml</DependentUpon>
163 169
    </Compile>
170
    <Page Include="Controls\TraceDocument.xaml">
171
      <Generator>MSBuild:Compile</Generator>
172
      <SubType>Designer</SubType>
173
    </Page>
164 174
    <Page Include="MainWindow.xaml">
165 175
      <Generator>MSBuild:Compile</Generator>
166 176
      <SubType>Designer</SubType>
ConvertService/ServiceBase/Markus.Service.StationController/StationController.ini
1 1
[SERVICE]
2 2
SERVICE_ADDRESS = http://172.20.120.142:9991/StationService,http://172.20.120.143:9991/StationService
3

  
4
# http://172.20.120.142:9991/StationService,http://172.20.120.143:9991/StationService
3 5
#,http://192.168.0.68:9101/StationService
4 6
#http://172.20.120.142:9991/StationService
5 7

  
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/AliveViewModel.cs
18 18

  
19 19
        private System.Collections.ObjectModel.ObservableCollection<ConvertItem> aliveItems;
20 20
        private bool isLoading;
21
        private System.Windows.Documents.FlowDocument connectionLog;
21 22

  
22 23
        public System.Collections.ObjectModel.ObservableCollection<ConvertItem> AliveItems
23 24
        {
......
40 41
            }
41 42
        }
42 43

  
44

  
45
        public System.Windows.Documents.FlowDocument ConnectionLog
46
        {
47
            get => connectionLog;
48
            set
49
            {
50
                if(connectionLog != value)
51
                {
52
                    connectionLog = value;
53
                    OnPropertyChanged(() => ConnectionLog);
54
                }
55
            }
56
        }
57

  
43 58
        public AliveViewModel()
44 59
        {
45 60
        }
......
59 74
        {
60 75
            while (IsAcitve)
61 76
            {
62
                System.Threading.Thread.Sleep(5000);
77
                System.Threading.Thread.Sleep(new TimeSpan(0,0,3));
63 78

  
64
                try
79
                if (!IsLoading)
65 80
                {
66 81
                    IsLoading = true;
67 82

  
68
                    List<ConvertItem> newitems = new List<ConvertItem>();
69

  
70
                    foreach (var client in App.StationClientList)
83
                    try
71 84
                    {
72
                        //if (SimplePing(client.Endpoint.Address.ToString()))
73
                        //{
74
                        try
75
                        {
76
                            var items = await client.AliveConvertListAsync();
77
                            newitems.AddRange(items);
78
                        }
79
                        catch (Exception ex)
85

  
86
                        List<ConvertItem> newitems = new List<ConvertItem>();
87

  
88
                        foreach (var client in App.StationClientList)
80 89
                        {
81
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
90
                            if (await SimplePingAsync(client.Endpoint.Address.ToString()))
91
                            {
92
                                try
93
                                {
94
                                    var items = await client.AliveConvertListAsync();
95
                                    newitems.AddRange(items);
96
                                    System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} ping");
97

  
98
                                    if (items.Count() == 0)
99
                                    {
100
                                        System.Diagnostics.Trace.WriteLine($"{client.Endpoint.Address} Alive Items is zero.");
101
                                    }
102
                                }
103
                                catch (Exception ex)
104
                                {
105
                                    System.Diagnostics.Trace.TraceError($"{client.Endpoint.Address} {ex.Message}");
106
                                }
107
                            }
108
                            else
109
                            {
110
                                System.Diagnostics.Trace.TraceError($"{client.Endpoint.Address} ping Error");
111
                            }
82 112
                        }
83
                        
84
                        //}
85
                    }
86 113

  
87
                    foreach (var item in newitems)
114
                        ItemsUpdate(newitems);
115
                    }
116
                    catch (Exception ex)
88 117
                    {
89
                        item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
90 118
                    }
91 119

  
92
                    if (AliveItems == null)
93
                    {
94
                        AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
120
                    IsLoading = false;
121
                }
95 122

  
96
                        foreach (var item in newitems)
97
                        {
98
                            AliveItems.Add(item);
99
                        }
100
                    }
101
                    else
102
                    {
103
                        /// 데이터 업데이트
104
                        newitems.ForEach(newitem =>
105
                        {
106
                            AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
107
                        });
123
            }
124
        }
108 125

  
109
                        // 추가
110
                        foreach (var item in newitems)
111
                        {
112
                            if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
113
                            {
114
                                AliveItems.Add(item);
115
                            }
116
                        }
126
       
117 127

  
118
                        /// 삭제
128
        private void ItemsUpdate(List<ConvertItem> newitems)
129
        {
119 130

  
120
                        for (int i = AliveItems.Count() -1; i > -1; --i)
121
                        {
122
                            var item = AliveItems[i];
131
            foreach (var item in newitems)
132
            {
133
                item.OriginfilePath = HttpUtility.UrlDecode(item.OriginfilePath);
134
            }
123 135

  
124
                            if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
125
                            {
126
                                AliveItems.RemoveAt(i);
127
                            }
128
                        }
136
            if (AliveItems == null)
137
            {
138
                AliveItems = new System.Collections.ObjectModel.ObservableCollection<ConvertItem>();
139

  
140
                foreach (var item in newitems)
141
                {
142
                    AliveItems.Add(item);
143
                }
144
            }
145
            else
146
            {
147
                /// 데이터 업데이트
148
                newitems.ForEach(newitem =>
149
                {
150
                    AliveItems.UpdateWhere(changeitem => ConvertItemEx.ChangeValues(changeitem, newitem), x => x.ProjectNumber == newitem.ProjectNumber && x.ConvertID == newitem.ConvertID);
151
                });
152

  
153
                // 추가
154
                foreach (var item in newitems)
155
                {
156
                    if (AliveItems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
157
                    {
158
                        AliveItems.Add(item);
129 159
                    }
130 160
                }
131
                catch (Exception ex)
161

  
162
                /// 삭제
163

  
164
                for (int i = AliveItems.Count() - 1; i > -1; --i)
132 165
                {
166
                    var item = AliveItems[i];
167

  
168
                    if (newitems.Count(x => x.ConvertID == item.ConvertID && x.ProjectNumber == item.ProjectNumber) == 0)
169
                    {
170
                        AliveItems.RemoveAt(i);
171
                    }
133 172
                }
134 173
            }
135
            
136 174
        }
137 175

  
138
   
176
        private void LogWrite(string log,bool IsError)
177
        {
178
            if(IsError)
179
            {
180
                System.Diagnostics.Trace.Fail(log);
181
            }
182
            else
183
            {
184
                System.Diagnostics.Trace.TraceInformation(log);
185
            }
186
        }
139 187

  
140 188

  
141
        public static bool SimplePing(string uri)
189
        public static async Task<bool> SimplePingAsync(string uri)
142 190
        {
143 191
            bool result = false;
144 192

  
......
146 194
            {
147 195
                using (System.Net.Http.HttpClient Client = new System.Net.Http.HttpClient())
148 196
                {
149
                    Client.Timeout = new TimeSpan(0, 0, 10);
197
                    Client.Timeout = new TimeSpan(0, 5,0);
198
                    
199
                    var message = await Client.GetAsync(uri);
150 200

  
151
                    System.Net.Http.HttpResponseMessage responseMessage = Client.GetAsync(uri).Result;
152
                    System.Net.HttpStatusCode StatusCode = responseMessage.StatusCode;
201
                    System.Net.HttpStatusCode StatusCode = message.StatusCode;
153 202

  
154 203
                    switch (StatusCode)
155 204
                    {
......
161 210
                    }
162 211
                }
163 212
            }
164
            catch (Exception)
213
            catch (Exception ex)
165 214
            {
215
                result = false;
166 216
            }
167 217

  
168 218
            return result;
ConvertService/ServiceBase/Markus.Service.StationController/Views/AliveView.xaml
7 7
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
8 8
              xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
9 9
              xmlns:vm="clr-namespace:Markus.Service.StationController.ViewModel"
10
             d:DesignHeight="450" d:DesignWidth="800">
10
             xmlns:Behaviors="clr-namespace:Markus.Service.StationController.Behaviors"
11
             xmlns:controls="clr-namespace:Markus.Service.Controls" Background="White"
12
             d:DesignHeight="800" d:DesignWidth="800">
11 13
    <UserControl.DataContext>
12 14
        <vm:AliveViewModel/>
13 15
    </UserControl.DataContext>
......
21 23
    </i:Interaction.Triggers>
22 24
    <Grid>
23 25
        <Grid.RowDefinitions>
24
            <RowDefinition Height="*"/>
26
            <RowDefinition Height="7*"/>
27
            <RowDefinition Height="3*" MinHeight="150" MaxHeight="300"/>
25 28
            <RowDefinition Height="Auto"/>
26 29
        </Grid.RowDefinitions>
27 30
        <telerik:RadGridView ItemsSource="{Binding AliveItems}" AutoGenerateColumns="False"
......
37 40
                <telerik:GridViewDataColumn  Header="Output Path" DataMemberBinding="{Binding ConvertPath}"/>
38 41
            </telerik:RadGridView.Columns>
39 42
        </telerik:RadGridView>
40
        <ProgressBar Grid.Row="1" IsIndeterminate="{Binding IsLoading}" Height="5"/>
43
        <!--<GroupBox Header="ServiceStation Connection Log" Background="White"  Grid.Row="1" Margin="3" BorderThickness="0">-->
44
            <Grid  Grid.Row="1">
45
            <RichTextBox IsReadOnly="True" AllowDrop="False" VerticalScrollBarVisibility="Visible"
46
                         IsUndoEnabled="False" HorizontalScrollBarVisibility="Auto"
47
                         Height="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}"
48
                         Width="{Binding ActualWidth, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}">
49
                <controls:TraceDocument PageWidth="{Binding ActualWidth, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}"
50
                                        PageHeight="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}"/>
51
            </RichTextBox>
52
            </Grid>
53
        <!--</GroupBox>-->
54
        <ProgressBar Grid.Row="2" IsIndeterminate="{Binding IsLoading}" Height="5"/>
41 55
    </Grid>
42 56
</UserControl>
ConvertService/ServiceBase/Markus.Service.WcfService/Helper/WcfHostHelper.cs
35 35

  
36 36
            if (HttpHostEndpoint != null)
37 37
            {
38
                Binding httpbinding = new BasicHttpBinding();
38
                Binding httpbinding = new BasicHttpBinding { TransferMode = TransferMode.Buffered};
39
                
40
                httpbinding.CloseTimeout = new TimeSpan(0, 10, 0);
41
                httpbinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
42
                httpbinding.SendTimeout = new TimeSpan(0, 10, 0);
43
                httpbinding.OpenTimeout = new TimeSpan(0, 10, 0);
44

  
39 45
                Binding bindingMex = MetadataExchangeBindings.CreateMexHttpBinding();
46
                bindingMex.CloseTimeout = new TimeSpan(0, 10, 0);
47
                bindingMex.ReceiveTimeout = new TimeSpan(0, 10, 0);
48
                bindingMex.SendTimeout = new TimeSpan(0, 10, 0);
49
                bindingMex.OpenTimeout = new TimeSpan(0, 10, 0);
40 50

  
41 51
                httpbinding.CreateBindingElements().Add(gBindingElement);
42 52

  
......
63 73
            }
64 74

  
65 75
            var behavior = serviceHost.Description.Behaviors.Find<ServiceBehaviorAttribute>();
76
            behavior.ConcurrencyMode = ConcurrencyMode.Multiple;
66 77
            behavior.InstanceContextMode = InstanceContextMode.Single;
67 78
            
68 79
            serviceHost.Open();
......
89 100
                MaxNameTableCharCount = Int32.MaxValue
90 101
            };
91 102
        }
92

  
93
        //rest 추가로 변경
94
        private static ServiceHost WcfCreate_old(this ServiceHost serviceHost, object service, Type serviceInterface, IEnumerable<Uri> HostEndpoints)
95
        {
96
            if (serviceHost != null)
97
            {
98
                foreach (var item in serviceHost.ChannelDispatchers)
99
                {
100
                    item.Abort();
101
                }
102

  
103
                serviceHost.Abort();
104
                serviceHost = null;
105
            }
106

  
107
            serviceHost = new ServiceHost(service, HostEndpoints.ToArray());
108

  
109
            if (HostEndpoints.GroupBy(f => f.Scheme).Count() != HostEndpoints.Count())
110
            {
111
                throw new Exception("Host Uri's schema must be unique.");
112
            }
113

  
114

  
115
            ServiceMetadataBehavior mBehave = new ServiceMetadataBehavior();
116
            mBehave.HttpGetEnabled = true;
117
            mBehave.HttpsGetEnabled = true;
118
            serviceHost.Description.Behaviors.Add(mBehave);
119

  
120
            //ServiceBehaviorAttribute attribute = new ServiceBehaviorAttribute();
121
            //attribute.InstanceContextMode = InstanceContextMode.Single;
122
            //attribute.IncludeExceptionDetailInFaults = false;
123

  
124
            //serviceHost.Description.Behaviors.Add(attribute);
125

  
126
            //ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
127
            //sdb.IncludeExceptionDetailInFaults = true;
128

  
129
            foreach (var item in HostEndpoints)
130
            {
131
                System.ServiceModel.Channels.Binding binding = null;
132
                System.ServiceModel.Channels.Binding bindingMex = null;
133

  
134
                if (item.Scheme == Uri.UriSchemeHttp)
135
                {
136
                    binding = new BasicHttpBinding();
137
                    bindingMex = MetadataExchangeBindings.CreateMexHttpBinding();
138

  
139
                    BindingElementCollection bindElemColl = new BindingElementCollection();
140
                    BinaryMessageEncodingBindingElement bindElem = new BinaryMessageEncodingBindingElement();
141
                    bindElem.MaxReadPoolSize = 64;
142
                    bindElem.MaxWritePoolSize = 16;
143
                    bindElem.MaxSessionSize = 2048;
144
                    XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
145
                    readerQuotas.MaxDepth = 32;
146
                    readerQuotas.MaxStringContentLength = Int32.MaxValue;
147
                    readerQuotas.MaxArrayLength = Int32.MaxValue;
148
                    readerQuotas.MaxBytesPerRead = Int32.MaxValue;
149
                    readerQuotas.MaxNameTableCharCount = Int32.MaxValue;
150
                    bindElem.ReaderQuotas = readerQuotas;
151

  
152
                    binding.CreateBindingElements().Add(bindElem);
153
                }
154
                else if (item.Scheme == Uri.UriSchemeHttps)
155
                {
156
                    binding = new BasicHttpsBinding();
157
                    bindingMex = MetadataExchangeBindings.CreateMexHttpsBinding();
158

  
159

  
160

  
161
                }
162
                else if (item.Scheme == Uri.UriSchemeNetTcp)
163
                {
164
                    binding = new NetTcpBinding();
165
                    bindingMex = MetadataExchangeBindings.CreateMexTcpBinding();
166
                }
167
                else
168
                {
169
                    throw new Exception($"{item.ToString()} is Not Support Schema.");
170
                }
171

  
172
                var endpoint = serviceHost.AddServiceEndpoint(serviceInterface, binding, item);
173

  
174
                if (binding is BasicHttpBinding)
175
                {
176
                    WebHttpBinding webHttp = new WebHttpBinding();
177
                    var serviceEndpoint = serviceHost.AddServiceEndpoint(serviceInterface, webHttp, item);
178
                    serviceEndpoint.EndpointBehaviors.Add(new WebHttpBehavior());
179
                }
180

  
181
                serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), bindingMex, "mex");
182
            }
183

  
184

  
185
            var behavior = serviceHost.Description.Behaviors.Find<ServiceBehaviorAttribute>();
186
            behavior.InstanceContextMode = InstanceContextMode.Single;
187

  
188
            serviceHost.Open();
189
            return serviceHost;
190
        }
191 103
    }
192 104
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)