/// <summary> /// 수신된 메시지 처리, null수신시 sleep /// </summary> private void prcRcvObject(object rcvObj) { if (rcvObj != null) { System.Diagnostics.Stopwatch objWatch = new System.Diagnostics.Stopwatch(); objWatch.Start(); libMyUtil.clsMSMQ objMSMQ = new libMyUtil.clsMSMQ(); libMyUtil.pageCallingInfo callingInfo = (libMyUtil.pageCallingInfo)rcvObj; string Result; string url = callingInfo.url; string postData = callingInfo.postData; int timeOut = callingInfo.timeOut; if (callingInfo.httpMethod.Equals("POST")) { Result = libMyUtil.clsWeb.SendPostData(postData, url, this.encodeType, timeOut * 1000); } else if (callingInfo.httpMethod.Equals("GET")) { Result = libMyUtil.clsWeb.SendQueryString(postData, url, timeOut * 1000); } else { Result = "UNKNOWN HTTP METHOD"; } objUtil.writeLog(string.Format("CALL RESULT : {0}\r\nFKEY:{1}\r\nURL:{2}", Result, callingInfo.FKEY, callingInfo.url)); if (Result.Equals(callingInfo.callresult)) { UpdateResult(callingInfo, Result);//성공 결과 DB에 저장 } else if (Result.Equals("FAIL")) { //재시도 callingInfo.failCnt++; //실패 카운트 증가 callingInfo.lastTry = System.DateTime.Now; //시간 기록 if (callingInfo.failCnt < this.MaxCallingFailCnt) //설정한 횟수만큼 재시도 { objMSMQ.sendData(qPath_retry, callingInfo); //재시도 큐에 저장 } else { callingInfo.writeLog(Result); //최종 실패 메시지 로그 기록 UpdateResult(callingInfo, Result); //실패 결과 DB에 저장 } } else { callingInfo.writeLog(Result); //최종 실패 메시지 로그 기록 UpdateResult(callingInfo, Result); //실패 결과 DB에 저장 } objWatch.Stop(); if (System.DateTime.Now.Millisecond > 500) { objUtil.writeLog(string.Format("TIME SPAN : {0} millisecond", objWatch.Elapsed.TotalMilliseconds.ToString())); } } else { System.Threading.Thread.Sleep(this.sleep);//큐에 메시지 없으면 슬립 } }
/// <summary> /// RSS정보 읽어와서 파싱 /// </summary> public clsFeed getRSSfeed(string RSS_idx, string URL, string user_id) { clsFeed objFeed = new clsFeed(); Create_XML_Reader(URL); if (reader == null) { return(new clsFeed()); } string title = ""; string link = ""; string desc = ""; DateTime date = new DateTime(); try { if (MoveCursor(XmlNodeType.Element, "channel")) { if (MoveCursor(XmlNodeType.Element, "title")) { objFeed.siteTitle = reader.ReadElementString(); objFeed.siteURL = URL; } } while (MoveCursor(XmlNodeType.Element, "item")) { if (MoveCursor(XmlNodeType.Element, "title")) { title = reader.ReadString(); } if (MoveCursor(XmlNodeType.Element, "link")) { link = reader.ReadString(); } if (MoveCursor(XmlNodeType.Element, "description")) { desc = reader.ReadString(); } if (MoveCursor(XmlNodeType.Element, "pubDate")) { date = Convert.ToDateTime(reader.ReadString()); } objFeed.addFeed(RSS_idx, title, link, desc, date, false, false); } } catch (Exception ex) { objUtil.writeLog("ERR PARSING XML : " + URL); return(new clsFeed()); } prcFavorItem(objFeed, user_id); prcPastItem(objFeed, user_id); return(objFeed); }
/// <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); }