프로젝트

일반

사용자정보

개정판 ca938a38

IDca938a38cda4e350afc9c86f98a76acbd332c71c
상위 c7555c83
하위 5a223b60

백흠경이(가) 5달 전에 추가함

Fix: FinalService에서 ID, Password로 UNC 경로를 접근하도록 수정

Change-Id: Idf82a8ae16fe13de8d191f33bae08675a95c3ab6

차이점 보기:

FinalService/KCOM_FinalService_DL/FinalProcess/FinalProcess.csproj
69 69
  </ItemGroup>
70 70
  <ItemGroup>
71 71
    <None Include="App.config" />
72
    <None Include="FinalService.ini">
73
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
74
    </None>
75 72
    <None Include="LogProcess.config">
76 73
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
77 74
    </None>
FinalService/KCOM_FinalService_DL/FinalProcess/FinalService.ini
1
[PDFMovePath]
2
URL=\\192.168.0.67\finalpdf\
3
[ApprovedImgPath]
4
URL=\\192.168.0.67\finalpdf\Approved.png
5
[CheckmarkImgPath]
6
URL=\\192.168.0.67\finalpdf\checkmark.png
7
[DebugSavePath]
8
URL=D:\\Develop\\Ensemble\\{0}_app\\VPCS_DOCLIB\\{1}\\{2}\\ToVendor\\
9
[DebugResultUrlPath]
10
URL=http://cloud.devdoftech.co.kr:5977/FinalPDF/{0}_app/VPCS_DOCLIB/{1}/{2}/ToVendor/{3}
11
[FinalServiceName]
12
NAME=FinalService
13
[UpLoadServiceUrl]
14
URL=
15
[ConnectionString]
16
STRING=tyEJJeokhOMWTRIHqgLi0s7NOmaFjuncpGJJHQsTgJ5nLR3X4onWcznboRsrRHEnVvMLkjL8BFikT7enPVaYDGQaP4HyeqEwticXhjyf1eE=
17
[MARKUS_API]
18
URL=http://www.devdoftech.co.kr:5979/ServiceDeepView.svc
FinalService/KCOM_FinalService_DL/FinalProcess/Program.cs
134 134
                    _markuptoPDF.FinalMakeError += new EventHandler<MarkupToPDF.MakeFinalErrorArgs>(_markuptoPDF_FinalMakeError);
135 135
                    _markuptoPDF.StatusChanged += new EventHandler<MarkupToPDF.StatusChangedEventArgs>(_markuptoPDF_StatusChange);
136 136
                    _markuptoPDF.EndFinal += _markuptoPDF_EndFinal;
137
                    using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
137

  
138
                    string ConnString = KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString();
139
                    _logger.Info($"ConnString : {ConnString}");
140
                    using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(ConnString))
