Orchard 324没有数据仅在Web服务器上使用自定义模块发送错误

时间:2012-12-31 17:49:58

标签: iis-7 module orchardcms application-pool timeoutexception

我刚开始遇到一个非常奇怪的问题,我的自定义模块直到昨晚才开始发生。基本上当我尝试请求我为模块创建的自定义视图时,前几页显示正常,然后突然其余的这些内容项页面超时,直到我回收应用程序池。 (在浏览器中我得到324没有数据发送错误)。我也没有在App_Data文件夹下的错误日志中收到与此事件有关的错误。

以下是我在事件查看器中收到的错误:

3005 
   An unhandled exception has occurred. 
   12/31/2012 12:03:17 PM 
   12/31/2012 5:03:17 PM 
   59d62d1f2da347caafd2dee71266126f 
   43 
   1 
   0 
   /LM/W3SVC/10/ROOT-2-130014459492939950 
   Full 
   / 
   E:\Inetpub\Test-Website\ 
   SERVERNAME 

   24756 
   w3wp.exe 
   NT AUTHORITY\NETWORK SERVICE 
   TimeoutException 
   Transaction Timeout  
   (the url was displayed here)
   admin 
   True 
   Forms 
   NT AUTHORITY\NETWORK SERVICE 
   39 
   NT AUTHORITY\NETWORK SERVICE 
   False 

我的开发计算机上没有此问题(在iis或visual studio上运行网站不会重现问题)。

我几乎肯定是设置了模块,以便有效地处理每个连接。此外,考虑到自从网站启动以来(现在大约一个月)没有发生这种情况,我猜它与代码无关。

以下是我如何设置服务类的示例:

    namespace Example.Services
{
    public interface IDocumentNoteService : ITransientDependency
    {
        List<DocumentNoteRecord> GetNotes(int? packageId, int noteTypeId);
    }

    public class DocumentNoteService : IDocumentNoteService
    {
        private readonly IRepository<DocumentNoteRecord> _docNoteRepo;

        public DocumentNoteService(IRepository<DocumentNoteRecord> docNoteRepo)
        {
            _docNoteRepo = docNoteRepo;
            Logger = NullLogger.Instance;
            T = NullLocalizer.Instance;
        }

        public ILogger Logger { get; set; }
        public Localizer T { get; set; }        

        public List<DocumentNoteRecord> GetNotes(int? packageId, int noteTypeId)
        {
                try {
                    var Notes = _docNoteRepo.Table.Where(x => x.Package_Id == packageId).Where(x => x.Note_Type_Id == noteTypeId).ToList();
                    _docNoteRepo.Flush();
                    return Notes;
                }
                catch (Exception ex) {
                    Logger.Error(ex, "There was a problem getting the document notes for this tour.");
                }
            return Enumerable.Empty<DocumentNoteRecord>().ToList<DocumentNoteRecord>();
        }

    }
}

以下是零件驱动程序的代码:

 namespace ExampleCode.Drivers
{
    public class TourPartDriver : ContentPartDriver<TourPart> {
        private readonly ITourPartService _tourPartService;
        private readonly ITourDateService _tourDateService;
        private readonly IItinDetailService _tourItinDetailsService;
        private readonly IExperiencesService _tourExpService;
        private readonly ITourOptionService _tourOptionService;
        private readonly IDestinationFactService _destinationFactService;
        private readonly IDestinationFactManager _destinationFactManager;
        private readonly IDocumentNoteService _documentNoteService;
        private readonly IPackageUpgradesService _packageUpgradesService;

         public TourPartDriver(
             ITourPartService tourService, 
             ITourDateService tourDateService,
             IItinDetailService tourItinDetailsService,
             IExperiencesService tourExpService,
             ITourOptionService tourOptionService,
             IDestinationFactService destinationFactService,
             IDestinationFactManager destinationFactManager,
             IDocumentNoteService documentNoteService,
             IPackageUpgradesService packageUpgradesService
             ) {
             _tourPartService = tourService;
             _tourDateService = tourDateService;
             _tourItinDetailsService = tourItinDetailsService;
             _tourExpService = tourExpService;
             _tourOptionService = tourOptionService;
             _destinationFactService = destinationFactService;
             _destinationFactManager = destinationFactManager;
             _documentNoteService = documentNoteService;
             _packageUpgradesService = packageUpgradesService;

             Logger = NullLogger.Instance;
             T = NullLocalizer.Instance;
         }

         public ILogger Logger { get; set; }
         public Localizer T { get; set; }

        protected override DriverResult Display(
            TourPart part, string displayType, dynamic shapeHelper) {
            return ContentShape("Parts_Tour", () => shapeHelper.Parts_Tour(
                TourID: part.tour_id,
                TourName: part.tour_name,
                PackageID: part.package_id,
                Highlights: _tourExpService.GetTourExperiences(part.tour_id, part.package_id),
                Description: part.description,
                TourDates: _tourDateService.GetTourDatesDD(part.tour_id),
                TourItinDetails: _tourItinDetailsService.GetItinDetails(part.package_id),
                InitialTourOffsetDate: _tourDateService.GetInitialTourDateOffset(part.package_id),
                TourOptions: _tourOptionService.GetInitialTourOptions(part.package_id),
                TourPrice: _tourDateService.GetTourPrice(part.package_id),
                TourNumDays: _tourItinDetailsService.GetTourNumDays(part.package_id),
                TourNumMeals: _tourDateService.GetTourNumMeals(part.package_id),
                DestinationFacts:_destinationFactManager.GetCategoryFacts(part.package_id),
                PleaseNote: _documentNoteService.GetNotes(part.package_id, (int)NoteTypes.DocNoteType.PleaseNote),
                WebRemarks: _documentNoteService.GetNotes(part.package_id, (int)NoteTypes.DocNoteType.WebRemarks),
                Pace: _documentNoteService.GetNotes(part.package_id, (int)NoteTypes.DocNoteType.Pace),
                PackageUpgrades: _packageUpgradesService.GetInitialPackageUpgrades(part.package_id)
                ));               
        }
    }
}

以下是视图的代码:

@{

List<DocumentNoteRecord> pleaseNote = Model.PleaseNote;
List<DocumentNoteRecord> webRemarks = Model.WebRemarks;
List<DocumentNoteRecord> pace = Model.Pace;

if (pleaseNote.Count > 0)
{
    <h4 class="tourSubTitle1">Please Note</h4>
    foreach (var note in pleaseNote) {
       <p>@Html.Raw(note.Note)</p>
    }
 }

 if (webRemarks.Count > 0) {
         <h4 class="tourSubTitle1">Web Remarks</h4>
         foreach (var noteRemark in webRemarks) {
             <p>@Html.Raw(noteRemark.Note)</p>

         }
     }

if (pace.Count > 0)
{
    <h4 class="tourSubTitle1">Pace</h4>
    foreach (var notePace in pace)
    {
       <p>@Html.Raw(notePace.Note)</p>
    }
 }

}

任何帮助将不胜感激!我肯定在这里泡芙。

感谢。

1 个答案:

答案 0 :(得分:0)

永远不要将记录传递到视图中。这样做可以捕获数据库上下文,并可能导致连接泄漏或更糟。使用类似于视图模型的普通对象构建您的形状,并且不包含持久性实体。