-
處理InitForm.xsn:
-
選擇VS 的項目路徑.點擊 "OK". 會生成很多文件在指定的路徑下. 其中有一個叫"MySchema.xsd" 的文件, 可修改名稱為"InitForm.xsd"(也可以不修改).
-
運行"Visual Studio 2005 Command Prompt";
- Cd 到VS 的項目路徑下. 執行"xsd InitForm.xsd /c ".會生成一個叫"initform.cs" 的文件.
- 打開 VS 項目。將initform.cs 加入到項目中.
-
工作流編碼.添加工作流中執行代碼. 和執行條件等.
namespace MarketingCampaign
{
public sealed partial class MarketingCampaign: SharePointSequentialWorkflowActivity
{
public MarketingCampaign()
{
InitializeComponent();
}
public Guid workflowId = default(System.Guid);
public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
public SPWorkflowActivationProperties onWorkflowActivated1_WorkflowProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
private string sTrafficCoordinator = default(string);
private string sMarketingDirectorEMail = default(string);
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
XmlSerializer serializer = new XmlSerializer(typeof(myFields));
XmlTextReader rdrInitForm = new XmlTextReader(new System.IO.StringReader(onWorkflowActivated1_WorkflowProperties1.InitiationData));
myFields frmInit = (myFields)serializer.Deserialize(rdrInitForm);
sTrafficCoordinator = @"ecmms\" + frmInit.trafficcoordinator;
sMarketingDirectorEMail = frmInit.marketingdirectoremail;
}
private void SendEmail1_MethodInvoking(object sender, EventArgs e)
{
sendEmail1.To = sMarketingDirectorEMail.ToString() + "@cmmsgsps03.ecmms.foxconn";
string sItemTitle = onWorkflowActivated1_WorkflowProperties1.Item["名稱"].ToString();
string sItemURL = onWorkflowActivated1_WorkflowProperties1.ItemUrl;
sendEmail1.Body = string.Format("New Marketing Campaign: {0}. URL:{1}", sItemTitle, sItemURL);
}
public Guid createTask1_TaskId1 = default(System.Guid);
public SPWorkflowTaskProperties createTask1_TaskProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
private bool taskCompleted;
private void createTask1_MethodInvoking(object sender, EventArgs e)
{
createTask1_TaskId1 = Guid.NewGuid();
createTask1_TaskProperties1.Title = "New Marketing Campaign";
createTask1_TaskProperties1.AssignedTo = sTrafficCoordinator;
string sItemTitle = onWorkflowActivated1_WorkflowProperties1.Item["名稱"].ToString();
string sItemURL = onWorkflowActivated1_WorkflowProperties1.ItemUrl;
string sOriginator = onWorkflowActivated1_WorkflowProperties1.Originator;
createTask1_TaskProperties1.Description = string.Format("New Marketing Campaign: {0}. URL:{1}", sItemTitle, sItemURL);
createTask1_TaskProperties1.ExtendedProperties["taskinstructions"] = string.Format("Please review this proposed marketing campaign and let {0} know if there are any scheduling issues.Thanks!", sOriginator);
}
private void WhileActivity1_condition(object sender, ConditionalEventArgs e)
{
e.Result = !taskCompleted;
}
private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
taskCompleted = bool.Parse(onTaskChanged1_AfterProperties1.ExtendedProperties["taskComplate"].ToString());
createTask1_TaskProperties1.ExtendedProperties["taskcomments"] = onTaskChanged1_AfterProperties1.ExtendedProperties["taskcomments"].ToString();
}
private void updateTask1_MethodInvoking(object sender, EventArgs e)
{ }
public SPWorkflowTaskProperties onTaskChanged1_AfterProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
public SPWorkflowTaskProperties onTaskChanged1_BeforeProperties1 = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
}
WF + Infopath(4)編碼
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)