프로젝트

일반

사용자정보

개정판 0d8516d2

ID0d8516d286c3c39194f91f7805919dd1eab19a24
상위 7842224c
하위 1d02c891

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

issue #00000 image create winGDI 적용

Change-Id: I3f0774dfcfd26adf9546d40d77ba21ce7c2cd1fe

차이점 보기:

ID2.Manager/MarkusImageCreate.sln
20 20
		Readme.txt = Readme.txt
21 21
	EndProjectSection
22 22
EndProject
23
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkusImageCreateAPI", "MarkusImageCreateAPI\MarkusImageCreateAPI.csproj", "{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}"
24
	ProjectSection(ProjectDependencies) = postProject
25
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5} = {465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}
26
	EndProjectSection
27
EndProject
23 28
Global
24 29
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 30
		Debug|Any CPU = Debug|Any CPU
......
105 110
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.Debug|x64.ActiveCfg = Debug|x86
106 111
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.Debug|x86.ActiveCfg = Debug|x86
107 112
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.MarkusImageCreate|Any CPU.ActiveCfg = Release|x86
108
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.MarkusImageCreate|x64.ActiveCfg = Release|x86
113
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.MarkusImageCreate|x64.ActiveCfg = Debug|x86
114
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.MarkusImageCreate|x64.Build.0 = Debug|x86
109 115
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.MarkusImageCreate|x86.ActiveCfg = Debug|x86
110 116
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.MarkusImageCreate|x86.Build.0 = Debug|x86
111 117
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.Release|Any CPU.ActiveCfg = Release|x86
112 118
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.Release|x64.ActiveCfg = Release|x86
113 119
		{465FA895-49CF-4E6D-A0E4-D12CA03B9FD5}.Release|x86.ActiveCfg = Release|x86
120
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
121
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
122
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Debug|x64.ActiveCfg = Debug|Any CPU
123
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Debug|x64.Build.0 = Debug|Any CPU
124
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Debug|x86.ActiveCfg = Debug|Any CPU
125
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Debug|x86.Build.0 = Debug|Any CPU
126
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.MarkusImageCreate|Any CPU.ActiveCfg = Debug|Any CPU
127
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.MarkusImageCreate|Any CPU.Build.0 = Debug|Any CPU
128
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.MarkusImageCreate|x64.ActiveCfg = Debug|Any CPU
129
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.MarkusImageCreate|x64.Build.0 = Debug|Any CPU
130
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.MarkusImageCreate|x86.ActiveCfg = Debug|Any CPU
131
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.MarkusImageCreate|x86.Build.0 = Debug|Any CPU
132
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
133
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Release|Any CPU.Build.0 = Release|Any CPU
134
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Release|x64.ActiveCfg = Release|Any CPU
135
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Release|x64.Build.0 = Release|Any CPU
136
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Release|x86.ActiveCfg = Release|Any CPU
137
		{55BA26BD-02BF-4BE8-BBDA-0496615E91C3}.Release|x86.Build.0 = Release|Any CPU
114 138
	EndGlobalSection
115 139
	GlobalSection(SolutionProperties) = preSolution
116 140
		HideSolutionNode = FALSE
ID2.Manager/MarkusImageCreate/MarkusImageCreate.INI
6 6
ID2ProjectsPath = \\DOFDEVSVR\ID2_Project
7 7
MarkusImagePath = \\markusdev\TileSource
8 8
Resolution = 250
9
FontPath = C:\MarkusFonts
9
FontPath = C:\MarkusFonts
10
IsOpenGL = false
ID2.Manager/MarkusImageCreate/MarkusImageCreate.csproj
16 16
  </PropertyGroup>
17 17
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
18 18
    <DebugSymbols>true</DebugSymbols>
19
    <OutputPath>bin\x86\Debug\</OutputPath>
19
    <OutputPath>..\Publish\MarkusImageCreate\</OutputPath>
20 20
    <DefineConstants>TRACE;DEBUG;MARKUS_IMAGE_CREATE</DefineConstants>
21 21
    <DebugType>full</DebugType>
22 22
    <PlatformTarget>x86</PlatformTarget>
......
108 108
      <Version>2018.12.7.1</Version>
109 109
    </PackageReference>
110 110
    <PackageReference Include="ODA_redist">
