개정판 de4c7a4a
issue #000 commonlib add
Change-Id: I09db0dc2e7f46bc88531cea1a257eec438f561b7
CommonLib/Common.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.IO; |
|
4 |
using System.Linq; |
|
5 |
using System.Runtime.InteropServices; |
|
6 |
using System.Security.Cryptography; |
|
7 |
using System.Text; |
|
8 |
using System.Threading.Tasks; |
|
9 |
|
|
10 |
namespace CommonLib |
|
11 |
{ |
|
12 |
public class Common |
|
13 |
{ |
|
14 |
[DllImport("kernel32")] |
|
15 |
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); |
|
16 |
|
|
17 |
public static string AppDataFolder |
|
18 |
{ |
|
19 |
get |
|
20 |
{ |
|
21 |
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS"); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
/// <summary> |
|
26 |
/// Client 에 설치된 MARKUS.ini 를 참조. |
|
27 |
/// </summary> |
|
28 |
/// <param name="section"></param> |
|
29 |
/// <param name="key"></param> |
|
30 |
/// <param name="def"></param> |
|
31 |
/// <returns></returns> |
|
32 |
public static string GetConfigString(string section, string key, string def) |
|
33 |
{ |
|
34 |
System.Text.StringBuilder strbuilder = new System.Text.StringBuilder(512); |
|
35 |
GetPrivateProfileString(section, key, def, strbuilder, 512, Path.Combine(AppDataFolder, "MARKUS.ini")); |
|
36 |
return strbuilder.ToString(); |
|
37 |
} |
|
38 |
|
|
39 |
/// <summary> |
|
40 |
/// 서버에 설치된 Service ini 의 Connection String 을 참조 |
|
41 |
/// </summary> |
|
42 |
/// <returns></returns> |
|
43 |
public static string GetConnectionString() |
|
44 |
{ |
|
45 |
System.Text.StringBuilder strbuilder = new System.Text.StringBuilder(512); |
|
46 |
GetPrivateProfileString("ConnectionString", "STRING", "", strbuilder, 512, Path.Combine(AppDataFolder, "FinalService.ini")); |
|
47 |
return Decrypt(strbuilder.ToString(), "Doftech1073#"); |
|
48 |
} |
|
49 |
private static string Decrypt(string textToDecrypt, string key) |
|
50 |
{ |
|
51 |
RijndaelManaged rijndaelCipher = new RijndaelManaged(); |
|
52 |
rijndaelCipher.Mode = CipherMode.CBC; |
|
53 |
rijndaelCipher.Padding = PaddingMode.PKCS7; |
|
54 |
rijndaelCipher.KeySize = 128; |
|
55 |
rijndaelCipher.BlockSize = 128; |
|
56 |
|
|
57 |
byte[] encryptedData = Convert.FromBase64String(textToDecrypt); |
|
58 |
byte[] pwdBytes = Encoding.UTF8.GetBytes(key); |
|
59 |
byte[] keyBytes = new byte[16]; |
|
60 |
|
|
61 |
int len = pwdBytes.Length; |
|
62 |
if (len > keyBytes.Length) |
|
63 |
{ |
|
64 |
len = keyBytes.Length; |
|
65 |
} |
|
66 |
|
|
67 |
Array.Copy(pwdBytes, keyBytes, len); |
|
68 |
rijndaelCipher.Key = keyBytes; |
|
69 |
rijndaelCipher.IV = keyBytes; |
|
70 |
|
|
71 |
byte[] plainText = rijndaelCipher.CreateDecryptor().TransformFinalBlock(encryptedData, 0, encryptedData.Length); |
|
72 |
return Encoding.UTF8.GetString(plainText); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
CommonLib/CommonLib.csproj | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
3 |
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|
4 |
<PropertyGroup> |
|
5 |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
6 |
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
7 |
<ProjectGuid>{DEF47FC2-B898-4C92-AD8D-D7B9E994495E}</ProjectGuid> |
|
8 |
<OutputType>Library</OutputType> |
|
9 |
<AppDesignerFolder>Properties</AppDesignerFolder> |
|
10 |
<RootNamespace>CommonLib</RootNamespace> |
|
11 |
<AssemblyName>CommonLib</AssemblyName> |
|
12 |
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|
13 |
<FileAlignment>512</FileAlignment> |
|
14 |
<Deterministic>true</Deterministic> |
|
15 |
</PropertyGroup> |
|
16 |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
17 |
<DebugSymbols>true</DebugSymbols> |
|
18 |
<DebugType>full</DebugType> |
|
19 |
<Optimize>false</Optimize> |
|
20 |
<OutputPath>bin\Debug\</OutputPath> |
|
21 |
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
22 |
<ErrorReport>prompt</ErrorReport> |
|
23 |
<WarningLevel>4</WarningLevel> |
|
24 |
</PropertyGroup> |
|
25 |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
26 |
<DebugType>pdbonly</DebugType> |
|
27 |
<Optimize>true</Optimize> |
|
28 |
<OutputPath>bin\Release\</OutputPath> |
|
29 |
<DefineConstants>TRACE</DefineConstants> |
|
30 |
<ErrorReport>prompt</ErrorReport> |
|
31 |
<WarningLevel>4</WarningLevel> |
|
32 |
</PropertyGroup> |
|
33 |
<ItemGroup> |
|
34 |
<Reference Include="System" /> |
|
35 |
<Reference Include="System.Core" /> |
|
36 |
<Reference Include="System.Xml.Linq" /> |
|
37 |
<Reference Include="System.Data.DataSetExtensions" /> |
|
38 |
<Reference Include="Microsoft.CSharp" /> |
|
39 |
<Reference Include="System.Data" /> |
|
40 |
<Reference Include="System.Net.Http" /> |
|
41 |
<Reference Include="System.Xml" /> |
|
42 |
</ItemGroup> |
|
43 |
<ItemGroup> |
|
44 |
<Compile Include="Common.cs" /> |
|
45 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
|
46 |
</ItemGroup> |
|
47 |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|
48 |
</Project> |
CommonLib/Properties/AssemblyInfo.cs | ||
---|---|---|
1 |
using System.Reflection; |
|
2 |
using System.Runtime.CompilerServices; |
|
3 |
using System.Runtime.InteropServices; |
|
4 |
|
|
5 |
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 |
|
6 |
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 |
|
7 |
// 이러한 특성 값을 변경하세요. |
|
8 |
[assembly: AssemblyTitle("CommonLib")] |
|
9 |
[assembly: AssemblyDescription("")] |
|
10 |
[assembly: AssemblyConfiguration("")] |
|
11 |
[assembly: AssemblyCompany("")] |
|
12 |
[assembly: AssemblyProduct("CommonLib")] |
|
13 |
[assembly: AssemblyCopyright("Copyright © 2019")] |
|
14 |
[assembly: AssemblyTrademark("")] |
|
15 |
[assembly: AssemblyCulture("")] |
|
16 |
|
|
17 |
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 |
|
18 |
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 |
|
19 |
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. |
|
20 |
[assembly: ComVisible(false)] |
|
21 |
|
|
22 |
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. |
|
23 |
[assembly: Guid("def47fc2-b898-4c92-ad8d-d7b9e994495e")] |
|
24 |
|
|
25 |
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. |
|
26 |
// |
|
27 |
// 주 버전 |
|
28 |
// 부 버전 |
|
29 |
// 빌드 번호 |
|
30 |
// 수정 버전 |
|
31 |
// |
|
32 |
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 |
|
33 |
// 기본값으로 할 수 있습니다. |
|
34 |
// [assembly: AssemblyVersion("1.0.*")] |
|
35 |
[assembly: AssemblyVersion("1.0.0.0")] |
|
36 |
[assembly: AssemblyFileVersion("1.0.0.0")] |
내보내기 Unified diff