프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.StationController / AppInit.cs @ 06f13e11

이력 | 보기 | 이력해설 | 다운로드 (2.44 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 myBinding = new BasicHttpBinding();
42
                    EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate(item));
43
                    var StationClient = new StationServiceClient(myBinding, myEndpoint);
44

    
45
                    StationClientList.Add(StationClient);
46
                }
47

    
48
                MarkusDataBaseConnecitonString = AESEncrypter.Decrypt(config.GetValue(CONFIG_DEFINE.SERVICE, CONFIG_DEFINE.MARKUS_CONNECTION_STRING));
49
            }
50
            catch (Exception ex)
51
            {
52
            }
53
        }
54

    
55
        private string GetAppPath(string productName)
56
        {
57
            const string foldersPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders";
58
            var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
59

    
60
            var subKey = baseKey.OpenSubKey(foldersPath);
61
            if (subKey == null)
62
            {
63
                baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
64
                subKey = baseKey.OpenSubKey(foldersPath);
65
            }
66
            return subKey != null ? subKey.GetValueNames().FirstOrDefault(kv => kv.Contains(productName)) : "ERROR";
67
        }
68

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