在Sitecore自动化项目创建过程中命令&q;超时 [英] Command "timing out" during Sitecore automated item creation

查看:18
本文介绍了在Sitecore自动化项目创建过程中命令&q;超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个命令,它已经添加到Sitecore编辑器中的"国家"节点。该命令将生成其下面50个状态节点的列表。然后,它遍历状态节点(一次一个),并生成每个状态节点下的本地节点列表。在本地节点列表中,我遍历它们并检查新项是否存在-如果不存在,我将其添加(创建)为本地节点下的子项。最终,在此命令执行期间将添加近300个本地项目。

有没有更有效的方法(快速查询将300个本地节点放到一个列表中,然后检查项目是否存在并创建它)?如果是这样的话,我不知道该怎么做。

我不确定手术中最昂贵的部分是什么。最终,我仍在执行多达300个单独的查询来检查它是否在那里,然后是INSERT语句,因此可能仍需要一段时间才能运行。如果是,Web配置中的哪个设置会增加Sitecore中适用的"超时"设置?示例结构如下:

//Derive the template from the name of the item (page) that was passed in - this assumes that the template name and the item name are the same
Sitecore.Data.Database database = Sitecore.Data.Database.GetDatabase("master");                

TemplateItem contentPageTemplate = database.SelectSingleItem("fast:/sitecore/Templates/User Defined/Home/Pages/Local Site/" + newPage);

Sitecore.Data.Items.Item[] stateNodes = null;
Sitecore.Data.Items.Item[] localNodes = null;
Item localHomePage = null;
Item newLocalPage = null;
int webBusinessID = 0;
string ID = "";
WebBusiness business;

//Get all of the immediate child nodes (state pages) under the "parent" node ("National Locations") - and put them into a list or array                

stateNodes = database.SelectItems("fast:/sitecore/content/Home/National Locations/*");

for (int i = 0; i < stateNodes.Length; i++)
{ 

  if (stateNodes[i].Children.Count > 0)
  {
    localNodes = database.SelectItems("fast:/sitecore/content/Home/National Locations/" + stateNodes[i].Fields["State Abbreviation"].ToString() + "/*");
  }
  else
  {
    //Do nothing
  }                   

  for (int j = 0; j < localNodes.Length; j++)
  {
    localHomePage = localNodes[j];

    if (localHomePage.Publishing.IsPublishable(DateTime.Now, false) == true)                        
    {   

      //If the new page does not exist, create it
      if (localHomePage.Children[newPage] == null)
      {
        newLocalPage = localHomePage.Add(newPage, contentPageTemplate);
        counter = counter + 1;
      }
      else
      {
        //Additional business logic
      }
    }
  }
}

推荐答案

除非我遗漏了您那里没有的逻辑/代码,否则我认为您可以通过更改xpath:

将其简化为一个查询以到达本地节点
localNodes = database.SelectItems("fast:/sitecore/content/Home/National Locations/*/*");

更改为获取"National Locations"直接子项的所有直接子项

这篇关于在Sitecore自动化项目创建过程中命令&q;超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