예제 #1
0
        /// <summary>
        /// yyyyMMddHHmmss, yyyyMMdd를 Datetime형식으로 변환
        /// </summary>
        public static DateTime StringToDatetime(string DateTimeString)
        {
            DateTime RtnDt = new DateTime(0);

            libCommon.clsUtil objUtil = new libCommon.clsUtil();

            try
            {
                if (DateTimeString.Length == 8)
                {
                    RtnDt = new DateTime(
                        objUtil.ToInt32(DateTimeString.Substring(0, 4)),
                        objUtil.ToInt32(DateTimeString.Substring(4, 2)),
                        objUtil.ToInt32(DateTimeString.Substring(6))
                        );
                }
                else if (DateTimeString.Length == 14)
                {
                    RtnDt = new DateTime(
                        objUtil.ToInt32(DateTimeString.Substring(0, 4)),
                        objUtil.ToInt32(DateTimeString.Substring(4, 2)),
                        objUtil.ToInt32(DateTimeString.Substring(6, 2)),
                        objUtil.ToInt32(DateTimeString.Substring(8, 2)),
                        objUtil.ToInt32(DateTimeString.Substring(10, 2)),
                        objUtil.ToInt32(DateTimeString.Substring(12))
                        );
                }
            }
            catch (Exception ex)
            {
                objUtil.writeLog(ex.Message);
            }

            return(RtnDt);
        }
예제 #2
0
        /// <summary>
        /// GET방식으로 데이터 전송
        /// </summary>
        /// <param name="timeOut">밀리세컨드</param>
        /// <returns>URL의 응답</returns>
        public static string SendQueryString(string SendData, string URL, int timeOut)
        {
            System.Diagnostics.Stopwatch objStopWatch = new System.Diagnostics.Stopwatch();
            libCommon.clsUtil            objUtil      = new libCommon.clsUtil();
            MyWebClient WC = new MyWebClient(timeOut);

            string Result;

            try
            {
                objStopWatch.Start();
                Result = WC.DownloadString(URL + "?" + SendData);
            }
            catch (Exception ex)
            {
                objStopWatch.Stop();
                objUtil.writeLog("FAIL SEND GET TRANSFER : " + ex.ToString() + "\r\nELAPSED TIME:" + objStopWatch.Elapsed.ToString());
                Result = "FAIL";
            }

            if (objStopWatch.IsRunning)
            {
                objStopWatch.Stop();
            }

            return(Result);
        }
예제 #3
0
        /// <summary>
        /// 해당path에서 일정 패턴의 파일 목록 반환
        /// </summary>
        /// <param name="path"></param>
        /// <param name="srchOption">서브디렉토리 포함 여부</param>
        /// <param name="srchPattern">";"로 구분된 복수의 패턴</param>
        /// <returns></returns>
        private void getFileList(string path, SearchOption objSrchoption, string srchPattern)
        {
            libCommon.clsUtil            objUtil = new libCommon.clsUtil();
            System.Collections.ArrayList arrList = new ArrayList();
            string[] fileExts = objUtil.Split(srchPattern, ";");

            for (int i = 0; i < fileExts.Length; i++)
            {
                string[] files      = Directory.GetFiles(path, fileExts[i], objSrchoption);
                string   statusStr1 = string.Format("STEP:{0}/{1}...", i + 1, fileExts.Length);
                string   statusStr2 = "0/0";

                if (files.Length > 0)
                {
                    for (int j = 0; j < files.Length; j++)
                    {
                        getEXIFinfo(files[j]);
                        if (j % 10 == 0 || j == files.Length - 1)
                        {
                            statusStr2 = string.Format("{0}/{1}", j + 1, files.Length);
                            libMyUtil.clsThread.SetLabel(this.status, statusStr1 + statusStr2);
                        }
                    }
                }

                libMyUtil.clsThread.SetTextBox(this.textBox1, statusStr1 + statusStr2 + "\r\n");
            }
        }