111
      <Version>1.3.0</Version>
111
      <Version>1.5.0</Version>
112 112
    </PackageReference>
113 113
    <PackageReference Include="Salaros.ConfigParser">
114 114
      <Version>0.3.8</Version>
ID2.Manager/MarkusImageCreate/OdReadExMgd.cs
3340 3340
        /************************************************************************/
3341 3341
        /* Export DWG to PNG                                                    */
3342 3342
        /************************************************************************/
3343
        public bool ExportPNG(Database pDb, string savePngPath,int pngWidth,int pngHeight)
3343
        public bool ExportPNG(Database pDb,bool IsOpenGL, string savePngPath,int pngWidth,int pngHeight)
3344 3344
        {
3345 3345
            bool result = false;
3346 3346
            string tempPngPath = null;
......
3353 3353

  
3354 3354
                chageColorAllObjects(pDb);
3355 3355

  
3356

  
3356 3357
                string gdPath = "WinOpenGL_20.5_15.txv";
3357 3358

  
3359
                if (!IsOpenGL)
3360
                {
3361
                    gdPath = "WinGDI_20.5_15.txv";
3362
                }
3363

  
3358 3364
                tempPngPath = System.IO.Path.GetTempFileName().Replace(".tmp", ".png");
3359 3365

  
3360 3366
                using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule(gdPath, false, true))
