• 将指定的年月日转初始化为DateTime新的实例(Nop.Admin.Controllers.OrderController.ParseProductAttributes)

    case AttributeControlType.Datepicker:
    {
    var day = form[controlId + "_day"];
    var month = form[controlId + "_month"];
    var year = form[controlId + "_year"];
    DateTime? selectedDate = null;
    try
    {

    selectedDate = new DateTime(Int32.Parse(year), Int32.Parse(month), Int32.Parse(day));
    }
    catch { }
    if (selectedDate.HasValue)
    {
    attributesXml = _productAttributeParser.AddProductAttribute(attributesXml,
    attribute, selectedDate.Value.ToString("D"));
    }
    }
    break;
  • 能否出订单信息(\src\Presentation\Nop.Web\Administration\Controllers\OrderController.cs(1346))
try
{
byte[] bytes = _exportManager.ExportOrdersToXlsx(orders);
return File(bytes, MimeTypes.TextXlsx, "orders.xlsx");
}
catch (Exception exc)
{
ErrorNotification(exc);
return RedirectToAction("List");
}
  • 发送HTTP请求(\src\Plugins\Nop.Plugin.ExchangeRate.EcbExchange\EcbExchangeRateProvider.cs(60))

    //get exchange rates to euro from European Central Bank
    var request = (HttpWebRequest)WebRequest.Create("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
    try
    {
    using (var response = request.GetResponse())
    {
    //load XML document
    var document = new XmlDocument();
    document.Load(response.GetResponseStream()); //add namespaces
    var namespaces = new XmlNamespaceManager(document.NameTable);
    namespaces.AddNamespace("ns", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref");
    namespaces.AddNamespace("gesmes", "http://www.gesmes.org/xml/2002-08-01"); //get daily rates
    var dailyRates = document.SelectSingleNode("gesmes:Envelope/ns:Cube/ns:Cube", namespaces);
    DateTime updateDate;
    if (!DateTime.TryParseExact(dailyRates.Attributes["time"].Value, "yyyy-MM-dd", null, DateTimeStyles.None, out updateDate))
    updateDate = DateTime.UtcNow; foreach (XmlNode currency in dailyRates.ChildNodes)
    {
    //get rate
    decimal currencyRate;
    if (!decimal.TryParse(currency.Attributes["rate"].Value, out currencyRate))
    continue; ratesToEuro.Add(new Core.Domain.Directory.ExchangeRate()
    {
    CurrencyCode = currency.Attributes["currency"].Value,
    Rate = currencyRate,
    UpdatedOn = updateDate
    });
    }
    }
    }
    catch (WebException ex)
    {
    _logger.Error("ECB exchange rate provider", ex);
    }
  • EF操作(\src\Libraries\Nop.Data\EfRepository.cs(182))
    try
    {
    if (entities == null)
    throw new ArgumentNullException("entities"); foreach (var entity in entities)
    this.Entities.Remove(entity); this._context.SaveChanges();
    }
    catch (DbEntityValidationException dbEx)
    {
    throw new Exception(GetFullErrorText(dbEx), dbEx);
    }
  • \src\Libraries\Nop.Core\WebHelper.cs(46)
            protected virtual Boolean IsRequestAvailable(HttpContextBase httpContext)
    {
    if (httpContext == null)
    return false; try
    {
    if (httpContext.Request == null)
    return false;
    }
    catch (HttpException)
    {
    return false;
    }
    return true;
    }
  • \src\Libraries\Nop.Core\Plugins\PluginManager.cs(434)
    try
    {
    File.Copy(plug.FullName, shadowCopiedPlug.FullName, true);
    }
    catch (IOException)
    {
    Debug.WriteLine(shadowCopiedPlug.FullName + " is locked, attempting to rename");
    //this occurs when the files are locked,
    //for some reason devenv locks plugin files some times and for another crazy reason you are allowed to rename them
    //which releases the lock, so that it what we are doing here, once it's renamed, we can re-shadow copy
    try
    {
    var oldFile = shadowCopiedPlug.FullName + Guid.NewGuid().ToString("N") + ".old";
    File.Move(shadowCopiedPlug.FullName, oldFile);
    }
    catch (IOException exc)
    {
    throw new IOException(shadowCopiedPlug.FullName + " rename failed, cannot initialize plugin", exc);
    }
    //ok, we've made it this far, now retry the shadow copy
    File.Copy(plug.FullName, shadowCopiedPlug.FullName, true);
    }

ASP.NET常见异常处理示例的更多相关文章

  1. ASP.NET Core 异常处理与日志记录

    1. ASP.NET Core 异常处理与日志记录 1.1. 异常处理 1.1.1. 异常产生的原因及处理 1.1.2. ASP.NET Core中启动开发人员异常页面 1.2. 日志记录 1.2.1 ...

  2. Asp.Net Core异常处理整理

    目前版本是Asp.Net Core v1.1,这个版本的感觉对Http请求中的错误处理方便不是很完善. 没有HttpException异常类,不能在任何的地方自由的抛出对应的异常状态. 一.默认的异常 ...

  3. [整理]ASP.NET 中异常处理

    [整理]ASP.NET 中异常处理 1.直接通过重写Controller的OnException来处理异常 public class HomeController : Controller { pub ...

  4. ASP.NET中异常处理的注意事项

    一.ASP.NET中需要引发异常的四类情况 1.如果运行代码后,造成内存泄漏.资源不可用或应用程序状态不可恢复,则引发异常.Console这个类中,有很多类似这样的代码: if ((value < ...

  5. ASP.NET MVC异常处理

    ASP.NET MVC异常处理方案 如何保留异常前填写表单的数据 ASP.NET MVC中的统一化自定义异常处理 MVC过滤器详解 MVC过滤器使用案例:统一处理异常顺道精简代码 ASP.NET MV ...

  6. Java Socket常见异常处理 和 网络编程需要注意的问题

    在java网络编程Socket通信中,通常会遇到以下异常情况: 第1个异常是 java.net.BindException:Address already in use: JVM_Bind. 该异常发 ...

  7. [转]Linux中find常见用法示例

    Linux中find常见用法示例[转]·find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \;find命令的参 ...

  8. EDI数据导入的注意事项&常见异常处理

    EXCEL表格注意事项: •      编码是0开头的,格式必须是文本,否则前面请加字母: •      注意全角半角,中文标点英文标点: •      编号文字类开头和结尾不要有空格,姓名中间也不要 ...

  9. Linux下命令行cURL的10种常见用法示例

    curl的命令行工具功能非常强大,这些数据交互的功能基本上都是通过URL方式进行的,下面这篇文章主要给大家分享了在Linux中命令行cURL的10种常见用法示例,通过示例代码介绍的非常详细,需要的朋友 ...

随机推荐

  1. 每天一个linux命令:chgrp

    1.命令简介         chgrp(Change group) 用来将每个指定文件的所属组设置为指定值.如果使用 --reference,则将每个文件的所属组设置为与指定参考文件相同. 2.用法 ...

  2. 【Linux】关于ffmpeg的一些常见用法

    一.FFmpeg简介 FFmpeg是一款非常快速的视频和音频转换器, 是开源项目 FFmpeg (Fast Forward moving pictures expert group) 的命令行程序. ...

  3. Centos7.4修改主机名HostName颜色及格式

    一.打开 .bashrc文件 1.位置:~(cd ~)目录下 2.cat .bashrc 原文件内容如下: # .bashrc # User specific aliases and function ...

  4. 【转】WPF 与 WinForm 间的按键值(枚举)转换

    There is a function for that in System.Windows.Input.KeyInterop static class. Try:var inputKey = Key ...

  5. Syncfusion SfDataGrid 导出Excel

    var options = new ExcelExportingOptions { ExcelVersion = ExcelVersion.Excel2013, }; //不需要导出的字段 optio ...

  6. WPF Button 样式

    WPF CheckBox 自定义样式 给Button设置ToolTip <Style TargetType="{x:Type Button}" x:Key="Def ...

  7. DTO转DOMAIN动态转换类。

    package dtotransfer.util; import dtotransfer.annotation.DomainField; import java.lang.annotation.Ann ...

  8. (原)关于ffmpeg使用custom io-context遇到的一些坑

    今天在使用android-as_video_player这个开源的框架来实现自己项目中的一个播放器,中间关于ndk编译ffmpeg遇到的坑,现在想起来,对ndk的心态,现在心里都有一万个cnm在奔腾, ...

  9. MSSQL和MYSQL数据库降权

    在服务器上如果是 system 用户在运行 MySQL ,这个是非常危险的,一旦Mysql 出现漏洞,或被其他模式提权,直接就是 system 权限.所以我们现在要给MySQL降权! 作用:增强服务器 ...

  10. Python sqlite3操作笔记

    创建数据库 def create_tables(dbname): conn = sqlite3.connect(dbname) print "Opened database successf ...