/// <summary> /// 将异常保存在数据库中备查 /// </summary> /// <param name="trace"></param> /// <param name="data"></param> private void HandleException(string trace, string data) { var bll = new ErrorBLL(); var obj = bll.GetObject(); obj.ErrorData = data; obj.ErrorMessage = trace; bll.Add(obj); }
/// <summary> /// Date Modified: 15/11/2011 /// Modified By: Josehine Gad /// (description) Capture error and insert in Exception Table /// =================================== /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Application_Error(object sender, EventArgs e) { //Server.Transfer("/Message.aspx"); //Response.Redirect("~/Message.aspx"); if (Server.GetLastError() != null) { Exception objErr = Server.GetLastError().GetBaseException(); DateTime currentDate = CommonFunctions.GetCurrentDateTime(); ErrorBLL.InsertError(objErr.Message, objErr.StackTrace.ToString(), Request.Url.AbsolutePath, currentDate, CommonFunctions.GetDateTimeGMT(currentDate), User.Identity.Name); Exception objError = Server.GetLastError().GetBaseException(); HttpContext.Current.Application.Remove("lastException"); HttpContext.Current.Application.Add("lastException", objError); Response.Redirect("~/Message.aspx?aspxerrorpath=" + Request.Url.AbsolutePath); } }
private string GetContent(AdPageInfoVO info, HttpContext context) { string curl = context.Request.Params["_curl"] ?? ""; string html = DN.Framework.Utility.HtmlHelper.DecodeHtml(info.Content); LogAdQcodeVO log = new LogAdQcodeVO(); log.AdId = info.Id; log.AdUserId = info.UserId; log.BrowseName = DN.Framework.Utility.ClientHelper.GetBrowseName(); log.BrowseType = DN.Framework.Utility.ClientHelper.GetUserAgent(); log.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion(); log.ClientId = GetClentId(context.Request, context.Response); log.ClientIp = DN.Framework.Utility.ClientHelper.ClientIP(); log.CreateDate = DateTime.Now; log.IsMobile = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0; log.OsName = DN.Framework.Utility.ClientHelper.GetOsName(); log.QcodeId = 0; log.ReferrerUrl = DN.Framework.Utility.ClientHelper.GetReferer(); log.Time = int.Parse(DateTime.Now.ToString("yyyyMMdd")); log.Url = curl; //获取统计代码 if (!string.IsNullOrEmpty(info.UserCode)) { html = html + DN.Framework.Utility.HtmlHelper.DecodeHtml(info.UserCode); } //配置的二维码信息 if (!string.IsNullOrEmpty(info.QcodeImg)) { var qcode = AdQcodeInfoBLL.Instance.GetRandQcode(info.Id); if (qcode != null) { log.QcodeId = qcode.Id; string url = qcode.QcodeUrl; if (!string.IsNullOrEmpty(url)) { var list = info.QcodeImg.Split(','); foreach (var item in list) { if (!string.IsNullOrEmpty(item)) { html = html.Replace(item, url); } } html = html.Replace("$QcodeUrl$", url); //替换微信相关内容 } } else { if (!string.IsNullOrEmpty(info.DefaultQcode)) { var list = info.QcodeImg.Split(','); foreach (var item in list) { if (!string.IsNullOrEmpty(item)) { html = html.Replace(item, info.DefaultQcode); } } } } } //如果没有配置相关内容,替换相关内容 html = html.Replace("$QcodeUrl$", ""); try { if (DN.WeiAd.Business.Config.AppConfig.IsLogBrowse == 0) { LogAdQcodeBLL.Instance.Add(log); } else { ErrorBLL.Add <LogAdQcodeVO>(log); } } catch (Exception ex) { ErrorBLL.Add <LogAdQcodeVO>(ex, log); DN.Framework.Utility.LogHelper.Write(ex.Message, "errorqcode"); } return(html); }
public void ProcessRequest(HttpContext context) { articleinfo tinfo = new articleinfo(); LogBrowseVO log = new LogBrowseVO(); tinfo.title = "我的标题"; tinfo.content = "我喜欢你"; try { context.Response.ContentType = "text/json"; string pname = context.Request.Params["_pname"] ?? ""; string curl = context.Request.Params["_curl"] ?? ""; string hisurl = context.Request.Params["_hisurl"] ?? ""; string adid = context.Request.Params["id"] ?? "0"; string filepath = Path.GetFileName(pname); string PageName = filepath; int last = PageName.IndexOf("?"); if (last != -1) { PageName = PageName.Substring(0, last); } log.BrowseType = DN.Framework.Utility.ClientHelper.GetUserAgent(); log.ClientIp = DN.Framework.Utility.ClientHelper.ClientIP(); log.CreateDate = DateTime.Now; log.AdUrl = pname; log.IsMoney = 0; log.Money = 0; log.Time = int.Parse(DateTime.Now.ToString("yyyyMMdd")); log.ClientId = GetClentId(context.Request, context.Response); log.IsMobile = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0; log.ReferrerUrl = hisurl; log.OsName = DN.Framework.Utility.ClientHelper.GetOsName(); log.BrowseName = DN.Framework.Utility.ClientHelper.GetBrowseName(); log.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion(); log.Url = curl; var ipinfo = DN.WeiAd.Business.Services.IpTaoBaoHelper.GetIpResult(log.ClientIp); if (ipinfo.code == 0 && ipinfo.data != null) { log.Country = ipinfo.data.country; log.Area = ipinfo.data.area; log.City = ipinfo.data.city; log.Region = ipinfo.data.region; log.County = ipinfo.data.county; log.Isp = ipinfo.data.isp; } bool ispass = true; if (DN.WeiAd.Business.Config.AppConfig.IsIpArea == 1) { if (DN.WeiAd.Business.Config.AppConfig.IpAreas.Count != 0) { foreach (var item in DN.WeiAd.Business.Config.AppConfig.IpAreas) { if (log.Region.IndexOf(item) != -1) { ispass = false; break; } } } } //检查ISP if (log.Isp.IndexOf("腾讯") != -1) { ispass = false; } //是否通过 if (ispass) { var adinfo = AdPageInfoBLL.Instance.GetModelById(int.Parse(adid)); if (adinfo == null) { adinfo = AdPageInfoBLL.Instance.GetModelById(int.Parse(adid)); } if (adinfo != null) { log.AdUserId = adinfo.UserId; log.AdId = adinfo.Id; } string content = string.Empty; string title = string.Empty; if (adinfo != null) { content = GetContent(adinfo, context); title = adinfo.Title; } tinfo.title = title; tinfo.content = content; } else { var info = ArticleInfoBLL.Instance.GetRandModel(); if (info != null) { tinfo.title = info.Title; tinfo.content = DN.Framework.Utility.HtmlHelper.DecodeHtml(info.Content); } } if (DN.WeiAd.Business.Config.AppConfig.IsLogBrowse == 1) { ErrorBLL.Add <LogBrowseVO>(log); } } catch (Exception ex) { ErrorBLL.Add <LogBrowseVO>(ex, log); DN.Framework.Utility.LogHelper.Write(ex.Message, "error"); } LogBrowseBLL.Instance.Add(log); string json = DN.Framework.Utility.Serializer.SerializeObject(tinfo); context.Response.ClearContent(); context.Response.Write(json); context.Response.End(); }
public void ProcessRequest(HttpContext context) { LogBrowseVO log = new LogBrowseVO(); try { context.Response.ContentType = "text/plain"; string pname = context.Request.Params["_pname"] ?? ""; string curl = context.Request.Params["_curl"] ?? ""; string hisurl = context.Request.Params["_hisurl"] ?? ""; string filepath = Path.GetFileName(pname); //string fileExt = Path.GetExtension(filepath); string PageName = filepath; int last = PageName.IndexOf("?"); if (last != -1) { PageName = PageName.Substring(0, last); } log.BrowseType = DN.Framework.Utility.ClientHelper.GetUserAgent(); log.ClientIp = DN.Framework.Utility.ClientHelper.ClientIP(); log.CreateDate = DateTime.Now; log.AdUrl = pname; log.IsMoney = 0; log.Money = 0; log.Time = int.Parse(DateTime.Now.ToString("yyyyMMdd")); log.ClientId = GetClentId(context.Request, context.Response); log.IsMobile = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0; log.ReferrerUrl = hisurl; log.OsName = DN.Framework.Utility.ClientHelper.GetOsName(); log.BrowseName = DN.Framework.Utility.ClientHelper.GetBrowseName(); log.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion(); log.Url = curl; var ipinfo = DN.WeiAd.Business.Services.IpTaoBaoHelper.GetIpResult(log.ClientIp); if (ipinfo.code == 0 && ipinfo.data != null) { log.Country = ipinfo.data.country; log.Area = ipinfo.data.area; log.City = ipinfo.data.city; log.Region = ipinfo.data.region; log.County = ipinfo.data.county; log.Isp = ipinfo.data.isp; } var userpage = AdUserPageBLL.Instance.GetModelByPageName(PageName); if (userpage != null) { var info = AdPageInfoBLL.Instance.GetModelById(userpage.AdPageId); if (info != null) { //访问日志 log.AdUserId = info.UserId; log.AdId = info.Id; if (userpage != null) { log.FlowUserId = userpage.FlowUserId; } } } else { var info = AdPageInfoBLL.Instance.GetModelByViewPage(PageName); if (info != null) { log.AdId = info.Id; log.AdUserId = info.UserId; } } if (DN.WeiAd.Business.Config.AppConfig.IsLogBrowse == 0) { LogBrowseBLL.Instance.Add(log); } else { ErrorBLL.Add <LogBrowseVO>(log); } } catch (Exception ex) { ErrorBLL.Add <LogBrowseVO>(ex, log); DN.Framework.Utility.LogHelper.Write(ex.Message, "errorlogbrow"); } }
/// <summary> /// Date Created: 16/11/2011 /// Created By: Josephine Gad /// (description) Create excel file of hotel manifest and email /// --------------------------------------------------------------------------- /// </summary> private void BindPortManifestExcel() { DataTable dt = null; try { SeafarerTravelBLL bll = new SeafarerTravelBLL(); dt = bll.GetSFPortTravelDetailsWithCount(GlobalCode.Field2String(Session["DateFrom"]), Session["Date"].ToString(), uoHiddenFieldUser.Value, GlobalCode.Field2String(Session["strPendingFilter"]), GlobalCode.Field2String(Session["Region"]), GlobalCode.Field2String(Session["Country"]), GlobalCode.Field2String(Session["City"]), uoDropDownListStatus.SelectedValue, uoDropDownListFilterBy.SelectedValue, uoTextBoxFilter.Text.Trim(), GlobalCode.Field2String(Session["Port"]), uoDropDownListVessel.SelectedValue, uoDropDownListNationality.SelectedValue, uoDropDownListGender.SelectedValue, uoDropDownListRank.SelectedValue, uoHiddenFieldRole.Value, Int16.Parse(uoHiddenFieldByVessel.Value), Int16.Parse(uoHiddenFieldByName.Value), Int16.Parse(uoHiddenFieldByRecLoc.Value), Int16.Parse(uoHiddenFieldByE1ID.Value), Int16.Parse(uoHiddenFieldByDateOnOff.Value), Int16.Parse(uoHiddenFieldByStatus.Value), Int16.Parse(uoHiddenFieldByPort.Value), Int16.Parse(uoHiddenFieldByRank.Value), Int16.Parse(uoHiddenFieldByPortStatus.Value), Int16.Parse(uoHiddenFieldByNationality.Value), 0, uolistviewPortTravelInfoPager.TotalRowCount); uoGridViewPortManifest.Visible = true; if (dt.Rows.Count > 0) { uoGridViewPortManifest.DataSource = dt; } else { uoGridViewPortManifest.EmptyDataText = "No Record."; } uoGridViewPortManifest.DataBind(); ////auto save string FilePath = MapPath("~/Extract/PortManifest/"); string sDate = DateTime.Now.ToString(TravelMartVariable.DateTimeFormatFileExtension); FileInfo FileName = new FileInfo(FilePath + "PortManifest_" + sDate + ".xls"); Response.Clear(); Response.ClearContent(); StringWriter stringWrite = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); uoGridViewPortManifest.RenderControl(htmlWrite); FileStream fs = new FileStream(FileName.FullName, FileMode.Create); StreamWriter sWriter = new StreamWriter(fs, Encoding.GetEncoding("UTF-8")); sWriter.Write(stringWrite.ToString().Trim()); sWriter.Close(); fs.Close(); //Use below line instead of Response.End() to avoid Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.; HttpContext.Current.ApplicationInstance.CompleteRequest(); ManifestSendEmail("Travelmart: Port Manifest", "This is a sample Port Manifest", FileName.FullName); AlertMessage("Email sent."); } catch (Exception ex) { DateTime currentDate = CommonFunctions.GetCurrentDateTime(); ErrorBLL.InsertError(ex.Message, ex.StackTrace.ToString(), Request.Url.AbsolutePath, currentDate, CommonFunctions.GetDateTimeGMT(currentDate), GlobalCode.Field2String(Session["UserName"])); AlertMessage(ex.Message); } finally { if (dt != null) { dt.Dispose(); } uoGridViewPortManifest.Visible = false; } }
private void BindPage() { string filepath = Path.GetFileName(Request.FilePath); string fileExt = Path.GetExtension(filepath); string PageName = filepath; int last = PageName.IndexOf("?"); if (last != -1) { PageName = PageName.Substring(0, last); } //访问日志 AdBrowseVO log = new AdBrowseVO(); try { var userpage = AdUserPageBLL.Instance.GetModelByPageName(PageName); log.BrowseType = DN.Framework.Utility.ClientHelper.GetBrowseInfo(); log.ClientIp = DN.Framework.Utility.ClientHelper.ClientIP(); log.CreateDate = DateTime.Now; log.AdUrl = Request.Url.ToString(); log.IsMoney = 0; log.Money = 0; log.Time = int.Parse(DateTime.Now.ToString("yyyyMMdd")); log.ClientId = GetClentId(); log.IsMobile = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0; log.ReferrerUrl = DN.Framework.Utility.ClientHelper.GetReferer(); log.OsName = DN.Framework.Utility.ClientHelper.GetOsName(); log.BrowseName = DN.Framework.Utility.ClientHelper.GetBrowseName(); log.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion(); if (userpage != null) { var info = AdPageInfoBLL.Instance.GetModelById(userpage.AdPageId); ltPageTitle.Text = info.Title; ltTitle.Text = info.Title; ltContent.Text = GetContent(info); var usercode = UserCodeInfoBLL.Instance.GetModelById(info.UserCodeId); if (usercode != null) { ltUserCode.Text = DN.Framework.Utility.HtmlHelper.DecodeHtml(usercode.CodeContent); } if (userpage != null) { log.FlowUserId = userpage.FlowUserId; } log.Url = AdPageInfoBLL.Instance.GetAdViewUrl(info.ViewPage); log.AdUserId = info.UserId; log.AdId = info.Id; //检查是否计费,如果为0则计费,否则不计费 //log.IsMoney = AdBrowseBLL.Instance.GetRecords(new AdBrowsePara() { ClientIp = log.ClientIp, AdId = log.AdId }); //if (log.IsMoney == 0) //{ // //log.Money = adinfo.ClickMoney; //} ////扣费信息 //if (log.IsMoney == 0) //{ // var account = AccountInfoBLL.Instance.GetSingle(new AccountInfoPara() { Id = adinfo.UserId }); // if (account != null) // { // account.Money = account.Money - log.Money; // account.ConsumptionMoney = account.ConsumptionMoney + log.Money; // account.LastMoneyDate = DateTime.Now; // AccountInfoBLL.Instance.Edit(account); // } //} } else { var info = AdPageInfoBLL.Instance.GetModelByViewPage(PageName); ltPageTitle.Text = info.Title; ltTitle.Text = info.Title; ltContent.Text = GetContent(info); ltUserCode.Text = DN.Framework.Utility.HtmlHelper.DecodeHtml(info.UserCode); log.Url = AdPageInfoBLL.Instance.GetAdViewUrl(info.ViewPage); log.AdUserId = info.UserId; log.AdId = info.Id; } if (Config.AppConfig.IsLogBrowse == 0) { AdBrowseBLL.Instance.Add(log); } else { ErrorBLL.Add <AdBrowseVO>(log); } } catch (Exception ex) { ErrorBLL.Add <AdBrowseVO>(ex, log); DN.Framework.Utility.LogHelper.Write(ex.Message, "erroradv0"); } }
private void BindPage() { string filepath = Path.GetFileName(Request.FilePath); string fileExt = Path.GetExtension(filepath); string PageName = filepath; int last = PageName.IndexOf("?"); if (last != -1) { PageName = PageName.Substring(0, last); } //访问日志 AdBrowseVO log = new AdBrowseVO(); try { var userpage = AdUserPageBLL.Instance.GetModelByPageName(PageName); log.BrowseType = DN.Framework.Utility.ClientHelper.GetBrowseInfo(); log.ClientIp = DN.Framework.Utility.ClientHelper.ClientIP(); log.CreateDate = DateTime.Now; log.AdUrl = Request.Url.ToString(); log.IsMoney = 0; log.Money = 0; log.Time = int.Parse(DateTime.Now.ToString("yyyyMMdd")); log.ClientId = GetClentId(); log.IsMobile = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0; log.ReferrerUrl = DN.Framework.Utility.ClientHelper.GetReferer(); log.OsName = DN.Framework.Utility.ClientHelper.GetOsName(); log.BrowseName = DN.Framework.Utility.ClientHelper.GetBrowseName(); log.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion(); if (Config.AppConfig.IsArticleView == 1) { var artilce = ArticleInfoBLL.Instance.GetRandModel(); ltPageTitle.Text = artilce.Title; ltTitle.Text = artilce.Title; ltContent.Text = DN.Framework.Utility.HtmlHelper.DecodeHtml(artilce.Content); } if (userpage != null) { var info = AdPageInfoBLL.Instance.GetModelById(userpage.AdPageId); log.Url = AdPageInfoBLL.Instance.GetAdViewUrl(info.ViewPage); log.AdUserId = info.UserId; log.AdId = info.Id; ltUserCode.Text = info.Id.ToString(); } else { var info = AdPageInfoBLL.Instance.GetModelByViewPage(PageName); log.Url = AdPageInfoBLL.Instance.GetAdViewUrl(info.ViewPage); log.AdUserId = info.UserId; log.AdId = info.Id; ltUserCode.Text = info.Id.ToString(); } if (Config.AppConfig.IsLogBrowse == 0) { AdBrowseBLL.Instance.Add(log); } else { ErrorBLL.Add <AdBrowseVO>(log); } } catch (Exception ex) { ErrorBLL.Add <AdBrowseVO>(ex, log); DN.Framework.Utility.LogHelper.Write(ex.Message, "erroradv1"); } }
/// Date Created: 16/11/2011 /// Created By: Josephine Gad /// (description) Create excel file of hotel manifest and email /// --------------------------------------------------------------------------- /// </summary> private void BindVehicleManifestExcel() { string strLogDescription; string strFunction; DataTable dt = null; try { dt = SeafarerTravelBLL.GetSFVehicleTravelListView( GlobalCode.Field2String(Session["DateFrom"]), GlobalCode.Field2String(Session["DateTo"]), GlobalCode.Field2String(Session["strPendingFilter"]), uoDropDownListFilterBy.SelectedValue, uoTextBoxFilter.Text.Trim(), GlobalCode.Field2String(Session["UserName"]), uoDropDownListStatus.SelectedValue, uoDropDownListNationality.SelectedValue, uoDropDownListGender.SelectedValue, uoDropDownListRank.SelectedValue, uoDropDownListVessel.SelectedValue, GlobalCode.Field2String(Session["Region"]), GlobalCode.Field2String(Session["Country"]), GlobalCode.Field2String(Session["City"]), GlobalCode.Field2String(Session["Port"]), GlobalCode.Field2String(Session["Hotel"]), Session["Vehicle"].ToString(), GlobalCode.Field2String(Session["UserRole"])); uoGridViewVehicleManifest.Visible = true; if (dt.Rows.Count > 0) { uoGridViewVehicleManifest.DataSource = dt; } else { uoGridViewVehicleManifest.EmptyDataText = "No Record."; } uoGridViewVehicleManifest.DataBind(); ////auto save string FilePath = MapPath("~/Extract/VehicleManifest/"); string sDate = DateTime.Now.ToString(TravelMartVariable.DateTimeFormatFileExtension); FileInfo FileName = new FileInfo(FilePath + "VehicleManifest_" + sDate + ".xls"); Response.Clear(); Response.ClearContent(); StringWriter stringWrite = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); uoGridViewVehicleManifest.RenderControl(htmlWrite); FileStream fs = new FileStream(FileName.FullName, FileMode.Create); StreamWriter sWriter = new StreamWriter(fs, Encoding.GetEncoding("UTF-8")); sWriter.Write(stringWrite.ToString().Trim()); sWriter.Close(); fs.Close(); //Use below line instead of Response.End() to avoid Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.; HttpContext.Current.ApplicationInstance.CompleteRequest(); ManifestSendEmail("Travelmart: Vehicle Manifest", "This is a sample Vehicle Manifest", FileName.FullName); AlertMessage("Email sent."); //Insert log audit trail (Gabriel Oquialda - 17/11/2011) strLogDescription = "Vehicle manifest as .xls file was sent to e-mail."; strFunction = "BindVehicleManifestExcel"; DateTime dateNow = CommonFunctions.GetCurrentDateTime(); //BLL.AuditTrailBLL.InsertLogAuditTrail(strLogDescription, strFunction, Path.GetFileName(Request.Path), // CommonFunctions.GetDateTimeGMT(dateNow), DateTime.Now, GlobalCode.Field2String(Session["UserName"])); } catch (Exception ex) { DateTime currentDate = CommonFunctions.GetCurrentDateTime(); ErrorBLL.InsertError(ex.Message, ex.StackTrace.ToString(), Request.Url.AbsolutePath, currentDate, CommonFunctions.GetDateTimeGMT(currentDate), GlobalCode.Field2String(Session["UserName"])); AlertMessage(ex.Message); } finally { if (dt != null) { dt.Dispose(); } uoGridViewVehicleManifest.Visible = false; } }