public ModelInvokeResult <FlowDefinePK> Create(FlowDefine flowDefine) { ModelInvokeResult <FlowDefinePK> result = new ModelInvokeResult <FlowDefinePK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); if (flowDefine.FlowDefineId == GlobalManager.GuidAsAutoGenerate) { flowDefine.FlowDefineId = Guid.NewGuid(); } /***********************begin 自定义代码*******************/ flowDefine.OperatedBy = NormalSession.UserId.ToGuid(); flowDefine.OperatedOn = DateTime.Now; /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = flowDefine.GetCreateMethodName(), ParameterObject = flowDefine.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements); result.instance = new FlowDefinePK { FlowDefineId = flowDefine.FlowDefineId }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public ModelInvokeResult <FlowDefinePK> Nullify(string strFlowDefineId) { ModelInvokeResult <FlowDefinePK> result = new ModelInvokeResult <FlowDefinePK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); Guid?_FlowDefineId = strFlowDefineId.ToGuid(); if (_FlowDefineId == null) { result.Success = false; result.ErrorCode = 59996; return(result); } FlowDefine flowDefine = new FlowDefine { FlowDefineId = _FlowDefineId, Status = 0 }; /***********************begin 自定义代码*******************/ flowDefine.OperatedBy = NormalSession.UserId.ToGuid(); flowDefine.OperatedOn = DateTime.Now; /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = flowDefine.GetUpdateMethodName(), ParameterObject = flowDefine.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements); result.instance = new FlowDefinePK { FlowDefineId = _FlowDefineId }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public InvokeResult NullifySelected(string strFlowDefineIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrFlowDefineIds = strFlowDefineIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrFlowDefineIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new FlowDefine().GetUpdateMethodName(); foreach (string strFlowDefineId in arrFlowDefineIds) { FlowDefine flowDefine = new FlowDefine { FlowDefineId = strFlowDefineId.ToGuid(), Status = 0 }; /***********************begin 自定义代码*******************/ flowDefine.OperatedBy = NormalSession.UserId.ToGuid(); flowDefine.OperatedOn = DateTime.Now; /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = flowDefine.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); } BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public InvokeResult DeleteSelected(string strFlowDefineIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrFlowDefineIds = strFlowDefineIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrFlowDefineIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new FlowDefine().GetDeleteMethodName(); foreach (string strFlowDefineId in arrFlowDefineIds) { FlowDefinePK pk = new FlowDefinePK { FlowDefineId = strFlowDefineId.ToGuid() }; DeleteCascade(statements, pk); statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE }); } BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
private InvokeResult ExecFlowAction(FlowAction flowAction, string strConnectId) { InvokeResult result = new InvokeResult { Success = true }; string[] bIds = flowAction.BIZ_IDs.Split('|'); //流转状态 0-正流,1-逆流 默认正流,正流(当前状态加上当前操作);逆流(当前状态) int iAction = 0; if (flowAction.FlowType == 0) { //默认正向流转 iAction += flowAction.ProcessAction; } try { FlowDefineMapping flowDefineMapping = BuilderFactory.DefaultBulder(strConnectId).List <FlowDefineMapping>(new { MappingType = flowAction.MappingType, MappingColumn = flowAction.MappingColumn, MappingId = flowAction.MappingId }.ToStringObjectDictionary()).FirstOrDefault(); if (flowDefineMapping != null && !string.IsNullOrEmpty(flowDefineMapping.FlowName)) { flowAction.FlowName = flowDefineMapping.FlowName; } //找出当前流程的最高去处和默认去处 IList <FlowDefine> flowDefineList = BuilderFactory.DefaultBulder(strConnectId).List <FlowDefine>(new { FlowName = flowAction.FlowName, TableName = flowAction.TableName, TableColumn = flowAction.TableColumn, Status = 1, OrderByClause = " FlowTo ,CurrentState " }.ToStringObjectDictionary()); //如果是流程到了最顶级的话或者未进入流程或者切换流程则跳回当前流程默认的最低级别,以达到重新开始流转效果 string sql = "insert into PUB_Flow (FlowId,OperatedBy,OperatedOn,BIZ_ID,TableName,FlowDefineId," + " FlowFrom,FlowTo,ProcessResult,ProcessComment,ProcessTitle )"; sql += "select NEWID(),'" + NormalSession.UserId + "',GETDATE(),t.{0},k.TableName,k.FlowDefineId,k.CurrentState," + " k.FlowTo,k.ProcessAction,'" + flowAction.ProcessComment + "',k.ProcessorTitle From (select x.{0}," + " (case when isnull(z.FlowName,'') <>'{2}' or y.FlowTo is null or y.FlowTo={4} then {3} else y.FlowTo end) as prevState, " + " (case when isnull(z.FlowName,'') <>'{2}' then '{2}' else z.FlowName end) FlowName ," + " isnull(z.TableColumn,'{0}') TableColumn, isnull(z.TableName,'{1}') TableName From " + " (select a.{0},MAX(b.Id) as FId From {1} a left join Pub_Flow b on a.{0}=b.BIZ_ID "; if (bIds.Length > 0 && bIds[0] != "") { //去掉空值,并给每个值加上'',以逗号隔开(支持部分批量) sql += " where a.{0} in( '" + string.Join("','", bIds.Where(s => !string.IsNullOrEmpty(s)).ToArray()) + "' )"; } else { //按区域进行过滤 以到达批量的效果 sql += " where a." + flowAction.MappingColumn + "= '" + flowAction.MappingId + "' "; if (!string.IsNullOrEmpty(flowAction.WhereClause)) { sql += " and " + flowAction.WhereClause; } } sql += " group by a.{0} ) x left join Pub_Flow y on x.FId=y.Id left join Pub_FlowDefine z on " + " y.FlowDefineId=z.FlowDefineId ) t left join Pub_FlowDefine k on k.CurrentState=t.prevState+{5} " + " and k.ProcessAction={5} and k.FlowName=t.FlowName and k.TableName=t.TableName and k.TableColumn=t.TableColumn" + " where k.CurrentState={6} and k.ProcessAction={5} and k.FlowName='{2}' and k.TableName='{1}' and k.TableColumn='{0}'"; string statements = string.Format(sql, flowAction.TableColumn, flowAction.TableName, flowAction.FlowName, flowDefineList.First().FlowTo, flowDefineList.Last().FlowTo, iAction, flowAction.ProcessState + iAction); BuilderFactory.DefaultBulder(strConnectId).ExecuteNativeSqlNoneQuery(statements); //是否流到最顶级。是的话返回true FlowDefine flowdefine = flowDefineList.FirstOrDefault(s => (s.CurrentState == flowAction.ProcessState + iAction) && (s.ProcessAction == flowAction.ProcessAction)); if (flowdefine != null && flowDefineList.Last() != null && flowdefine.FlowTo == flowDefineList.Last().FlowTo) { result.ErrorMessage = "true"; } } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }