这是一个很好的.. 应该提到这是Sitecore 6.5
我们一直使用这种方法以编程方式将文件上传到sitecore的媒体库多年,没有任何问题:
public static MediaItem CreateMediaItem(string mediaLibraryPath, string filePath, string altText, bool overwriteExisting)
{
MediaCreatorOptions options = new MediaCreatorOptions();
options.Database = Factory.GetDatabase("master");
options.Language = Sitecore.Globalization.Language.Parse(Settings.DefaultLanguage);
options.Versioned = Settings.Media.UploadAsVersionableByDefault;
options.KeepExisting = !overwriteExisting;
options.Destination = mediaLibraryPath.StartsWith("/") ?
"/sitecore/media library" + mediaLibraryPath :
"/sitecore/media library/" + mediaLibraryPath;
options.FileBased = Settings.Media.UploadAsFiles;
options.AlternateText = altText;
MediaCreator creator = new MediaCreator();
MediaItem created = creator.CreateFromFile(filePath, options);
return created;
}
在我们尝试创建媒体项目之前,我们已经验证了
Media.MaxSizeInDatabase
等),我们正在尝试的文件大约是6MB而且不应该成为问题Media.UploadAsFiles
配置true或false的相同结果。由于我无法控制的力量,我无法直接调试出现此问题的环境,但我确实有日志记录。
通过记录,我们的应用程序中的一切都很好,直到我们尝试使用上述方法创建项目。一旦这个方法被击中一切都会停止。我所说的一切
并且sitecore最终会重启。但是没有先前冻结的错误。
现在,如果我将方法包装在try catch中,我会获得更多结果,虽然很奇怪 - 在sitecore重新启动后,会记录带有异常的catch块。这里是整个记录
3368 16:30:57 INFO Media Path: /Company Documents/ZeSubdomain/Small Doc Three
3368 16:30:57 INFO File Path: F:\ZeCompany\Websites\zesite.com\web\temp\a686d5a4-d3b4-474c-b54e-927edb247a84\QA Test Plan.docx
//This is when the method is hit!
4004 16:32:13 INFO HttpModule is being initialized
3728 16:33:28 INFO Scheduler - Adding agents
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.DatabaseAgent (interval: 00:10:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.DatabaseAgent (interval: 00:10:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.UrlAgent (interval: 01:00:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.TaskDatabaseAgent (interval: 00:10:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.CompactClientDataAgent (interval: 04:00:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.CleanupHistory (interval: 04:00:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.CleanupPublishQueue (interval: 04:00:00)
3728 16:33:28 INFO Scheduler - Adding agent: Sitecore.Tasks.CleanupEventQueue (interval: 04:00:00)
3728 16:33:28 INFO Scheduler - Skipping inactive agent: Sitecore.Tasks.HtmlCacheClearAgent
3728 16:33:29 INFO Scheduler - Skipping inactive agent: Sitecore.Tasks.PublishAgent
3728 16:33:29 INFO Scheduler - Adding agent: Sitecore.Tasks.CleanupAgent (interval: 06:00:00)
3728 16:33:29 INFO Scheduler - Adding agent: Sitecore.Tasks.CloneNotificationsCleanupAgent (interval: 1.00:00:00)
3728 16:33:29 INFO Scheduler - Adding agent: Sitecore.Tasks.CleanupFDAObsoleteMediaData (interval: 1.00:00:00)
3728 16:33:29 INFO Scheduler - Adding agent: Sitecore.Tasks.WebDAVOptionsCleanupAgent (interval: 1.00:00:00)
3728 16:33:29 INFO Scheduler - Agents added
ManagedPoolThread #3 16:38:29 INFO Job started: Sitecore.Tasks.DatabaseAgent
ManagedPoolThread #3 16:38:29 INFO Scheduling.DatabaseAgent started. Database: core
ManagedPoolThread #3 16:38:29 INFO Examining schedules (count: 0)
ManagedPoolThread #3 16:38:29 INFO Job ended: Sitecore.Tasks.DatabaseAgent (units processed: )
ManagedPoolThread #4 16:38:29 INFO Job started: Sitecore.Tasks.DatabaseAgent
ManagedPoolThread #4 16:38:29 INFO Scheduling.DatabaseAgent started. Database: master
ManagedPoolThread #4 16:38:29 INFO Examining schedules (count: 1)
ManagedPoolThread #4 16:38:29 INFO Starting: __Task Schedule
ManagedPoolThread #4 16:38:29 INFO Ended: __Task Schedule
ManagedPoolThread #4 16:38:29 INFO Job ended: Sitecore.Tasks.DatabaseAgent (units processed: 1)
ManagedPoolThread #5 16:38:29 INFO Job started: Sitecore.Tasks.TaskDatabaseAgent
ManagedPoolThread #5 16:38:29 INFO Processing tasks (count: 0)
ManagedPoolThread #5 16:38:29 INFO Job ended: Sitecore.Tasks.TaskDatabaseAgent (units processed: )
3896 16:39:01 INFO HttpModule is being initialized
3516 16:40:22 INFO HttpModule is being initialized
3368 16:41:11 INFO Failed on mediaCreateItem!
Exception: System.Threading.ThreadAbortException
Message: Thread was being aborted.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters)
at Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper)
at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert)
at Sitecore.Search.SearchManager.get_SearchConfiguration()
at Sitecore.Data.Managers.IndexingManager.UpdateIndexAsync(Database database)
at Sitecore.MainUtil.RaiseEvent[T](EventHandler`1 subscribers, Object sender, T eventArgs)
at Sitecore.Data.Engines.HistoryEngine.RegisterItemCreated(Item item)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at Sitecore.Data.Engines.DataCommands.CreateItemCommand.Executed()
at Sitecore.Data.Engines.EngineCommand`2.Execute()
at Sitecore.Data.Engines.DataEngine.CreateItem(String itemName, Item destination, ID templateId, ID newId)
at Sitecore.Data.Managers.ItemProvider.CreateItem(String itemName, Item destination, ID templateId, ID newId, SecurityCheck securityCheck)
at Sitecore.Data.Managers.ItemManager.CreateItem(String itemName, Item destination, ID templateId, ID newId, SecurityCheck securityCheck)
at Sitecore.Data.Managers.ItemManager.CreateItem(String itemName, Item destination, ID templateId, ID newId)
at Sitecore.Nexus.Data.DataCommands.AddFromTemplateCommand.(String itemName, Item destination, ID templateId, ID newId)
at Sitecore.Nexus.Data.NexusDataApi.AddFromTemplate(ID templateId, Item destination, String itemName, ID newId)
at Sitecore.Data.Engines.DataCommands.AddFromTemplateCommand.DoExecute()
at Sitecore.Data.Engines.EngineCommand`2.Execute()
at Sitecore.Data.Engines.DataEngine.AddFromTemplate(String itemName, ID templateId, Item destination, ID newId)
at Sitecore.Data.Managers.ItemProvider.AddFromTemplate(String itemName, ID templateId, Item destination, ID newId)
at Sitecore.Data.Managers.ItemManager.AddFromTemplate(String itemName, ID templateId, Item destination, ID newItemId)
at Sitecore.Data.Managers.ItemManager.AddFromTemplate(String itemName, ID templateId, Item destination)
at Sitecore.Data.Items.Item.Add(String name, TemplateID templateID)
at Sitecore.Data.Items.Item.Add(String name, TemplateItem template)
at Sitecore.Resources.Media.MediaCreator.CreateItem(String itemPath, String filePath, MediaCreatorOptions options)
at Sitecore.Resources.Media.MediaCreator.AttachStreamToMediaItem(Stream stream, String itemPath, String fileName, MediaCreatorOptions options)
at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, MediaCreatorOptions options)
at Sitecore.Resources.Media.MediaCreator.CreateFromFile(String filePath, MediaCreatorOptions options)
at PreparisCore.Utilities.SitecoreHelper.MasterDatabase.CreateMediaItem(String mediaLibraryPath, String filePath, String altText, Boolean overwriteExisting) in c:\TeamCity\BuildAgents\Production\work\4a6b68672be2163f\main\CompanyCore\Utilities\SitecoreHelper.cs:line 682
at PreparisCore.Utilities.DocumentHelper.SaveDocumentMediaFile(Document doc, Boolean storePreparis, Boolean storePrivate, FileUpload fileUpload) in c:\TeamCity\BuildAgents\Production\work\4a6b68672be2163f\main\CompanyCore\Utilities\DocumentHelper.cs:line 292
3368 16:41:13 ERROR Application error.
Exception: System.Web.HttpException
Message: Request timed out.
这是方法调用后的整整10分钟。
直到最近,这还没有出现问题,据我所知,我们没有做出任何远程影响该系统任何部分的更改。任何人都可以猜测可能会导致这种情况或从哪里开始寻找?除了直接调试之外,我怎样才能获得更多的诊断信息?