Ejemplo n.º 1
0
        public static Suser GetSuser(string suser)
        {
            string query       = string.Format(GET_SUSER_SQL, suser.Trim().ToLower());
            Suser  suserObject = null;

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

                if (sql.Execute(false, query))
                {
                    if (sql.Read())
                    {
                        suserObject = new Suser(
                            0,
                            sql.GetValueOfColumn <string>("Suser"),
                            sql.GetValueOfColumn <string>("Password")
                            );
                    }
                }

                SqlServerIo.Release(sql);
            }

            return(suserObject);
        }
Ejemplo n.º 2
0
        public static bool AddSuser(Suser suser, out bool registered)
        {
            bool result;

            registered = false;

            if (GetSuser(suser.SuserName) != null)
            {
                return(true);
            }

            SqlServerIo sql = SqlServerIo.Create();

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

            result = sql.Execute(
                true,
                ADD_SUSER_SQL,
                suser.SuserName, suser.PasswordHash, "*****@*****.**"
                );

            if (result)
            {
                registered = sql.RecordCount > 0;
            }


            SqlServerIo.Release(sql);

            return(result);
        }
Ejemplo n.º 3
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);
        }