/// <summary> /// 动态获取路线,根据决策节点设置条件表达式,自动去判断流转的路线 /// </summary> /// <returns>路线</returns> public Transition GetTransition(Node n) { Command command = n.Command; IList <WorkflowConfiguration> settings = ConfigurationService.Query(); WorkflowConfiguration config = settings .Where(cfg => cfg.ID == long.Parse(command.ID)) .FirstOrDefault(); using ISession session = DbFactory.CreateSessionFactory(config.ConnectionString, config.ProviderName).OpenSession(); try { DataTable resultSet = new DataTable(Guid.NewGuid().ToString()); IDbCommand cmd = session.Connection.CreateCommand(); IDbDataParameter dataParameter = cmd.CreateParameter(); dataParameter.ParameterName = "InstanceID"; dataParameter.Value = n.InstanceID; dataParameter.Size = 50; dataParameter.DbType = DbType.String; dataParameter.Direction = ParameterDirection.Input; cmd.Parameters.Add(dataParameter); cmd.CommandText = command.Text; DataTable result = new DataTable(); using (IDataReader reader = cmd.ExecuteReader()) { resultSet.Load(reader); reader.Close(); } Transition instance = null; List <Transition> transitions = n.Transitions.ToList(); if (resultSet.Rows.Count > 0) { foreach (Transition transition in transitions) { if (!String.IsNullOrEmpty(transition.Expression) && resultSet.Select(transition.Expression).Length > 0) { instance = transition; break; } } } resultSet.Dispose(); return(instance); } catch (Exception ex) { throw ex; } }
public void Execute(Node n) { if (n.Command != null) { Command command = n.Command; IList <WorkflowConfiguration> settings = ConfigurationService.Query(); WorkflowConfiguration config = settings.Where(cfg => cfg.ID == long.Parse(command.ID)).FirstOrDefault(); try { using ISession session = DbFactory.CreateSessionFactory(config.ConnectionString, config.ProviderName).OpenSession(); session.CreateSQLQuery(command.Text) .SetParameter("InstanceID", n.InstanceID) .ExecuteUpdate(); } catch (Exception ex) { throw ex; } } }