Ejemplo n.º 1
0
        public bool TryGetWorkflow(Guid workflowInstanceId, out SqlTrackingWorkflowInstance workflowInstance)
        {
            bool          flag;
            SqlCommand    command = this.BuildCommand(workflowInstanceId);
            SqlDataReader reader  = null;

            workflowInstance = null;
            try
            {
                command.Connection = this.GetConnection();
                reader             = command.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    workflowInstance = this.BuildInstance(reader);
                    return(true);
                }
                flag = false;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (((command != null) && (command.Connection != null)) && (command.Connection.State != ConnectionState.Closed))
                {
                    command.Connection.Close();
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        internal static SqlTrackingWorkflowInstance BuildInstance(SqlDataReader reader, string connectionString)
        {
            if (null == reader)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.IsClosed)
            {
                throw new ArgumentException(ExecutionStringManager.InvalidSqlDataReader, "reader");
            }

            SqlTrackingWorkflowInstance inst = new SqlTrackingWorkflowInstance(connectionString);

            inst.WorkflowInstanceId         = reader.GetGuid(1);
            inst.WorkflowInstanceInternalId = reader.GetInt64(2);
            inst.Initialized = reader.GetDateTime(3);
            if (DBNull.Value == reader[4])
            {
                inst.InvokingWorkflowInstanceId = Guid.Empty;
            }
            else
            {
                inst.InvokingWorkflowInstanceId = reader.GetGuid(4);
            }
            inst.Status = (WorkflowStatus)reader.GetInt32(5);
            //
            // Xaml only workflows do not have types
            if (!reader.IsDBNull(6))
            {
                string fullName = reader.GetString(6), assemblyName = reader.GetString(7);
                inst.WorkflowType = Type.GetType(fullName + ", " + assemblyName, true, false);
            }

            return(inst);
        }
Ejemplo n.º 3
0
        internal static SqlTrackingWorkflowInstance BuildInstance(SqlDataReader reader, string connectionString)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.IsClosed)
            {
                throw new ArgumentException(ExecutionStringManager.InvalidSqlDataReader, "reader");
            }
            SqlTrackingWorkflowInstance instance = new SqlTrackingWorkflowInstance(connectionString)
            {
                WorkflowInstanceId         = reader.GetGuid(1),
                WorkflowInstanceInternalId = reader.GetInt64(2),
                Initialized = reader.GetDateTime(3)
            };

            if (DBNull.Value == reader[4])
            {
                instance.InvokingWorkflowInstanceId = Guid.Empty;
            }
            else
            {
                instance.InvokingWorkflowInstanceId = reader.GetGuid(4);
            }
            instance.Status = (WorkflowStatus)reader.GetInt32(5);
            if (!reader.IsDBNull(6))
            {
                instance.WorkflowType = Type.GetType(reader.GetString(6) + ", " + reader.GetString(7), true, false);
            }
            return(instance);
        }
        public bool TryGetWorkflow(Guid workflowInstanceId, out SqlTrackingWorkflowInstance workflowInstance)
        {
            SqlCommand cmd = BuildCommand(workflowInstanceId);
            SqlDataReader reader = null;
            workflowInstance = null;

            try
            {

                cmd.Connection = GetConnection();
                reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                //
                // There will only be 1 row
                if (reader.Read())
                {
                    workflowInstance = BuildInstance(reader);
                    return true;
                }
                else
                    return false;
            }
            finally
            {
                if (null != reader)
                    reader.Close();

                if (null != cmd && null != cmd.Connection && ConnectionState.Closed != cmd.Connection.State)
                    cmd.Connection.Close();
            }
        }
Ejemplo n.º 5
0
        private void LoadInvokedWorkflowsFromReader(SqlDataReader reader, object parameter)
        {
            if (null == reader)
            {
                throw new ArgumentNullException("reader");
            }

            DateTime tmpMin = SqlDateTime.MinValue.Value;

            while (reader.Read())
            {
                SqlTrackingWorkflowInstance inst = SqlTrackingQuery.BuildInstance(reader, _connectionString);

                if (inst.Initialized > tmpMin)
                {
                    tmpMin = inst.Initialized;
                }

                _invoked.Add(inst);
            }
            //
            // set the min for the next query to the most recently invoked instance from this query
            // Don't overwrite the previous min if nothing came back for this query
            if (tmpMin > SqlDateTime.MinValue.Value)
            {
                _invMinDT = tmpMin;
            }
        }
