프로젝트

일반

사용자정보

개정판 7842224c

ID7842224c454bd3980d69f15311fbe49e0c5aa684
상위 b617ac15
하위 0d8516d2

김태성이(가) 일년 이상 전에 추가함

issue #00000 DWG ID를 입력하여 Convert 가능하도록 기능 추가

Change-Id: Ic02f74c3f04393f9d8b3c204b3707b2d8ae0139b

차이점 보기:

ID2.Manager/MarkusImageCreate/Dapper/NotifyPropertyChange.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.CompilerServices;
6
using System.Text;
7
using System.Threading.Tasks;
8

  
9
namespace ID2.Manager.Data
10
{
11
    public class NotifyPropertyChange : INotifyPropertyChanged
12
    {
13
         
14
        public event PropertyChangedEventHandler PropertyChanged;
15

  
16
        protected void RaisePropertyChanged(string propertyName)
17
        {
18
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
19
        }
20

  
21
        protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
22
        {
23
            if (EqualityComparer<T>.Default.Equals(storage, value))
24
                return false;
25

  
26
            storage = value;
27
            RaisePropertyChanged(propertyName);
28
            return true;
29
        }
30
    }
31
}
ID2.Manager/MarkusImageCreate/MarkusImageCreate.csproj
84 84
    <Compile Include="..\ID2.Manager.Data\Models\ProjectInfo.cs">
85 85
      <Link>Dapper\Models\ProjectInfo.cs</Link>
86 86
    </Compile>
87
    <Compile Include="Dapper\NotifyPropertyChange.cs" />
87 88
    <Compile Include="HostAppServ.cs" />
88 89
    <Compile Include="OdActivationInfo.cs" />
89 90
    <Compile Include="OdReadExMgd.cs" />
ID2.Manager/MarkusImageCreate/Program.cs
9 9
using Teigha.DatabaseServices;
10 10
using OdReadExMgd;
11 11
using CredentialManagement;
12
using Dapper;
12 13

  
13 14
namespace MarkusImageCreate
14 15
{
......
69 70

  
70 71
                    if (args.Length > 0)
71 72
                    {
72
                        if (args[0].Contains(".dwg"))
73
                        if (args[0] == "INPUT")
74
                        {
75
                            string ProjectCode = null;
76
                            string DocID = null;
77

  
78
                            Console.WriteLine("# 생성이 필요한 DWG ID 입력 #");
79
                            
80
                            Console.Write("Team Code : ");
81
                            ProjectCode = Console.ReadLine();
82

  
83
                            Console.Write("DWG ID : ");
84
                            DocID = Console.ReadLine();
85

  
86

  
87
                            ConvertDWG(ProjectCode, DocID);
88

  
89
                        }
90
                        else if (args[0].Contains(".dwg"))
73 91
                        {
74 92
                            Show(args[0]);
75 93
                        }
......
135 153
        {
136 154
            foreach (var code in ProjectCodes())
137 155
            {
138
                ConvertDWG(code);
156
                ConvertAllProject(code);
139 157
            }
140 158
        }
141 159

  
......
152 170
                    Target = path,
153 171
                };
154 172

  
155
                if (credential.Load() == false)
173
                result = credential.Load();
174

  
175
                if (!result)
156 176
                {
157 177
                    VistaPrompt prompt = new VistaPrompt();
158 178
                    prompt.Title = $"{Message}";
......
183 203
            return result;
184 204
        }
185 205

  
186
        static void ConvertDWG(string code)
206
        static void ConvertAllProject(string code)
187 207
        {
188 208
            string sourcePath = Path.Combine(Path.Combine(Path.Combine(ID2ProjectsPath, code), "drawings"),"Native");
189 209
            string targetPath = Path.Combine(MarkusImagePath, code);
......
272 292
                }
273 293
            }
274 294
        }
295

  
296
        static bool ConvertDWG(string code, string DocID)