ID2.Manager/MarkusImageCreate/Program.cs
13 13

  
14 14
namespace MarkusImageCreate
15 15
{
16
    class Program
16
    public class Program
17 17
    {
18 18
        const string CONST_SETTINGS = "SETTINGS";
19 19
        const string CONST_ID2Manager_Connect = "ID2Manager";
......
22 22
        const string CONST_MarkusImagePath = "MarkusImagePath";
23 23
        const string CONST_Resolution = "Resolution";
24 24
        const string CONST_FontPath  = "FontPath";
25
        
25
        const string CONST_IsOpenGL = "IsOpenGL";
26 26

  
27 27
        static string MarkusConnectionStr;
28 28
        static string ID2ConnectionStr;
......
30 30
        static string MarkusImagePath;
31 31
        static int Resolution;
32 32
        static string FontPath;
33
        static bool IsOpenGL = false;
33 34

  
34
        static void Main(string[] args)
35
        public static void Main(string[] args)
35 36
        {
37

  
36 38
            bool bSuccess = true;
39
            string cmd = "DEFAULT";
40

  
41
            if(args.Length > 0)
42
            {
43
                cmd = args[0];
44
            }
37 45

  
38 46
            try
39 47
            {
40
                Teigha.Runtime.Services.odActivate(ActivationData.userInfo, ActivationData.userSignature);
48
                try
49
                {
50
                    Teigha.Runtime.Services.odActivate(ActivationData.userInfo, ActivationData.userSignature);
51
                }
52
                catch (Exception ex)
53
                {
54
                    Console.WriteLine(ex.ToString());
55

  
56
                }
57

  
58
                Console.WriteLine("Activate Teigha");
59

  
41 60
                using (Teigha.Runtime.Services srv = new Teigha.Runtime.Services())
42 61
                {
43
                    HostApplicationServices.Current = new OdaMgdMViewApp.HostAppServ();
44 62
                    /**********************************************************************/
45 63
                    /* Display the Product and Version that created the executable        */
46 64
                    /**********************************************************************/
47 65
                    Console.WriteLine("\nReadExMgd developed using {0} ver {1}", HostApplicationServices.Current.Product, HostApplicationServices.Current.VersionString);
48 66

  
49
                    Salaros.Configuration.ConfigParser config = new Salaros.Configuration.ConfigParser(Path.Combine(AppContext.BaseDirectory, "MarkusImageCreate.ini"));
67
                    Salaros.Configuration.ConfigParser config;
68

  
69
                    try
70
                    {
71
                        config = new Salaros.Configuration.ConfigParser(Path.Combine(AppContext.BaseDirectory, "MarkusImageCreate.ini"));
72
                    }
73
                    catch (Exception)
74
                    {
75
                        Console.WriteLine($"Config File Path Not Found : {Path.Combine(AppContext.BaseDirectory, "MarkusImageCreate.ini")}");
76
                        Console.ReadKey();
77
                        throw;
78
                    }
79

  
50 80
                    ID2ConnectionStr = config.GetValue(CONST_SETTINGS, CONST_ID2Manager_Connect);
51 81
                    MarkusConnectionStr = config.GetValue(CONST_SETTINGS, CONST_Markus_Connect);
52 82
                    //ID2ConnectionStr = Encoding.Unicode.GetString(Convert.FromBase64String(config.GetValue(CONST_SETTINGS, CONST_ID2Manager_Connect)));
......
55 85
                    MarkusImagePath = config.GetValue(CONST_SETTINGS, CONST_MarkusImagePath);
56 86
                    Resolution = config.GetValue(CONST_SETTINGS, CONST_Resolution, 250);
57 87
                    FontPath = config.GetValue(CONST_SETTINGS, CONST_FontPath);
88
                    IsOpenGL = config.GetValue(CONST_SETTINGS,CONST_IsOpenGL,false);
58 89

  
59 90
                    while (!Directory.Exists(ID2ProjectsPath))
60 91
                    {
61 92
                        string sourceComputer = ID2ProjectsPath.Split('\\').FirstOrDefault(x => !string.IsNullOrEmpty(x));
62
                        IsCredential($"\\\\{sourceComputer}에 대한 인증이 필요합니다.",sourceComputer);
93
                        IsCredential($"\\\\{sourceComputer}에 대한 인증이 필요합니다.", sourceComputer);
63 94
                    }
64 95

  
65 96
                    while (!Directory.Exists(MarkusImagePath))
66 97
                    {
67 98
                        string sourceComputer = MarkusImagePath.Split('\\').FirstOrDefault(x => !string.IsNullOrEmpty(x));
68
                        IsCredential($"\\\\{sourceComputer}에 대한 인증이 필요합니다.",sourceComputer);
99
                        IsCredential($"\\\\{sourceComputer}에 대한 인증이 필요합니다.", sourceComputer);
69 100
                    }
70 101

  
71
                    if (args.Length > 0)
102
                    if (cmd == "DEFAULT")
103
                    {
104
                        InitConvertPDF();
105
                    }
106
                    else if (cmd == "INPUT")
72 107
                    {
73
                        if (args[0] == "INPUT")
108
                        bool isBreak = false;
109

  
110
                        while (!isBreak)
74 111
                        {
75 112
                            string ProjectCode = null;
76 113
                            string DocID = null;
77 114

  
78 115
                            Console.WriteLine("# 생성이 필요한 DWG ID 입력 #");
79
                            
116

  
80 117
                            Console.Write("Team Code : ");
81 118
                            ProjectCode = Console.ReadLine();
82 119

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

  
86

  
87 123
                            ConvertDWG(ProjectCode, DocID);
88 124

  
125
                            Console.WriteLine("계속 진행은 아무키나 입력,종료는 CTRL+BREAK");
126
                            Console.ReadKey();
89 127
                        }
90
                        else if (args[0].Contains(".dwg"))
128
                    }
129
                    else if (args[0] == "RUN")
130
                    {
131
                        if (args.Count() == 3)
91 132
                        {
92
                            Show(args[0]);
133
                            string ProjectCode = args[1];
134
                            string DocID = args[2];
135

  
136
                            ConvertDWG(ProjectCode, DocID);
93 137
                        }
94 138
                    }
95
                    else
139
                    else if (args[0].Contains(".dwg"))
96 140
                    {
97
                        InitConvertPDF();
141
                        Show(args[0]);
98 142
                    }
99 143
                }
100 144
            }
......
109 153

  
110 154
            if (bSuccess)
111 155
                Console.WriteLine("OdReadExMgd Finished Successfully");
112
          
113
            Console.WriteLine("완료");
114
            Console.ReadKey();
156

  
157
            if (cmd == "DEFAULT")
158
            {
159
                Console.WriteLine("완료");
160
                Console.ReadKey();
161
            }
115 162
        }
116 163

  
117 164
        static string[] ProjectCodes()
......
242 289
                            
243 290
                            //dumper.prepareDump(pDb);
244 291
                            dumper.ExplodeAndPurgeNestedBlocks(pDb);
245

  
292
                            
246 293
                            var pngFile = Path.Combine(targetPath, item.DOCUMENT_ID + ".png");
247 294
                                
248 295
                            int width = 9600;
249 296
                            int height = 6787;
250 297
                            
251
                            if (dumper.ExportPNG(pDb, pngFile, width, height))
298
                            if (dumper.ExportPNG(pDb, IsOpenGL, pngFile, width, height))
252 299
                            {
253 300
                                File.Delete(dwgFile);
254 301
                                
......
293 340
            }
294 341
        }
295 342

  
296
        static bool ConvertDWG(string code, string DocID)
343
        public static bool ConvertDWG(string code, string DocID)
297 344
        {
298 345
            bool result = false;
299 346

  
......
307 354

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

  
312 359
                    var parameters = new DynamicParameters();
313 360
                    parameters.Add("@PROJECT_NO", code);
......
317 364

  
318 365
                    if (convertItems.Count() > 0)
319 366
                    {
320
                        foreach (var item in convertItems)
321
                        {
322
                            result = false;
323
                            string dwgFile = null;
367
                        var item = convertItems.First();
368
                        
369
                        result = false;
370
                        string dwgFile = null;
324 371

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

  
330 377

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

  
333
                                using (Database pDb = new Database(false, true))
380
                            using (Database pDb = new Database(false, true))
381
                            {
382
                                pDb.ReadDwgFile(dwgFile, FileShare.Read, true, "");
383
                                HostApplicationServices.WorkingDatabase = pDb;
384
                                /****************************************************************/
385
                                /* Display the File Version                                     */
386
                                /****************************************************************/
387
                                Console.WriteLine("File Version: {0}", pDb.OriginalFileVersion);
388
                                /****************************************************************/
389
                                /* Dump the database                                            */
390
                                /****************************************************************/
391
                                DbDumper dumper = new DbDumper();
392

  
393
                                //dumper.prepareDump(pDb);
394
                                dumper.ExplodeAndPurgeNestedBlocks(pDb);
395

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

  
398
                                int width = 9600;
399
                                int height = 6787;
400

  
401
                                if (dumper.ExportPNG(pDb,IsOpenGL, pngFile, width, height))
334 402
                                {
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);
403
                                    File.Delete(dwgFile);
348 404

  
349
                                    var pngFile = Path.Combine(targetPath, item.DOCUMENT_ID + ".png");
405
                                    var docInfoID = rep.CreateDocInfo(item.ID, 1);
350 406

  
351
                                    int width = 9600;
352
                                    int height = 6787;
407
                                    var docPageResult = rep.CreateDocPage(new[]{
408
                                        new DocPage {
409
                                            docinfo_id = docInfoID,
410
                                            page_angle = 0,
411
                                            page_width  = width.ToString(),
412
                                            page_height =  height.ToString(),
413
                                            page_number = 1
353 414

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

  
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
                                    }
417
                                    rep.UpdateStatusAsync(item.SERVICE_ID, item.ID, 4, 1, 1, null);
418
                                    Console.WriteLine($"Ok. {item.DOCUMENT_ID}");
419
                                    result = true;
420
                                }
421
                                else
422
                                {
423
                                    rep.UpdateStatusAsync(item.SERVICE_ID, item.ID, 50, 1, 1, "DWG Convert Error");
424
                                    Console.WriteLine($"Error. {item.DOCUMENT_ID}");
379 425
                                }
380 426
                            }
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
427
                        }
428
                        catch (Exception ex)
429
                        {
430
                            Console.WriteLine($"Error. {item.DOCUMENT_ID} {ex.ToString()}");
431
                            rep.UpdateStatusAsync(item.SERVICE_ID, item.ID, 50, 1, 1, ex.ToString());
432
                        }
433
                        finally
434
                        {
435
                            if (dwgFile != null)
387 436
                            {
388
                                if (dwgFile != null)
437
                                if (File.Exists(dwgFile))
389 438
                                {
390
                                    if (File.Exists(dwgFile))
391
                                    {
392
                                        File.Delete(dwgFile);
393
                                    }
439
                                    File.Delete(dwgFile);
394 440
                                }
395 441
                            }
396 442
                        }
397 443
                    }
398

  
399 444
                }
400 445
            }
401 446
            catch (Exception ex)

내보내기 Unified diff

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