所以这就是问题所在.我有一个公共类库,包含所有存储库,域和映射文件,因此库可以在其他Web beased应用程序中重用.现在,在这个类库中,有一段代码允许自己创建一个在其存储库中使用的会话工厂.代码看起来像这样.
private static ISessionFactory sessionFactory;
private static Configuration configuration;
public static Configuration Configuration()
{
if (configuration == null)
{
configuration = new Configuration().Configure();
}
return configuration;
}
private static ISessionFactory SessionFactory
{
get
{
if (sessionFactory == null)
{
sessionFactory = Configuration().BuildSessionFactory();
}
return sessionFactory;
}
}
public static ISession GetCurrentSession()
{
if (!CurrentSessionContext.HasBind(SessionFactory))
{
CurrentSessionContext.Bind(SessionFactory.OpenSession());
}
return SessionFactory.GetCurrentSession();
}
Run Code Online (Sandbox Code Playgroud)
因此,存储库调用GetCurrentSession()方法来获取ISession.现在这工作正常,但我担心它可能不是线程安全的.任何人都可以帮助我一个方法,帮助我使线程安全.
几点注意事项:
我已经考虑过在启动事件的web应用程序的global.asax中配置和构建SessionFactory,但问题是所讨论的公共类库在20个不同的应用程序中使用,这意味着要进入所有应用程序并更新在我这样做之前的global.asax文件我想在那里提出问题,看看是否还有其他方法可以解决这个问题.这样公共类库可以配置其SessionFactory本身,但仍然是线程安全的.
感谢您阅读这个巨大的问题.将提供任何帮助.
我正在与FedEx国际船舶服务集成.但我真的被困在一个方面.我正在尝试使用他们的测试环境创建原产地证书.我已经遵循了xml架构,并提出了以下代码
private static void SetCustomInvoice(ProcessShipmentRequest request)
{
request.RequestedShipment.ShippingDocumentSpecification = new ShippingDocumentSpecification();
request.RequestedShipment.ShippingDocumentSpecification.ShippingDocumentTypes = new RequestedShippingDocumentType[1] { new RequestedShippingDocumentType() };
request.RequestedShipment.ShippingDocumentSpecification.ShippingDocumentTypes[0] = RequestedShippingDocumentType.CERTIFICATE_OF_ORIGIN;
request.RequestedShipment.ShippingDocumentSpecification.CertificateOfOrigin = new CertificateOfOriginDetail();
request.RequestedShipment.ShippingDocumentSpecification.CertificateOfOrigin.DocumentFormat = new ShippingDocumentFormat { StockType = ShippingDocumentStockType.STOCK_4X6, ImageType = ShippingDocumentImageType.PDF, ImageTypeSpecified = true, StockTypeSpecified = true };
request.RequestedShipment.SpecialServicesRequested = new ShipmentSpecialServicesRequested();
request.RequestedShipment.SpecialServicesRequested.SpecialServiceTypes = new ShipmentSpecialServiceType[1] { new ShipmentSpecialServiceType() };
request.RequestedShipment.SpecialServicesRequested.SpecialServiceTypes[0] = ShipmentSpecialServiceType.ELECTRONIC_TRADE_DOCUMENTS;
request.RequestedShipment.SpecialServicesRequested.EtdDetail = new EtdDetail();
request.RequestedShipment.SpecialServicesRequested.EtdDetail.RequestedDocumentCopies = new RequestedShippingDocumentType[1] { RequestedShippingDocumentType.CERTIFICATE_OF_ORIGIN };
request.RequestedShipment.SpecialServicesRequested.EtdDetail.DocumentReferences = new UploadDocumentReferenceDetail[1] { new UploadDocumentReferenceDetail() };
request.RequestedShipment.SpecialServicesRequested.EtdDetail.RequestedDocumentCopies[0] = …Run Code Online (Sandbox Code Playgroud) 我有一份清单
IList<IRule> allRules = new List<IRule>()
Run Code Online (Sandbox Code Playgroud)
在该列表中,我继续并随机添加不同类型的规则,即
allRules.add(DeleteRule1)
allRules.add(AddRule1)
allRules.add(DeleteRule2)
allRules.add(EditRule1)
allRules.add(AddRule2)
allRules.add(DeleteRule3)
Run Code Online (Sandbox Code Playgroud)
所有这一切工作正常,我想弄清楚的是,我需要这个列表进行排序,所以它首先有所有的AddRules然后EditRules,最后是DeleteRules.
任何人都可以指定我可以采取的方法吗?
如果这没有意义,请告诉我,我会尝试更详细地解释.
非常感谢
更新:问题是我的应用程序Global.asax.cs并非源自Sitecore.Web.Application.
所以我刚刚使用MongoDB 2.6.11安装了Sitecore 8.
出于测试目的,我将下面的代码放在页面加载事件中,以激活我之前在sitecore中创建的目标.
目标是通过部署和发布成功创建的.我还确认了目标的项目ID是正确的.
if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.Current.CurrentPage != null)
{
Sitecore.Data.Items.Item GoaltoTrigger = Sitecore.Context.Database.GetItem("{EDA8EA2C-7AF5-4D0F-AF76-A9C4E6BD7169}");
if (GoaltoTrigger != null)
{
Sitecore.Analytics.Data.Items.PageEventItem registerthegoal = new Sitecore.Analytics.Data.Items.PageEventItem(GoaltoTrigger);
Sitecore.Analytics.Model.PageEventData eventData = Sitecore.Analytics.Tracker.Current.CurrentPage.Register(registerthegoal);
eventData.Data = GoaltoTrigger["Description"];
Sitecore.Analytics.Tracker.Current.Interaction.AcceptModifications();
}
}
Session.Abandon();
Run Code Online (Sandbox Code Playgroud)
遗憾的是,这不起作用,我无法在交互下的xDB中看到目标.
我调查的其他事情是我的布局肯定有标签
<sc:VisitorIdentification runat="server" />
Run Code Online (Sandbox Code Playgroud)
我的Global.asax实现了Sitecore.Web.Application
public class Global : Sitecore.Web.Application
Run Code Online (Sandbox Code Playgroud)
但没有运气.在Mongo中无法看到交互(使用mongo shell和roboMongo来查找集合).我错过了别的什么吗?
Sitecore错误
ManagedPoolThread #3 16:43:00 INFO Job ended: Sitecore.ListManagement.Analytics.UnlockContactListsAgent (units processed: )
12980 16:43:05 INFO Cache created: '[no name]' (max size: 976KB, running total: 2918MB)
12980 16:43:05 INFO Cache …Run Code Online (Sandbox Code Playgroud) Arial在Sitecore 8的文本编辑器中将字体设置为默认字体的最佳方法是什么?我环顾四周,看到有关更改的说明toolsfile.xml.那是对的吗?
c# ×3
sitecore ×2
sitecore8 ×2
fedex ×1
generics ×1
list ×1
mongodb ×1
nhibernate ×1
sitecore-xdb ×1