public void OnPersist(StoreView snapshot, IReadOnlyList <Blockchain.ApplicationExecuted> applicationExecutedList) { foreach (var appExec in applicationExecutedList.Where(e => e.Transaction != null)) { var execResult = new ExecuteResultInfo(); execResult.TxId = appExec.Transaction.Hash.ToString(); execResult.Trigger = appExec.Trigger; execResult.VMState = appExec.VMState; execResult.GasConsumed = appExec.GasConsumed; try { execResult.ResultStack = appExec.Stack.Select(q => q.ToParameter().ToJson()).ToArray(); } catch (InvalidOperationException) { execResult.ResultStack = "error: recursive reference"; } execResult.Notifications = appExec.Notifications.Select(q => { var notification = new NotificationInfo(); notification.Contract = q.ScriptHash.ToString(); try { notification.State = q.State.ToParameter().ToJson(); } catch (InvalidOperationException) { notification.State = "error: recursive reference"; } return(notification); }).ToList(); _db.AddExecuteLog(appExec.Transaction.Hash, execResult); } }
/// <summary> /// save log after call <see cref="Commit"/> method /// </summary> /// <param name="txId"></param> /// <param name="log"></param> public void AddExecuteLog(UInt256 txId, ExecuteResultInfo log) { if (log != null) { writeBatch.Put(ExecuteLogKey(txId), log.SerializeJsonBytes()); } }
/// <summary> /// save execute result log after call <see cref="Commit"/> method /// </summary> /// <param name="log"></param> public void SaveTxExecuteLog(ExecuteResultInfo log) { if (log != null && log.TxId != null) { writeBatch.Put(ExecuteLogKey(log.TxId), log.SerializeJsonBytes()); } }
/// <summary> /// 重写流程结束方法 /// </summary> public override Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo DoServiceEvent(int k2_workflowId, SerializableDictionary <string, string> dataFields) { Logger.logger.DebugFormat("Params:{0},{1}", k2_workflowId, dataFields.Keys.Count); foreach (KeyValuePair <string, string> item in dataFields) { Logger.logger.DebugFormat("df:{0}-{1}", item.Key, item.Value); } Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo info = new ExecuteResultInfo(); try { //根据流程ID获取FormId JC_TenderSpecialItemInfo companyInfo = Pkurg.PWorldBPM.Business.BIZ.JC.JC_TenderSpecialItem.GetJC_TenderSpecialItemInfoByWfId(k2_workflowId.ToString()); string jcFormCode = companyInfo.FormID; string jcFormName = companyInfo.Title; string StartUserName = companyInfo.UserName; //判断是否审批通过,存储0,1表示通过与不通过 string resultString = dataFields["IsPass"]; //这部分是根据自己的流程来判定的,现在只是通过流程ID得到FormId来进行判断结束 Logger.logger.DebugFormat("Proc:{0},{1}", jcFormCode, resultString); JC_TenderSpecialItemInfo model = new JC_TenderSpecialItemInfo(); model.FormID = jcFormCode; model.IsApproval = resultString; //两个文件名字最好不能起的一样,尤其是增删改查操作的时候文件名不能一样 Pkurg.PWorldBPM.Business.BIZ.JC.JC_TenderSpecialItem.UpdateJC_TenderSpecialItemInfoInfoByModel(model); //流程结束之后授权给集团招采部门所有人 //得到各参数的值:AuthorizedByUserCode:授权人编号;AuthorizedByUserName:授权人姓名;ProId:流程ID;ProcName:流程编号;AuthorizedUserCode:被授权部门编号;AuthorizedUserName:被授权部门名称 DataTable dt = Pkurg.PWorldBPM.Business.Controls.WF_WorkFlowInstances.GetWorkFlowInstanceByFormID(jcFormCode); DataRow dataRow = dt.Rows[0]; string AuthorizedByUserCode = dataRow["CreateByUserCode"].ToString(); string AuthorizedByUserName = dataRow["CreateByUserName"].ToString(); string ProId = jcFormCode; string ProcName = jcFormName; //得到子公司的招采部的编号以及名称 Pkurg.PWorld.Entities.Department deptInfo = new Pkurg.PWorld.Business.Permission.BFPmsUserRoleDepartment().GetDeptByCurrentDeptCodeAndOtherDeptName(companyInfo.StartDeptId, "招标采购部"); //授权给所在公司的招标采购部 InsertAuthorizationToJCGroup(AuthorizedByUserCode, AuthorizedByUserName, ProId, ProcName, deptInfo.DepartCode); //授权给集团的采购管理部 InsertAuthorizationToJCGroup(AuthorizedByUserCode, AuthorizedByUserName, ProId, ProcName, CGDeptCode); info.IsSuccess = true; } catch (Exception ex) { info.ExecException = ex.StackTrace; info.IsSuccess = false; } Logger.logger.DebugFormat("Result:{0}", info.IsSuccess); Logger.logger.DebugFormat("Result-e:{0}", info.ExecException); return(info); }
/// <summary> /// 重写流程结束方法 /// </summary> public override Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo DoServiceEvent(int k2_workflowId, SerializableDictionary <string, string> dataFields) { Logger.logger.DebugFormat("Params:{0},{1}", k2_workflowId, dataFields.Keys.Count); foreach (KeyValuePair <string, string> item in dataFields) { Logger.logger.DebugFormat("df:{0}-{1}", item.Key, item.Value); } Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo info = new ExecuteResultInfo(); try { //根据流程ID获取FormId //string jcFormCode = Pkurg.PWorldBPM.Business.BIZ.JC.JC_FinalistApproval.GetJC_FinalistApprovalInfoByWfId(k2_workflowId.ToString()).FormID; JC_FinalistApprovalInfo companyInfo = Pkurg.PWorldBPM.Business.BIZ.JC.JC_FinalistApproval.GetJC_FinalistApprovalInfoByWfId(k2_workflowId.ToString()); string jcFormCode = companyInfo.FormID; string jcFormName = companyInfo.ProjectName; string StartUserName = companyInfo.ArchiveName; //判断是否审批通过,存储0,1表示通过与不通过 string resultString = dataFields["IsPass"]; //添加判断在招标委员会的节点上,如果时间过去两天,还有人没有审批, //则根据相关的字段给数据库插入“默认同意”字段,并且时间为截至时间[三个表关联] //条件=招标委员会意见/集团招标委员会意见,同时时间=2天,option.value=null //option.value="同意" 时间=当前时间 //方法 insertinto:加意见 instanceid //先得到节点,再把节点上的datefield的人分隔开,再挨个判断他有没有意见,没有意见的再插入 //if (dataFields["IsPass"] == "1") //{ // string currentActiveName = ""; // string persons = ""; // if (dataFields["IsReportToResource"] == "0") // { // persons = dataFields["GroupTenderCommitteeManager"]; // currentActiveName = "集团招标委员会意见"; // } // else // { // persons = dataFields["TenderCommitteeManager"]; // currentActiveName = "招标委员会意见"; // } // //把上面节点的datefield的人分隔开,再挨个判断他有没有意见,没有意见的再插入 // foreach (string person in persons.Split(',')) // { // //通过一个方法定义三个变量得到 // // l WF_InstanogionnameceId CurrentActiveName // //loginName, wfInstanceId, currentActiveName // string LoginName = person.ToLower().Replace("k2:founder\\", ""); // string WFInstanceId = k2_workflowId.ToString(); // //给表中插入数据,并且option字段值默认为“默认同意” // if (!string.IsNullOrEmpty(LoginName)) // { // Pkurg.PWorldBPM.Business.BIZ.JC.JC_FinalistApproval.InsertWF_Approval_RecordByInstanceID(currentActiveName, LoginName, WFInstanceId); // } // } //} //添加判断在招标委员会主任的节点上,如果时间过去两天,还有人没有审批, //则根据相关的字段给数据库插入“同意”字段,并且时间为截至时间[三个表关联] //条件=招标委员会主任意见/集团招标委员会主任意见,同时时间=2天,option.value=null //option.value="同意" 时间=当前时间 //instanceid //先得到节点,再把节点上的datefield的人分隔开,再挨个判断他有没有意见,没有意见的再插入 //if (dataFields["IsPass"] == "1") //{ // string currentActiveName = ""; // string person = ""; // if (dataFields["IsReportToResource"] == "0") // { // person = dataFields["GroupTenderCommitteeChairman"]; // currentActiveName = "集团招标委员会主任意见"; // } // else // { // person = dataFields["TenderCommitteeChairman"]; // currentActiveName = "招标委员会主任意见"; // } // //定义三个变量得到 // //loginName, wfInstanceId, currentActiveName // string LoginName = person.ToLower().Replace("k2:founder\\", ""); // string WFInstanceId = k2_workflowId.ToString(); // //给表中插入数据,并且option字段值默认为“默认同意” // Pkurg.PWorldBPM.Business.BIZ.JC.JC_FinalistApproval.InsertWF_Approval_RecordByInstanceID(currentActiveName, LoginName, WFInstanceId); //} //这部分是根据自己的流程来判定的,现在只是通过流程ID得到FormId来进行判断结束 Logger.logger.DebugFormat("Proc:{0},{1}", jcFormCode, resultString); JC_FinalistApprovalInfo model = new JC_FinalistApprovalInfo(); model.FormID = jcFormCode; model.IsApproval = resultString; //两个文件名字最好不能起的一样,尤其是增删改查操作的时候文件名不能一样 Pkurg.PWorldBPM.Business.BIZ.JC.JC_FinalistApproval.UpdateJC_FinalistApprovalInfoInfoByModel(model); //流程结束之后授权给集团招采部门所有人 //得到各参数的值:AuthorizedByUserCode:授权人编号;AuthorizedByUserName:授权人姓名;ProId:流程ID; //ProcName:流程编号;AuthorizedUserCode:被授权部门编号;AuthorizedUserName:被授权部门名称 DataTable dt = Pkurg.PWorldBPM.Business.Controls.WF_WorkFlowInstances.GetWorkFlowInstanceByFormID(jcFormCode); DataRow dataRow = dt.Rows[0]; string AuthorizedByUserCode = dataRow["CreateByUserCode"].ToString(); string AuthorizedByUserName = dataRow["CreateByUserName"].ToString(); string ProId = jcFormCode; string ProcName = jcFormName; InsertAuthorizationToJCGroup(AuthorizedByUserCode, AuthorizedByUserName, ProId, ProcName, CGDeptCode); info.IsSuccess = true; } catch (Exception ex) { info.ExecException = ex.StackTrace; info.IsSuccess = false; } Logger.logger.DebugFormat("Result:{0}", info.IsSuccess); Logger.logger.DebugFormat("Result-e:{0}", info.ExecException); return(info); }
private void AnalysisAppExecuteResult(Blockchain.ApplicationExecuted appExec) { var execResult = new ExecuteResultInfo(); Transaction transaction = appExec.Transaction; if (transaction != null) { //fee account Result.BalanceChangeAccounts.Add(new AccountAsset(transaction.Sender, NativeContract.GAS.Hash)); execResult.TxId = transaction.Hash; } execResult.Trigger = appExec.Trigger; execResult.VMState = appExec.VMState; execResult.GasConsumed = appExec.GasConsumed; try { execResult.ResultStack = appExec.Stack.Select(q => q.ToContractParameter().ToJson()).ToArray(); } catch (InvalidOperationException) { execResult.ResultStack = "error: recursive reference"; } execResult.Notifications = appExec.Notifications.Select(n => n.ToNotificationInfo()).ToList(); Result.ExecuteResultInfos.Add(execResult); foreach (var contract in execResult.Notifications.Select(n => n.Contract).Distinct()) { var asset = AssetCache.GetAssetInfo(contract, _snapshot); if (asset != null) { Result.AssetInfos[asset.Asset] = asset; } } if (execResult.VMState.HasFlag(VMState.FAULT)) { //no need to track return; } if (execResult.Notifications.IsEmpty()) { //no need to track return; } foreach (var notification in appExec.Notifications) { switch (notification.EventName) { case "transfer": case "Transfer": ProcessTransfer(notification, appExec); break; case "Deploy": ProcessDeploy(notification, appExec); break; case "Destory": ProcessDestory(notification, appExec); break; default: break; } } }