Esempio n. 1
0
        public Blog Save(string id, string owner, string title, string keywords, string data, params string[] categories)
        {
            Blog blog = Get(id);

            using (IConnectinContext cc = DBContext.DB1)
            {
                cc.BeginTransaction();
                if (blog == null)
                {
                    blog       = new Blog();
                    blog.Owner = owner;
                }
                blog.Title    = title;
                blog.Keywords = keywords;
                blog.Content  = data;
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(data);
                blog.Summary = doc.DocumentNode.InnerText;
                blog.Summary = blog.Summary.Substring(0, blog.Summary.Length > 300 ? 300 : blog.Summary.Length);
                blog.Save();
                (BlogLinkCategory.blog == id).Delete <BlogLinkCategory>();
                foreach (string item in categories)
                {
                    BlogLinkCategory blc = new BlogLinkCategory();
                    blc.Blog     = blog.ID;
                    blc.Category = item;
                    blc.Save();
                }
                cc.Commit();
            }

            return(blog);
        }
Esempio n. 2
0
 public static void Transaction(IConnectinContext cc, Action <IConnectinContext> handler)
 {
     using (cc)
     {
         cc.BeginTransaction();
         handler(cc);
         cc.Commit();
     }
 }
Esempio n. 3
0
 public static void Transaction(DB db, Action <IConnectinContext> handler)
 {
     using (IConnectinContext cc = DBContext.GetConnection(db))
     {
         cc.BeginTransaction();
         handler(cc);
         cc.Commit();
     }
 }
Esempio n. 4
0
 public static void Transaction(string connName, Action <IConnectinContext> handler)
 {
     using (IConnectinContext cc = DBContext.GetConnection(connName))
     {
         cc.BeginTransaction();
         handler(cc);
         cc.Commit();
     }
 }
Esempio n. 5
0
 public void CategoryDelete(params string[] categories)
 {
     using (IConnectinContext cc = DBContext.DB1)
     {
         cc.BeginTransaction();
         (BlogLinkCategory.category == categories).Delete <BlogLinkCategory>();
         (BlogCategory.iD == categories).Delete <BlogCategory>();
         cc.Commit();
     }
 }
Esempio n. 6
0
 public void Delete(params string[] blogs)
 {
     using (IConnectinContext cc = DBContext.DB1)
     {
         cc.BeginTransaction();
         (BlogLinkCategory.blog == blogs).Delete <BlogLinkCategory>();
         (Blog.iD == blogs).Delete <Blog>();
         cc.Commit();
     }
 }
Esempio n. 7
0
        public static int Add(params Mappings.DataObject[] obj)
        {
            int result = 0;

            using (IConnectinContext cc = DBContext.DB1)
            {
                cc.BeginTransaction();
                result = Add(cc, obj);
                cc.Commit();
            }
            return(result);
        }