Line 1: using System;
Line 2: using System.Data;
Line 3: using System.Configuration;
Line 4: using System.Web;
Line 5: using System.Web.Mail;
Line 6: using System.Web.Security;
Line 7: using System.Web.UI;
Line 8: using System.Web.UI.WebControls;
Line 9: using System.Web.UI.WebControls.WebParts;
Line 10: using System.Web.UI.HtmlControls;
Line 11: using IDSService;
Line 12: using System.Text;
Line 13: using Microsoft.Web.Services3.Security.Tokens;
Line 14: using System.Data.SqlClient;
Line 15:
Line 16: /// <summary>
Line 17: /// Summary description for Global
Line 18: /// </summary>
Line 19: public class Global : System.Web.HttpApplication
Line 20: {
Line 21: Exception webException = null;
Line 22: public int cstMonth;
Line 23: public int cstYear;
Line 24: public string cstdate;
Line 25: string username = ConfigurationManager.AppSettings["Username"].ToString();
Line 26: string password = ConfigurationManager.AppSettings["Password"].ToString();
Line 27: ProductServiceWse oProductService = new ProductServiceWse();
Line 28: Profiles oProfiles = new Profiles();
Line 29: CommonMethodsWse oCommonMethods = new CommonMethodsWse();
Line 30: public static DataSet ds = new DataSet();
Line 31: public string keyword;
Line 32: public static int siteid;
Line 33: public string searchtype;
Line 34: public string criteria;
Line 35: public string fromprice;
Line 36: public string toprice;
Line 37: public string[] HysMaster1 = { "default.aspx", "customerservice.aspx", "Premium_Capes_Aprons.aspx", "clearance.aspx", "viewtestimonial.aspx", "productrating.aspx", "testimonialentry.aspx", "contactus.aspx", "aboutus.aspx", "products.aspx", "custregistrationconfirmed.aspx", "previouslyvisitedpage.aspx", "closeout.aspx", "closeoutcategory.aspx", "closeoutproducts.aspx", "specialcategory.aspx", "specialproducts.aspx", "activation.aspx", "emailunsub.aspx", "salonaccessories.aspx", "AccessoriesProducts.aspx", "defaultNew.aspx", "car-wash-list.aspx", "car-wash-products.aspx", "restaurant-industry-table-linen-product-resptemp1.aspx", "enquiryform.aspx" };
Line 38: public Global()
Line 39: {
Line 40: //
Line 41: // TODO: Add constructor logic here
Line 42: //
Line 43: }
Line 44:
Line 45: public void Application_Start(object sender, EventArgs e)
Line 46: {
Line 47: // Code that runs on application startup
Line 48:
Line 49:
Line 50: }
Line 51: public void Application_End(object sender, EventArgs e)
Line 52: {
Line 53: // Code that runs on application shutdown
Line 54:
Line 55: }
Line 56: public void Application_Error(object sender, EventArgs e)
Line 57: {
Line 58: webException = Server.GetLastError();
Line 59: string var = Request.Url.ToString().ToUpper();
Line 60: if (var.Contains("! "))
Line 61: {
Line 62: var = var.Replace("! ", "");
Line 63: Response.Redirect(var);
Line 64: }
Line 65: if (var.Contains("!%20"))
Line 66: {
Line 67: var = var.Replace("!%20", "");
Line 68: Response.Redirect(var);
Line 69: }
Line 70: if (var.Contains("HTTP://WWW.HYSUPPLIES.COM/PRODUCTS/"))
Line 71: {
Line 72: string pgnm = var.Substring(var.LastIndexOf("/") + 1);
Line 73: pgnm = pgnm.Replace(".ASPX", "");
Line 74: if (pgnm.Contains("_"))
Line 75: {
Line 76: pgnm = pgnm.Replace("_", " ");
Line 77: }
Line 78: if (pgnm.Contains("-"))
Line 79: {
Line 80: pgnm = pgnm.Replace("-", " ");
Line 81: }
Line 82: searchtype = "Match Any Word";
Line 83: criteria = "Or";
Line 84: fromprice = "";
Line 85: toprice = "";
Line 86: Response.Redirect("~/webforms/SearchResults.aspx?keywd=" + pgnm + "&stype=" + searchtype + "&cri=" + criteria + "&fprice=" + fromprice + "&tprice=" + toprice + "&pgdisp=10");
Line 87: }
Line 88: DataSet ds1 = new DataSet();
Line 89:
Line 90: ds1 = oProfiles.GetEmail("WebErrors");
Line 91: if (ds1 != null)
Line 92: {
Line 93: DataRow PathInfo = ds1.Tables[0].Rows[0];
Line 94: /*oMailMsg.From = "custserv@hysupplies.com";
Line 95: oMailMsg.To = "uday@hysupplies.com;jothimaheshkumar@cbssys.com;rajamanigandan@cbssys.com";
Line 96: // oMailMsg.To = "rajamanigandan@cbssys.com";
Line 97: //oMailMsg.To = PathInfo["MailTo"].ToString();
Line 98: //oMailMsg.Cc = PathInfo["MailCc"].ToString();
Line 99: //oMailMsg.Cc = "max@hysupplies.com";
Line 100: //oMailMsg.Bcc = PathInfo["MailBCC1"].ToString() + ";" + PathInfo["MailBCC2"].ToString() + ";" + PathInfo["MailBCC3"].ToString() + ";" + PathInfo["MailBCC4"].ToString() + ";" + PathInfo["MailBCC5"].ToString();
Line 101: oMailMsg.Subject = "HYSupplies Error (Ajax Version)"; //PathInfo["MailSubject"].ToString();
Line 102: oMailMsg.BodyFormat = MailFormat.Html;
Line 103: oMailMsg.Body = sbWebErrorDetails.ToString();
Line 104: SmtpMail.SmtpServer = "mail.cbssys.com"; //PathInfo["MailServer"].ToString();
Line 105: SmtpMail.Send(oMailMsg);*/
Line 106:
Line 107:
Line 108: System.Net.NetworkCredential cred = new System.Net.NetworkCredential("webmaster@hysupplies.com", "Webmaster7209$!#");
Line 109: System.Net.Mail.MailMessage oMailMsg = new System.Net.Mail.MailMessage();
Line 110: oMailMsg.From = new System.Net.Mail.MailAddress("webmaster@hysupplies.com");
Line 111: oMailMsg.To.Add("jothimaheshkumar@cbssys.com");
Line 112: //oMailMsg.To.Add("tom@cbssys.com");
Line 113: oMailMsg.Subject = "HYSupplies Error (Ajax Version)";
Line 114: oMailMsg.IsBodyHtml = true;
Line 115: StringBuilder sbWebErrorDetails = new StringBuilder();
Line 116: sbWebErrorDetails = BuildErrorMessage();
Line 117:
Line 118: oMailMsg.Body = sbWebErrorDetails.ToString();
Line 119: System.Net.Mail.SmtpClient Smtp = new System.Net.Mail.SmtpClient("smtpout.secureserver.net");
Line 120: Smtp.UseDefaultCredentials = false;
Line 121: Smtp.Credentials = cred;
Line 122: Smtp.Port = 80;
Line 123: //Smtp.Send(oMailMsg);
Line 124:
Line 125: }
Line 126: RefreshDS();
Line 127: }
Line 128: private void RefreshDS()
Line 129: {
Line 130: int SiteID;
Line 131: DataSet ds = new DataSet();
Line 132: SiteID = int.Parse(Session["SiteID"].ToString());
Line 133: //UsernameToken token = new UsernameToken(username, password, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendPlainText);
Line 134: //oProductService.RequestSoapContext.Security.Tokens.Add(token);
Line 135: ds = oProductService.GetAllIndustryProductDetails(SiteID);
Line 136: if (ds == null || ds.Tables.Count < 5)
Line 137: {
Line 138:
Line 139: }
Line 140: else
Line 141: {
Line 142: Global.ds = ds;
Line 143: if (ds != null && ds.Tables.Count > 0)
Line 144: {
Line 145: ds.Tables["RootParent"].TableName = "RootParent" + Session["SiteID"].ToString();
Line 146: ds.Tables["category"].TableName = "category" + Session["SiteID"].ToString();
Line 147: ds.Tables["products"].TableName = "products" + Session["SiteID"].ToString();
Line 148: ds.Tables["Industry"].TableName = "Industry" + Session["SiteID"].ToString();
Line 149: ds.Tables["sku"].TableName = "sku" + Session["SiteID"].ToString();
Line 150: ds.Tables["OldProduct"].TableName = "OldProduct" + Session["SiteID"].ToString();
Line 151: ds.Tables["ProductPricing"].TableName = "ProductPricing" + Session["SiteID"].ToString();
Line 152: ds.Tables["ProductWareHouse"].TableName = "ProductWareHouse" + Session["SiteID"].ToString();
Line 153: ds.Tables["Promocode"].TableName = "Promocode";
Line 154: ds.Tables["PromoProducts"].TableName = "PromoProducts";
Line 155: }
Line 156: }
Line 157: }
Line 158: public StringBuilder BuildErrorMessage()
Line 159: {
Line 160: StringBuilder sbWebErrorDetails = new StringBuilder("<body bgcolor=#d7d7d7><table cellpadding=0 bgcolor=#ffffff border=1 width=770 bordercolor=#d7d7d7 cellspacing=0 align=center style='BORDER-RIGHT: #556b2f 0px solid; BORDER-TOP: #556b2f 0px solid; BORDER-LEFT: #556b2f 0px solid; BORDER-BOTTOM: #556b2f 0px solid; BORDER-COLLAPSE: collapse;padding-left:10px;'>");
Line 161: DataSet dsCST = oProfiles.GetCSTDate();
Line 162: if (dsCST != null)
Line 163: {
Line 164: cstdate = dsCST.Tables[0].Rows[0]["cstdate"].ToString();
Line 165: }
Line 166: sbWebErrorDetails.Append("<tr><td colspan= 2 height=50 bgcolor=#efefef><font size=3 face=verdana color=#08598c><b>Web Exception - HY Supplies Inc.</b></font></td></tr>");
Line 167: sbWebErrorDetails.Append("<tr>");
Line 168: sbWebErrorDetails.Append("<td colspan=2 align=left><br/><br/><font size=1 face=verdana><b>");
Line 169: sbWebErrorDetails.Append("An exception occured in the website HYSupplies.com. (" + cstdate + ")");
Line 170: sbWebErrorDetails.Append("</b></font><br/>");
Line 171: sbWebErrorDetails.Append("<p align=left>");
Line 172: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000><b>Error Page :</b></font> ");
Line 173: sbWebErrorDetails.Append("<font size=2 face=arial color=#b22222>");
Line 174: sbWebErrorDetails.Append(Request.Url.ToString());
Line 175: sbWebErrorDetails.Append("</font>");
Line 176: sbWebErrorDetails.Append("<br/><br/>");
Line 177: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000><b>Exception :</b></font> ");
Line 178: sbWebErrorDetails.Append("<font size=2 face=arial color=#b22222>");
Line 179: sbWebErrorDetails.Append(webException.Message);
Line 180: sbWebErrorDetails.Append("<br/><br/>");
Line 181: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000><b>Exception Description :</b></font> ");
Line 182: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000>");
Line 183: sbWebErrorDetails.Append(webException.ToString());
Line 184: sbWebErrorDetails.Append("</font><br/><br/>");
Line 185: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000><b>Stack Trace :</b></font> ");
Line 186: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000>");
Line 187: sbWebErrorDetails.Append(webException.StackTrace.ToString());
Line 188: sbWebErrorDetails.Append("</font><br/><br/>");
Line 189: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000><b>User IPAddress :</b></font> ");
Line 190: sbWebErrorDetails.Append("<font size=2 face=arial color=#b22222>");
Line 191: sbWebErrorDetails.Append(Request.UserHostAddress.ToString());
Line 192: sbWebErrorDetails.Append("</font><br/><br/>");
Line 193:
Line 194: sbWebErrorDetails.Append("<font size=1 face=arial color=#000000><b>Our WebSite : </b></font>");
Line 195: sbWebErrorDetails.Append("<font size=2 face=arial color=#000000><b><a href=http://www.hysupplies.com>www.hysupplies.com</a></b></font>");
Line 196: sbWebErrorDetails.Append("</p><font size=1 face=arial><b>");
Line 197: sbWebErrorDetails.Append("<br/>");
Line 198: sbWebErrorDetails.Append("</b></font></td>");
Line 199: sbWebErrorDetails.Append("</tr></table></body>");
Line 200: return sbWebErrorDetails;
Line 201: }
Line 202: public void Application_PreRequestHandlerExecute(object src, EventArgs e)
Line 203: {
Line 204: // hook up the PreInit page handler
Line 205: Page p = this.Context.Handler as Page;
Line 206: if (p != null)
Line 207: {
Line 208: p.PreInit += new EventHandler(page_PreInit);
Line 209: }
Line 210: }
Line 211: public void page_PreInit(object sender, EventArgs e)
Line 212: {
Line 213:
Line 214: Page p = this.Context.Handler as Page;
Line 215: if (p != null)
Line 216: {
Line 217: string str1 = p.Request.FilePath;
Line 218: str1 = str1.Substring(str1.LastIndexOf("/") + 1);
Line 219: for (int i = 0; i < HysMaster1.Length; i++)
Line 220: {
Line 221: if (str1.ToUpper() != "ORDERPRINTVIEW.ASPX" && str1.ToUpper() != "NEWDEFAULT.ASPX" && str1.ToUpper() != "VIEWDETAIL.ASPX" && str1.ToUpper() != "WMVPLAY.ASPX" && str1.ToUpper() != "TESTIMONIALDETAIL.ASPX" && str1.ToUpper() != "LPMCBSTRACK.ASPX" && str1.ToUpper() != "MAILTOFRIEND.ASPX" && str1.ToUpper() != "DEFAULTNEW.ASPX" && str1.ToUpper() != "TABLENEWDEFAULT.ASPX" && str1.ToUpper() != "HFNEWDEFAULT.ASPX" && str1.ToUpper() != "HCNEWDEFAULT.ASPX" && str1.ToUpper() != "HOSPNEWDEFAULT.ASPX" && str1.ToUpper() != "HHCNEWDEFAULT.ASPX" && str1.ToUpper() != "CREDITCARDADDANDEDITNEWS.ASPX" && str1.ToUpper() != "CREDITCARDADDANDEDITNEWE.ASPX" && str1.ToUpper() != "PAYMENTS.ASPX" && str1.ToUpper() != "ORDERSAVE.ASPX" && str1.ToUpper() != "TESTHYS.ASPX" && str1.ToUpper() != "RESTAURANT-INDUSTRY-TABLE-LINEN-PRODUCT-RESPTEMP1.ASPX" && str1.ToUpper() != "UPSTEST.ASPX" && str1.ToUpper() != "NMICHECK.ASPX" && str1.ToUpper() != "IMTS2018.ASPX")
Line 222: {
Line 223: p.MasterPageFile = "~/HYSupplies.master";
Line 224: if (HysMaster1[i] == str1.ToLower())
Line 225: {
Line 226: p.MasterPageFile = "~/HYSuppliesLeft.master";
Line 227: // p.MasterPageFile = "~/HYSupplies.master";
Line 228: break;
Line 229: }
Line 230: }
Line 231: }
Line 232: }
Line 233:
Line 234: }
Line 235: public void Session_Start(object sender, EventArgs e)
Line 236: {
Line 237: // Code that runs when a new session is started
Line 238: //UsernameToken token = new UsernameToken(username, password, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendPlainText);
Line 239: //oProductService.RequestSoapContext.Security.Tokens.Add(token);
Line 240:
Line 241: //Session["SiteID"] = 1;
Line 242: string Web = Request.Url.ToString().ToUpper();
Line 243: //if (Web.Contains("HTTP://WWW.HYSUPPLIESHEALTHCLUB.COM") || Web.Contains("HTTP://HYSUPPLIESHEALTHCLUB.COM"))
Line 244: //{
Line 245: // Session["SiteID"] = 3;
Line 246: //}
Line 247: //else if (Web.Contains("HYSUPPLIES.COM"))
Line 248: //{
Line 249: // Session["SiteID"] = 1;
Line 250: //}
Line 251:
Line 252: Session["SiteID"] = 1;
Line 253: if (ds != null)
Line 254: {
Line 255: //Session["SiteID"] = 1;
Line 256: if (!(ds.Tables.Contains("RootParent" + Session["SiteID"].ToString())))
Line 257: {
Line 258: ds = oProductService.GetAllIndustryProductDetails(Convert.ToInt32(Session["SiteID"].ToString()));
Line 259: if (ds != null && ds.Tables.Count > 0)
Line 260: {
Line 261: ds.Tables["RootParent"].TableName = "RootParent" + Session["SiteID"].ToString();
Line 262: ds.Tables["category"].TableName = "category" + Session["SiteID"].ToString();
Line 263: ds.Tables["products"].TableName = "products" + Session["SiteID"].ToString();
Line 264: ds.Tables["Industry"].TableName = "Industry" + Session["SiteID"].ToString();
Line 265: ds.Tables["sku"].TableName = "sku" + Session["SiteID"].ToString();
Line 266: ds.Tables["OldProduct"].TableName = "OldProduct" + Session["SiteID"].ToString();
Line 267: ds.Tables["ProductPricing"].TableName = "ProductPricing" + Session["SiteID"].ToString();
Line 268: ds.Tables["ProductWareHouse"].TableName = "ProductWareHouse" + Session["SiteID"].ToString();
Line 269: ds.Tables["Promocode"].TableName = "Promocode";
Line 270: ds.Tables["PromoProducts"].TableName = "PromoProducts";
Line 271: }
Line 272: }
Line 273: }
Line 274:
Line 275: //Session["SiteID"] = 1;
Line 276: siteid = int.Parse(Session["SiteID"].ToString());
Line 277: //Response.Write(Session["SiteID"].ToString());
Line 278:
Line 279: if (Request.QueryString["Admin"] != null)
Line 280: {
Line 281: if (Request.QueryString["Admin"].ToString() == "Reset")
Line 282: {
Line 283: //do
Line 284: //{
Line 285: ds = oProductService.GetAllIndustryProductDetails(siteid);
Line 286: // }
Line 287: // while (ds.Tables.Count < 10);
Line 288: if (ds != null && ds.Tables.Count < 10)
Line 289: {
Line 290: ds = oProductService.GetAllIndustryProductDetails(siteid);
Line 291: }
Line 292: }
Line 293: }
Line 294: Session["promocode"] = string.Empty;
Line 295: Session["Page"] = null;
Line 296: Session["SalesAmount"] = "0";
Line 297: CheckIPName();
Line 298: }
Line 299: private void CheckIPName()
Line 300: {
Line 301: string IP = Request.ServerVariables["REMOTE_ADDR"];
Line 302: //string IP = "196.185.169.184";
Line 303: //string IP = "12.21.13.255";
Line 304: string Idval = "0";
Line 305: string returnValue = string.Empty;
Line 306: string conString = ConfigurationManager.ConnectionStrings["GetIPDB"].ConnectionString;
Line 307: SqlConnection sqlConn = new SqlConnection(conString);
Line 308: try
Line 309: {
Line 310: DataTable dt = new DataTable();
Line 311: SqlDataAdapter sdt = new SqlDataAdapter();
Line 312:
Line 313:
Line 314: SqlCommand sqlCmd = new SqlCommand("proc_GetLocation", sqlConn);
Line 315: sqlCmd.CommandType = CommandType.StoredProcedure;
Line 316: sqlCmd.Parameters.AddWithValue("@ip", IP);
Line 317: sqlConn.Open();
Line 318: sdt.SelectCommand = sqlCmd;
Line 319: sdt.Fill(dt);
Line 320: Session["CountryIDVal"] = dt.Rows[0]["CountryID"].ToString();
Line 321: Session["CountryVal"] = dt.Rows[0]["CountryName"].ToString();
Line 322:
Line 323: }
Line 324: catch
Line 325: {
Line 326: //Handle Error
Line 327: }
Line 328: finally
Line 329: {
Line 330: sqlConn.Close();
Line 331: }
Line 332:
Line 333:
Line 334: }
Line 335:
Line 336: public void Session_End(object sender, EventArgs e)
Line 337: {
Line 338: // Code that runs when a session ends.
Line 339: // Note: The Session_End event is raised only when the sessionstate mode
Line 340: // is set to InProc in the Web.config file. If session mode is set to StateServer
Line 341: // or SQLServer, the event is not raised.
Line 342:
Line 343: }
Line 344: public void Application_BeginRequest(object sender, EventArgs e)
Line 345: {
Line 346: //UsernameToken token1 = new UsernameToken(username, password, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendPlainText);
Line 347: //oProductService.RequestSoapContext.Security.Tokens.Add(token1);
Line 348: }
Line 349: }
|