/// <summary> /// 第二次查询的工作流方法(恢复工作流) /// </summary> public override void Execute() { //从redis中查询准备恢复的wf_id //9月25日注释掉 //测试暂时注释掉 var obj_hashWFObj = query_bll.ExecuteQueryGetWFId(); if (obj_hashWFObj == null) { return; } //3.2 恢复工作流 Activity workflow_temp = new MainStatistics_Advanced(); //测试将此行注释掉 var guid = Guid.Parse(obj_hashWFObj.WFId); //var guid = Guid.Parse("68dfde0a-f560-437d-a485-b7663ef51b01"); //恢复工作流 var work_reus = WorkFlowAppHelper.LoadWorkflowApplication(workflow_temp, guid); //3.3 读取WF_Query_Instance表根据指定WF_Id取出对应的State、StepId、WF_Result(或从hash中读取)!!!!! var bookmark = new PMS.Model.WFModel.BookMarkObj<int>() { BookMarkName = "恢复书签", State = 1, StepId = 1, // WF_Result = 4,//9月25日测试暂时注释掉 WF_Result = 6, MsgId=obj_hashWFObj.MsgId }; work_reus.ResumeBookmark("书签1", bookmark); }
static void Main(string[] args) { //启动工作流的方式(一) //Activity workflow_temp = new MainStatistics_Advanced(); //WorkflowInvoker.Invoke(workflow1); //启动工作流的方式(二) //使用WorkflowApplication承载工作流 //此种方式已经封装至Common中的WorkFlowHelper类中 #region 此种方法已被封装,此处注释掉 ////1.1 创建传入的参数字典(可以传入多个参数) ////1.2 创建工作流活动实例 //Activity workflow_temp = new MainStatistics_Advanced(); ////2 将活动传递给工作流 //WorkflowApplication app = new WorkflowApplication(workflow_temp); ////3 将工作流写入数据库中 //string connect_str = Common.ConfigHelper.GetSettingValue("workflowConnection"); //SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connect_str); //app.InstanceStore = store; ////封装至Common中的WorkFlowHelper类中 #endregion //暂时注释掉 Activity workflow_temp = new MainStatistics_Advanced(); var dic = new Dictionary<string, object>() { { "TempBookMarkName", "书签1" } }; //var work = Common.WorkFlowAppHelper.CreateWorkflowApplication(workflow_temp, dic); //var work_reus = Common.WorkFlowAppHelper.LoadWorkflowApplication(workflow_temp,Guid.Parse("fcc19c2c-5af9-4da3-a9c8-64c997adbeaf")); //work_reus.ResumeBookmark("TempBookMarkName",); //测试 持久化 已经可以持久化(注意 数据库的 连接字符串) #region 测试持久化问题(已解决) Activity activity = new Activity_Test(); //1 创建工作流 //1.1 此处为为创建的工作流输入的参数 dic = new Dictionary<string, object>() { { "temp", "1987" } }; //var work = Common.WorkFlowAppHelper.CreateWorkflowApplication(activity, dic); //2 恢复工作流 var work_reus = Common.WorkFlowAppHelper.LoadWorkflowApplication(activity, Guid.Parse("4acfaedb-fba0-4d3b-9845-f55570911584")); //第一个参数为工作流创建时为书签所起的名字,第二个参数为创建书签时,声明的回调方法BookmarkCallback指定的某个方法 //BookmarkCallback 要求的 签名 为 //NativeActivityContext context, Bookmark bookmark, object value //此处的dic及为方法签名中的第三个参数value work_reus.ResumeBookmark("测试书签", dic); #endregion Console.WriteLine("工作流结束,输入任何键退出"); Console.ReadLine(); }
public override void Execute() { Activity workflow_temp = new MainStatistics_Advanced(); var dic = new Dictionary<string, object>() { { "TempBookMarkName", "书签1" } }; var work = Common.WorkFlowAppHelper.CreateWorkflowApplication(workflow_temp, dic); }
/// <summary> /// 执行第二个线程的查询操作 /// </summary> public void Execute() { //反复执行匹配操作,直到提取出第一个不符合时间间隔的对象才跳出 //1 先执行去除过期对象的操作 while (CheckFirstObjMatchCondition()) { } //2 判断无过期对象的list中第一个对象是否满足间隔时间 var first_obj = redisListhelper.GetFirstObj(List_Key); if(CheckFirstObjOvertime(first_obj, Interval_QueryAgain)) { //根据msgid取出对应的hash表中的对象 if(hash_helper.Exist(Hash_Key, first_obj.MsgId)) { var obj= hash_helper.Get<Redis_HashWFObj>(Hash_Key, first_obj.MsgId); //3.1 取出WF_Id,并根据该id继续书签 var wf_id = obj.WFId; //3.2 恢复工作流 Activity workflow_temp = new MainStatistics_Advanced(); //恢复工作流 var work_reus=Common.WorkFlowAppHelper.LoadWorkflowApplication(workflow_temp, Guid.Parse("9c7b78a5-e6f2-496b-9ba9-bc80b48e2aee")); //3.3 读取WF_Query_Instance表根据指定WF_Id取出对应的State、StepId、WF_Result(或从hash中读取)!!!!! var bookmark = new PMS.Model.WFModel.BookMarkObj<int>() { BookMarkName = "恢复书签", State = 1, StepId = 1, WF_Result = 6 }; work_reus.ResumeBookmark("书签1", bookmark); } } }
static void Main(string[] args) { //启动工作流的方式(一) //Activity workflow_temp = new MainStatistics_Advanced(); //WorkflowInvoker.Invoke(workflow1); //启动工作流的方式(二) //使用WorkflowApplication承载工作流 //此种方式已经封装至Common中的WorkFlowHelper类中 #region 此种方法已被封装,此处注释掉 ////1.1 创建传入的参数字典(可以传入多个参数) ////1.2 创建工作流活动实例 //Activity workflow_temp = new MainStatistics_Advanced(); ////2 将活动传递给工作流 //WorkflowApplication app = new WorkflowApplication(workflow_temp); ////3 将工作流写入数据库中 //string connect_str = Common.ConfigHelper.GetSettingValue("workflowConnection"); //SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connect_str); //app.InstanceStore = store; ////封装至Common中的WorkFlowHelper类中 #endregion //暂时注释掉 Activity workflow_temp = new MainStatistics_Advanced(); //var bookmark = new PMS.Model.WFModel.BookMarkObj<int>() //{ // BookMarkName = "恢复书签", // State = 1, // StepId = 1, // WF_Result = 4, // MsgId = obj_hashWFObj.MsgId //}; #region 9月25日 测试简单的工作流恢复的问题,此处暂时注释掉 var dic = new Dictionary<string, object>() { { "TempBookMarkName", "书签1" } }; //var work = Common.WorkFlowAppHelper.CreateWorkflowApplication(workflow_temp, dic); //{370159d5-24b5-4a54-b3d6-1ac569938a78} var work_reus = Common.WorkFlowAppHelper.LoadWorkflowApplication(workflow_temp, Guid.Parse("9e98b7d3-781f-4419-9a2b-a2e1c8300465")); var bookmark = new PMS.Model.WFModel.BookMarkObj<int>() { BookMarkName = "恢复书签", State = 1, StepId = 1, WF_Result = 4, //57403176c40e4368977735c42ab45539 MsgId= "3cea5aab338f497fb9e6782528d94aff" }; work_reus.ResumeBookmark("书签1", bookmark); #endregion //测试 持久化 已经可以持久化(注意 数据库的 连接字符串) //9月26日 测试工作流 暂时注释掉 #region 测试持久化问题(已解决) //Activity activity = new Activity_Test(); ////1 创建工作流 ////1.1 此处为为创建的工作流输入的参数 //Dictionary<string, object> dic = new Dictionary<string, object>() { { "temp", "测试输入参数" } }; //var work = Common.WorkFlowAppHelper.CreateWorkflowApplication(activity, dic); ////2 恢复工作流 //var work_reus = Common.WorkFlowAppHelper.LoadWorkflowApplication(activity, Guid.Parse("a95f8bf4-4004-4ac5-9949-955ce1fabe97")); ////第一个参数为工作流创建时为书签所起的名字,第二个参数为创建书签时,声明的回调方法BookmarkCallback指定的某个方法 ////BookmarkCallback 要求的 签名 为 ////NativeActivityContext context, Bookmark bookmark, object value ////此处的dic及为方法签名中的第三个参数value //work_reus.ResumeBookmark("测试书签", dic); #endregion Console.WriteLine("工作流结束,输入任何键退出"); Console.ReadLine(); }