• 将指定的年月日转初始化为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. (原)DropBlock A regularization method for convolutional networks

    转载请注明出处: https://www.cnblogs.com/darkknightzh/p/9985027.html 论文网址: https://arxiv.org/abs/1810.12890 ...

  2. 并行排序ShearSort ---[MPI , c++]

    思想: (1) 对于一个nxm的数组,使用N个work进行处理. (2) 先按行对数组进行升序和降序排序[由左至右],一般奇数序列work升序,偶数序号的work进行降序 (3)再按列对数组进行升序排 ...

  3. html5利用websocket完成的推送功能(tomcat)

    html5利用websocket完成的推送功能(tomcat) 利用websocket和java完成的消息推送功能,服务器用的是tomcat7.0.42,一些东西是自己琢磨的,也不知道恰不恰当,不恰当 ...

  4. SpringBoot中自定义properties文件配置参数并带有输入提示

    1. 创建配置类 在项目中创建一个参数映射类如下 @ConfigurationProperties(prefix = "user.info") public class MyPro ...

  5. linux内核剖析(十)进程间通信之-信号量semaphore

    信号量 什么是信号量 信号量的使用主要是用来保护共享资源,使得资源在一个时刻只有一个进程(线程)所拥有. 信号量的值为正的时候,说明它空闲.所测试的线程可以锁定而使用它.若为0,说明它被占用,测试的线 ...

  6. android4.2 telephone应用层分析

    InCallScreen.java 复制通话界面的显示和提供人机交互的接口.进入该界面第一个调用ONCreate.否则进入OnNewIntent,该配置文件是incall_screen.xml,当中i ...

  7. 【转载】Linux下查看CPU、内存占用率

    不错的文章(linux系统性能监控--CPU利用率):https://blog.csdn.net/ctthuangcheng/article/details/52795477 在linux的系统维护中 ...

  8. 微信小程序--data的赋值与取值

    通过小程序官方文档可知:Page() 函数用来注册一个页面.接受一个 object 参数,其指定页面的初始数据.生命周期函数.事件处理函数等.其中的参数data用来设置初始数据,WXML 中的动态数据 ...

  9. Asp.Net MVC三层架构之autofac使用教程

    开发环境:vs2015..net4.5.2.mvc5.ef6 Autofac简介 IOC控制反转(Inversion of Control,缩写为IOC),Autofac是一个开源的依赖注入框架,Au ...

  10. 解决Warning Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.

    系统:Ubuntu 16.04 LTS 环境:vscode+java extension pack打开了一个gradle的java项目:另外,用一个terminal启动了groovysh 报错: gr ...