コード例 #1
0
        public static bool Create(List <WX_Article> models)
        {
            if (models == null || models.Count == 0)
            {
                throw new ArgumentNullException("models");
            }

            IWXArticle factory = WXArticleFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection()) {
                try
                {
                    dbOperator.BeginTransaction();

                    factory.DeleteByGroupID(models.First().GroupID, dbOperator);
                    foreach (var item in models)
                    {
                        bool result = factory.Create(item, dbOperator);
                        if (!result)
                        {
                            throw new MyException("添加图文失败");
                        }
                        OperateLogServices.AddOperateLog <WX_Article>(item, OperateType.Add);
                    }

                    dbOperator.CommitTransaction();
                    return(true);
                }
                catch {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
コード例 #2
0
 public static IWXArticle GetFactory()
 {
     if (factory == null)
     {
         Type type = Type.GetType("Common." + SystemDefaultConfig.DatabaseProvider + "Repository.WeiXin.WXArticleDAL,Common." + SystemDefaultConfig.DatabaseProvider + "Repository", true);
         factory = (IWXArticle)Activator.CreateInstance(type);
     }
     return(factory);
 }
コード例 #3
0
        public static List <WX_Article> QueryByGroupID(string groupId)
        {
            if (groupId.IsEmpty())
            {
                throw new ArgumentNullException("groupId");
            }

            IWXArticle factory = WXArticleFactory.GetFactory();

            return(factory.QueryByGroupID(groupId));
        }
コード例 #4
0
        public static WX_Article QueryById(int id)
        {
            if (id < 1)
            {
                throw new ArgumentNullException("id");
            }

            IWXArticle factory = WXArticleFactory.GetFactory();

            return(factory.QueryById(id));
        }
コード例 #5
0
        public static bool DeleteByGroupID(string groupId)
        {
            if (groupId.IsEmpty())
            {
                throw new ArgumentNullException("groupId");
            }

            IWXArticle factory = WXArticleFactory.GetFactory();
            bool       result  = factory.DeleteByGroupID(groupId);

            if (result)
            {
                OperateLogServices.AddOperateLog("groupId:" + groupId, OperateType.Delete);
            }
            return(result);
        }
コード例 #6
0
        public static bool Delete(int id)
        {
            if (id < 1)
            {
                throw new ArgumentNullException("id");
            }

            IWXArticle factory = WXArticleFactory.GetFactory();
            bool       result  = factory.Delete(id);

            if (result)
            {
                OperateLogServices.AddOperateLog("删除编号:" + id, OperateType.Delete);
            }
            return(result);
        }
コード例 #7
0
        public static List <WX_Article> QueryAll(string companyId)
        {
            IWXArticle factory = WXArticleFactory.GetFactory();

            return(factory.QueryAll(companyId));
        }