private string SetEmailBody(string strBody, int intOrderID, int intCustomerID, ref string strSubject, ref string strErr, ref string strOrderID, ref string strCustEmail, ref string strSenderEmailID, ref string strSenderEmailPwd) { clsDB objDB = null; string strResult; DataSet dstOutPut; StringBuilder str = new StringBuilder(strBody); StringBuilder strText = new StringBuilder(""); try { objDB = new clsDB(); objDB.AddParameter("p_intOrderID", intOrderID); objDB.AddParameter("p_intCustomerID", intCustomerID); dstOutPut = objDB.ExecuteSelect("spOrderDetailsEmail", CommandType.StoredProcedure, 0, ref strErr, "p_ErrMsg"); if (strErr != "") { strResult = "Error:" + strErr; } if (dstOutPut != null && dstOutPut.Tables.Count > 0) { strOrderID = Convert.ToString(dstOutPut.Tables[0].Rows[0]["OrderID"]); strCustEmail = Convert.ToString(dstOutPut.Tables[0].Rows[0]["CustomerEmailID"]); strSenderEmailID = Convert.ToString(dstOutPut.Tables[0].Rows[0]["SenderEmailID"]); strSenderEmailPwd = System.Web.Configuration.WebConfigurationManager.AppSettings["SenderPwd"]; strSubject = Convert.ToString(dstOutPut.Tables[0].Rows[0]["CustomerName"]) + " Oredr Itinerary :: Order ID " + Convert.ToString(dstOutPut.Tables[0].Rows[0]["OrderID"]); if (dstOutPut.Tables.Count > 0 && dstOutPut.Tables[0].Rows.Count > 0) { strText.Append("<tr><td >Your Order is Booked Successfully</td></tr>"); } //str= str.Append("<table width='600px' border='0'>" + strText.ToString() + "</table>").ToString(); strBody = strText.ToString(); } } catch (Exception ex) { } return(strBody); }
static void Main(string[] args) { try { clsDB dbObj = new clsDB(); DataSet ds = dbObj.ExecuteSelect("CMS_PULL_GET_NEW_TRIPS_FOR_CRS_INFO", CommandType.StoredProcedure, 160); int cnt = 0; string[] arrTrip_info = new string[ds.Tables[0].Rows.Count]; int[] arrTrip_ids = new int[ds.Tables[0].Rows.Count]; int[] arrCompany_ids = new int[ds.Tables[0].Rows.Count]; int intTrip_id; int intCompanyId; foreach (DataRow dataRow in ds.Tables[0].Rows) { try { using (WebClient client = new WebClient()) { string webUrl = ConfigurationSettings.AppSettings["WebserviceURL"].ToString(); intTrip_id = Convert.ToInt32(dataRow["TRIP_ID"]); intCompanyId=Convert.ToInt32(dataRow["COMPANY_ID"]); webUrl += "&KeyCode=''&intTripID=" + intTrip_id.ToString(); webUrl += "&dtChartDate=" + ((DateTime)dataRow["CHART_DATE"]).ToString("yyyy-MMM-dd").ToString(); byte[] obj = client.DownloadData(webUrl); string json = Encoding.ASCII.GetString(obj); arrTrip_info[cnt] = json; arrTrip_ids[cnt] = intTrip_id; arrCompany_ids[cnt] = intCompanyId; } } catch (System.Exception es) { } cnt++; } int maxRow = 100; DataTable dt = new DataTable(); //dt.TableName = "TRIP_INFO"; dt.Columns.Add("TRIP_ID", typeof(int)); dt.Columns.Add("COMPANY_ID", typeof(int)); dt.Columns.Add("ROUTE_INFO", typeof(string)); dt.Columns.Add("DEPARTURE_TIME", typeof(DateTime)); for (int i = 0; i < arrTrip_info.Length; i++) { if (arrTrip_info[i].Length > 0) { string ctName = ""; string deprTime = ""; try { JObject tripInfo = JObject.Parse(arrTrip_info[i]); var cts = tripInfo["APITripsSummaryResult"].Children(); foreach (var ct in cts) { ctName += ct["CityName"].ToString().Trim('"') + "-"; if (ct["Position"].ToString().Trim('"') == "1") deprTime = ct["DepartureTime"].ToString().Trim('"'); } } catch (System.Exception ex) { } DataRow dr = dt.NewRow(); dr["TRIP_ID"] = arrTrip_ids[i]; dr["COMPANY_ID"] = arrCompany_ids[i]; dr["ROUTE_INFO"] = ctName.Remove(ctName.Length - 1); dr["DEPARTURE_TIME"] = Convert.ToDateTime(deprTime); dt.Rows.Add(dr); if (dt.Rows.Count == maxRow) { try { dbObj = null; dbObj = new clsDB(); dbObj.AddParameter("TRIP_INFO", dt); dbObj.ExecuteDML("CMS_PULL_UPDATE_TRIP_INFO", CommandType.StoredProcedure, 180); dt.Rows.Clear(); } catch (System.Exception ex) { } } } } if (dt.Rows.Count > 0) { try { dbObj = null; dbObj = new clsDB(); dbObj.AddParameter("TRIP_INFO", dt); dbObj.ExecuteDML("CMS_PULL_UPDATE_TRIP_INFO", CommandType.StoredProcedure, 180); dt.Rows.Clear(); } catch (System.Exception ex) { } } } catch (System.Exception ex) { } }