297
        {
298
            bool result = false;
299

  
300
            try
301
            {
302
                string sourcePath = Path.Combine(Path.Combine(Path.Combine(ID2ProjectsPath, code), "drawings"), "Native");
303
                string targetPath = Path.Combine(MarkusImagePath, code);
304

  
305
                if (!Directory.Exists(targetPath))
306
                    Directory.CreateDirectory(targetPath);
307

  
308
                using (MarkusRepository rep = new MarkusRepository(MarkusConnectionStr))
309
                {
310
                    string SQL = "SELECT * FROM CONVERTER_DOC WHERE STATUS <> 4 and DOCUMENT_ID = @DOCUMENT_ID and PROJECT_NO = @PROJECT_NO";
311

  
312
                    var parameters = new DynamicParameters();
313
                    parameters.Add("@PROJECT_NO", code);
314
                    parameters.Add("@DOCUMENT_ID", DocID);
315

  
316
                    var convertItems = rep.Query<ConvertDoc>(SQL, parameters);
317

  
318
                    if (convertItems.Count() > 0)
319
                    {
320
                        foreach (var item in convertItems)
321
                        {
322
                            result = false;
323
                            string dwgFile = null;
324

  
325
                            try
326
                            {
327
                                var orgFile = Path.Combine(sourcePath, item.DOCUMENT_ID + ".dwg");
328
                                dwgFile = System.IO.Path.GetTempFileName().Replace(".tmp", ".dwg");
329

  
330

  
331
                                File.Copy(orgFile, dwgFile, true);
332

  
333
                                using (Database pDb = new Database(false, true))
334
                                {
335
                                    pDb.ReadDwgFile(dwgFile, FileShare.Read, true, "");
336
                                    HostApplicationServices.WorkingDatabase = pDb;
337
                                    /****************************************************************/
338
                                    /* Display the File Version                                     */
339
                                    /****************************************************************/
340
                                    Console.WriteLine("File Version: {0}", pDb.OriginalFileVersion);
341
                                    /****************************************************************/
342
                                    /* Dump the database                                            */
343
                                    /****************************************************************/
344
                                    DbDumper dumper = new DbDumper();
345

  
346
                                    //dumper.prepareDump(pDb);
347
                                    dumper.ExplodeAndPurgeNestedBlocks(pDb);
348

  
349
                                    var pngFile = Path.Combine(targetPath, item.DOCUMENT_ID + ".png");
350

  
351
                                    int width = 9600;
352
                                    int height = 6787;
353

  
354
                                    if (dumper.ExportPNG(pDb, pngFile, width, height))
355
                                    {
356
                                        File.Delete(dwgFile);
357

  
358
                                        var docInfoID = rep.CreateDocInfo(item.ID, 1);
359

  
360
                                        var docPageResult = rep.CreateDocPage(new[]{
361
                                            new DocPage {
362
                                                docinfo_id = docInfoID,
363
                                                page_angle = 0,
364
                                                page_width  = width.ToString(),
365
                                                page_height =  height.ToString(),
366
                                                page_number = 1
367

  
368
                                            } });
369

  
370
                                        rep.UpdateStatusAsync(item.SERVICE_ID, item.ID, 4, 1, 1, null);
371
                                        Console.WriteLine($"Ok. {item.DOCUMENT_ID}");
372
                                        result = true;
373
                                    }
374
                                    else
375
                                    {
376
                                        rep.UpdateStatusAsync(item.SERVICE_ID, item.ID, 50, 1, 1, "DWG Convert Error");
377
                                        Console.WriteLine($"Error. {item.DOCUMENT_ID}");
378
                                    }
379
                                }
380
                            }
381
                            catch (Exception ex)
382
                            {
383
                                Console.WriteLine($"Error. {item.DOCUMENT_ID} {ex.ToString()}");
384
                                rep.UpdateStatusAsync(item.SERVICE_ID, item.ID, 50, 1, 1, ex.ToString());
385
                            }
386
                            finally
387
                            {
388
                                if (dwgFile != null)
389
                                {
390
                                    if (File.Exists(dwgFile))
391
                                    {
392
                                        File.Delete(dwgFile);
393
                                    }
394
                                }
395
                            }
396
                        }
397
                    }
398

  
399
                }
400
            }
401
            catch (Exception ex)
402
            {
403
                Console.WriteLine("Error" + ex.ToString());
404
            }
405

  
406
            return result;
407
        }
275 408
    }
276 409
}

내보내기 Unified diff

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