private string insertURL(string longURL) { libCommon.clsDB objDB = new libCommon.clsDB(); System.Data.SqlClient.SqlConnection dbCon = libMyUtil.clsCmnDB.getConnection("sa", "rhksflwk", "urlShorten", "192.168.10.10"); System.Data.SqlClient.SqlTransaction TRX; Random objRandom = new Random(); byte[] shortURL_byte; string shortURL; string Result; shortURL_byte = System.BitConverter.GetBytes(new UInt32()); objRandom.NextBytes(shortURL_byte); shortURL = libMyUtil.clsFile.toBase62(System.BitConverter.ToUInt32(shortURL_byte, 0)); dbCon.Open(); TRX = dbCon.BeginTransaction(); Result = libMyUtil.clsCmnDB.INSERT_DB(dbCon, TRX, "tb_URL", "longURL|shortURL", longURL + "|" + shortURL); if (Result.Equals("FAIL")) { TRX.Rollback(); shortURL = ""; } else { TRX.Commit(); } dbCon.Close(); return(shortURL); }
//RSS URL 추가 public string insertURL(System.Data.SqlClient.SqlConnection dbCon, string URL, string loginID) { System.Data.SqlClient.SqlTransaction TRX; string tb_Name = "tb_RSSsite"; string Result = ""; int idx; string Cols = "user_id|RSS_name|RSS_state|reg_date|update_date"; string Vals = loginID + "||" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "|" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); TRX = dbCon.BeginTransaction(); Result = objCmnDB.INSERT_DB(dbCon, TRX, tb_Name, Cols, Vals); if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog("FAIL INSERT URL : " + URL); } else { TRX.Commit(); } return(Result); }
/// <summary> /// 오류는 FAIL, 중복은 DUPE 리턴 /// </summary> public string insertUser(System.Data.SqlClient.SqlConnection dbCon, clsUserInfo objUserInfo, string loginID) { System.Data.SqlClient.SqlTransaction TRX; string tb_Name = "tb_user"; string Result = ""; TRX = dbCon.BeginTransaction(); Result = chkUserID(dbCon, TRX, objUserInfo.user_id); if (Result.Equals("OK")) { Result = objCmnDB.INSERT_DB(dbCon, TRX, tb_Name, objUserInfo.getICols(), objUserInfo.getIVals(loginID)); if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog("FAIL INSERT USER : " + objUserInfo.user_id); } else { TRX.Commit(); } } else { TRX.Rollback(); } return(Result); }
/// <summary> /// tb_aURLresult 테이블 결과 업데이트 /// </summary> /// <param name="Result">전달받은 결과값</param> private void UpdateResult(libMyUtil.pageCallingInfo callingInfo, string Result) { libCommon.clsDB objDB = new libCommon.clsDB(); System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; string updateResult; if (System.Text.Encoding.Default.GetByteCount(Result) > 1000) { Result = Result.Substring(0, 500); } try { dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); updateResult = libMyUtil.clsCmnDB.UPDATE_DB(dbCon, TRX, "tb_aURLresult", "RESULT", Result, "aURLidx|FKEY", callingInfo.aURLset_Idx + "|" + callingInfo.FKEY); if (updateResult.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog(string.Format("FAIL UPDATE URL RESULT\r\nFKEY:{0}\r\nResult:{1}", callingInfo.FKEY, Result)); } else { TRX.Commit(); } dbCon.Close(); } catch (Exception ex) { objUtil.writeLog("ERR UPDATE URL CALL RESULT : " + ex.ToString()); } }
/// <summary> /// RSS사이트 인서트, 실패/오류시 FAIL 리턴 /// </summary> public string insertRSSsite(string URL, string user_id) { System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; string Cols; string Vals; string flag; string Result = "FAIL"; setSiteInfo(URL); if (siteURL.Trim().Length > 0 && siteTitle.Trim().Length > 0) { Cols = "user_id|RSS_name|RSS_url"; Vals = user_id + "|" + siteTitle + "|" + siteURL; dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); flag = isDupeSite(dbCon, TRX, user_id, URL); if (flag.Equals("OK")) { Result = objCmnDB.INSERT_DB(dbCon, TRX, "tb_RSSsite", Cols, Vals); } else if (flag.Equals("DUPE")) { Result = toggleSiteState(dbCon, TRX, user_id, URL, "AA"); } if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog(string.Format("FAIL INSERT RSS SITE INFO : {0}-{1}({2})", user_id, siteTitle, siteURL)); } else { TRX.Commit(); } dbCon.Close(); } return(Result); }
/// <summary> /// 관심기사 인서트 실패/오류시 FAIL 리턴 /// </summary> /// <param name="RSS_idx">RSS사이트 idx</param> /// <param name="Item_desc">요약정보</param> /// <param name="Item_date">yyyy-MM-dd HH:mm:ss</param> public string insertFavorItem(string RSS_idx, string Item_title, string Item_url, string Item_desc, string Item_date, string user_id) { System.Data.SqlClient.SqlConnection dbCon; System.Data.SqlClient.SqlTransaction TRX; string strDate; string Cols; string Vals; string Result = "FAIL"; string flag; strDate = Convert.ToDateTime(Item_date).ToString("yyyy-MM-dd HH:mm:ss"); Cols = "RSS_idx|user_id|Item_title|Item_url|Item_desc|Item_date"; Vals = RSS_idx + "|" + user_id + "|" + Item_title.Replace("|", "") + "|" + Item_url + "|" + Item_desc.Replace("|", "") + "|" + strDate; dbCon = objDB.GetConnection(); TRX = dbCon.BeginTransaction(); flag = isDupeItem(dbCon, TRX, user_id, Item_url, "tb_favorite"); if (flag.Equals("OK")) { Result = objCmnDB.INSERT_DB(dbCon, TRX, "tb_favorite", Cols, Vals); } else if (flag.Equals("DUPE")) { Result = toggleFavorState(dbCon, TRX, Item_url, user_id, "AA"); } if (Result.Equals("FAIL")) { TRX.Rollback(); objUtil.writeLog(string.Format("FAIL INSERT FAVORITE : {0}-{1}({2})", user_id, RSS_idx, Item_url)); } else { TRX.Commit(); } dbCon.Close(); return(Result); }