138 141
                    {
139 142
                        var items = _entity.FINAL_PDF.Where(x => x.ID == sFinalID && x.PROJECT_NO == sProjectNo);
140 143
                        if(items.Any())
......
295 298

  
296 299
        public static void StatusChange(FINAL_PDF finalpdf, FinalStatus status, string msg)
297 300
        {
298
            using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
301
            string ConnString = KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString();
302
            _logger.Info($"Connection String : {ConnString}");
303
            using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(ConnString))
299 304
            {
300 305
                var items = _entity.FINAL_PDF.Where(x => x.ID == finalpdf.ID).ToList();
301 306
                if (items.Any())
FinalService/KCOM_FinalService_DL/KCOMDataModel/DataModel/KCOM_Model.Designer.cs
34 34
        public KCOMEntities() : base("name=KCOMEntities", "KCOMEntities")
35 35
        {
36 36
            this.ContextOptions.LazyLoadingEnabled = true;
37
            this.CommandTimeout = int.MaxValue;
37 38
            OnContextCreated();
38 39
        }
39 40
    
......
43 44
        public KCOMEntities(string connectionString) : base(connectionString, "KCOMEntities")
44 45
        {
45 46
            this.ContextOptions.LazyLoadingEnabled = true;
47
            this.CommandTimeout = int.MaxValue;
46 48
            OnContextCreated();
47 49
        }
48 50
    
......
52 54
        public KCOMEntities(EntityConnection connection) : base(connection, "KCOMEntities")
53 55
        {
54 56
            this.ContextOptions.LazyLoadingEnabled = true;
57
            this.CommandTimeout = int.MaxValue;
55 58
            OnContextCreated();
56 59
        }
57 60
    
FinalService/KCOM_FinalService_DL/KCOM_FinalService/FinalService.cs
120 120
        private void LaunchFindPDFAgent(string UID, string ProjectNo, string FinalID)
121 121
        {
122 122
            string ExeName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory , $"{AgentName}.exe");
123
            logger.Write($"LaunchFindPDFAgent : {ExeName}", LogLevel.Info);
123 124

  
124 125
            // 실행파일 실행
125 126
            var startInfo = new System.Diagnostics.ProcessStartInfo(ExeName);
FinalService/KCOM_FinalService_DL/KCOM_FinalService/FinalService.ini
16 16
STRING=tyEJJeokhOMWTRIHqgLi0s7NOmaFjuncpGJJHQsTgJ5nLR3X4onWcznboRsrRHEnVvMLkjL8BFikT7enPVaYDGQaP4HyeqEwticXhjyf1eE=
17 17
[MARKUS_API]
18 18
URL=http://www.devdoftech.co.kr:5979/ServiceDeepView.svc
19
#[Remoting]
20
#port=9098
19
[Remoting]
20
port=7707
21
[UNC]
22
ID=daelim\markuslabadmin
23
Password=markus02!
FinalService/KCOM_FinalService_DL/KCOM_FinalService/Program_old.cs
1
#if DEBUG
2
using KCOMDataModel.DataModel;
3
#endif
4
using System;
5
using System.IO;
6
using System.Reflection;
7
using System.ServiceProcess;
8
using log4net;
9
using KCOM_FinalService.Common;
10

  
11
namespace KCOM_FinalService
12
{
13
    static class Program
14
    {
15
        /// <summary>
16
        /// Application Data Folder
17
        /// </summary>
18
        public static string AppDataFolder
19
        {
20
            get
21
            {
22
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS");
23
            }
24
        }
25

  
26
        public static ServiceBase[] ServicesToRun = null;
27

  
28
        public static MethodInfo UploadFinalPDFMethod { get; set; }
29
        public static object UploadFinalPDFInst { get; set; }
30

  
31
        static MarkusFinalService service = new MarkusFinalService();
32

  
33
        /// <summary>
34
        /// The main entry point for the application.
35
        /// </summary>
36
        static void Main(string[] args)
37
        {
38
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
39

  
40
            log4net.GlobalContext.Properties["LogFilePath"] = Path.Combine(AppDataFolder, "Log", "FinalService.log");
41
         
42
            /// get legacy interface for upload final pdf file
43
            string UploadFinalDllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UploadFinal.dll");
44
            if (File.Exists(UploadFinalDllPath))
45
            {
46
                Assembly asm = Assembly.LoadFrom(UploadFinalDllPath);
47
                Type _UploadFinalClassType = asm.GetType("UploadFinal.UploadFinal");
48

  
49
                //Legacy IF
50
                Program.UploadFinalPDFMethod = _UploadFinalClassType.GetMethod("UploadFinalPDF", new Type[] { typeof(string), typeof(string), typeof(KCOMDataModel.DataModel.FINAL_PDF), typeof(string) });
51
                if (null != Program.UploadFinalPDFMethod)
52
                {
53
                    Program.UploadFinalPDFInst = Activator.CreateInstance(_UploadFinalClassType, null);
54
                }
55
            }
56

  
57
            if (Environment.UserInteractive)
58
            {
59
                try
60
                {
61
                    service.TestStartupAndStop(args);
62

  
63
                }
64
                catch (Exception ex)
65
                {
66
                    Console.WriteLine(ex);
67
                }
68
            }
69
            else
70
            {
71
                /// up to here
72
                ServicesToRun = new ServiceBase[]
73
                {  new MarkusFinalService()
74
                };
75
                ServiceBase.Run(ServicesToRun);
76
            }
77
        }
78

  
79
        /// <summary>
80
        /// log unhandled exception
81
        /// </summary>
82
        /// <author>humkyung</author>
83
        /// <date>2019.06.04</date>
84
        /// <param name="sender"></param>
85
        /// <param name="e"></param>
86
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
87
        {
88
            try
89
            {
90
                service.logger.Write(e.ExceptionObject as Exception);
91
            }
92
            catch (Exception ex)
93
            {
94
                Console.WriteLine(ex.InnerException.ToString());
95
            }
96
            finally
97
            {
98
            }
99
        }
100
    }
101
}
FinalService/KCOM_FinalService_DL/KCOM_FinalService/Properties/Settings.Designer.cs
12 12
    
13 13
    
14 14
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
15
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
16 16
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 17
        
18 18
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......
25 25
        
26 26
        [global::System.Configuration.UserScopedSettingAttribute()]
27 27
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28
        [global::System.Configuration.DefaultSettingValueAttribute("9093")]
29
        public int RemotingPort {
30
            get {
31
                return ((int)(this["RemotingPort"]));
32
            }
33
            set {
34
                this["RemotingPort"] = value;
35
            }
36
        }
37
        
38
        [global::System.Configuration.UserScopedSettingAttribute()]
39
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
40 28
        [global::System.Configuration.DefaultSettingValueAttribute("15")]
41 29
        public int MultipleFinalCount {
42 30
            get {
......
172 160
                this["resultFileFolder"] = value;
173 161
            }
174 162
        }
163
        
164
        [global::System.Configuration.UserScopedSettingAttribute()]
165
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
166
        [global::System.Configuration.DefaultSettingValueAttribute("9092")]
167
        public int RemotingPort {
168
            get {
169
                return ((int)(this["RemotingPort"]));
170
            }
171
            set {
172
                this["RemotingPort"] = value;
173
            }
174
        }
175 175
    }
176 176
}
FinalService/KCOM_FinalService_DL/KCOM_FinalService/Properties/Settings.settings
2 2
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="KCOM_FinalService.Properties" GeneratedClassName="Settings">
3 3
  <Profiles />
