markus / MarkupToPDF / Common / GetUserSign.cs @ master
이력 | 보기 | 이력해설 | 다운로드 (4.79 KB)
1 |
using KCOMDataModel.Common; |
---|---|
2 |
using KCOMDataModel.DataModel; |
3 |
using System; |
4 |
using System.Collections.Generic; |
5 |
using System.IO; |
6 |
using System.Linq; |
7 |
using System.Net; |
8 |
using System.Runtime.InteropServices; |
9 |
using System.ServiceModel; |
10 |
using System.Text; |
11 |
|
12 |
namespace MarkupToPDF.Common |
13 |
{ |
14 |
public class GetUserSign |
15 |
{ |
16 |
/// |
17 |
/// <summary> |
18 |
/// Application Data Folder |
19 |
/// </summary> |
20 |
/// |
21 |
public static string AppDataFolder |
22 |
{ |
23 |
get |
24 |
{ |
25 |
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS"); |
26 |
} |
27 |
} |
28 |
|
29 |
|
30 |
/// <summary> |
31 |
/// get signature of given user of given project |
32 |
/// </summary> |
33 |
/// <param name="UserID"></param> |
34 |
/// <param name="ProjectNo"></param> |
35 |
/// <returns></returns> |
36 |
public static string GetSign(string UserID, string ProjectNo,bool isExternal= false) |
37 |
{ |
38 |
string sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
39 |
|
40 |
System.ServiceModel.Channels.Binding binding; |
41 |
EndpointAddress _EndPoint; |
42 |
|
43 |
Uri serviceUri = new Uri(sBaseServiceURL); |
44 |
|
45 |
if (serviceUri.Scheme == Uri.UriSchemeHttp) |
46 |
{ |
47 |
var _basichttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); |
48 |
_basichttpbinding.MaxBufferSize = 2147483647; |
49 |
_basichttpbinding.MaxReceivedMessageSize = 2147483647; |
50 |
_basichttpbinding.OpenTimeout = new TimeSpan(0, 1, 0); |
51 |
_basichttpbinding.ReceiveTimeout = new TimeSpan(0, 10, 0); |
52 |
_basichttpbinding.CloseTimeout = new TimeSpan(0, 5, 0); |
53 |
_basichttpbinding.SendTimeout = new TimeSpan(0, 5, 0); |
54 |
_basichttpbinding.TextEncoding = System.Text.Encoding.UTF8; |
55 |
_basichttpbinding.TransferMode = TransferMode.Buffered; |
56 |
|
57 |
binding = _basichttpbinding; |
58 |
} |
59 |
else |
60 |
{ |
61 |
var customBinding = new System.ServiceModel.Channels.CustomBinding() |
62 |
{ |
63 |
OpenTimeout = new TimeSpan(0, 30, 0), |
64 |
ReceiveTimeout = new TimeSpan(0, 30, 0), |
65 |
CloseTimeout = new TimeSpan(0, 30, 0), |
66 |
SendTimeout = new TimeSpan(0, 30, 0), |
67 |
}; |
68 |
var httpTranport = new System.ServiceModel.Channels.HttpsTransportBindingElement |
69 |
{ |
70 |
MaxBufferPoolSize = Int32.MaxValue, |
71 |
MaxBufferSize = Int32.MaxValue, |
72 |
MaxReceivedMessageSize = Int32.MaxValue, |
73 |
RequestInitializationTimeout = new TimeSpan(0, 30, 0), |
74 |
}; |
75 |
|
76 |
customBinding.CreateBindingElements(); |
77 |
|
78 |
var reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement(); |
79 |
|
80 |
var encoding = new System.ServiceModel.Channels.TextMessageEncodingBindingElement |
81 |
{ |
82 |
MaxReadPoolSize = Int32.MaxValue, |
83 |
MaxWritePoolSize = Int32.MaxValue, |
84 |
MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12WSAddressing10, |
85 |
WriteEncoding = System.Text.Encoding.UTF8, |
86 |
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas |
87 |
{ |
88 |
MaxArrayLength = Int32.MaxValue, |
89 |
MaxBytesPerRead = Int32.MaxValue, |
90 |
MaxDepth = Int32.MaxValue, |
91 |
MaxNameTableCharCount = Int32.MaxValue, |
92 |
MaxStringContentLength = Int32.MaxValue |
93 |
} |
94 |
}; |
95 |
customBinding.Elements.Add(reliableSession); |
96 |
customBinding.Elements.Add(httpTranport); |
97 |
|
98 |
binding = customBinding; |
99 |
} |
100 |
|
101 |
string localdomain = CommonLib.Common.GetConfigString("HOST_DOMAIN", "DOMAIN", ""); |
102 |
|
103 |
var hostEntry = CommonLib.DNSHelper.GetHostEntryTask(); |
104 |
|
105 |
if (hostEntry == null) |
106 |
{ |
107 |
System.Diagnostics.Debug.WriteLine("(hostEntry == null"); |
108 |
isExternal = true; |
109 |
} |
110 |
else if (!hostEntry.HostName.EndsWith(localdomain)) |
111 |
{ |
112 |
// 외부 사용자 |
113 |
isExternal = true; |
114 |
} |
115 |
//CommonLib.Common.GetConfigString("BaseClientAddress", "URL", ""); |
116 |
|
117 |
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
118 |
|
119 |
markus_api.ServiceDeepViewClient client = new markus_api.ServiceDeepViewClient(binding, _EndPoint); |
120 |
var _sign = client.GetSignData(ProjectNo, UserID); |
121 |
|
122 |
return _sign; |
123 |
} |
124 |
} |
125 |
} |