Esempio n. 1
0
        public static bool AddEntry(Entry entry)
        {
            bool result;

            if (string.IsNullOrEmpty(entry.Content))
            {
                return(false);
            }

            SqlServerIo sql = SqlServerIo.Create();

            if (!sql.Ready)
            {
                return(false);
            }

            //naa
            entry.FixForMultipleLineFeeds();

            result = sql.Execute(false, NEW_ENTRY_SQL, entry.Baslik, entry.Suser, entry.Date.ToString(), entry.Content);

            if (result)
            {
                if (!sql.Read())
                {
                    result = false;
                }
                else
                {
                    entry.SetId(sql.GetValueOfColumn <int>("BaslikId"));


                    CacheManager.InvalidateCacheSet(KeysetId.Baslik(entry.BaslikID));

                    var indexKeyid = KeysetId.Index(entry.Baslik[0]);
                    CacheManager.InvalidateCacheSet(indexKeyid);

                    if (sql.GetValueOfColumn <int>("IsNewBaslikInsert") == 1)
                    {
                        //invalidate also todays section keyset a.k.a Taze
                        CacheManager.InvalidateCacheSet(KeysetId.Todays());
                    }
                }
            }


            SqlServerIo.Release(sql);

            return(result);
        }
Esempio n. 2
0
        private static SearchAndIndexQueryResult FetchBasliksIndexed(int pageNumber, char beginChar, string pagerHash)
        {
            SearchAndIndexQueryResult resultSet;
            SqlServerIo sql;
            TimeSpan    invTimeout;
            int         rowBegin, rowEnd;
            string      query, baslik;
            int         entryCount;

            rowBegin = (pageNumber * BasliksPerPage) + 1;
            rowEnd   = rowBegin + BasliksPerPage - 1;

            beginChar = char.ToLower(beginChar);

            if (beginChar == '.')
            {
                invTimeout = AllBasliksTimeout;
            }
            else
            {
                invTimeout = IndexedBasliksTimeout;
            }

            query = BuildFetchAllSQLQuery(ref pagerHash, rowBegin, rowEnd, beginChar);

            if (!CacheManager.TryGetCachedQueryResult <SearchAndIndexQueryResult>(query, out resultSet))
            {
                sql = SqlServerIo.Create();

                if (!sql.Execute(false, query))
                {
                    SqlServerIo.Release(sql);
                    return(new SearchAndIndexQueryResult());
                }

                resultSet = new SearchAndIndexQueryResult
                {
                    PagerHash = pagerHash
                };

                while (sql.Read())
                {
                    baslik     = sql.GetValueOfColumn <string>("Baslik");
                    entryCount = sql.GetValueOfColumn <int>("EntryCount");

                    if (resultSet.TotalRecordCount == 0)
                    {
                        resultSet.TotalRecordCount = sql.GetValueOfColumn <int>("TotalRecordCount");
                    }

                    resultSet.Entries.Add(new Entry(baslik, string.Empty, string.Empty, string.Empty, entryCount));

                    resultSet.PhysicalRecordCount++;
                }

                resultSet.LogicalRecordCount = resultSet.Entries.Count;

                SqlServerIo.Release(sql);

                CacheManager.CacheObject(KeysetId.Index(beginChar, true), true, query, resultSet, invTimeout);
            }

            return(resultSet);
        }