프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.StationController / AppInit.cs @ 503cb09e

이력 | 보기 | 이력해설 | 다운로드 (2.72 KB)

1
using Markus.Service.Helper;
2
using Microsoft.Win32;
3
using System;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.ServiceModel;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows;
10
using static Markus.Service.Extensions.Encrypt;
11
using Markus.Service.WcfClient.StationServiceTask;
12

    
13
namespace Markus.Service.StationController
14
{
15
    public partial class App : Application
16
    {
17
        public static  List<StationServiceClient> StationClientList;
18
        public static string MarkusDataBaseConnecitonString;
19

    
20
        public App()
21
        {
22
            var path = GetAppPath("ConvertService");
23
            System.Diagnostics.Debug.WriteLine(path);
24
            ServiceConnection();
25
        }
26

    
27
        private void ServiceConnection()
28
        {
29
            try
30
            {
31
                var configFileName = $"StationController.ini";
32

    
33
                var config = ConfigHelper.AppConfig(configFileName);
34

    
35
                var serviceUri = config.GetValue(CONFIG_DEFINE.SERVICE, CONFIG_DEFINE.SERVICE_ADDRESS, "http://Localhost:9101/StationService");
36
                StationClientList = new List<StationServiceClient>();
37

    
38
               foreach (var item in serviceUri.Split(','))
39
                {
40

    
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

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

    
51
                    StationClientList.Add(StationClient);
52
                }
53

    
54
                MarkusDataBaseConnecitonString = AESEncrypter.Decrypt(config.GetValue(CONFIG_DEFINE.SERVICE, CONFIG_DEFINE.MARKUS_CONNECTION_STRING));
55
            }
56
            catch (Exception ex)
57
            {
58
            }
59
        }
60

    
61
        private string GetAppPath(string productName)
62
        {
63
            const string foldersPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders";
64
            var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
65

    
66
            var subKey = baseKey.OpenSubKey(foldersPath);
67
            if (subKey == null)
68
            {
69
                baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
70
                subKey = baseKey.OpenSubKey(foldersPath);
71
            }
72
            return subKey != null ? subKey.GetValueNames().FirstOrDefault(kv => kv.Contains(productName)) : "ERROR";
73
        }
74

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