/// <summary>
        ///     Gets the data from reporting DB.
        /// </summary>
        /// <param name="spWeb">The sp web.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        private static IEnumerable <DataTable> GetDataFromReportingDb(
            SPWeb spWeb,
            string data)
        {
            Guard.ArgumentIsNotNull(spWeb, nameof(spWeb));

            SqlDateTime dateTimeFrom;
            SqlDateTime dateTimeTo;
            bool        getCompletedItems;
            var         listIdQuery = ListIdQuery(data, out dateTimeFrom, out dateTimeTo, out getCompletedItems);

            Guid myWorkListId;
            var  theWeb    = spWeb;
            var  lockedWeb = CoreFunctions.getLockedWeb(theWeb);

            using (var configWeb = Utils.GetConfigWeb(theWeb, lockedWeb))
            {
                myWorkListId = configWeb.Lists[MyWorkText].ID;
            }

            var       tables = new List <DataTable>();
            DataTable myWorkDataTable;
            DataTable fieldsTable;
            DataTable flagsTable;
            var       siteId = spWeb.Site.ID;

            using (var myWorkReportData = new MyWorkReportData(siteId))
            {
                MapCompleteField(spWeb, myWorkReportData);

                string sql;
                var    currentUser = CurrentUser(spWeb, listIdQuery, getCompletedItems, siteId, dateTimeFrom, dateTimeTo, out sql);

                IEnumerable <string>    columns;
                IList <string>          lists;
                IEnumerable <DataTable> enumerable = null;

                if (ProcessDataTables(myWorkReportData, sql, tables, myWorkListId, out myWorkDataTable, out columns, out lists, ref enumerable))
                {
                    return(enumerable);
                }

                sql =
                    $@"SELECT ColumnName, InternalName, SharePointType, RPTListId AS ListId 
                                 FROM dbo.RPTColumn WHERE (ColumnName IN ({string.Join(Comma, columns.ToArray())})) AND (RPTListId IN ({string.Join(Comma, lists.ToArray())}))";
                fieldsTable = myWorkReportData.ExecuteSql(sql);

                sql =
                    $@"SELECT ListId, ItemId, Value FROM dbo.PERSONALIZATIONS WHERE [Key] = 'Flag' AND UserId = N'{currentUser.LoginName.ToSqlCompliant()}'";
                flagsTable            = myWorkReportData.ExecuteEpmLiveSql(sql);
                flagsTable.PrimaryKey = new[] { flagsTable.Columns[ListId], flagsTable.Columns[ItemId] };
            }

            AddTables(spWeb, myWorkDataTable, fieldsTable, flagsTable, tables);

            return(tables);
        }
        public void ExecuteEpmLiveSql_ReturnsDataTable()
        {
            // Act
            _testObj.ExecuteEpmLiveSql(Sql);

            // Assert
            Assert.IsTrue(_adoShims.IsCommandCreated(Sql));
            Assert.IsTrue(_adoShims.IsCommandExecuted(Sql));
            Assert.IsTrue(_adoShims.IsDataReaderCreatedForCommand(Sql));
            Assert.IsTrue(_adoShims.IsDataReaderDisposedForCommand(Sql));
        }