@@ -1549,6 +1549,7 @@ public static string RazorTemplRenderList(string razorTemplName, int moduleid, s
15491549 return RazorTemplRenderList ( razorTemplName , moduleid , cacheKey , objList , templateControlPath , theme , lang , settings , null ) ;
15501550 }
15511551
1552+ private static string lockobjectRazorTemplRenderList = "lockitRazorTemplRenderList" ;
15521553 public static string RazorTemplRenderList ( string razorTemplName , int moduleid , string cacheKey , List < NBrightInfo > objList , string templateControlPath , string theme , string lang , Dictionary < string , string > settings , NBrightInfo headerData )
15531554 {
15541555 // do razor template
@@ -1560,51 +1561,59 @@ public static string RazorTemplRenderList(string razorTemplName, int moduleid, s
15601561 var razorTempl = ( string ) GetModCache ( ckey ) ;
15611562 if ( razorTempl == null || StoreSettings . Current . DebugMode )
15621563 {
1563- razorTempl = GetRazorTemplateData ( razorTemplName , templateControlPath , theme , lang ) ;
1564- if ( razorTempl != "" )
1564+ lock ( lockobjectRazorTemplRenderList )
15651565 {
1566- var nbRazor = new NBrightRazor ( objList . Cast < object > ( ) . ToList ( ) , settings , HttpContext . Current . Request . QueryString ) ;
1567- nbRazor . ModuleId = moduleid ;
1568- nbRazor . FullTemplateName = theme + "." + razorTemplName ;
1569- nbRazor . TemplateName = razorTemplName ;
1570- nbRazor . ThemeFolder = theme ;
1571- nbRazor . Lang = lang ;
1572-
1573- nbRazor . HeaderData = headerData ;
1574-
1575- var razorTemplateKey = "NBrightBuyRazorKey" + theme + razorTemplName + PortalSettings . Current . PortalId . ToString ( ) ;
1576- razorTempl = RazorRender ( nbRazor , razorTempl , razorTemplateKey , StoreSettings . Current . DebugMode ) ;
1577- if ( cacheKey != "" ) SetModCache ( moduleid , ckey , razorTempl ) ; // only save to cache if we pass in a cache key.
1566+ razorTempl = GetRazorTemplateData ( razorTemplName , templateControlPath , theme , lang ) ;
1567+ if ( razorTempl != "" )
1568+ {
1569+ var nbRazor = new NBrightRazor ( objList . Cast < object > ( ) . ToList ( ) , settings , HttpContext . Current . Request . QueryString ) ;
1570+ nbRazor . ModuleId = moduleid ;
1571+ nbRazor . FullTemplateName = theme + "." + razorTemplName ;
1572+ nbRazor . TemplateName = razorTemplName ;
1573+ nbRazor . ThemeFolder = theme ;
1574+ nbRazor . Lang = lang ;
1575+
1576+ nbRazor . HeaderData = headerData ;
1577+
1578+ var razorTemplateKey = "NBrightBuyRazorKey" + theme + razorTemplName + PortalSettings . Current . PortalId . ToString ( ) ;
1579+ razorTempl = RazorRender ( nbRazor , razorTempl , razorTemplateKey , StoreSettings . Current . DebugMode ) ;
1580+ if ( cacheKey != "" ) SetModCache ( moduleid , ckey , razorTempl ) ; // only save to cache if we pass in a cache key.
1581+ }
15781582 }
15791583 }
15801584 return razorTempl ;
15811585 }
15821586
1587+ private static string lockobjectRenderGroupCategoryList = "lockitRenderGroupCategoryList" ;
15831588 public static string RazorTemplRenderGroupCategoryList ( string razorTemplName , int moduleid , string cacheKey , List < GroupCategoryData > objList , string templateControlPath , string theme , string lang , Dictionary < string , string > settings )
15841589 {
15851590 // do razor template
15861591 var cachekey = "NBrightBuyRazorOutputGrp" + theme + razorTemplName + "*" + cacheKey + PortalSettings . Current . PortalId . ToString ( ) ;
15871592 var razorTempl = ( string ) GetModCache ( cachekey ) ;
15881593 if ( razorTempl == null || StoreSettings . Current . DebugMode )
15891594 {
1590- razorTempl = GetRazorTemplateData ( razorTemplName , templateControlPath , theme , lang ) ;
1591- if ( razorTempl != "" )
1595+ lock ( lockobjectRenderGroupCategoryList )
15921596 {
1593- var nbRazor = new NBrightRazor ( objList . Cast < object > ( ) . ToList ( ) , settings , HttpContext . Current . Request . QueryString ) ;
1594- nbRazor . ModuleId = moduleid ;
1595- nbRazor . FullTemplateName = theme + "." + razorTemplName ;
1596- nbRazor . TemplateName = razorTemplName ;
1597- nbRazor . ThemeFolder = theme ;
1598- nbRazor . Lang = lang ;
1599-
1600- var razorTemplateKey = "NBrightBuyRazorKey" + theme + razorTemplName + PortalSettings . Current . PortalId . ToString ( ) ;
1601- razorTempl = RazorRender ( nbRazor , razorTempl , razorTemplateKey , StoreSettings . Current . DebugMode ) ;
1602- if ( cacheKey != "" ) SetModCache ( moduleid , cachekey , razorTempl ) ; // only save to cache if we pass in a cache key.
1597+ razorTempl = GetRazorTemplateData ( razorTemplName , templateControlPath , theme , lang ) ;
1598+ if ( razorTempl != "" )
1599+ {
1600+ var nbRazor = new NBrightRazor ( objList . Cast < object > ( ) . ToList ( ) , settings , HttpContext . Current . Request . QueryString ) ;
1601+ nbRazor . ModuleId = moduleid ;
1602+ nbRazor . FullTemplateName = theme + "." + razorTemplName ;
1603+ nbRazor . TemplateName = razorTemplName ;
1604+ nbRazor . ThemeFolder = theme ;
1605+ nbRazor . Lang = lang ;
1606+
1607+ var razorTemplateKey = "NBrightBuyRazorKey" + theme + razorTemplName + PortalSettings . Current . PortalId . ToString ( ) ;
1608+ razorTempl = RazorRender ( nbRazor , razorTempl , razorTemplateKey , StoreSettings . Current . DebugMode ) ;
1609+ if ( cacheKey != "" ) SetModCache ( moduleid , cachekey , razorTempl ) ; // only save to cache if we pass in a cache key.
1610+ }
16031611 }
16041612 }
16051613 return razorTempl ;
16061614 }
16071615
1616+ private static string lockobjectRazorPreProcessTempl = "lockitRazorPreProcessTempl" ;
16081617 public static Dictionary < string , string > RazorPreProcessTempl ( string razorTemplName , string templateControlPath , string theme , string lang , Dictionary < string , string > settings , string moduleid = "" )
16091618 {
16101619 // match the "AddPreProcessMetaData()" cachekey.
@@ -1618,37 +1627,40 @@ public static Dictionary<string, string> RazorPreProcessTempl(string razorTemplN
16181627 if ( cachedlist != null ) return cachedlist ;
16191628 }
16201629
1621- // build cache data from template.
1622- var razorTemplate = GetRazorTemplateData ( razorTemplName , templateControlPath , theme , lang ) ;
1623- if ( razorTemplate != "" && razorTemplate . Contains ( "AddPreProcessMetaData" ) )
1624- {
1625- var obj = new NBrightInfo ( true ) ;
1626- obj . Lang = lang ;
1627- obj . ModuleId = - 1 ;
1628- var l = new List < object > ( ) ;
1629- l . Add ( obj ) ;
1630- var modRazor = new NBrightRazor ( l , settings , HttpContext . Current . Request . QueryString ) ;
1631- modRazor . FullTemplateName = theme + "." + razorTemplName ;
1632- modRazor . TemplateName = razorTemplName ;
1633- modRazor . ThemeFolder = theme ;
1634- modRazor . Lang = lang ;
1635- try
1630+ lock ( lockobjectRazorPreProcessTempl )
1631+ {
1632+ // build cache data from template.
1633+ var razorTemplate = GetRazorTemplateData ( razorTemplName , templateControlPath , theme , lang ) ;
1634+ if ( razorTemplate != "" && razorTemplate . Contains ( "AddPreProcessMetaData" ) )
16361635 {
1637- // do razor and cache preprocessmetadata
1638- razorTemplate = RazorRender ( modRazor , razorTemplate , cachekey , false ) ;
1636+ var obj = new NBrightInfo ( true ) ;
1637+ obj . Lang = lang ;
1638+ obj . ModuleId = - 1 ;
1639+ var l = new List < object > ( ) ;
1640+ l . Add ( obj ) ;
1641+ var modRazor = new NBrightRazor ( l , settings , HttpContext . Current . Request . QueryString ) ;
1642+ modRazor . FullTemplateName = theme + "." + razorTemplName ;
1643+ modRazor . TemplateName = razorTemplName ;
1644+ modRazor . ThemeFolder = theme ;
1645+ modRazor . Lang = lang ;
1646+ try
1647+ {
1648+ // do razor and cache preprocessmetadata
1649+ razorTemplate = RazorRender ( modRazor , razorTemplate , cachekey , false ) ;
1650+ }
1651+ catch ( Exception ex )
1652+ {
1653+ // Only log exception, could be a error because of missing data. The preprocessing doesn't care.
1654+ }
1655+ cachedlist = ( Dictionary < string , string > ) Utils . GetCache ( cachekey ) ;
1656+ if ( cachedlist == null ) cachedlist = new Dictionary < string , string > ( ) ;
1657+ Utils . SetCache ( cachekey , cachedlist ) ;
16391658 }
1640- catch ( Exception ex )
1659+ else
16411660 {
1642- // Only log exception, could be a error because of missing data. The preprocessing doesn't care.
1661+ cachedlist = new Dictionary < string , string > ( ) ;
1662+ Utils . SetCache ( cachekey , cachedlist ) ;
16431663 }
1644- cachedlist = ( Dictionary < string , string > ) Utils . GetCache ( cachekey ) ;
1645- if ( cachedlist == null ) cachedlist = new Dictionary < string , string > ( ) ;
1646- Utils . SetCache ( cachekey , cachedlist ) ;
1647- }
1648- else
1649- {
1650- cachedlist = new Dictionary < string , string > ( ) ;
1651- Utils . SetCache ( cachekey , cachedlist ) ;
16521664 }
16531665 return cachedlist ;
16541666 }
0 commit comments