프로젝트

일반

사용자정보

개정판 e05bed4e

IDe05bed4e5b655047d3c494611c9fcba1f48af299
상위 959b3ef2
하위 dd00cda0, f69db4e1

김동진이(가) 5년 이상 전에 추가함

issue #000 connectionString App.Config -> ini move , daelim final service setupfile add

Change-Id: I62de9b0cdbd79173f7da663a4ea897433de2849e

차이점 보기:

FinalService/KCOM_FinalService/ConsoleApp1/Program.cs
1
using KCOMDataModel;
1
using IFinalPDF;
2
using KCOMDataModel;
2 3
using KCOMDataModel.Common;
3 4
using KCOMDataModel.DataModel;
4 5
using System;
......
9 10

  
10 11
namespace ConsoleApp1
11 12
{
12
    class Program
13
    static class Program
13 14
    {
14 15
        static void Main(string[] args)
15 16
        {
......
41 42
            //                         + @"\" + "11111111" + @"\";
42 43
            //    }
43 44
            //}
44

  
45
            using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
45
            try
46 46
            {
47
                //FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "ngKwBgMotw8d56dea3839120d").FirstOrDefault();
48
                FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "f8Gv6hVdw8d6e881c26a4199").FirstOrDefault();
49
		        ///FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "Bm6qsYD9Hu8d6e7c702626345").FirstOrDefault();
50
                //_entity.FINAL_PDF.AddObject(new FINAL_PDF
51
                //{
52
                //    ID = Guid.NewGuid().ToString(),
53
                //    CREATE_DATETIME = DateTime.Now,
54
                //    CREATE_USER_ID = "h2011357",
55
                //    DOCINFO_ID = "ac77a75e-39d1-1764-eae3-cd252ddf4324",
56
                //    DOCUMENT_ID = "11111116",
57
                //    MARKUPINFO_ID = "LDEeSHCzVT8d56b76220a8e9e",
58
                //    PROJECT_NO = "000000",
59
                //    TOTAL_PAGE = 8,
60
                //    STATUS = 0,
61
                //    CURRENT_PAGE = 1,
62
                //});
63
                //_entity.SaveChanges();
47
                Console.WriteLine("Test Process...");
48
                Console.WriteLine("Insert Final PDF id :");
49
                string inputstr = Console.ReadLine();
50
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
51
                {
52
                    //FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "ngKwBgMotw8d56dea3839120d").FirstOrDefault();
53
                    FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == inputstr).FirstOrDefault();
54
                    if (item != null)
55
                    {
56
                        Console.WriteLine("final pdf start");
57
                        MarkupToPDF.MarkupToPDF pdf = new MarkupToPDF.MarkupToPDF();
58
                        pdf.EndFinal += Pdf_EndFinal;
59
                        pdf.FinalMakeError += Pdf_FinalMakeError;
60
                        //pdf.MakeFinalPDF(_entity.FINAL_PDF.FirstOrDefault());
61
                        pdf.MakeFinalPDF(item);
62
                        //_Thread.Add(item);
63
                    }
64
                    else
65
                    {
66
                        Console.WriteLine("item is null");
67
                    }
68

  
69
                }
64 70

  
65
                MarkupToPDF.MarkupToPDF pdf = new MarkupToPDF.MarkupToPDF();
66
                pdf.EndFinal += Pdf_EndFinal;
67
                pdf.FinalMakeError += Pdf_FinalMakeError;
68
                //pdf.MakeFinalPDF(_entity.FINAL_PDF.FirstOrDefault());
69
                pdf.MakeFinalPDF(item);
70 71
            }
72
            catch (Exception ex)
73
            {
74
                Console.WriteLine("error: "+ ex.ToString());
75
            }
76
            
71 77
        }
72 78

  
73 79
        private static void Pdf_FinalMakeError(object sender, MarkupToPDF.MakeFinalErrorArgs e)
74 80
        {
75 81
            
76 82
        }
77

  
83
        static List<FINAL_PDF> _Thread = new List<FINAL_PDF>();
78 84
        private static void Pdf_EndFinal(object sender, MarkupToPDF.EndFinalEventArgs e)
