- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Sitecore 工作流程。当我使用项目旁边的“批准”按钮批准项目时,它会要求发表评论。当我使用“批准”(选定)或“批准”(全部)按钮批准多个项目时,它不会要求发表评论。这是为什么?我可以让它请求评论并将该评论与所有已批准的项目相关联吗?谢谢
最佳答案
为了启用 Selected
的评论或All
您需要的元素:
Website\sitecore\shell\Applications\Workbox\Workbox.xml
至Website\sitecore\shell\Override\
目录并更改<CodeBeside Type="..." />
至<CodeBeside Type="My.Assembly.Namespace.WorkboxForm,My.Assembly" />
哪里My.Assembly
和My.Assembly.Namespace
与您的项目相匹配。WorkboxForm
这将覆盖 Sitecore WorkboxForm
并匹配Type
从点 1. 开始并使用编辑后的代码 WorkBox
形式:using Sitecore;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Exceptions;
using Sitecore.Globalization;
using Sitecore.Resources;
using Sitecore.Shell.Framework.CommandBuilders;
using Sitecore.Text;
using Sitecore.Web;
using Sitecore.Web.UI.HtmlControls;
using Sitecore.Web.UI.Sheer;
using Sitecore.Web.UI.XmlControls;
using Sitecore.Workflows;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace My.Assembly.Namespace
{
public class WorkboxForm : Sitecore.Shell.Applications.Workbox.WorkboxForm
{
private NameValueCollection stateNames;
public void CommentMultiple(ClientPipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
if (!args.IsPostBack)
{
Context.ClientPage.ClientResponse.Input("Enter a comment:", string.Empty);
args.WaitForPostBack();
}
else if (args.Result.Length > 2000)
{
Context.ClientPage.ClientResponse.ShowError(new Exception(string.Format("The comment is too long.\n\nYou have entered {0} characters.\nA comment cannot contain more than 2000 characters.", args.Result.Length)));
Context.ClientPage.ClientResponse.Input("Enter a comment:", string.Empty);
args.WaitForPostBack();
}
else
{
if (args.Result == null || args.Result == "null" || args.Result == "undefined")
return;
IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
if (workflowProvider == null)
return;
IWorkflow workflow = workflowProvider.GetWorkflow(Context.ClientPage.ServerProperties["workflowid"] as string);
if (workflow == null)
return;
string stateId = (string)Context.ClientPage.ServerProperties["ws"];
string command = (string)Context.ClientPage.ServerProperties["command"];
string[] itemRefs = ((string)Context.ClientPage.ServerProperties["ids"] ?? string.Empty).Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
bool flag = false;
int num = 0;
foreach (string itemRef in itemRefs)
{
string[] strArray = itemRef.Split(new[] { ',' });
Item items = Context.ContentDatabase.Items[strArray[0], Language.Parse(strArray[1]), Sitecore.Data.Version.Parse(strArray[2])];
if (items != null)
{
WorkflowState state = workflow.GetState(items);
if (state.StateID == stateId)
{
try
{
workflow.Execute(command, items, args.Result, true, new object[0]);
}
catch (WorkflowStateMissingException)
{
flag = true;
}
++num;
}
}
}
if (flag)
SheerResponse.Alert("One or more items could not be processed because their workflow state does not specify the next step.", new string[0]);
if (num == 0)
{
Context.ClientPage.ClientResponse.Alert("There are no selected items.");
}
else
{
UrlString urlString = new UrlString(WebUtil.GetRawUrl());
urlString["reload"] = "1";
Context.ClientPage.ClientResponse.SetLocation(urlString.ToString());
}
}
}
public override void HandleMessage(Message message)
{
Assert.ArgumentNotNull(message, "message");
switch (message.Name)
{
case "workflow:sendselectednew":
SendSelectedNew(message);
return;
case "workflow:sendallnew":
SendAllNew(message);
return;
}
base.HandleMessage(message);
}
protected override void DisplayState(IWorkflow workflow, WorkflowState state, DataUri[] items, System.Web.UI.Control control, int offset, int pageSize)
{
Assert.ArgumentNotNull(workflow, "workflow");
Assert.ArgumentNotNull(state, "state");
Assert.ArgumentNotNull(items, "items");
Assert.ArgumentNotNull(control, "control");
if (items.Length <= 0)
return;
int num = offset + pageSize;
if (num > items.Length)
num = items.Length;
for (int index = offset; index < num; ++index)
{
Item obj = Context.ContentDatabase.Items[items[index]];
if (obj != null)
CreateItem(workflow, obj, control);
}
Border border1 = new Border();
border1.Background = "#e9e9e9";
Border border2 = border1;
control.Controls.Add(border2);
border2.Margin = "0px 4px 0px 16px";
border2.Padding = "2px 8px 2px 8px";
border2.Border = "1px solid #999999";
foreach (WorkflowCommand workflowCommand in WorkflowFilterer.FilterVisibleCommands(workflow.GetCommands(state.StateID)))
{
XmlControl xmlControl1 = (XmlControl) Resource.GetWebControl("WorkboxCommand");
Assert.IsNotNull(xmlControl1, "workboxCommand is null");
xmlControl1["Header"] = (workflowCommand.DisplayName + " " + Translate.Text("(selected)"));
xmlControl1["Icon"] = workflowCommand.Icon;
xmlControl1["Command"] = ("workflow:sendselectednew(command=" + workflowCommand.CommandID + ",ws=" + state.StateID + ",wf=" + workflow.WorkflowID + ")");
border2.Controls.Add(xmlControl1);
XmlControl xmlControl2 = (XmlControl) Resource.GetWebControl("WorkboxCommand");
Assert.IsNotNull(xmlControl2, "workboxCommand is null");
xmlControl2["Header"] = (workflowCommand.DisplayName + " " + Translate.Text("(all)"));
xmlControl2["Icon"] = workflowCommand.Icon;
xmlControl2["Command"] = ("workflow:sendallnew(command=" + workflowCommand.CommandID + ",ws=" + state.StateID + ",wf=" + workflow.WorkflowID + ")");
border2.Controls.Add(xmlControl2);
}
}
private static void CreateCommand(IWorkflow workflow, WorkflowCommand command, Item item, XmlControl workboxItem)
{
Assert.ArgumentNotNull(workflow, "workflow");
Assert.ArgumentNotNull(command, "command");
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNull(workboxItem, "workboxItem");
XmlControl xmlControl = (XmlControl) Resource.GetWebControl("WorkboxCommand");
Assert.IsNotNull(xmlControl, "workboxCommand is null");
xmlControl["Header"] = command.DisplayName;
xmlControl["Icon"] = command.Icon;
CommandBuilder commandBuilder = new CommandBuilder("workflow:send");
commandBuilder.Add("id", item.ID.ToString());
commandBuilder.Add("la", item.Language.Name);
commandBuilder.Add("vs", item.Version.ToString());
commandBuilder.Add("command", command.CommandID);
commandBuilder.Add("wf", workflow.WorkflowID);
commandBuilder.Add("ui", command.HasUI);
commandBuilder.Add("suppresscomment", command.SuppressComment);
xmlControl["Command"] = commandBuilder.ToString();
workboxItem.AddControl(xmlControl);
}
private void CreateItem(IWorkflow workflow, Item item, System.Web.UI.Control control)
{
Assert.ArgumentNotNull(workflow, "workflow");
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNull(control, "control");
XmlControl workboxItem = (XmlControl) Resource.GetWebControl("WorkboxItem");
Assert.IsNotNull(workboxItem, "workboxItem is null");
control.Controls.Add(workboxItem);
StringBuilder stringBuilder = new StringBuilder(" - (");
Language language = item.Language;
stringBuilder.Append(language.CultureInfo.DisplayName);
stringBuilder.Append(", ");
stringBuilder.Append(Translate.Text("version"));
stringBuilder.Append(' ');
stringBuilder.Append(item.Version);
stringBuilder.Append(")");
Assert.IsNotNull(workboxItem, "workboxItem");
workboxItem["Header"] = item.DisplayName;
workboxItem["Details"] = (stringBuilder).ToString();
workboxItem["Icon"] = item.Appearance.Icon;
workboxItem["ShortDescription"] = item.Help.ToolTip;
workboxItem["History"] = GetHistory(workflow, item);
workboxItem["HistoryMoreID"] = Control.GetUniqueID("ctl");
workboxItem["HistoryClick"] = ("workflow:showhistory(id=" + item.ID + ",la=" + item.Language.Name + ",vs=" + item.Version + ",wf=" + workflow.WorkflowID + ")");
workboxItem["PreviewClick"] = ("Preview(\"" + item.ID + "\", \"" + item.Language + "\", \"" + item.Version + "\")");
workboxItem["Click"] = ("Open(\"" + item.ID + "\", \"" + item.Language + "\", \"" + item.Version + "\")");
workboxItem["DiffClick"] = ("Diff(\"" + item.ID + "\", \"" + item.Language + "\", \"" + item.Version + "\")");
workboxItem["Display"] = "none";
string uniqueId = Control.GetUniqueID(string.Empty);
workboxItem["CheckID"] = ("check_" + uniqueId);
workboxItem["HiddenID"] = ("hidden_" + uniqueId);
workboxItem["CheckValue"] = (item.ID + "," + item.Language + "," + item.Version);
foreach (WorkflowCommand command in WorkflowFilterer.FilterVisibleCommands(workflow.GetCommands(item)))
CreateCommand(workflow, command, item, workboxItem);
}
private string GetHistory(IWorkflow workflow, Item item)
{
Assert.ArgumentNotNull(workflow, "workflow");
Assert.ArgumentNotNull(item, "item");
WorkflowEvent[] history = workflow.GetHistory(item);
string str;
if (history.Length > 0)
{
WorkflowEvent workflowEvent = history[history.Length - 1];
string text = workflowEvent.User;
string name = Context.Domain.Name;
if (text.StartsWith(name + "\\", StringComparison.OrdinalIgnoreCase))
text = StringUtil.Mid(text, name.Length + 1);
str = string.Format(Translate.Text("{0} changed from <b>{1}</b> to <b>{2}</b> on {3}."),
StringUtil.GetString(new[]
{
text,
Translate.Text("Unknown")
}), GetStateName(workflow, workflowEvent.OldState),
GetStateName(workflow, workflowEvent.NewState),
DateUtil.FormatDateTime(workflowEvent.Date, "D", Context.User.Profile.Culture));
}
else
str = Translate.Text("No changes have been made.");
return str;
}
private static DataUri[] GetItems(WorkflowState state, IWorkflow workflow)
{
Assert.ArgumentNotNull(state, "state");
Assert.ArgumentNotNull(workflow, "workflow");
ArrayList arrayList = new ArrayList();
DataUri[] items = workflow.GetItems(state.StateID);
if (items != null)
{
foreach (DataUri index in items)
{
Item obj = Context.ContentDatabase.Items[index];
if (obj != null && obj.Access.CanRead() && (obj.Access.CanReadLanguage() && obj.Access.CanWriteLanguage()) && (Context.IsAdministrator || obj.Locking.CanLock() || obj.Locking.HasLock()))
arrayList.Add(index);
}
}
return arrayList.ToArray(typeof(DataUri)) as DataUri[];
}
private string GetStateName(IWorkflow workflow, string stateID)
{
Assert.ArgumentNotNull(workflow, "workflow");
Assert.ArgumentNotNull(stateID, "stateID");
if (stateNames == null)
{
stateNames = new NameValueCollection();
foreach (WorkflowState workflowState in workflow.GetStates())
stateNames.Add(workflowState.StateID, workflowState.DisplayName);
}
return StringUtil.GetString(new[] {stateNames[stateID], "?"});
}
private void SendAll(Message message)
{
Assert.ArgumentNotNull(message, "message");
IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
if (workflowProvider == null)
return;
string workflowID = message["wf"];
string stateID = message["ws"];
IWorkflow workflow = workflowProvider.GetWorkflow(workflowID);
if (workflow == null)
return;
WorkflowState state = workflow.GetState(stateID);
DataUri[] items = GetItems(state, workflow);
Assert.IsNotNull(items, "uris is null");
string comments = state != null ? state.DisplayName : string.Empty;
bool flag = false;
foreach (DataUri index in items)
{
Item obj = Context.ContentDatabase.Items[index];
if (obj != null)
{
try
{
workflow.Execute(message["command"], obj, comments, true, new object[0]);
}
catch (WorkflowStateMissingException)
{
flag = true;
}
}
}
if (flag)
SheerResponse.Alert("One or more items could not be processed because their workflow state does not specify the next step.", new string[0]);
UrlString urlString = new UrlString(WebUtil.GetRawUrl());
urlString["reload"] = "1";
Context.ClientPage.ClientResponse.SetLocation(urlString.ToString());
}
private void SendAllNew(Message message)
{
Assert.ArgumentNotNull(message, "message");
IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
if (workflowProvider == null)
return;
string workflowID = message["wf"];
string stateID = message["ws"];
IWorkflow workflow = workflowProvider.GetWorkflow(workflowID);
if (workflow == null)
return;
if (message["ui"] != "1")
{
if (message["suppresscomment"] != "1")
{
string ids = String.Empty;
WorkflowState state = workflow.GetState(stateID);
DataUri[] items = GetItems(state, workflow);
foreach (DataUri dataUri in items)
{
ids += dataUri.ItemID + "," + dataUri.Language + "," + dataUri.Version.Number + "," + "::";
}
if (String.IsNullOrEmpty(ids))
{
Context.ClientPage.ClientResponse.Alert("There are no selected items.");
return;
}
Context.ClientPage.ServerProperties["ids"] = ids;
Context.ClientPage.ServerProperties["language"] = message["la"];
Context.ClientPage.ServerProperties["version"] = message["vs"];
Context.ClientPage.ServerProperties["command"] = message["command"];
Context.ClientPage.ServerProperties["ws"] = message["ws"];
Context.ClientPage.ServerProperties["workflowid"] = workflowID;
Context.ClientPage.Start(this, "CommentMultiple");
return;
}
}
// no comment - use the old SendAll
SendAll(message);
}
private void SendSelectedNew(Message message)
{
Assert.ArgumentNotNull(message, "message");
IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
if (workflowProvider == null)
return;
string workflowID = message["wf"];
IWorkflow workflow = workflowProvider.GetWorkflow(workflowID);
if (workflow == null)
return;
if (message["ui"] != "1")
{
if (message["suppresscomment"] != "1")
{
string ids = String.Empty;
foreach (string str2 in Context.ClientPage.ClientRequest.Form.Keys)
{
if (str2 != null && str2.StartsWith("check_", StringComparison.InvariantCulture))
{
ids += Context.ClientPage.ClientRequest.Form["hidden_" + str2.Substring(6)] + "::";
}
}
if (String.IsNullOrEmpty(ids))
{
Context.ClientPage.ClientResponse.Alert("There are no selected items.");
return;
}
Context.ClientPage.ServerProperties["ids"] = ids;
Context.ClientPage.ServerProperties["language"] = message["la"];
Context.ClientPage.ServerProperties["version"] = message["vs"];
Context.ClientPage.ServerProperties["command"] = message["command"];
Context.ClientPage.ServerProperties["ws"] = message["ws"];
Context.ClientPage.ServerProperties["workflowid"] = workflowID;
Context.ClientPage.Start(this, "CommentMultiple");
return;
}
}
// no comment - use the old SendSelected
SendSelected(message);
}
private void SendSelected(Message message, string comment = null)
{
Assert.ArgumentNotNull(message, "message");
IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;
if (workflowProvider == null)
return;
string workflowID = message["wf"];
string str1 = message["ws"];
IWorkflow workflow = workflowProvider.GetWorkflow(workflowID);
if (workflow == null)
return;
int num = 0;
bool flag = false;
foreach (string str2 in Context.ClientPage.ClientRequest.Form.Keys)
{
if (str2 != null && str2.StartsWith("check_", StringComparison.InvariantCulture))
{
string[] strArray = Context.ClientPage.ClientRequest.Form["hidden_" + str2.Substring(6)].Split(new [] { ',' });
Item obj = Context.ContentDatabase.Items[strArray[0], Language.Parse(strArray[1]), Sitecore.Data.Version.Parse(strArray[2])];
if (obj != null)
{
WorkflowState state = workflow.GetState(obj);
if (state.StateID == str1)
{
try
{
workflow.Execute(message["command"], obj, comment ?? state.DisplayName, true, new object[0]);
}
catch (WorkflowStateMissingException)
{
flag = true;
}
++num;
}
}
}
}
if (flag)
SheerResponse.Alert("One or more items could not be processed because their workflow state does not specify the next step.", new string[0]);
if (num == 0)
{
Context.ClientPage.ClientResponse.Alert("There are no selected items.");
}
else
{
UrlString urlString = new UrlString(WebUtil.GetRawUrl());
urlString["reload"] = "1";
Context.ClientPage.ClientResponse.SetLocation(urlString.ToString());
}
}
}
}
关于sitecore workbox 在批准多个项目时不提示评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22947912/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!