本文整理汇总了C#中System.Activities.WorkflowApplication.Unload方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowApplication.Unload方法的具体用法?C# WorkflowApplication.Unload怎么用?C# WorkflowApplication.Unload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Activities.WorkflowApplication
的用法示例。
在下文中一共展示了WorkflowApplication.Unload方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Interact
// single interaction with the user. The user enters a string in the console and that
// string is used to resume the ReadLine activity bookmark
static void Interact(WorkflowApplication application, AutoResetEvent resetEvent)
{
Console.WriteLine("Workflow is ready for input");
Console.WriteLine("Special commands: 'unload', 'exit'");
bool done = false;
while (!done)
{
Console.Write("> ");
string s = Console.ReadLine();
if (s.Equals("unload"))
{
try
{
// attempt to unload will fail if the workflow is idle within a NoPersistZone
application.Unload(TimeSpan.FromSeconds(5));
done = true;
}
catch (TimeoutException e)
{
Console.WriteLine(e.Message);
}
}
else if (s.Equals("exit"))
{
application.ResumeBookmark("inputBookmark", s);
done = true;
}
else
{
application.ResumeBookmark("inputBookmark", s);
}
}
resetEvent.WaitOne();
}
示例2: GetReimbursementVoid
private void GetReimbursementVoid(Guid id)
{
// Initialize Windows Workflow Foundation
WorkflowApplication _wfApp = new WorkflowApplication(new ReimbursementRequest());
SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["workflows"].ConnectionString);
_wfApp.InstanceStore = store;
_wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs ex)
{
return PersistableIdleAction.Persist;
};
_wfApp.Run();
_wfApp.Unload();
Session["wfid"] = _wfApp.Id;
}
示例3: Main
static void Main(string[] args)
{
SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connectionString);
WorkflowApplication.CreateDefaultInstanceOwner(store, null, WorkflowIdentityFilter.Any);
IDictionary<WorkflowIdentity, DynamicUpdateInfo> updateMaps = LoadMaps();
foreach (Guid id in GetIds())
{
// Get a proxy to the instance.
WorkflowApplicationInstance instance =
WorkflowApplication.GetInstance(id, store);
Console.WriteLine("Inspecting: {0}", instance.DefinitionIdentity);
// Only update v1 workflows.
if (instance.DefinitionIdentity != null &&
instance.DefinitionIdentity.Version.Equals(new Version(1, 0, 0, 0)))
{
DynamicUpdateInfo info = updateMaps[instance.DefinitionIdentity];
// Associate the persisted WorkflowApplicationInstance with
// a WorkflowApplication that is configured with the updated
// definition and updated WorkflowIdentity.
Activity wf = WorkflowVersionMap.GetWorkflowDefinition(info.newIdentity);
WorkflowApplication wfApp =
new WorkflowApplication(wf, info.newIdentity);
// Apply the Dynamic Update.
wfApp.Load(instance, info.updateMap);
// Persist the updated instance.
wfApp.Unload();
Console.WriteLine("Updated to: {0}", info.newIdentity);
}
else
{
// Not updating this instance, so unload it.
instance.Abandon();
}
}
}
示例4: cmdUpdateInstance_Click
private void cmdUpdateInstance_Click(object sender, RoutedEventArgs e)
{
SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore();
instanceStore.ConnectionString =
@"Data Source=(LocalDB)\v11.0;Initial Catalog=WFPersist;Integrated Security=True";
WorkflowApplicationInstance wfInstance =
WorkflowApplication.GetInstance(new Guid(txtUpdateInstance.Text), instanceStore);
DataContractSerializer s = new DataContractSerializer(typeof(DynamicUpdateMap));
using (FileStream fs = File.Open(txtUpdateMapFile.Text, FileMode.Open))
{
updateMap = s.ReadObject(fs) as DynamicUpdateMap;
}
var wfApp =
new WorkflowApplication(new MovieRentalProcess(),
new WorkflowIdentity
{
Name = "v2MovieRentalProcess",
Version = new System.Version(2, 0, 0, 0)
});
IList<ActivityBlockingUpdate> act;
if (wfInstance.CanApplyUpdate(updateMap, out act))
{
wfApp.Load(wfInstance, updateMap);
wfApp.Unload();
}
}
示例5: btnEdit_ServerClick
//.........这里部分代码省略.........
}
Model.SelectRecord selectRecord = new Model.SelectRecord("WorkFlow", "", "*", "where id='" + dt.Rows[0]["WorkFlowID"].ToString() + "'");
DataTable table = BLL.SelectRecord.SelectRecordData(selectRecord).Tables[0];
string content = File.ReadAllText(System.Web.HttpContext.Current.Request.MapPath("../") + table.Rows[0]["URL"].ToString());
instance = engineManager.createInstance(content, null, null);
if (instanceStore == null)
{
instanceStore = new SqlWorkflowInstanceStore(SqlHelper.strconn);
view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
instanceStore.DefaultInstanceOwner = view.InstanceOwner;
}
instance.InstanceStore = instanceStore;
Guid guid = new Guid(dt.Rows[0]["FlowInstranceID"].ToString());
instance.Load(guid);
//end
if (this.DropDown_sp.SelectedValue == "true")
{
string[] s = dt.Rows[0]["OID"].ToString().Split(new char[] { ',' });
if (s[s.Length - 1] == "1")
{
Model.SelectRecord selectExecut = new Model.SelectRecord("WorkFlowExecution", "", "*", "where DID='" + id + "' and step ='" + dt.Rows[0]["WStep"].ToString() + "' and UID='"+this.Session["admin"].ToString()+"'");
DataTable executdt = BLL.SelectRecord.SelectRecordData(selectExecut).Tables[0];
if (executdt.Rows.Count > 0)
{
MessageBox.ShowAndRedirect(this, "该公文您已审核,请等待其他人审核!", "/document/DocumentList.aspx");
}
else {
Model.SelectRecord selectExecutCount = new Model.SelectRecord("WorkFlowExecution", "", "distinct UID", "where DID='" + id + "' and step ='" + dt.Rows[0]["WStep"].ToString() + "'");
DataTable dtcount = BLL.SelectRecord.SelectRecordData(selectExecutCount).Tables[0];
string where = "where IsState=2 AND (1=2 ";
string[] str = dt.Rows[0]["OID"].ToString().Split(new char[] { ',' });
for (int j = 1; j < str.Length-1; j++)
{
where += "OR OID like '%" + str[j].ToString() + "%' ";
}
where += ") order by id desc";
Model.SelectRecord selectUserCount = new Model.SelectRecord("Users", "", "ID", where);
DataTable usercount = BLL.SelectRecord.SelectRecordData(selectUserCount).Tables[0];
if (dtcount.Rows.Count + 1 == usercount.Rows.Count)
{
if (instance.GetBookmarks().Count(p => p.BookmarkName == dt.Rows[0]["value"].ToString()) == 1)
{
instance.ResumeBookmark(dt.Rows[0]["value"].ToString(), this.DropDown_sp.SelectedValue.ToString());
}
}
}
}
else
{
//一旦审批未通过,删除该公文当前流转步骤信息
BLL.GeneralMethods.GeneralDelDB("WorkFlowExecution", "where DID ='" + id + "' and step='" + dt.Rows[0]["WStep"].ToString() + "'");
if (instance.GetBookmarks().Count(p => p.BookmarkName == dt.Rows[0]["value"].ToString()) == 1)
{
instance.ResumeBookmark(dt.Rows[0]["value"].ToString(), this.DropDown_sp.SelectedValue.ToString());
}
}
Model.WorkFlowExecution workexe = new Model.WorkFlowExecution
{
DID = dt.Rows[0]["ID"].ToString(),
UID = this.Session["admin"].ToString(),
step = dt.Rows[0]["WStep"].ToString(),
Remark = this.txtSP.Value.Trim(),
Result = "1",
};
BLL.WorkFlowExecution.Add(workexe);
}
else
{
Model.WorkFlowExecution workexe = new Model.WorkFlowExecution
{
DID = dt.Rows[0]["ID"].ToString(),
UID = this.Session["admin"].ToString(),
step = dt.Rows[0]["WStep"].ToString(),
Remark = this.txtSP.Value.Trim(),
Result = "2",
};
BLL.WorkFlowExecution.Add(workexe);
if (instance.GetBookmarks().Count(p => p.BookmarkName == dt.Rows[0]["value"].ToString()) == 1)
{
instance.ResumeBookmark(dt.Rows[0]["value"].ToString(), this.DropDown_sp.SelectedValue.ToString());
}
}
UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "公文管理", "公文审核" + dt.Rows[0]["Name"].ToString() + "的信息成功");
MessageBox.ShowAndRedirect(this, "审核公文成功!", "/document/DocumentList.aspx");
instance.Unload();
}
}
示例6: ProcessRequest
/// <summary>
/// Invoked when a web request arrives.
/// </summary>
public void ProcessRequest(HttpContext context)
{
try
{
// bind ourselves to the context
Context = context;
// request was for a resource
if (Request[ResourceQueryKey] != null)
{
// handle it and return, no need to deal with workflow
ProcessResourceRequest(Request[ResourceQueryKey]);
return;
}
// obtain our activity instance
Activity = CreateActivity();
// configure application
WorkflowApplication = Request[InstanceIdQueryKey] == null ? new WorkflowApplication(Activity, GetArguments()) : new WorkflowApplication(Activity);
WorkflowApplication.Extensions.Add<ITwilioContext>(() => this);
WorkflowApplication.SynchronizationContext = new SynchronizedSynchronizationContext();
WorkflowApplication.InstanceStore = CreateInstanceStore();
WorkflowApplication.Aborted = OnAborted;
WorkflowApplication.Completed = OnCompleted;
WorkflowApplication.Idle = OnIdle;
WorkflowApplication.OnUnhandledException = OnUnhandledException;
WorkflowApplication.PersistableIdle = OnPersistableIdle;
WorkflowApplication.Unloaded = OnUnloaded;
// attempt to resolve current instance id and reload workflow state
if (Request[InstanceIdQueryKey] != null)
WorkflowApplication.Load(Guid.Parse(Request[InstanceIdQueryKey]), Timeout);
// postback to resume a bookmark
if (Request[BookmarkQueryKey] != null)
WorkflowApplication.ResumeBookmark(Request[BookmarkQueryKey], GetPostData(), Timeout);
else
// begin running the workflow from the start
WorkflowApplication.Run(Timeout);
// throw exception
if (UnhandledExceptionInfo != null)
UnhandledExceptionInfo.Throw();
// strip off temporary attributes
foreach (var element in TwilioResponse.DescendantsAndSelf())
foreach (var attribute in element.Attributes())
if (attribute.Name.Namespace == tmpNs)
attribute.Remove();
// write finished twilio output
Response.ContentType = "text/xml";
using (var wrt = XmlWriter.Create(Response.Output))
TwilioResponse.WriteTo(wrt);
// if we've reached the end, no need to force unload
WorkflowApplication = null;
}
finally
{
// clean up application if possible
if (WorkflowApplication != null)
{
try
{
WorkflowApplication.Unload(Timeout);
WorkflowApplication = null;
}
catch
{
// ignore
}
}
}
}