Esempio n. 1
0
        public XElement Find(string id)
        {
            string content = DBFactory.GetMemcachedData(id);

            if (!string.IsNullOrEmpty(content))
            {
                return(XElement.Parse(content));
            }
            var cmd = new NpgsqlCommand("select data from content where id=@id", _connection);

            cmd.Parameters.AddWithValue("@id", id);
            var reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                content = reader.GetString(0);
            }
            reader.Close();
            if (content == null)
            {
                return(null);
            }
            DBFactory.UpdateMemcachedData(id, content);
            return(XElement.Parse(content));
        }
Esempio n. 2
0
        public void UpdateContent(string id, string content, string updated)
        {
            var comm1 = new NpgsqlCommand("update content set data=@content, updated=@updated  where id=@id", _connection);

            comm1.Parameters.AddWithValue("@id", id);
            comm1.Parameters.AddWithValue("@content", content);
            comm1.Parameters.AddWithValue("@updated", updated);
            comm1.ExecuteNonQuery();
            DBFactory.UpdateMemcachedData(id, content);
        }
Esempio n. 3
0
        //public void UpdateRelationship(string masterId, string type, string slaveId)
        //{
        //    var comm1 = new NpgsqlCommand("update relationship set type=@type, slave=@slave where master=@master",
        //        _connection);
        //    comm1.Parameters.AddWithValue("@master", masterId);
        //    comm1.Parameters.AddWithValue("@type", type);
        //    comm1.Parameters.AddWithValue("@slave", slaveId);
        //    comm1.ExecuteNonQuery();
        //}

        public void CreateContent(string id, string content, string type, string created, string updated)
        {
            try
            {
                var comm1 = new NpgsqlCommand("insert into content values(@id,@content,@type,@created,@updated)", _connection);
                comm1.Parameters.AddWithValue("@id", id);
                comm1.Parameters.AddWithValue("@content", content);
                comm1.Parameters.AddWithValue("@type", type);
                comm1.Parameters.AddWithValue("@created", created);
                comm1.Parameters.AddWithValue("@updated", updated);
                comm1.ExecuteNonQuery();
                DBFactory.UpdateMemcachedData(id, content);
            }
            catch (Exception ex)
            {
                Log.Error(ExceptionHelper.FormatStackTrace(ex));
            }
        }