我從編程工作流中學習了以下內容,並使用SPD進行了部署。
1.不要依賴在工作流程標註中傳遞所需的所有字段:定義看似合理的內容,但請記住,一旦您訪問了SPList項目,就可以從內部繞過對象模型您的工作流程無需重複更改界面並重新部署。
即一旦你已經在你的.actions文件中定義的這三樣東西,並將其傳遞給您的工作流程
public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(YourWorkflowClass));
public static DependencyProperty __ListIdProperty = DependencyProperty.Register("__ListId", typeof(string), typeof(YourWorkflowClass));
public static DependencyProperty __ListItemProperty = DependencyProperty.Register("__ListItem", typeof(int), typeof(YourWorkflowClass));
你設置訪問任何你可能已經忘記了部署時明確地傳遞。
2.使用上下文直接創建您想要的SharePoint項目的實例時註銷,因爲您可能會不知不覺地傳遞調用該工作流程的人的權限。即爲此
SPWeb tmpweb = __Context.Web;
SPSite site = new SPSite(tmpweb.Url);
SPWeb web = site.OpenWeb();
,而不是這樣的:
SPWeb web = __Context.Web;
3.Debugging是難以成立,如果你不碰巧有安裝在同一臺機器包括SharePoint視覺工作室。