예제 #4
0
        //관심항목 select ds ---> objfeed
        public clsFeed TOobjFeed(System.Data.DataSet DS)
        {
            string   idx   = "";
            string   title = "";
            string   url   = "";
            string   desc  = "";
            DateTime date  = new DateTime();

            int i;

            libCommon.clsUtil objUtil = new libCommon.clsUtil();
            clsFeed           objFeed = new clsFeed();


            if (DS.Tables[0].Rows.Count > 0)
            {
                for (i = 0; i < DS.Tables[0].Rows.Count; i++)
                {
                    idx   = DS.Tables[0].Rows[i][0].ToString();
                    title = DS.Tables[0].Rows[i][1].ToString();
                    url   = DS.Tables[0].Rows[i][2].ToString();
                    desc  = DS.Tables[0].Rows[i][3].ToString();
                    date  = Convert.ToDateTime(DS.Tables[0].Rows[i][4]);

                    objFeed.addFeed(idx, title, url, desc, date, true, false);
                }
            }

            return(objFeed);
        }
예제 #5
0
        private void send()
        {
            libCommon.clsUtil objUtil = new libCommon.clsUtil();

            MailMessage message    = new MailMessage();
            SmtpClient  smtpClient = new SmtpClient();
            string      retMsg     = string.Empty;

            try
            {
                MailAddress fromAddress = new MailAddress(this.from);
                MailAddress toAddress   = new MailAddress(this.to);

                message.From = fromAddress;
                message.To.Add(toAddress);
                message.Subject    = this.title;
                message.IsBodyHtml = false;
                message.Body       = this.msg;

                smtpClient.Host                  = "smtp.gmail.com";
                smtpClient.Port                  = 587;
                smtpClient.EnableSsl             = true;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials           = new System.Net.NetworkCredential(this.mailAccountID, this.mailAccountPass);
                smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtpClient.Send(message);
            }
            catch (Exception ex)
            {
                libMyUtil.clsFile.writeLog(ex.ToString());
            }

            message.Dispose();
        }