79 85
        {
86
            FINAL_PDF _item = (sender as MarkupToPDF.MarkupToPDF).FinalItem;
87

  
88
            SetFinalState(_item.ID, FinalStatus.PdfStamp);
89

  
90
            try
91
            {
92
                Console.WriteLine("final pdf end");
93
                string soapurl = string.Empty;
94
                using (KCOMDataModel.DataModel.KCOMEntities _systemEntity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
95
                {
96
                    var item = _systemEntity.PROPERTIES.Where(data => data.TYPE == "UpLoadServiceUrl").FirstOrDefault();
97
                    if (item != null) soapurl = item.VALUE;
98
                }
99
                Console.WriteLine("soapurl:"+soapurl);
100
                if (!string.IsNullOrEmpty(soapurl))
101
                {
102
                    //Legacy IF
103
                    KeyValuePair<bool, string> result = UploadFinal.UploadFinal.UploadFinalPDF(e.FinalPDFPath.Replace(@"\\172.20.121.220\comment3\finalPDF\", ""), e.OriginPDFName, e.FinalPDF, soapurl);
104
                    if (result.Key)
105
                    {
106
                        SetFinalState(_item.ID, FinalStatus.Success);
107
                    }
108
                    else
109
                    {
110
                        SetFinalState(_item.ID, FinalStatus.Error);
111
                        Console.WriteLine("pram1:"+ e.FinalPDFPath.Replace(@"\\172.20.121.220\comment3\finalPDF\", "")+",pram2:"+ e.OriginPDFName);
112
                        //_Log.Write("Upload error .." + e.FinalPDFPath + ",pdfname:" + e.OriginPDFName);
113
                    }                    
114
                }
115
                else
116
                {
117
                    ///TODO: 저장할 폴더 위치를 configuration으로 빼주세요
118
                    ///Local Test 용 저장 위치
119
                    string savepath = CommonLib.Common.GetConfigString("DebugSavePath", "URL", "");
120
                    
121
                    string saveFolder = String.Format(savepath, _item.PROJECT_NO, Convert.ToInt32(_item.DOCUMENT_ID) / 100, _item.DOCUMENT_ID);
122
                    if (!System.IO.Directory.Exists(saveFolder))
123
                    {
124
                        System.IO.Directory.CreateDirectory(saveFolder);
125
                    }
126

  
127
                    //this._Log.Write(String.Format("saveFolder : {0}", saveFolder) + DateTime.Now);
128
                    System.IO.File.Copy(e.FinalPDFPath, saveFolder + e.OriginPDFName, true);
129

  
130
                    using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(_item.PROJECT_NO).ToString()))
131
                    {
132
                        var item = _entity.DOCUMENT_ITEM.Where(d => d.DOCUMENT_ID == _item.DOCUMENT_ID).FirstOrDefault();
133
                        ///TODO: RESULT FILE 경로 위치를 configuration으로 빼주세요
134
                        ///Local Test 용 result url
135
                        
136
                        string resultpath = CommonLib.Common.GetConfigString("DebugResultUrlPath", "URL", "");
137
                        item.RESULT_FILE = String.Format(resultpath.ToString(), _item.PROJECT_NO, Convert.ToInt32(_item.DOCUMENT_ID) / 100, _item.DOCUMENT_ID, e.OriginPDFName);
138

  
139
                        //sendReqLog("RESULT_FILE_PATH", item.RESULT_FILE);
140
                        _entity.SaveChanges();
141
                        SetFinalState(_item.ID, FinalStatus.Success);
142
                        //_Thread.Remove(_T.First());
143
                    }
144
                }
145
            }
146
            catch (Exception ex)
147
            {
148
                SetFinalState(_item.ID, FinalStatus.Error);
149
                //_Log.Write("에러 .." + ex.Message);
150
                //_Thread.Remove(_T.First());
151
            }
152
        }
153
        private static void SetFinalState(string finalID, FinalStatus status)
154
        {
155
            using (KCOMDataModel.DataModel.KCOMEntities _entity = new KCOMDataModel.DataModel.KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
156
            {
157
                var finalList = _entity.FINAL_PDF.Where(final => final.ID == finalID);
158

  
159
                if (finalList.Count() > 0)
160
                {
161
                    if (status == FinalStatus.Create)
162
                    {
163
                        finalList.First().START_DATETIME = DateTime.Now;
164
                    }
165
                    if (status == FinalStatus.Success)
166
                    {
167
                        finalList.First().END_DATETIME = DateTime.Now;
168
                    }
80 169

  
81
            //경로 에러가 있음 "\\\\192.168.0.67\\finalpdf\\resulttmpE468.pdf"
170
                    finalList.First().STATUS = (int)status;
171
                    _entity.SaveChanges();
172
                }
173
            };
82 174
        }
83 175
    }
84 176
}

내보내기 Unified diff

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