我正在尝试访问查询字符串参数并将其保存到Session变量.由于我正在处理的解决方案有几个基本布局,最简单的方法是将其添加到管道处理程序.但是,我的代码失败了,因为args.Context.Session为null:
public class SaveQueryStringToSession : HttpRequestProcessor
{
public override void Process(HttpRequestArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string queryString = WebUtil.GetQueryString("parm1");
if (queryString.Length <= 0)
return;
args.Context.Session["parm1"] = queryString;
}
}
Run Code Online (Sandbox Code Playgroud)
将此方法插入HttpRequestBegin或HttpRequestEnd管道时会发生这种情况.很想知道为什么,以及在这里使用标准的变通方法或模式.(是的,我会添加一个空检查.不需要指出它.)
我在IIS 7.5(集成.Net 2.0)上运行Sitecore Sitecore.NET 6.4.1(rev.110720)
可能相关的链接:
我开始尝试使用Rhino-Mocks(3.6),同时阅读Roy Osherove的单元测试艺术.他有一个示例,演示了当使用相同的参数调用两次时,可以编写一个mocked方法来返回不同的结果:
[Test]
public void ReturnResultsFromMock()
{
MockRepository repository = new MockRepository();
IGetRestuls resultGetter = repository.DynamicMock<IGetRestuls>();
using(repository.Record())
{
resultGetter.GetSomeNumber("a");
LastCall.Return(1);
resultGetter.GetSomeNumber("a");
LastCall.Return(2);
resultGetter.GetSomeNumber("b");
LastCall.Return(3);
}
int result = resultGetter.GetSomeNumber("b");
Assert.AreEqual(3, result);
int result2 = resultGetter.GetSomeNumber("a");
Assert.AreEqual(1, result2);
int result3 = resultGetter.GetSomeNumber("a");
Assert.AreEqual(2, result3);
}
Run Code Online (Sandbox Code Playgroud)
这很好用.但是当我使用Stub尝试同样的事情,以及接受并返回字符串的方法时,我无法生成第二个返回值:
[Test]
public void StubMethodWithStringParameter_ScriptTwoResponses_SameResponseReceived()
{
MockRepository mocks = new MockRepository();
IMessageProvider stub = mocks.Stub<IMessageProvider>();
using (mocks.Record())
{
stub.GetMessageForValue("a");
LastCall.Return("First call");
stub.GetMessageForValue("a");
LastCall.Return("Second call");
}
Assert.AreEqual("First call", stub.GetMessageForValue("a"));
Assert.AreEqual("Second call", stub.GetMessageForValue("a"));
}
}
public …Run Code Online (Sandbox Code Playgroud) 我可以使用代码知道如何检测用户是否处于页面编辑器模式?这是因为,我有一个组件,当用户从页面编辑器浏览时,它将搜索master_index文件夹而不是web_index文件夹.
根据Sitecore数据定义参考,版本6.4,第4.3.1节:
Sitecore使用可能的禁用技术处理查询.如果数据提供程序支持所请求的查询,则可以是SQL数据库,也可以是Sitecore数据管理器.
如果是这样,使用"fast:"语法有什么好处吗?什么版本的自动技术选择被引入?
更新 我想我弄清楚了.Reqular Sitecore查询只有在没有谓词的情况下才能使用SQL Server.快速查询允许简单谓词(例如*[@ somefield ='somevalue']),同时仍然使用SQL Server.
来自Sitecore CMS 6.4数据定义参考(第4.3.4节):
SQL Server数据提供程序不支持谓词(用方括号括起来的搜索字符串部分:[@ IsHidden!='1']).
从Sitecore CMS 6使用Sitecore快速查询(第4.2节):
本节介绍Sitecore Fast Query中可用的谓词.谓词总是嵌在方括号中.
Example: fast:/sitecore/content/Home/*[@Title = 'Welcome to Sitecore']
Run Code Online (Sandbox Code Playgroud)
结果:返回将"标题"字段的值设置为"欢迎使用Sitecore"的项目.搜索在Home Item的子项中执行.
Rvest 选择选项,我认为用一个可重现的例子来解释是最容易的
网站:http : //www.verema.com/vinos/portada 我想获取葡萄酒的类型(Tipos de vinos),在 html 代码中是:
<select class="campo select" id="producto_tipo_producto_id" name="producto[tipo_producto_id]">
<option value="">Todos</option>
<option value="211">Tinto</option>
<option value="213">Blanco</option>
<option value="215">Rosado</option>
<option value="216">Espumoso</option>
<option value="217">Dulces y Generosos</option></select>
XPath : //*[@id="producto_tipo_producto_id"] or
CSS : #producto_tipo_producto_id or
Class: campo select
Run Code Online (Sandbox Code Playgroud)
我想要一个 data.frame 作为
211 丁托
213 布兰科
215 罗萨多
第216章
第217话
我的代码(R):
library(rvest)
Pagina.R <- html(x = "http://www.verema.com/vinos/portada")
text <- Pagina.R %>%
html_nodes(xpath='//*[@id="producto_tipo_producto_id"]')%>%
html_text()
text
values <- Pagina.R %>%
html_nodes(xpath='//*[@id="producto_tipo_producto_id"]')%>%
html_attr("option value") #problem????
values
Res <- data.frame(text = text, …Run Code Online (Sandbox Code Playgroud) 据我所知,每个事务都会看到自己的数据库版本,因此系统无法从某个计数器获取总行数,因此需要扫描索引.但我认为它将是主键上的聚簇索引,而不是附加索引.如果我有一个以上的附加索引,那么将选择哪一个?
在深入研究此事时,我注意到了另一件奇怪的事情.假设有两个相同的表,Article和Articles2,每个表有三列:Id,View_Count和Title.第一个只有一个基于PK的聚簇索引,而第二个索引在view_count上有一个额外的非聚集,非唯一索引.SELECT COUNT(1) FROM Articles对于具有附加索引的表,查询运行速度提高了2倍.
假设我有一个经典的页面布局.
现在让我们说所有这些都可以在页面编辑器中进行编辑,让我们添加一个事实,即我希望所有内容都能通过工作流程.
当编辑进入特定页面(比如"关于我们"页面)时,当他点击编辑时,Sitecore究竟应该做什么?该页面上显示的所有项目是否会切换到DRAFT状态?或者只有当编辑器实际上编辑了页面上显示的某些"内容项"中的某些内容时才会发生这种情况?
当页面提交审批时会发生什么?修改后的所有子项是否也会进入"已提交审批"状态并出现在审批者/发布者的工作箱中?
如果没有开箱即用,怎么能实现这一切?有没有人已经解决了这个问题并成功解决了它?这似乎是一个常见的问题,但我似乎无法找到关于如何将这些联系起来的任何指导.
谢谢,FG
使用Solr 4.x中,HTTP://本地主机:8983/solr的/管理/芯返回加载的芯的XML描述,其表示的文件路径位置instanceDir.
...
<lst name="collection1">
<str name="name">collection1</str>
<bool name="isDefaultCore">true</bool>
<str name="instanceDir">C:\solr\solr-4.10.1\example\solr\collection1\</str>
...
Run Code Online (Sandbox Code Playgroud)
在我的Windows 7 PC上,这是一个完整路径,但其他人已将此报告为相对路径.哪些因素可以将此值表示为相对路径,是否有办法强制将其显示为完整路径?
我正在尝试将图像项添加到内容树 - 但我在以下点获得了访问被拒绝错误:
item.Add("New Node1"......
我的方法的完整代码是:
Sitecore.Data.Database master;
master = Sitecore.Configuration.Factory.GetDatabase("master");
Item item = master.Items["/sitecore/Content/Media/Images/Places"];
// item.Fields["Related Issues"].Value = "Asia and the Pacific";
if (item != null)
{
// add a new Item based on the Document Template
Item itm = item.Add("New Node1", master.Templates[new ID(new Guid("EJ0F53DF-5486-4UF4-A2D1-64C119E419A5"))]);
if (itm != null)
{
// report the Item path to the User
Response.Write(itm.Paths.Path);
}
}
Run Code Online (Sandbox Code Playgroud) 需要在页面编辑器,项目编辑部分添加"发布"功能.(在"更多"部分下是理想的).我怎样才能做到这一点?

sitecore ×6
page-editor ×3
c# ×1
r ×1
rhino-mocks ×1
rvest ×1
sitecore6 ×1
sitecore7 ×1
solr ×1
solr4 ×1
sql ×1
sql-server ×1
unit-testing ×1
web-scraping ×1