예제 #6
0
        /// <summary>
        /// 엑셀 쉬트명 구하기, 실패시 null 반환
        /// </summary>
        public static string[] getSheetName(OleDbConnection oleDBCon)
        {
            libCommon.clsUtil objUtil      = new libCommon.clsUtil();
            DataTable         DT_sheetName = null;

            string[] sheetName = null;

            try
            {
                //쉬트명 구하기
                DT_sheetName = oleDBCon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object[] { null, null, null, "TABLE" });

                if (DT_sheetName.Rows.Count > 0)
                {
                    sheetName = new string[DT_sheetName.Rows.Count];

                    for (int i = 0; i < DT_sheetName.Rows.Count; i++)
                    {
                        sheetName[i] = DT_sheetName.Rows[i]["TABLE_NAME"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                objUtil.writeLog("ERR GET SHEETS NAME" + "\r\n" + ex.ToString());
            }

            return(sheetName);
        }
예제 #7
0
        /// <summary>
        /// POST방식으로 데이터 전송
        /// </summary>
        /// <param name="timeOut">밀리세컨드</param>
        /// <param name="EncodingType">ex) EUC-KR, UTF-8</param>
        /// <returns>URL의 응답</returns>
        public static string SendPostData(string SendData, string URL, string EncodingType, int timeOut)
        {
            System.Diagnostics.Stopwatch objStopWatch = new System.Diagnostics.Stopwatch();
            libCommon.clsUtil            objUtil      = new libCommon.clsUtil();

            HttpWebRequest  httpWebRequest;
            HttpWebResponse httpWebResponse;
            Stream          requestStream;
            StreamReader    streamReader;

            byte[] Data;
            string Result;
            string encType = EncodingType.ToLower();

            if (!encType.Equals("euc-kr"))
            {
                encType = "utf-8";//euc-kr이 아닌 기타 입력은 utf-8로 처리
            }
            Data = System.Text.Encoding.GetEncoding(encType).GetBytes(SendData);

            try
            {
                objStopWatch.Start();
                httpWebRequest               = (HttpWebRequest)WebRequest.Create(URL);
                httpWebRequest.ContentType   = "application/x-www-form-urlencoded; charset=" + EncodingType;
                httpWebRequest.Method        = "POST";
                httpWebRequest.ContentLength = Data.Length;

                //타임아웃 설정
                httpWebRequest.Timeout          = timeOut;
                httpWebRequest.ReadWriteTimeout = timeOut;

                requestStream = httpWebRequest.GetRequestStream();
                requestStream.Write(Data, 0, Data.Length);
                requestStream.Close();

                httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                streamReader    = new StreamReader(httpWebResponse.GetResponseStream());

                Result = streamReader.ReadToEnd();
                streamReader.Close();
                httpWebResponse.Close();
            }
            catch (Exception ex)
            {
                objStopWatch.Stop();
                objUtil.writeLog("FAIL SEND POST TRANSFER : " + ex.ToString() + "\r\nELAPSED TIME:" + objStopWatch.Elapsed.ToString());
                Result = "FAIL";
            }

            if (objStopWatch.IsRunning)
            {
                objStopWatch.Stop();
            }

            return(Result);
        }
예제 #8
0
        /// <summary>
        /// iphone, android는 true
        /// </summary>
        public static bool isMobileDevice(System.Web.HttpRequest objRequest)
        {
            string userAgent = objRequest.UserAgent.ToLower();

            libCommon.clsUtil objUtil = new libCommon.clsUtil();
            if (userAgent.IndexOf("iphone") > -1 || userAgent.IndexOf("android") > -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #9
0
        public string DELETE_DB(System.Data.SqlClient.SqlConnection dbCon, System.Data.SqlClient.SqlTransaction TRX, string tbName, string Wcols, string Wvals)
        {
            int i;

            string Result = "";

            StringBuilder strBuilder = new StringBuilder();

            libCommon.clsDB   objDB   = new libCommon.clsDB();
            libCommon.clsUtil objUtil = new libCommon.clsUtil();

            System.Collections.ArrayList arrWCols = new System.Collections.ArrayList();
            System.Collections.ArrayList arrWVals = new System.Collections.ArrayList();

            arrWCols.AddRange(objUtil.Split(Wcols, "|"));
            arrWVals.AddRange(objUtil.Split(Wvals, "|"));

            strBuilder.Append("DELETE FROM " + tbName);
            strBuilder.Append(" WHERE ");
            for (i = 0; i < arrWCols.Count; i++)
            {
                if (i > 0)
                {
                    strBuilder.Append(" AND ");
                }
                strBuilder.Append("[");
                strBuilder.Append(objUtil.toDb(arrWCols[i].ToString()));
                strBuilder.Append("]");
                strBuilder.Append(" = ");
                strBuilder.Append("'");
                strBuilder.Append(objUtil.toDb(arrWVals[i].ToString()));
                strBuilder.Append("'");
            }

            try
            {
                Result = objDB.ExecuteNonQuery(dbCon, TRX, strBuilder.ToString());
            }
            catch (Exception e)
            {
                objUtil.writeLog("ERR CMN DELETE [" + tbName + "] " + "[" + Wcols + "] " + "[" + Wvals + "]");
                objUtil.writeLog("ERR CMN DELETE QUERY : " + strBuilder.ToString());
                objUtil.writeLog("ERR CMN DELETE MSG : " + e.ToString());
                Result = "FAIL";
            }

            return(Result);
        }
예제 #10
0
        /// <summary>
        /// 로그 기록
        /// </summary>
        /// <param name="Result">에러 결과</param>
        public void writeLog(string Result)
        {
            libCommon.clsUtil objUtil = new libCommon.clsUtil();

            string logStr = string.Format("FINALLY FAILED CALLING URL : {0}\r\nFKEY:{1}\r\nAUTO URL IDX:{2}\r\nPOSTDATA:{3}\r\nFAIL COUNT:{4}\r\nLAST TRY:{5}\r\nTIME OUT:{6}\r\nRESULT:{7}\r\nRECEIVED RESULT:{8}"
                                          , this.url
                                          , this.FKEY
                                          , this.aURLset_Idx
                                          , this.postData
                                          , this.failCnt
                                          , this.lastTry
                                          , this.timeOut
                                          , this.callresult
                                          , Result);

            objUtil.writeLog(logStr);
        }
예제 #11
0
        public void delDupe(StringBuilder stackBuilder, StringBuilder srcBuilder)
        {
            libCommon.clsUtil objUtil = new libCommon.clsUtil();

            string[] srcText;
            int      i;

            srcText = objUtil.Split(srcBuilder.ToString(), "\r\n");

            for (i = 0; i < srcText.Length; i++)
            {
                if (stackBuilder.ToString().IndexOf(srcText[i]) < 0)
                {
                    stackBuilder.AppendLine(srcText[i]);
                }
            }
        }
예제 #12
0
        private int rcvTimeOut;        //큐 대기시간

        private void Form1_Load(object sender, EventArgs e)
        {
            objUtil = new libCommon.clsUtil();

            this.objType     = new Type[] { typeof(libMyUtil.pageCallingInfo) };
            this.qPath       = objUtil.getAppCfg("queuePath");
            this.qPath_retry = objUtil.getAppCfg("queuePath_retry");
            this.encodeType  = objUtil.getAppCfg("encodeType").ToUpper();



            this.sleep = objUtil.ToInt32(objUtil.getAppCfg("sleep")) * 1000;
            if (this.sleep == 0)
            {
                this.sleep = 1000;
            }

            this.MaxCallingFailCnt = objUtil.ToInt32(objUtil.getAppCfg("MaxCallingFailCnt"));
            if (this.MaxCallingFailCnt == 0)
            {
                this.MaxCallingFailCnt = 10;
            }

            this.rcvTimeOut = objUtil.ToInt32(objUtil.getAppCfg("rcvTimeout"));
            if (this.rcvTimeOut == 0)
            {
                this.rcvTimeOut = 1;
            }

            this.retryInterval = objUtil.ToInt32(objUtil.getAppCfg("retryInterval")) * 1000;
            if (this.retryInterval == 0)
            {
                this.retryInterval = 60 * 1000;
            }



            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

            MainCallerState.Text  = "정지됨";
            RetryCallerState.Text = "정지됨";

            button1.PerformClick();
        }
예제 #13
0
        /// <summary>
        /// 엑셀 컬럼명 구하기, 실패시 null 반환
        /// </summary>
        public static string[] getColumnName(OleDbConnection oleDBCon, string TableName)
        {
            libCommon.clsUtil objUtil       = new libCommon.clsUtil();
            DataTable         DT_ColumnName = null;

            System.Collections.ArrayList arrList = new System.Collections.ArrayList();
            string[] ColumnName = null;

            try
            {
                //컬럼명 구하기
                DT_ColumnName = oleDBCon.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new Object[] { null, null, TableName, null });
                if (DT_ColumnName.Rows.Count > 0)
                {
                    for (int i = 0; i < DT_ColumnName.Rows.Count; i++)
                    {
                        if (DT_ColumnName.Rows[i]["TABLE_NAME"].ToString().Equals(TableName))
                        {
                            arrList.Add(DT_ColumnName.Rows[i]["COLUMN_NAME"].ToString());
                        }
                    }

                    if (arrList.Count > 0)
                    {
                        ColumnName = new string[arrList.Count];

                        for (int i = 0; i < arrList.Count; i++)
                        {
                            ColumnName[i] = (string)arrList[i];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objUtil.writeLog("ERR GET SHEETS NAME" + "\r\n" + ex.ToString());
            }

            return(ColumnName);
        }
예제 #14
0
        public Form1()
        {
            InitializeComponent();

            objUtil = new libCommon.clsUtil();

            user_id = objUtil.getAppCfg("user_id");
            user_pw = objUtil.getAppCfg("password");

            if (user_id.Trim().Length == 0 || user_pw.Trim().Length == 0)
            {
                MessageBox.Show("로그인 정보 없음");
                Application.Exit();
            }

            mainURL       = "http://www.slrclub.com";
            myArticleURL  = "http://www.slrclub.com/mypage/myarticle.php?";
            delArticleURL = "http://www.slrclub.com/bbs/delete.php?";
            articleURL    = "http://www.slrclub.com/bbs/vx2.php?";

            articleList = new System.Collections.ArrayList();

            wc = new System.Net.WebClient();
            wb = new WebBrowser();
            wb.ScriptErrorsSuppressed = true;
            wb.DocumentCompleted     += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
            wb.DocumentText           = "";
            doc = wb.Document.OpenNew(true);

            nStep = "start";

            progressFlag    = 0;
            used_marketFlag = 0;
            myarticlePage   = 1;

            lastItem = "";

            this.label1.Text = "";
        }
예제 #15
0
        private void genPropertyList()
        {
            libCommon.clsUtil objUtil      = new libCommon.clsUtil();
            string            propertyList = @"Artist|0x013B,
BitsPerSample|0x0102,
Compression|0x0103,
CellWidth|0x0108,
CellHeight|0x0109,
ColorMap|0x0140,
ColorTransferFunction|0x501A,
ChrominanceTable|0x5091,
Copyright|0x8298,
DocumentName|0x010D,
DateTime|0x0132,
DotRange|0x0150,
EquipMake|0x010F,
EquipModel|0x0110,
ExtraSamples|0x0152,
ExifExposureTime|0x829A,
ExifFNumber|0x829D,
ExifIFD|0x8769,
ExifExposureProg|0x8822,
ExifSpectralSense|0x8824,
ExifISOSpeed|0x8827,
ExifOECF|0x8828,
ExifVer|0x9000,
ExifDTOrig|0x9003,
ExifDTDigitized|0x9004,
ExifCompConfig|0x9101,
ExifCompBPP|0x9102,
ExifShutterSpeed|0x9201,
ExifAperture|0x9202,
ExifBrightness|0x9203,
ExifExposureBias|0x9204,
ExifMaxAperture|0x9205,
ExifSubjectDist|0x9206,
ExifMeteringMode|0x9207,
ExifLightSource|0x9208,
ExifFlash|0x9209,
ExifFocalLength|0x920A,
ExifMakerNote|0x927C,
ExifUserComment|0x9286,
ExifDTSubsec|0x9290,
ExifDTOrigSS|0x9291,
ExifDTDigSS|0x9292,
ExifFPXVer|0xA000,
ExifColorSpace|0xA001,
ExifPixXDim|0xA002,
ExifPixYDim|0xA003,
ExifRelatedWav|0xA004,
ExifInterop|0xA005,
ExifFlashEnergy|0xA20B,
ExifSpatialFR|0xA20C,
ExifFocalXRes|0xA20E,
ExifFocalYRes|0xA20F,
ExifFocalResUnit|0xA210,
ExifSubjectLoc|0xA214,
ExifExposureIndex|0xA215,
ExifSensingMethod|0xA217,
ExifFileSource|0xA300,
ExifSceneType|0xA301,
ExifCfaPattern|0xA302,
FillOrder|0x010A,
FreeOffset|0x0120,
FreeByteCounts|0x0121,
FrameDelay|0x5100,
GpsVer|0x0000,
GpsLatitudeRef|0x0001,
GpsLatitude|0x0002,
GpsLongitudeRef|0x0003,
GpsLongitude|0x0004,
GpsAltitudeRef|0x0005,
GpsAltitude|0x0006,
GpsGpsTime|0x0007,
GpsGpsSatellites|0x0008,
GpsGpsStatus|0x0009,
GpsGpsMeasureMode|0x000A,
GpsGpsDop|0x000B,
GpsSpeedRef|0x000C,
GpsSpeed|0x000D,
GpsTrackRef|0x000E,
GpsTrack|0x000F,
GpsImgDirRef|0x0010,
GpsImgDir|0x0011,
GpsMapDatum|0x0012,
GpsDestLatRef|0x0013,
GpsDestLat|0x0014,
GpsDestLongRef|0x0015,
GpsDestLong|0x0016,
GpsDestBearRef|0x0017,
GpsDestBear|0x0018,
GpsDestDistRef|0x0019,
GpsDestDist|0x001A,
GpsIFD|0x8825,
GrayResponseUnit|0x0122,
GrayResponseCurve|0x0123,
Gamma|0x0301,
GridSize|0x5011,
GlobalPalette|0x5102,
HostComputer|0x013C,
HalftoneHints|0x0141,
HalftoneLPI|0x500A,
HalftoneLPIUnit|0x500B,
HalftoneDegree|0x500C,
HalftoneShape|0x500D,
HalftoneMisc|0x500E,
HalftoneScreen|0x500F,
ImageWidth|0x0100,
ImageHeight|0x0101,
ImageDescription|0x010E,
InkSet|0x014C,
InkNames|0x014D,
ICCProfileDescriptor|0x0302,
ImageTitle|0x0320,
IndexBackground|0x5103,
IndexTransparent|0x5104,
ICCProfile|0x8773,
JPEGProc|0x0200,
JPEGInterFormat|0x0201,
JPEGInterLength|0x0202,
JPEGRestartInterval|0x0203,
JPEGLosslessPredictors|0x0205,
JPEGPointTransforms|0x0206,
JPEGQTables|0x0207,
JPEGDCTables|0x0208,
JPEGACTables|0x0209,
JPEGQuality|0x5010,
LuminanceTable|0x5090,
LoopCount|0x5101,
MinSampleValue|0x0118,
MaxSampleValue|0x0119,
NewSubfileType|0x00FE,
NumberOfInks|0x014E,
Orientation|0x0112,
PhotometricInterp|0x0106,
PlanarConfig|0x011C,
PageName|0x011D,
PageNumber|0x0129,
Predictor|0x013D,
PrimaryChromaticities|0x013F,
PrintFlags|0x5005,
PrintFlagsVersion|0x5006,
PrintFlagsCrop|0x5007,
PrintFlagsBleedWidth|0x5008,
PrintFlagsBleedWidthScale|0x5009,
PixelUnit|0x5110,
PixelPerUnitX|0x5111,
PixelPerUnitY|0x5112,
PaletteHistogram|0x5113,
RowsPerStrip|0x0116,
ResolutionUnit|0x0128,
REFBlackWhite|0x0214,
ResolutionXUnit|0x5001,
ResolutionYUnit|0x5002,
ResolutionXLengthUnit|0x5003,
ResolutionYLengthUnit|0x5004,
SubfileType|0x00FF,
StripOffsets|0x0111,
SamplesPerPixel|0x0115,
StripBytesCount|0x0117,
SoftwareUsed|0x0131,
SampleFormat|0x0153,
SMinSampleValue|0x0154,
SMaxSampleValue|0x0155,
SRGBRenderingIntent|0x0303,
ThreshHolding|0x0107,
T4Option|0x0124,
T6Option|0x0125,
TransferFunction|0x012D,
TileWidth|0x0142,
TileLength|0x0143,
TileOffset|0x0144,
TileByteCounts|0x0145,
TargetPrinter|0x0151,
TransferRange|0x0156,
ThumbnailFormat|0x5012,
ThumbnailWidth|0x5013,
ThumbnailHeight|0x5014,
ThumbnailColorDepth|0x5015,
ThumbnailPlanes|0x5016,
ThumbnailRawBytes|0x5017,
ThumbnailSize|0x5018,
ThumbnailCompressedSize|0x5019,
ThumbnailData|0x501B,
ThumbnailImageWidth|0x5020,
ThumbnailImageHeight|0x5021,
ThumbnailBitsPerSample|0x5022,
ThumbnailCompression|0x5023,
ThumbnailPhotometricInterp|0x5024,
ThumbnailImageDescription|0x5025,
ThumbnailEquipMake|0x5026,
ThumbnailEquipModel|0x5027,
ThumbnailStripOffsets|0x5028,
ThumbnailOrientation|0x5029,
ThumbnailSamplesPerPixel|0x502A,
ThumbnailRowsPerStrip|0x502B,
ThumbnailStripBytesCount|0x502C,
ThumbnailResolutionX|0x502D,
ThumbnailResolutionY|0x502E,
ThumbnailPlanarConfig|0x502F,
ThumbnailResolutionUnit|0x5030,
ThumbnailTransferFunction|0x5031,
ThumbnailSoftwareUsed|0x5032,
ThumbnailDateTime|0x5033,
ThumbnailArtist|0x5034,
ThumbnailWhitePoint|0x5035,
ThumbnailPrimaryChromaticities|0x5036,
ThumbnailYCbCrCoefficients|0x5037,
ThumbnailYCbCrSubsampling|0x5038,
ThumbnailYCbCrPositioning|0x5039,
ThumbnailRefBlackWhite|0x503A,
ThumbnailCopyRight|0x503B,
WhitePoint|0x013E,
XResolution|0x011A,
XPosition|0x011E,
YResolution|0x011B,
YPosition|0x011F,
YCbCrCoefficients|0x0211,
YCbCrSubsampling|0x0212,
YCbCrPositioning|0x0213";

            DT = new DataTable();
            string[] property_arr = objUtil.Split(propertyList.Replace("\r\n", ""), ",");

            DT.Columns.Add("ID");
            DT.Columns.Add("Name");

            for (int i = 0; i < property_arr.Length; i++)
            {
                DT.Rows.Add();
                DT.Rows[i][0] = objUtil.Split(property_arr[i], "|")[1];
                DT.Rows[i][1] = objUtil.Split(property_arr[i], "|")[0];
            }
        }
예제 #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strFilePath">엑셀 파일 경로</param>
        /// <param name="QUERY"></param>
        /// <param name="maxRow">0이면 전체 행 가져오기</param>
        private static DataSet readExcelData(string strFilePath, string QUERY, int maxRow)
        {
            libCommon.clsUtil objUtil = new libCommon.clsUtil();

            OleDbConnection oleDBCon = null;

            StringBuilder strBuilder = new StringBuilder();
            DataSet       DS         = new DataSet();

            string strProvider;

            string[] Temp;
            string[] sheetName;
            string[] columnName;
            string   strQuery;

            int i;
            int j;

            Temp = objUtil.Split(strFilePath, ".");

            //파일경로가 올바르면 실행
            if (Temp.Length > 0)
            {
                if (Temp[Temp.Length - 1].Equals("xlsx"))
                {
                    strProvider = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + strFilePath + "; Extended Properties=Excel 12.0";
                }
                else
                {
                    strProvider = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + strFilePath + "; Extended Properties=Excel 8.0";
                }

                try
                {
                    oleDBCon = new OleDbConnection(strProvider);

                    //접속
                    oleDBCon.Open();

                    //쉬트 네임 가져오기
                    sheetName = getSheetName(oleDBCon);
                    if (sheetName == null)
                    {
                        return(DS);
                    }

                    if (QUERY.Length > 0)
                    {
                        strQuery = QUERY;

                        using (OleDbCommand oleDBCom = new OleDbCommand(strQuery, oleDBCon))
                        {
                            using (OleDbDataReader oleReader = oleDBCom.ExecuteReader())
                            {
                                DS.Tables.Add();
                                DS.Tables[0].Load(oleReader);
                            }
                        }
                    }
                    else
                    {
                        for (i = 0; i < sheetName.Length; i++)
                        {
                            //컬럼명 가져오기
                            columnName = getColumnName(oleDBCon, sheetName[i]);
                            if (columnName == null)
                            {
                                return(DS);
                            }

                            if (maxRow > 0)
                            {
                                strQuery = "SELECT TOP " + maxRow.ToString() + " * FROM [" + sheetName[i] + "]";
                            }
                            else
                            {
                                strQuery = "SELECT * FROM [" + sheetName[i] + "]";
                            }

                            //값이 없는 행은 제거하는 조건 추가
                            for (j = 0; j < columnName.Length; j++)
                            {
                                if (j == 0)
                                {
                                    strBuilder.Append(" WHERE");
                                }
                                else
                                {
                                    strBuilder.Append(" OR");
                                }

                                strBuilder.Append(string.Format(" [{0}.{1}] IS NOT NULL", sheetName[i], columnName[0]));
                            }
                            strQuery += strBuilder.ToString();

                            using (OleDbCommand oleDBCom = new OleDbCommand(strQuery, oleDBCon))
                            {
                                using (OleDbDataReader oleReader = oleDBCom.ExecuteReader())
                                {
                                    DS.Tables.Add();
                                    DS.Tables[i].Load(oleReader);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    objUtil.writeLog("ERR READ EXCEL" + "\r\n" + ex.ToString());
                }

                if (oleDBCon != null)
                {
                    oleDBCon.Close();
                    oleDBCon.Dispose();
                }
            }

            return(DS);
        }