public ModelInvokeResult <FlowDefineMappingPK> Nullify(string strId) { ModelInvokeResult <FlowDefineMappingPK> result = new ModelInvokeResult <FlowDefineMappingPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); FlowDefineMapping flowDefineMapping = new FlowDefineMapping { Id = int.Parse(strId), Status = 0 }; /***********************begin 自定义代码*******************/ flowDefineMapping.OperatedBy = NormalSession.UserId.ToGuid(); flowDefineMapping.OperatedOn = DateTime.Now; /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = flowDefineMapping.GetUpdateMethodName(), ParameterObject = flowDefineMapping.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements); result.instance = new FlowDefineMappingPK { Id = int.Parse(strId) }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public InvokeResult UpdateBaseResidentsAll(FlowAction flowAction) { InvokeResult result = new InvokeResult { Success = true }; //流转状态 0-正流,1-逆流 默认正流,正流(当前状态加上当前操作);逆流(当前状态) int iAction = 0; if (flowAction.FlowType == 0) { //默认正向流转 iAction += flowAction.ProcessAction; } try { FlowDefineMapping flowDefineMapping = BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).List <FlowDefineMapping>(new { MappingType = flowAction.MappingType, MappingColumn = flowAction.MappingColumn, MappingId = flowAction.MappingId }.ToStringObjectDictionary()).First(); if (flowDefineMapping != null && !string.IsNullOrEmpty(flowDefineMapping.FlowName)) { flowAction.FlowName = flowDefineMapping.FlowName; } //找出当前流程的最高去处和默认去处 IList <FlowDefine> flowDefineList = BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).List <FlowDefine>(new { FlowName = flowAction.FlowName, TableName = flowAction.TableName, TableColumn = flowAction.TableColumn, Status = 1, OrderByClause = " FlowTo ,CurrentState " }.ToStringObjectDictionary()); //如果是流程到了最顶级的话或者未进入流程或者切换流程则跳回当前流程默认的最低级别,以达到重新开始流转效果 string sql = "update {1} set Status=1 where {0} in ("; sql += "select x.{0} From (" + "select a.{0},MAX(b.Id) as FId From {1} a left join Pub_Flow b on a.{0}=b.BIZ_ID " + "where a.{4}= '{5}' "; 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 " + "where z.FlowName='{2}' and z.TableName='{1}' and z.TableColumn='{0}' and y.FlowTo = {3}"; sql += ")"; string statements = string.Format(sql, flowAction.TableColumn, flowAction.TableName, flowAction.FlowName, flowDefineList.Last().FlowTo, flowAction.MappingColumn, flowAction.MappingId); BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public InvokeResult NullifySelected(string strIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrIds = strIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new FlowDefineMapping().GetUpdateMethodName(); foreach (string strId in arrIds) { FlowDefineMapping flowDefineMapping = new FlowDefineMapping { Id = int.Parse(strId), Status = 0 }; /***********************begin 自定义代码*******************/ flowDefineMapping.OperatedBy = NormalSession.UserId.ToGuid(); flowDefineMapping.OperatedOn = DateTime.Now; /***********************end 自定义代码*********************/ statements.Add(new IBatisNetBatchStatement { StatementName = statementName, ParameterObject = flowDefineMapping.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 strIds) { InvokeResult result = new InvokeResult { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); string[] arrIds = strIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arrIds.Length == 0) { result.Success = false; result.ErrorCode = 59996; return(result); } string statementName = new FlowDefineMapping().GetDeleteMethodName(); foreach (string strId in arrIds) { FlowDefineMappingPK pk = new FlowDefineMappingPK { Id = int.Parse(strId) }; 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); }