4 4
  <Settings>
5
    <Setting Name="RemotingPort" Type="System.Int32" Scope="User">
6
      <Value Profile="(Default)">9093</Value>
7
    </Setting>
8 5
    <Setting Name="MultipleFinalCount" Type="System.Int32" Scope="User">
9 6
      <Value Profile="(Default)">15</Value>
10 7
    </Setting>
......
38 35
    <Setting Name="resultFileFolder" Type="System.String" Scope="User">
39 36
      <Value Profile="(Default)">http://cloud.devdoftech.co.kr:5977/FinalPDF/{0}_app/VPCS_DOCLIB/{1}/{2}/ToVendor/{3}</Value>
40 37
    </Setting>
38
    <Setting Name="RemotingPort" Type="System.Int32" Scope="User">
39
      <Value Profile="(Default)">9092</Value>
40
    </Setting>
41 41
  </Settings>
42 42
</SettingsFile>
FinalService/KCOM_FinalService_DL/KCOM_FinalService/app.config
33 33
  </log4net>
34 34
  <userSettings>
35 35
    <KCOM_FinalService.Properties.Settings>
36
      <setting name="RemotingPort" serializeAs="String">
37
        <value>9092</value>
38
      </setting>
39 36
      <setting name="MultipleFinalCount" serializeAs="String">
40 37
        <value>15</value>
41 38
      </setting>
......
69 66
      <setting name="resultFileFolder" serializeAs="String">
70 67
        <value>http://cloud.devdoftech.co.kr:5977/FinalPDF/{0}_app/VPCS_DOCLIB/{1}/{2}/ToVendor/{3}</value>
71 68
      </setting>
69
      <setting name="RemotingPort" serializeAs="String">
70
        <value>9092</value>
71
      </setting>
72 72
    </KCOM_FinalService.Properties.Settings>
73 73
  </userSettings>
74 74
  <startup>
FinalService/KCOM_FinalService_DL/MarkupToPDF/MarkupToPDF.cs
56 56
        #endregion
57 57

  
58 58
        #region 메서드        
59
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
60
        public struct NETRESOURCE
61
        {
62
            public uint dwScope;
63
            public uint dwType;
64
            public uint dwDisplayType;
65
            public uint dwUsage;
66
            public string lpLocalName;
67
            public string lpRemoteName;
68
            public string lpComment;
69
            public string lpProvider;
70
        }
71

  
72
        [DllImport("mpr.dll", CharSet = CharSet.Auto)]
73
        public static extern int WNetUseConnection(
74
            IntPtr hwndOwner,
75
            [MarshalAs(UnmanagedType.Struct)] ref NETRESOURCE lpNetResource,
76
            string lpPassword,
77
            string lpUserID,
78
            uint dwFlags,
79
            StringBuilder lpAccessName,
80
            ref int lpBufferSize,
81
            out uint lpResult);
82

  
83
        [DllImport("mpr.dll", EntryPoint = "WNetCancelConnection2", CharSet = CharSet.Auto)]
84
        public static extern int WNetCancelConnection2A(string lpName, int dwFlags, int fForce);
85

  
86
        /// <summary>
87
        /// UNC 경로에 접속
88
        /// </summary>
89
        /// <param name="server"></param>
90
        /// <param name="sUNCID"></param>
91
        /// <param name="sUNCPassword"></param>
