• 将指定的年月日转初始化为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. Jacoco统计web接口/功能测试的代码覆盖率【转】

    原文:https://www.jianshu.com/p/d2fd02d4164b 一.代码覆盖率 通常我们在做单元测试的时候会接触到代码覆盖率的概念,通过在单元测试的过程中收集代码覆盖率去判断测试用 ...

  2. sqlite基础

    常用命令 sqlite3提供的特殊命令, 以.开头: .help: 帮助 .databases: 列出数据库 .tables: 列出表名 .open dbname: 打开数据库 .save dbnam ...

  3. 单片机成长之路(51基础篇) - 007 CH340CH341最全说明

    比较全的CH340,CH341应用说明 CH340 以前用USB转串口时图方便一般也都是直接买现成的USB转串口模块,但是后面设计需要,不等不将CH340这个模块集成到电路板中,经过多次失败,终于得到 ...

  4. [转]调试利器-SSH隧道

    在开发微信公众号或小程序的时候,由于微信平台规则的限制,部分接口需要通过线上域名才能正常访问.但我们一般都会在本地开发,因为这能快速的看到源码修改后的运行结果.但当涉及到需要调用微信接口时,由于不和你 ...

  5. 使用protobuf编译onnx.proto过程中的一些问题总结

    使用git clone下载protobuf的源代码,然后git checkout到branch2.7.0: 编译protobuf,先在代码顶层目录执行./configure,然后执行make,成功后执 ...

  6. 关于python协程中aiorwlock 使用问题

    最近工作中多个项目都开始用asyncio aiohttp aiomysql aioredis ,其实也是更好的用python的协程,但是使用的过程中也是遇到了很多问题,最近遇到的就是 关于aiorwl ...

  7. csproj文件中copy指令的使用方式

    实际开发中有很多项目需要引用第三方的dll或者资源文件,且文件比较多,在运行时这些文件需要被拷贝到BIN目录. 使用VS自带的"复制到输出目录",似然方便,但是比较不零活,经过多次 ...

  8. Asp.Net WebApi接口返回值IHttpActionResult

    WebApi是微软在VS2012 MVC4版本中绑定发行的,webapi2.0同mvc5发行的 webapi一共有以下接口返回值 1.void无返回值2.IHttpActionResult Json( ...

  9. 范型方法 & 范型参数 & 范型返回值

    Java范型类 public class FanXingClassTest { public static void main(String args[]){ Test<Integer> ...

  10. 电子商务(电销)平台中订单模块(Order)数据库设计明细(转)

    以下是自己在电子商务系统设计中的订单模块的数据库设计经验总结,而今发表出来一起分享,如有不当,欢迎跟帖讨论~ 订单表 (order)|-- 自动编号(order_id, 自增长主键)|-- 订单单号( ...