コード例 #1
0
        public static PageView Load(Int32 pageViewId, bool useCache)
        {
            if (pageViewId == 0)
            {
                return(null);
            }
            PageView pageView = null;
            string   key      = "PageView_" + pageViewId.ToString();

            if (useCache)
            {
                pageView = ContextCache.GetObject(key) as PageView;
                if (pageView != null)
                {
                    return(pageView);
                }
            }
            pageView = new PageView();
            if (pageView.Load(pageViewId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, pageView);
                }
                return(pageView);
            }
            return(null);
        }
コード例 #2
0
        public static bool Delete(Int32 pageViewId)
        {
            PageView pageView = new PageView();

            if (pageView.Load(pageViewId))
            {
                return(pageView.Delete());
            }
            return(false);
        }
コード例 #3
0
        public static PageViewCollection LoadForStore(int maximumRows, int startRowIndex, string sortExpression)
        {
            int storeId = Token.Instance.StoreId;
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + PageView.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_PageViews");
            selectQuery.Append(" WHERE StoreId = @storeId");
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, storeId);
            //EXECUTE THE COMMAND
            PageViewCollection results = new PageViewCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        PageView pageView = new PageView();
                        PageView.LoadDataReader(pageView, dr);
                        results.Add(pageView);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
コード例 #4
0
 /// <summary>
 /// Loads the given PageView object from the given database data reader.
 /// </summary>
 /// <param name="pageView">The PageView object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(PageView pageView, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     pageView.PageViewId        = dr.GetInt32(0);
     pageView.StoreId           = dr.GetInt32(1);
     pageView.ActivityDate      = LocaleHelper.ToLocalTime(dr.GetDateTime(2));
     pageView.RemoteIP          = dr.GetString(3);
     pageView.RequestMethod     = dr.GetString(4);
     pageView.UserId            = dr.GetInt32(5);
     pageView.UriStem           = dr.GetString(6);
     pageView.UriQuery          = NullableData.GetString(dr, 7);
     pageView.TimeTaken         = dr.GetInt32(8);
     pageView.UserAgent         = NullableData.GetString(dr, 9);
     pageView.Referrer          = NullableData.GetString(dr, 10);
     pageView.CatalogNodeId     = NullableData.GetInt32(dr, 11);
     pageView.CatalogNodeTypeId = NullableData.GetInt16(dr, 12);
     pageView.Browser           = dr.GetString(13);
     pageView.BrowserName       = dr.GetString(14);
     pageView.BrowserPlatform   = dr.GetString(15);
     pageView.BrowserVersion    = dr.GetString(16);
     pageView.AffiliateId       = dr.GetInt32(17);
     pageView.IsDirty           = false;
 }
コード例 #5
0
 public static SaveResult Insert(PageView pageView)
 {
     return(pageView.Save());
 }
コード例 #6
0
 public static SaveResult Update(PageView pageView)
 {
     return(pageView.Save());
 }
コード例 #7
0
 public static bool Delete(PageView pageView)
 {
     return(pageView.Delete());
 }