92
        /// <returns></returns>
93
        public int ConnectRemoteServer(string server, string sUNCID, string sUNCPassword)
94
        {
95
            int capacity = 64;
96
            uint resultFlags = 0;
97
            uint flags = 0;
98
            StringBuilder sb = new StringBuilder(capacity);
99
            NETRESOURCE ns = new NETRESOURCE();
100
            ns.dwType = 1;
101
            ns.lpLocalName = null;
102
            ns.lpRemoteName = server;
103
            ns.lpProvider = null;
104
            int result = 0;
105
            result = WNetUseConnection(IntPtr.Zero, ref ns, sUNCPassword, @sUNCID, flags, sb, ref capacity, out resultFlags);
106

  
107
            return result;
108
        }
109

  
110
        public void CancelRemoteServer(string server)
111
        {
112
            WNetCancelConnection2A(server, 1, 0);
113
        }
114

  
115
        /// <summary>
116
        /// 주어진 경로가 UNC 경로인지 확인하여 리턴
117
        /// </summary>
118
        /// <param name="path"></param>
119
        /// <returns></returns>
120
        public static bool IsUncPath(string path)
121
        {
122
            return Uri.TryCreate(path, UriKind.Absolute, out Uri uri) && uri.IsUnc;
123
        }
124

  
59 125
        public static bool IsLocalIPAddress(string host)
60 126
        {
61 127
            try
......
179 245
            }
180 246
            catch (Exception)
181 247
            {
182

  
183 248
                throw;
184 249
            }
185 250

  
......
199 264
            FinalItem = FinalPDF;
200 265
            
201 266
            string PdfFilePathRoot = null;
202
            string TempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath() , System.IO.Path.GetRandomFileName());
267
            string TempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath() , System.IO.Path.GetTempFileName());
203 268

  
204 269
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
205 270
            try
......
281 346

  
282 347
                        DocPageItem = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == DocInfoItem.ID).ToList();
283 348

  
349
                        if (IsUncPath(PdfFilePathRoot))
350
                        {
351
                            string ID = CommonLib.Common.GetConfigString("UNC", "ID", "");
352
                            string Password = CommonLib.Common.GetConfigString("UNC", "Password", "");
353
#if DEBUG
354
                            if (string.IsNullOrEmpty(ID)) ID = @"daelim\markuslabadmin";
355
                            if (string.IsNullOrEmpty(Password)) Password = @"markus02!";
356
#endif
357

  
358
                            ConnectRemoteServer(PdfFilePathRoot, ID, Password);
359
                        }
360

  
284 361
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
285 362
                                         + (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5))
286 363
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
287 364

  
365
                        SetFinalPDFLog(FinalPDF.ID, FinalPDF.PROJECT_NO, $"PdfFilePathRoot = {PdfFilePathRoot}");
366

  
288 367
                        var infoItems = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == DocInfoItem.ID && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0);
289 368
                        if (infoItems.Count() == 0)
290 369
                        {
......
326 405
                            OriginFileName = _files[0].Name;
327 406
                            PdfFilePath = _files[0].CopyTo(TempFile, true);
328 407
                            StatusChange($"Copy File  file Count = 1 : {PdfFilePath}", 0);
408
                            SetFinalPDFLog(FinalPDF.ID, FinalPDF.PROJECT_NO, $"Copy File = {OriginFileName},{TempFile}");
329 409
                            #endregion
330 410
                        }
331 411
                        else if (_files.Count() > 1)
......
384 464
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
385 465
                }
386 466
            }
387
            #endregion
467
#endregion
388 468

  
389 469
            #region FinalPDF 생성 후 EndFinal 이벤트 호출
390 470
            try
......
445 525
            }
446 526
            #endregion
447 527
        }
448
        #endregion
528
#endregion
449 529

  
450 530
        #region PDF
451 531
        public static float scaleWidth = 0;
......
548 628
                FileInfo tempFileInfo = new FileInfo(TempFile);
549 629
                if (!Directory.Exists(_FinalPDFStorgeLocal))
550 630
                {
631
                    SetFinalPDFLog(finaldata.ID, finaldata.PROJECT_NO, $"Create Directory = {_FinalPDFStorgeLocal}");
551 632
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
552 633
                }
553 634

  
......
1287 1368
                SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString());
1288 1369
                SetFinalPDFLog(finaldata.ID, finaldata.PROJECT_NO, "SetStempinPDF error: " + ex.ToString());
1289 1370
            }
1371

  
1290 1372
            return false;
1291 1373
        }
1292 1374

  

내보내기 Unified diff

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