public override ICollection Scan()
        {
            var arrayList = new ArrayList();
            DateTime dt = DateTime.Now.AddDays(-Days);
            var workflowProvider = Db.WorkflowProvider as WorkflowProvider;
            if (workflowProvider == null)
                return arrayList;
            string connectionString = Sitecore.Configuration.Settings.GetConnectionString(Db.Name);
            SqlConnection sqlConnection = null;
            SqlDataReader sqlDataReader = null;
            try
            {
                sqlConnection = new SqlConnection(connectionString);
                SqlCommand command = sqlConnection.CreateCommand();
                command.CommandText = "SELECT DISTINCT ItemID, Language FROM WorkflowHistory WHERE Date > @date";
                command.Parameters.Add(new SqlParameter("@date", SqlDbType.DateTime)).Value = dt;
                sqlConnection.Open();
                sqlDataReader = command.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    Item obj = Db.GetItem(new ID(sqlDataReader.GetGuid(0)), Language.Parse(sqlDataReader.GetString(1)));
                    if (!obj.Paths.Path.StartsWith(RootItem.Paths.Path))
                        continue;

                    foreach (WorkflowEvent wEvent in (workflowProvider.HistoryStore.GetHistory(obj)).Where((hi =>
                    {
                        if (hi.Date > dt)
                            return hi.NewState != hi.OldState;
                        return
                            false;
                    })))
                    {
                        var workflowEventCustom = new WorkflowEventCustom(obj, wEvent);
                        arrayList.Add(workflowEventCustom);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, this);
            }
            finally
            {
                if (sqlDataReader != null)
                    sqlDataReader.Close();
                if (sqlConnection != null)
                    sqlConnection.Close();
            }
            return arrayList;
        }
        public override ICollection Scan()
        {
            var      arrayList        = new ArrayList();
            DateTime dt               = DateTime.Now.AddDays(-Days);
            var      workflowProvider = Db.WorkflowProvider as WorkflowProvider;

            if (workflowProvider == null)
            {
                return(arrayList);
            }
            string        connectionString = Sitecore.Configuration.Settings.GetConnectionString(Db.Name);
            SqlConnection sqlConnection    = null;
            SqlDataReader sqlDataReader    = null;

            try
            {
                sqlConnection = new SqlConnection(connectionString);
                SqlCommand command = sqlConnection.CreateCommand();
                command.CommandText = "SELECT DISTINCT ItemID, Language FROM WorkflowHistory WHERE Date > @date";
                command.Parameters.Add(new SqlParameter("@date", SqlDbType.DateTime)).Value = dt;
                sqlConnection.Open();
                sqlDataReader = command.ExecuteReader();
                while (sqlDataReader.Read())
                {
                    Item obj = Db.GetItem(new ID(sqlDataReader.GetGuid(0)), Language.Parse(sqlDataReader.GetString(1)));
                    if (!obj.Paths.Path.StartsWith(RootItem.Paths.Path))
                    {
                        continue;
                    }

                    foreach (WorkflowEvent wEvent in (workflowProvider.HistoryStore.GetHistory(obj)).Where((hi =>
                    {
                        if (hi.Date > dt)
                        {
                            return(hi.NewState != hi.OldState);
                        }
                        return
                        (false);
                    })))
                    {
                        var workflowEventCustom = new WorkflowEventCustom(obj, wEvent);
                        arrayList.Add(workflowEventCustom);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, this);
            }
            finally
            {
                if (sqlDataReader != null)
                {
                    sqlDataReader.Close();
                }
                if (sqlConnection != null)
                {
                    sqlConnection.Close();
                }
            }
            return(arrayList);
        }
        public override System.Collections.ICollection Scan()
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();

            DateTime dt = DateTime.Now.AddDays(-Days);

            WorkflowProvider wProvider = Sitecore.Context.ContentDatabase.WorkflowProvider as WorkflowProvider;
            if (wProvider == null)
            {
                return result;
            }

            string stConnection =
                Sitecore.Configuration.Settings.GetConnectionString(Sitecore.Context.ContentDatabase.Name);

            SqlConnection conn = null;
            SqlCommand command = null;
            SqlDataReader reader = null;
            try
            {
                conn = new SqlConnection(stConnection);
                command = conn.CreateCommand();
                command.CommandText = "SELECT DISTINCT ItemID FROM WorkflowHistory WHERE Date > @date";
                command.Parameters.Add(
                    new SqlParameter("@date", System.Data.SqlDbType.DateTime)).Value = dt;

                conn.Open();
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Guid gId = reader.GetGuid(0);

                    Item item = Sitecore.Context.ContentDatabase.GetItem(new Sitecore.Data.ID(gId));

                    foreach (var wEvent in wProvider.HistoryStore.GetHistory(item).Where(hi => hi.Date > dt && hi.NewState != hi.OldState))
                    {
                        WorkflowEventCustom wec = new WorkflowEventCustom(item, wEvent);
                        result.Add(wec);
                    }
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.Message, this);
            }
            finally
            {
                if (reader != null) reader.Close();
                if (conn != null) conn.Close();
            }

            return result;
        }
        public override System.Collections.ICollection Scan()
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();

            DateTime dt = DateTime.Now.AddDays(-Days);


            WorkflowProvider wProvider = Sitecore.Context.ContentDatabase.WorkflowProvider as WorkflowProvider;

            if (wProvider == null)
            {
                return(result);
            }

            string stConnection =
                Sitecore.Configuration.Settings.GetConnectionString(Sitecore.Context.ContentDatabase.Name);

            SqlConnection conn    = null;
            SqlCommand    command = null;
            SqlDataReader reader  = null;

            try
            {
                conn                = new SqlConnection(stConnection);
                command             = conn.CreateCommand();
                command.CommandText = "SELECT DISTINCT ItemID FROM WorkflowHistory WHERE Date > @date";
                command.Parameters.Add(
                    new SqlParameter("@date", System.Data.SqlDbType.DateTime)).Value = dt;

                conn.Open();
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Guid gId = reader.GetGuid(0);

                    Item item = Sitecore.Context.ContentDatabase.GetItem(new Sitecore.Data.ID(gId));

                    foreach (var wEvent in wProvider.HistoryStore.GetHistory(item).Where(hi => hi.Date > dt && hi.NewState != hi.OldState))
                    {
                        WorkflowEventCustom wec = new WorkflowEventCustom(item, wEvent);
                        result.Add(wec);
                    }
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.Message, this);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(result);
        }