Ejemplo n.º 6
0
        private void LoadInvokedWorkflowsFromReader(SqlDataReader reader, object parameter)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            DateTime initialized = SqlDateTime.MinValue.Value;

            while (reader.Read())
            {
                SqlTrackingWorkflowInstance item = SqlTrackingQuery.BuildInstance(reader, this._connectionString);
                if (item.Initialized > initialized)
                {
                    initialized = item.Initialized;
                }
                this._invoked.Add(item);
            }
            if (initialized > SqlDateTime.MinValue.Value)
            {
                this._invMinDT = initialized;
            }
        }
Ejemplo n.º 7
0
        public bool TryGetWorkflow(Guid workflowInstanceId, out SqlTrackingWorkflowInstance workflowInstance)
        {
            SqlCommand    cmd    = BuildCommand(workflowInstanceId);
            SqlDataReader reader = null;

            workflowInstance = null;

            try
            {
                cmd.Connection = GetConnection();
                reader         = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                //
                // There will only be 1 row
                if (reader.Read())
                {
                    workflowInstance = BuildInstance(reader);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            finally
            {
                if (null != reader)
                {
                    reader.Close();
                }

                if (null != cmd && null != cmd.Connection && ConnectionState.Closed != cmd.Connection.State)
                {
                    cmd.Connection.Close();
                }
            }
        }
 public bool TryGetWorkflow(Guid workflowInstanceId, out SqlTrackingWorkflowInstance workflowInstance)
 {
     bool flag;
     SqlCommand command = this.BuildCommand(workflowInstanceId);
     SqlDataReader reader = null;
     workflowInstance = null;
     try
     {
         command.Connection = this.GetConnection();
         reader = command.ExecuteReader(CommandBehavior.CloseConnection);
         if (reader.Read())
         {
             workflowInstance = this.BuildInstance(reader);
             return true;
         }
         flag = false;
     }
     finally
     {
         if (reader != null)
         {
             reader.Close();
         }
         if (((command != null) && (command.Connection != null)) && (command.Connection.State != ConnectionState.Closed))
         {
             command.Connection.Close();
         }
     }
     return flag;
 }
 internal static SqlTrackingWorkflowInstance BuildInstance(SqlDataReader reader, string connectionString)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     if (reader.IsClosed)
     {
         throw new ArgumentException(ExecutionStringManager.InvalidSqlDataReader, "reader");
     }
     SqlTrackingWorkflowInstance instance = new SqlTrackingWorkflowInstance(connectionString) {
         WorkflowInstanceId = reader.GetGuid(1),
         WorkflowInstanceInternalId = reader.GetInt64(2),
         Initialized = reader.GetDateTime(3)
     };
     if (DBNull.Value == reader[4])
     {
         instance.InvokingWorkflowInstanceId = Guid.Empty;
     }
     else
     {
         instance.InvokingWorkflowInstanceId = reader.GetGuid(4);
     }
     instance.Status = (WorkflowStatus) reader.GetInt32(5);
     if (!reader.IsDBNull(6))
     {
         instance.WorkflowType = Type.GetType(reader.GetString(6) + ", " + reader.GetString(7), true, false);
     }
     return instance;
 }
Ejemplo n.º 10
0
 internal bool TryGetWorkflow(Guid workflowInstanceId, out SqlTrackingWorkflowInstance sqlTrackingWorkflowInstance)
 {
     SqlTrackingQuery sqlTrackingQuery = new SqlTrackingQuery(connectionString);
     return sqlTrackingQuery.TryGetWorkflow(workflowInstanceId, out sqlTrackingWorkflowInstance);
 }
        internal static SqlTrackingWorkflowInstance BuildInstance(SqlDataReader reader, string connectionString)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");
            if (reader.IsClosed)
                throw new ArgumentException(ExecutionStringManager.InvalidSqlDataReader, "reader");

            SqlTrackingWorkflowInstance inst = new SqlTrackingWorkflowInstance(connectionString);
            inst.WorkflowInstanceId = reader.GetGuid(1);
            inst.WorkflowInstanceInternalId = reader.GetInt64(2);
            inst.Initialized = reader.GetDateTime(3);
            if (DBNull.Value == reader[4])
                inst.InvokingWorkflowInstanceId = Guid.Empty;
            else
                inst.InvokingWorkflowInstanceId = reader.GetGuid(4);
            inst.Status = (WorkflowStatus)reader.GetInt32(5);
            //
            // Xaml only workflows do not have types
            if (!reader.IsDBNull(6))
            {
                string fullName = reader.GetString(6), assemblyName = reader.GetString(7);
                inst.WorkflowType = Type.GetType(fullName + ", " + assemblyName, true, false);
            }

            return inst;
        }