protected void Page_Load(object sender, EventArgs e)
        {
            if (!int.TryParse(this.Request.QueryString["infoid"], out this.infoId))
            {
                this.Response.Write("<script>alert('参数错误!');</script>");
                this.Response.Write("<script>window.location = 'info_manager.aspx';</script>");
                return;
            }

            this.articleManager = new ArticleManager("EFConnectionString");
            this.article = this.articleManager.Get(this.infoId) as ArticleEntity;

            NodeManager nodeManager = new NodeManager("EFConnectionString");
            NodeEntity node = nodeManager.Get(this.article.NodeId);
            StringDictionary roles = (this.Master as AdminLayout).UserRoles;

            if (!nodeManager.CheckNodeRole(node, roles, ActionType.ManageInfo))
            {
                this.Response.Write("<script>alert('无权限!');</script>");
                this.Response.Write("<script>window.location = 'info_manager.aspx';</script>");
                return;
            }

            if (!this.IsPostBack)
            {
                this.title.Text = this.article.Title;
                this.content.Text = this.article.Content;
                this.source.Text = this.article.Source;
                this.image.Text = this.article.Image;
                this.link.Text = this.article.Link;
                this.isTop.Checked = this.article.IsTop;
                this.stateList.SelectedIndex = (int)this.article.State;
            }
        }
        public void CreateFullArticleEntity(FullArticleEntity fullArticle)
        {
            if (fullArticle == null)
                return;
            var article = new ArticleEntity()
            {
                Id = fullArticle.Id,
                Title = fullArticle.Title,
                CreationTime = fullArticle.CreationTime,
                Text = fullArticle.Text,
                TitleImage = fullArticle.TitleImage,
                UserId = fullArticle.User.Id,
                BlogId = fullArticle.Blog.Id
            };
            uow.ArticleRepository.Create(article.ToDalArticle());

            var articleTag =
                fullArticle.Tags.Select(x => new ArticleTagEntity() { ArticleId = fullArticle.Id, TagId = x.Id }.ToDalArticleTag());

            foreach (var item in articleTag)
            {
                uow.ArticleTagRepository.Create(item);
            }
            uow.Commit();
        }
        protected void addArticleButton_Click(object sender, EventArgs e)
        {
            ArticleEntity article = new ArticleEntity()
            {
                Title = this.title.Text,
                Content = this.content.Text,
                AuthorName = Membership.GetUser().UserName,
                Source = this.source.Text,
                Link = this.link.Text.Trim(),
                Image = this.image.Text.Trim(),
                NodeId = this.nodeId,
                FullNodeIds = node.FullIdsStringType
            };

            ArticleManager articleManager = new ArticleManager("EFConnectionString");
            articleManager.Add(article);

            this.Response.Write("<script>alert('添加文章成功!');</script>");
            this.Response.Write("<script>window.location = 'add_info.aspx';</script>");
        }
Beispiel #4
0
        /// <summary>
        /// 获取一篇文章。
        /// </summary>
        /// <param name="articleId">欲获取文章的Id。</param>
        public override InfoEntity Get(int articleId)
        {
            Contract.Requires(articleId > 0);

            IDataParameter[] parameters = new IDataParameter[1];
            parameters[0] = this.db.NewDataParameter("@InfoId", articleId);

            ArticleEntity article;

            using (IDataReader reader = this.db.ExcuteReader(CommandType.StoredProcedure, "EF_Info_Get", parameters))
            {
                if (reader.Read())
                {
                    article = this.PopulateArticle(reader);
                }
                else
                {
                    article = new ArticleEntity();
                }
            }

            return article;
        }
Beispiel #5
0
        /// <summary>
        /// 添加一篇文章。
        /// </summary>
        /// <param name="article">待添加的文章。</param>
        public void Add(ArticleEntity article)
        {
            Contract.Requires(article != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(article.Title));
            Contract.Requires(article.NodeId > 0);

            IDataParameter[] parameters = new IDataParameter[8];

            parameters[0] = this.db.NewDataParameter("@Title", article.Title);
            parameters[1] = this.db.NewDataParameter("@Content", article.Content);
            parameters[2] = this.db.NewDataParameter("@AuthorName", article.AuthorName);
            parameters[3] = this.db.NewDataParameter("@Source", article.Source);
            parameters[4] = this.db.NewDataParameter("@Link", article.Link);
            parameters[5] = this.db.NewDataParameter("@Image", article.Image);
            parameters[6] = this.db.NewDataParameter("@NodeId", article.NodeId);
            parameters[7] = this.db.NewDataParameter("@FullNodeIds", article.FullNodeIds);

            int result = this.db.ExecuteNonQuery(CommandType.StoredProcedure, "EF_Article_Add", parameters);

            if (result == 0)
            {
                throw new Exception("新建文章失败!");
            }
        }
Beispiel #6
0
        protected override void Seed(ApplicationDbContext context)
        {
            var bookingsystem1 = new BookingSystemEntity()
            {
                ServiceType       = 4,
                BookningSystemId  = 1,
                SystemName        = "Bil och Däck",
                SystemDescription = "Verkstad",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.bilochdack.se",
                CompanyName       = "Bil och Däck",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Glanshammarsvägen 16",
                Latitude          = 59.294810,
                Longitude         = 15.231510,
                PostaICode        = "703 64",
                City = "Örebro",
            };

            context.BookingSystems.Add(bookingsystem1);

            var bookingsystem2 = new BookingSystemEntity()
            {
                ServiceType       = 1,
                BookningSystemId  = 2,
                SystemName        = "Salong Klipp",
                SystemDescription = "Frisör",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.salongklipp.se",
                CompanyName       = "Salong Klipp",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Skolgatan 42",
                Latitude          = 59.280750,
                Longitude         = 15.223650,
                PostaICode        = "703 64",
                City = "Örebro",
            };

            context.BookingSystems.Add(bookingsystem2);

            var bookingsystem3 = new BookingSystemEntity()
            {
                ServiceType       = 1,
                BookningSystemId  = 3,
                SystemName        = "Klipp och Trimm",
                SystemDescription = "Frisör",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.klippochtrimm.se",
                CompanyName       = "Klipp och Trimm",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Sandkullsvägen 24",
                Latitude          = 59.382580,
                Longitude         = 17.917903,
                PostaICode        = "703 64",
                City = "Stockholm",
            };

            context.BookingSystems.Add(bookingsystem3);

            var bookingsystem4 = new BookingSystemEntity()
            {
                ServiceType       = 2,
                BookningSystemId  = 4,
                SystemName        = "Saras Massage",
                SystemDescription = "Massage",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.sarasmassage.se",
                CompanyName       = "Saras Massage",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Glanshammarsvägen 16",
                Latitude          = 59.294810,
                Longitude         = 15.231510,
                PostaICode        = "703 64",
                City = "Örebro",
            };

            context.BookingSystems.Add(bookingsystem4);

            var bookingsystem5 = new BookingSystemEntity()
            {
                ServiceType       = 3,
                BookningSystemId  = 5,
                SystemName        = "Stefans Skön och Fin",
                SystemDescription = "Skönhetssalong",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.stefansskonochfin.se",
                CompanyName       = "Stefans Skön och Fin",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Skolgatan 42",
                Latitude          = 59.281750,
                Longitude         = 15.223650,
                PostaICode        = "703 64",
                City = "Örebro",
            };

            context.BookingSystems.Add(bookingsystem5);

            var bookingsystem6 = new BookingSystemEntity()
            {
                ServiceType       = 3,
                BookningSystemId  = 6,
                SystemName        = "Salong Finast",
                SystemDescription = "Skönhetssalong",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.salongfinast.se",
                CompanyName       = "Salong Finast",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Skolgatan 42",
                Latitude          = 59.280750,
                Longitude         = 15.233650,
                PostaICode        = "703 64",
                City = "Örebro",
            };

            context.BookingSystems.Add(bookingsystem6);

            var bookingsystem7 = new BookingSystemEntity()
            {
                ServiceType       = 5,
                BookningSystemId  = 7,
                SystemName        = "Aspholmens Biltvätt",
                SystemDescription = "Biltvätt",
                Email             = "*****@*****.**",
                PhoneNumber       = "070-000 00 00",
                Website           = "www.aspholmensbiltvatt.se",
                CompanyName       = "Aspholmens Biltvätt",
                ContactEmail      = "*****@*****.**",
                ContactPhone      = "070-000 00 00",
                Adress            = "Skolgatan 42",
                Latitude          = 59.280750,
                Longitude         = 15.233650,
                PostaICode        = "703 64",
                City = "Örebro",
            };

            context.BookingSystems.Add(bookingsystem7);

            var bookedTime1 = new BookingTableEntity()
            {
                BookingTableId = 1,
                Date           = DateTime.Now,
                StartTime      = DateTime.Now,
                EndTime        = DateTime.Now,
                ArticleId      = 1
            };

            context.BookingTabels.Add(bookedTime1);

            var bookedTime2 = new BookingTableEntity()
            {
                BookingTableId = 1,
                Date           = DateTime.Now,
                StartTime      = DateTime.Now,
                EndTime        = DateTime.Now,
                ArticleId      = 1
            };

            context.BookingTabels.Add(bookedTime2);

            var article1 = new ArticleEntity()
            {
                ArticleId       = 1,
                Name            = "Däck Byte",
                Length          = 20,
                Price           = 150,
                BookingSystemId = 1,
                Service         = 1
            };

            context.Articles.Add(article1);

            var article2 = new ArticleEntity()
            {
                ArticleId       = 2,
                Name            = "Service",
                Length          = 60,
                Price           = 1000,
                BookingSystemId = 1,
                Service         = 1
            };

            context.Articles.Add(article2);

            var article3 = new ArticleEntity()
            {
                ArticleId       = 3,
                Name            = "Besiktning",
                Length          = 30,
                Price           = 600,
                BookingSystemId = 1,
                Service         = 2
            };

            context.Articles.Add(article3);

            var article4 = new ArticleEntity()
            {
                ArticleId       = 4,
                Name            = "Herrklippning",
                Length          = 20,
                Price           = 300,
                BookingSystemId = 2,
                Service         = 1
            };

            context.Articles.Add(article4);

            var article5 = new ArticleEntity()
            {
                ArticleId       = 5,
                Name            = "Damklippning",
                Length          = 30,
                Price           = 400,
                BookingSystemId = 2,
                Service         = 1
            };

            context.Articles.Add(article5);

            var article6 = new ArticleEntity()
            {
                ArticleId       = 6,
                Name            = "Permanenta",
                Length          = 60,
                Price           = 700,
                BookingSystemId = 2,
                Service         = 2
            };

            context.Articles.Add(article6);

            var article7 = new ArticleEntity()
            {
                ArticleId       = 7,
                Name            = "Herrklippning",
                Length          = 20,
                Price           = 300,
                BookingSystemId = 3,
                Service         = 1
            };

            context.Articles.Add(article7);

            var article8 = new ArticleEntity()
            {
                ArticleId       = 8,
                Name            = "Damklippning",
                Length          = 30,
                Price           = 400,
                BookingSystemId = 3,
                Service         = 1
            };

            context.Articles.Add(article8);

            var article9 = new ArticleEntity()
            {
                ArticleId       = 9,
                Name            = "Permanenta",
                Length          = 60,
                Price           = 700,
                BookingSystemId = 3,
                Service         = 2
            };

            context.Articles.Add(article9);

            var article10 = new ArticleEntity()
            {
                ArticleId       = 10,
                Name            = "Svensk Massage",
                Length          = 30,
                Price           = 500,
                BookingSystemId = 4,
                Service         = 1
            };

            context.Articles.Add(article10);

            var article11 = new ArticleEntity()
            {
                ArticleId       = 11,
                Name            = "Thailändsk Massage",
                Length          = 30,
                Price           = 500,
                BookingSystemId = 4,
                Service         = 1
            };

            context.Articles.Add(article11);

            var article12 = new ArticleEntity()
            {
                ArticleId       = 12,
                Name            = "Kiropraktor",
                Length          = 45,
                Price           = 600,
                BookingSystemId = 4,
                Service         = 2
            };

            context.Articles.Add(article12);

            var article13 = new ArticleEntity()
            {
                ArticleId       = 13,
                Name            = "Ansiktsbehandling",
                Length          = 30,
                Price           = 400,
                BookingSystemId = 5,
                Service         = 1
            };

            context.Articles.Add(article13);

            var article14 = new ArticleEntity()
            {
                ArticleId       = 14,
                Name            = "Ansiktsmask",
                Length          = 30,
                Price           = 350,
                BookingSystemId = 5,
                Service         = 1
            };

            context.Articles.Add(article14);

            var article15 = new ArticleEntity()
            {
                ArticleId       = 15,
                Name            = "Pedekyr",
                Length          = 30,
                Price           = 300,
                BookingSystemId = 5,
                Service         = 2
            };

            context.Articles.Add(article15);

            var article16 = new ArticleEntity()
            {
                ArticleId       = 16,
                Name            = "Ansiktsbehandling",
                Length          = 30,
                Price           = 400,
                BookingSystemId = 6,
                Service         = 1
            };

            context.Articles.Add(article16);

            var article17 = new ArticleEntity()
            {
                ArticleId       = 17,
                Name            = "Ansiktsmask",
                Length          = 30,
                Price           = 350,
                BookingSystemId = 6,
                Service         = 1
            };

            context.Articles.Add(article17);

            var article18 = new ArticleEntity()
            {
                ArticleId       = 18,
                Name            = "Pedekyr",
                Length          = 30,
                Price           = 300,
                BookingSystemId = 6,
                Service         = 2
            };

            context.Articles.Add(article18);

            var article19 = new ArticleEntity()
            {
                ArticleId       = 19,
                Name            = "Biltvätt",
                Length          = 20,
                Price           = 200,
                BookingSystemId = 7,
                Service         = 1
            };

            context.Articles.Add(article19);

            var article20 = new ArticleEntity()
            {
                ArticleId       = 20,
                Name            = "Städning",
                Length          = 15,
                Price           = 150,
                BookingSystemId = 7,
                Service         = 1
            };

            context.Articles.Add(article20);

            var article21 = new ArticleEntity()
            {
                ArticleId       = 21,
                Name            = "Biltvätt och Städning",
                Length          = 45,
                Price           = 300,
                BookingSystemId = 7,
                Service         = 1
            };

            context.Articles.Add(article21);

            var article22 = new ArticleEntity()
            {
                ArticleId       = 22,
                Name            = "Waxning",
                Length          = 30,
                Price           = 300,
                BookingSystemId = 7,
                Service         = 2
            };

            context.Articles.Add(article22);

            context.SaveChanges();
            base.Seed(context);
        }
Beispiel #7
0
 public static ArticleInfo LoadFromEntity( ArticleEntity entity )
 {
     if (entity == null)
         return default(ArticleInfo);
     ArticleInfo info = new ArticleInfo() {
         ID = entity.ID,
         Title = entity.Title,
         Path = entity.Path,
         Summary = entity.Summary,
         Content = entity.Content,
         CreateTime = entity.CreateTime,
         LastChanged = entity.LastChanged,
         State = (DbState)entity.State,
         PageViewCount = entity.PageViewCount,
         RssViewCount = entity.RssViewCount,
         EnableComment = entity.EnableComment,
         AnymousComment = entity.AnymousComment,
         DownCount = entity.DownCount,
         UpCount = entity.UpCount
     };
     return info;
 }
Beispiel #8
0
        /// <summary>
        /// 发送文章信息
        /// </summary>
        /// <param name="article"></param>
        void SendArticle(ArticleEntity article)
        {
            string[] groups = article.ToGroup.Split(',');
            for (int i = 0; i < groups.Length; i++)
            {
                int type = int.Parse(groups[i]);
                switch (type)
                {
                case (int)QX360.Model.Enums.ToGroupType.普通会员:
                    var list = MemberBLL.Instance.GetList(new MemberEntity()
                    {
                        LevId = ((int)QX360.Model.Enums.UserType.预约记时会员).ToString()
                    });
                    if (list != null)
                    {
                        foreach (var item in list)
                        {
                            InsertNotice(item.MemberId, item.MemberName, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.普通会员);
                        }
                    }
                    break;

                case (int)QX360.Model.Enums.ToGroupType.VIP会员:
                    list = MemberBLL.Instance.GetList(new MemberEntity()
                    {
                        LevId = ((int)QX360.Model.Enums.UserType.VIP会员).ToString()
                    });
                    if (list != null)
                    {
                        foreach (var item in list)
                        {
                            InsertNotice(item.MemberId, item.MemberName, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.VIP会员);
                        }
                    }
                    break;

                case (int)QX360.Model.Enums.ToGroupType.保险机构:
                    var userlist = UserBLL.Instance.GetList().Where((o) => { return(o.OrganizeType == (int)QX360.Model.Enums.ToGroupType.保险机构); }).ToList();
                    if (userlist != null)
                    {
                        foreach (var item in userlist)
                        {
                            InsertNotice(item.UserId, item.Account, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.保险机构);
                        }
                    }
                    break;

                case (int)QX360.Model.Enums.ToGroupType.店铺机构:
                    userlist = UserBLL.Instance.GetList().Where((o) => { return(o.OrganizeType == (int)QX360.Model.Enums.ToGroupType.店铺机构); }).ToList();
                    if (userlist != null)
                    {
                        foreach (var item in userlist)
                        {
                            InsertNotice(item.UserId, item.Account, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.店铺机构);
                        }
                    }
                    break;

                case (int)QX360.Model.Enums.ToGroupType.管理机构:
                    userlist = UserBLL.Instance.GetList().Where((o) => { return(o.OrganizeType == (int)QX360.Model.Enums.ToGroupType.管理机构); }).ToList();
                    if (userlist != null)
                    {
                        foreach (var item in userlist)
                        {
                            InsertNotice(item.UserId, item.Account, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.管理机构);
                        }
                    }
                    break;

                case (int)QX360.Model.Enums.ToGroupType.驾校机构:
                    userlist = UserBLL.Instance.GetList().Where((o) => { return(o.OrganizeType == (int)QX360.Model.Enums.ToGroupType.驾校机构); }).ToList();
                    if (userlist != null)
                    {
                        foreach (var item in userlist)
                        {
                            InsertNotice(item.UserId, item.Account, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.驾校机构);
                        }
                    }
                    break;

                case (int)QX360.Model.Enums.ToGroupType.年检机构:
                    userlist = UserBLL.Instance.GetList().Where((o) => { return(o.OrganizeType == (int)QX360.Model.Enums.ToGroupType.年检机构); }).ToList();
                    if (userlist != null)
                    {
                        foreach (var item in userlist)
                        {
                            InsertNotice(item.UserId, item.Account, article.ArticleId, article.Title, (int)QX360.Model.Enums.ToGroupType.年检机构);
                        }
                    }
                    break;
                }
            }
        }
Beispiel #9
0
        public BaseObject UpdateArticle(ArticleEntity param)
        {
            var obj = new BaseObject();

            var article = _db.Articles.Find(param.ID);

            if (article == null)
            {
                obj.Tag     = -1;
                obj.Message = "记录不存在!";
                return(obj);
            }
            if (_db.Articles.Any(m => m.IsDelete != PublicType.Yes && m.Title == param.Title && m.ID != param.ID))
            {
                obj.Tag     = -1;
                obj.Message = "该文章标题已存在!";

                return(obj);
            }

            article.ColumnID        = param.ColumnID;
            article.Content         = param.Content;
            article.IsPublic        = param.IsPublic;
            article.MetaDescription = param.MetaDescription;
            article.MetaKeywords    = param.MetaKeywords;
            article.Overview        = param.Overview;
            article.PageTitle       = param.PageTitle;
            article.Slug            = param.Slug;
            article.Title           = param.Title;
            article.UpdateTime      = DateTime.Now;
            article.UpdateUser      = param.UpdateUser;
            article.Author          = param.Author;
            article.ShortTitle      = param.ShortTitle;
            article.SortOrder       = param.SortOrder;
            article.Source          = param.Source;

            _db.Connection.Open();
            using (var tran = _db.Connection.BeginTransaction())
            {
                try
                {
                    _db.SaveChanges();

                    tran.Commit();
                    obj.Tag     = 1;
                    obj.Message = "保存成功!";
                }
                catch (Exception e)
                {
                    tran.Rollback();
                    obj.Tag     = -1;
                    obj.Message = "保存失败!";
                }
                finally
                {
                    tran.Dispose();
                }
            }

            return(obj);
        }
        public static void Initialize(ApplicationDbContext context)
        {
            // Seed statuts de commande
            if (!context.NomCommandeStatutEntities.Any())
            {
                var commande_status = new NomCommandeStatutEntity[]
                {
                    new NomCommandeStatutEntity {
                        Code = "P", Libelle = "Panier"
                    },
                    new NomCommandeStatutEntity {
                        Code = "V", Libelle = "Livrée"
                    },
                    new NomCommandeStatutEntity {
                        Code = "A", Libelle = "En attente de préparation"
                    },
                    new NomCommandeStatutEntity {
                        Code = "L", Libelle = "En cours de livraison"
                    },
                    new NomCommandeStatutEntity {
                        Code = "X", Libelle = "Annulée"
                    }
                };

                foreach (NomCommandeStatutEntity s in commande_status)
                {
                    context.NomCommandeStatutEntities.Add(s);
                }
                context.SaveChanges();
            }

            // Seed statuts de commande fournisseur
            if (!context.NomCommandeFournisseurStatutEntities.Any())
            {
                var commande_fournisseur_status = new NomCommandeFournisseurStatutEntity[]
                {
                    new NomCommandeFournisseurStatutEntity {
                        Code = "C", Libelle = "Création"
                    },
                    new NomCommandeFournisseurStatutEntity {
                        Code = "T", Libelle = "Transmise au fournisseur"
                    },
                    new NomCommandeFournisseurStatutEntity {
                        Code = "R", Libelle = "Réceptionnée"
                    },
                    new NomCommandeFournisseurStatutEntity {
                        Code = "A", Libelle = "Annulation"
                    }
                };

                foreach (NomCommandeFournisseurStatutEntity s in commande_fournisseur_status)
                {
                    context.NomCommandeFournisseurStatutEntities.Add(s);
                }
                context.SaveChanges();
            }

            // Seed statuts des inventaires
            if (!context.NomInventaireStatutEntities.Any())
            {
                var inventaire_status = new NomInventaireStatutEntity[]
                {
                    new NomInventaireStatutEntity {
                        Code = "E", Libelle = "En cours"
                    },
                    new NomInventaireStatutEntity {
                        Code = "T", Libelle = "Terminé"
                    }
                };

                foreach (NomInventaireStatutEntity s in inventaire_status)
                {
                    context.NomInventaireStatutEntities.Add(s);
                }
                context.SaveChanges();
            }

            // ARTICLE FAMILLE
            if (!context.ArticleFamilleEntities.Any())
            {
                var article_familles = new ArticleFamilleEntity[]
                {
                    new ArticleFamilleEntity {
                        Code = "MOB", Libelle = "Mobilier"
                    },
                    new ArticleFamilleEntity {
                        Code = "DECO", Libelle = "Décoration"
                    },
                    new ArticleFamilleEntity {
                        Code = "ELEC", Libelle = "Electronique"
                    }
                };

                foreach (ArticleFamilleEntity s in article_familles)
                {
                    context.ArticleFamilleEntities.Add(s);
                }
                context.SaveChanges();
            }

            // TVA
            if (!context.NomTypeTVAEntities.Any())
            {
                var type_tvas = new NomTypeTVAEntity[]
                {
                    new NomTypeTVAEntity {
                        Code = "DOUZE", Libelle = "Douze", Taux = 12M
                    },
                    new NomTypeTVAEntity {
                        Code = "VINGT", Libelle = "Vingt", Taux = 20M
                    },
                    new NomTypeTVAEntity {
                        Code = "ZERO", Libelle = "Zero", Taux = 0M
                    }
                };

                foreach (NomTypeTVAEntity s in type_tvas)
                {
                    context.NomTypeTVAEntities.Add(s);
                }
                context.SaveChanges();
            }

            // ADRESSES (pour fournisseur, notamment)
            if (!context.AdresseEntities.Any())
            {
                var adresses = new AdresseEntity[]
                {
                    /*
                     * Champ1 = "", Champ2 = "", CodePostal = "", Ville = "", Pays = ""
                     */
                    new AdresseEntity {
                        Champ1 = "1 bld de Strasbourg", Champ2 = "", CodePostal = "44000", Ville = "NANTES", Pays = "FRANCE"
                    },
                    new AdresseEntity {
                        Champ1 = "12 rue de la Foret", Champ2 = "", CodePostal = "49500", Ville = "CRESSON", Pays = "FRANCE"
                    }
                };

                foreach (AdresseEntity s in adresses)
                {
                    context.AdresseEntities.Add(s);
                }
                context.SaveChanges();
            }

            // FOURNISSEUR
            if (!context.FournisseurEntities.Any())
            {
                var id_adresse_A = context.AdresseEntities.Where(f => f.Champ1 == "1 bld de Strasbourg").First().Id;
                var id_adresse_B = context.AdresseEntities.Where(f => f.Champ1 == "12 rue de la Foret").First().Id;

                var fournisseurs = new FournisseurEntity[]
                {
                    new FournisseurEntity {
                        Raison    = "Meubles SARL",
                        Telephone = "+33622657991",
                        Email     = "*****@*****.**",
                        AdresseId = id_adresse_A
                    },
                    new FournisseurEntity {
                        Raison    = "Boiserie and Co.",
                        Telephone = "+33801223040",
                        Email     = "*****@*****.**",
                        AdresseId = id_adresse_B
                    },
                };

                foreach (FournisseurEntity s in fournisseurs)
                {
                    context.FournisseurEntities.Add(s);
                }
                context.SaveChanges();
            }

            // ARTICLES
            if (!context.ArticleEntities.Any())
            {
                var id_fournisseur_A = context.FournisseurEntities.Where(f => f.Raison == "Meubles SARL").First().Id;
                var id_fournisseur_B = context.FournisseurEntities.Where(f => f.Raison == "Boiserie and Co.").First().Id;

                var articles = new ArticleEntity[]
                {
                    new ArticleEntity {
                        Code             = "CHA",
                        Libelle          = "Chaise",
                        PrixUnitaire     = 20,
                        Threshold        = 10,
                        ArticleFamilleId = context.ArticleFamilleEntities.Where(f => f.Code == "MOB").First().Id,
                        NomTypeTVAId     = context.NomTypeTVAEntities.Where(f => f.Code == "VINGT").First().Id,
                        FournisseurId    = id_fournisseur_A
                    },
                    new ArticleEntity {
                        Code             = "TAB",
                        Libelle          = "Table",
                        PrixUnitaire     = 150,
                        Threshold        = 5,
                        ArticleFamilleId = context.ArticleFamilleEntities.Where(f => f.Code == "MOB").First().Id,
                        NomTypeTVAId     = context.NomTypeTVAEntities.Where(f => f.Code == "DOUZE").First().Id,
                        FournisseurId    = id_fournisseur_B
                    },
                    new ArticleEntity {
                        Code             = "LUX",
                        Libelle          = "Lampe",
                        PrixUnitaire     = 12.5M,
                        Threshold        = 30,
                        ArticleFamilleId = context.ArticleFamilleEntities.Where(f => f.Code == "DECO").First().Id,
                        NomTypeTVAId     = context.NomTypeTVAEntities.Where(f => f.Code == "ZERO").First().Id,
                        FournisseurId    = id_fournisseur_A
                    },
                };

                foreach (ArticleEntity s in articles)
                {
                    context.ArticleEntities.Add(s);
                }
                context.SaveChanges();
            }

            // STOCK :: initialise AU MOINS a 0, si par exemple l'Article provient du Seeding
            List <StockEntity> stocks = new List <StockEntity>();

            foreach (var article in context.ArticleEntities)
            {
                if (!context.StockEntities.Where(w => w.ArticleID == article.Id).Any())
                {
                    var stock = new StockEntity();
                    stock.ArticleID = article.Id;
                    stock.Quantite  = article.Threshold;

                    stocks.Add(stock);
                }
            }
            foreach (var item in stocks)
            {
                context.StockEntities.Add(item);
            }
            if (stocks.Any())
            {
                context.SaveChanges();
            }
        }
Beispiel #11
0
        ArticleEntity PopulateArticle(IDataReader reader)
        {
            ArticleEntity info = new ArticleEntity()
            {
                InfoId = (int)reader["InfoId"],
                Title = reader["Title"].ToString(),
                Content = reader["Content"].ToString(),
                AuthorName = reader["AuthorName"].ToString(),
                AuditName = reader["AuditName"].ToString(),
                Source = reader["Source"].ToString(),
                Link = reader["Link"].ToString(),
                Image = reader["Image"].ToString(),
                IsTop = (bool)reader["IsTop"],
                NodeId = (int)reader["NodeId"],
                FullNodeIds = reader["FullNodeIds"].ToString(),
                CreationDate = (DateTime)reader["CreationDate"],
                UpdateDate = (DateTime)reader["UpdateDate"],
                State = (InfoState)(int)reader["State"]
            };

            return info;
        }
        public async Task <CommandeFournisseurLigneEntity> AddArticle(CommandeFournisseurEntity commande_fournisseur, ArticleEntity article, int article_quantite)
        {
            foreach (CommandeFournisseurLigneEntity l in commande_fournisseur.CommandeFournisseurLignes)
            {
                if (l.ArticleId == article.Id)
                {
                    l.Quantite = l.Quantite + article_quantite;
                    return(await Update(l));
                }
            }

            CommandeFournisseurLigneEntity ligne = new CommandeFournisseurLigneEntity();

            ligne.CommandeFournisseurId = commande_fournisseur.Id;
            ligne.ArticleId             = article.Id;
            ligne.Quantite = article_quantite;

            return(await _repository.AddAsync(ligne));
        }
Beispiel #13
0
 public int InsertArticle(ArticleEntity entity)
 {
     return(EFHelper.Insert <ArticleEntity>(entity));
 }
 public void UpdateSimpleArticle(ArticleEntity article)
 {
     uow.ArticleRepository.Update(article?.ToDalArticle());
     uow.Commit();
 }
 public void CreateArticle(ArticleEntity e)
 {
     uow.ArticleRepository.Create(e.ToDalArticle());
     uow.Commit();
 }
 public FullArticleEntity GetFullArticleEntity(ArticleEntity e)
 {
     if (e == null)
         return null;
     var result = new FullArticleEntity()
     {
         Id = e.Id,
         Title = e.Title,
         CreationTime = e.CreationTime,
         Text = e.Text,
         User = uow.UserRepository.GetById(e.UserId)?.ToBllUser(),
         TitleImage = e.TitleImage,
         Blog = uow.BlogRepository.GetById(e.BlogId)?.ToBllBlog(),
         Tags = uow.ArticleTagRepository.GetAll().Where(tag => tag.ArticleId == e.Id).Select(x => uow.TagRepository.GetById(x.TagId)?.ToBllTag()),
         Comments = uow.CommentRepository.GetAll().Where(comment => comment.ArticleId == e.Id).Select(x => x.ToFullCommentEntity())
     };
     return result;
 }
Beispiel #17
0
 public int Add(ArticleEntity entity)
 {
     _context.Article.Add(entity);
     return(_context.SaveChanges());
 }
Beispiel #18
0
 /// <summary>
 /// Creates new article entity with specified tag string
 /// </summary>
 /// <param name="articleEntity">Base entity for new article entity</param>
 /// <param name="tags">String that contains tags</param>
 public void Create(ArticleEntity articleEntity, string tags)
 {
     articleRepository.Create(articleEntity.ToDalArticle(), tags);
     uow.Commit();
 }
Beispiel #19
0
        /// <summary>
        /// 保存文章的相关图片
        /// </summary>
        /// <param name="article"></param>
        public void ArticleImageSave(ArticleEntity article)
        {
            if (article.ImgFileList != null)
            {
                ArticleImageBLL articleImageBLL = new ArticleImageBLL();
                //为图片命名获取参数

                List <SqlDbParameter> parms = new List <SqlDbParameter>();
                SqlDbParameter        parm  = null;
                parm                = new SqlDbParameter();
                parm.ColumnName     = "ArticleId";
                parm.ParameterName  = "ArticleId";
                parm.ParameterValue = article.Id;
                parm.ColumnType     = DbType.Int32;
                parms.Add(parm);



                List <ArticleImageEntity> articleList = articleImageBLL.GetAllArticleImage(parms, "Id DESC");
                int j = 1;
                if (articleList.Count > 0)
                {
                    Match  numMatch = Regex.Match(articleList[0].ImageFileName, @"_(\d+)\."); //获取最大的编号
                    string num      = numMatch.Groups[1].Value;
                    int    _j       = 0;
                    if (int.TryParse(num, out _j))
                    {
                        j = ++_j;
                    }
                }

                for (int i = 0; i < article.ImgFileList.Count; i++)
                {
                    if (article.ImgFileList[i].Id != null) //New Add Picture
                    {
                        continue;
                    }
                    string savePath      = System.Web.HttpContext.Current.Server.MapPath("~");
                    string fromPath      = savePath + ConfigurationManager.AppSettings["UploadTmp"] + article.ImgFileList[i].ImgFileName;
                    string fileExtension = Path.GetExtension(fromPath); // 文件扩展名

                    string categoryFix = "other";
                    //根据文件类别+分类下序数命名新图片名
                    var firstKey = Constants.ChannelToCategory.FirstOrDefault(q => q.Value == article.CategoryId.Value).Key;
                    if (!string.IsNullOrEmpty(firstKey))
                    {
                        categoryFix = firstKey;
                    }
                    string newFileName = categoryFix + article.NoOfCategory.ToString().PadLeft(2, '0') + "_" + j + fileExtension; // 文件扩展名  //jt01_1.jpg
                    ++j;
                    string toPath = savePath + ConfigurationManager.AppSettings["AriticleImagePath"] + newFileName;
                    if (!Directory.Exists(savePath + ConfigurationManager.AppSettings["AriticleImagePath"]))
                    {
                        Directory.CreateDirectory(savePath + ConfigurationManager.AppSettings["AriticleImagePath"]);
                    }
                    System.IO.File.Copy(fromPath, toPath);
                    //TODO Insert ArticleImage
                    ArticleImageEntity articleImage = new ArticleImageEntity();
                    articleImage.ArticleId     = article.Id;
                    articleImage.ImageFileName = newFileName;
                    articleImageBLL.AddArticleImageEntity(articleImage);
                }
            }
        }
        public async Task <InventaireLigneEntity> AddArticle(InventaireEntity inventaire, ArticleEntity article)
        {
            InventaireLigneEntity ligne = new InventaireLigneEntity();

            ligne.Inventaire        = inventaire;
            ligne.Article           = article;
            ligne.QuantiteTheorique = article.Stock.Quantite;

            return(await _repository.AddAsync(ligne));
        }
Beispiel #21
0
        public IActionResult Modify(ArticleEntity entity)
        {
            int result = _service.Update(entity);

            return(Redirect($"/admin/article/modify/{entity.Id}"));
        }
Beispiel #22
0
 public ArticleModel(ArticleEntity map)
 {
     this.Id       = map.Id;
     this.Title    = map.Title;
     this.ImageUrl = map.ImageUrl;
 }
Beispiel #23
0
 public int UpdateArticle(ArticleEntity entity)
 {
     return(EFHelper.Update <ArticleEntity>(entity));
 }
Beispiel #24
0
 /// <summary>
 /// Updates article entity with specified tag string
 /// </summary>
 /// <param name="entity">Base entity for updating</param>
 /// <param name="tags">String that contains tags</param>
 public void Update(ArticleEntity entity, string tags)
 {
     articleRepository.Update(entity.ToDalArticle(), tags);
     uow.Commit();
     DeleteUnusableTags();
 }
Beispiel #25
0
        //public List<VMImages> GetArticleImage(string id)
        //{
        //    BaseSetDA da = new BaseSetDA();

        //    List<VMImages> imgs = new List<VMImages>();

        //    var result = da.GetArticleByKey(id);
        //    result.ImageUrl = CommonHelper.LinkImageUrl(result.ImageUrl);


        //    int begin = result.ImageUrl.IndexOf("/Images");
        //    if (begin > 0)
        //    {
        //        VMImages img = new VMImages()
        //        {
        //            imageId = result.ArticleId,
        //            name = result.ArticleTitle,
        //            url = result.ImageUrl
        //        };
        //        imgs.Add(img);
        //    }



        //    return imgs;
        //}


        public int SaveArticle(ArticleEntity Article, string loginName)
        {
            BaseSetDA da = new BaseSetDA();

            return(da.SaveArticle(Article, loginName));
        }
Beispiel #26
0
 public string save(ArticleEntity article)
 {
     return(dao.save(article));
 }
Beispiel #27
0
 public IActionResult Update([FromBody] ArticleEntity article)
 {
     return(Ok(_articleService.Update(article)));
 }
Beispiel #28
0
 public void update(ArticleEntity article)
 {
     dao.update(article);
 }
Beispiel #29
0
        public static void SetArticle(this RouteValueDictionary routeValue, ArticleEntity article)
        {
            string key = StringKeys.RouteVale_Article.FormatWith(article.ID);

            routeValue.TryAdd(key, article);
        }
Beispiel #30
0
        public ArticleEntity getById(string articleId)
        {
            ArticleEntity article = dao.getById(articleId);

            return(article);
        }
        private void gvArticle_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            ArticleEntity r = (ArticleEntity)gvArticle.GetFocusedRow();

            fncLoadDetail(r);
        }
 private void LoadArticleEntity(DataRow row, ArticleEntity articleInfo)
 {
     articleInfo.BlogId   = Convert.ToInt64(row["BlogId"]);
     articleInfo.Title    = row["Title"] != DBNull.Value ? row["Title"].ToString() : string.Empty;
     articleInfo.PostTime = Convert.ToDateTime(row["CreatedTime"]);
 }
Beispiel #33
0
        public DataServiceMessage <ArticleDetailsDTO> GetDetails(string encryptedId)
        {
            string decryptedId = encryptor.Decrypt(encryptedId);
            int    id;

            List <string>     errors    = new List <string>();
            bool              succeeded = true;
            ArticleDetailsDTO data      = null;

            if (Int32.TryParse(decryptedId, out id))
            {
                try
                {
                    ArticleEntity articleEntity = unitOfWork.Articles.Get(id);
                    if (articleEntity != null)
                    {
                        data = new ArticleDetailsDTO
                        {
                            Id           = encryptedId,
                            CategoryName = articleEntity.Category.Name,
                            DateCreated  = articleEntity.DateCreated,
                            Header       = articleEntity.Header,
                            PhotoLink    = articleEntity.PhotoLink,
                            Text         = articleEntity.Text,
                            Comments     = articleEntity.Comments.Select(commentEntity =>
                            {
                                ApplicationUser author = commentEntity.Author;
                                string fullName        = String.Format("{0} {1}", author.FirstName, author.LastName);
                                if (author.Moderator != null)
                                {
                                    fullName += " - [Moderator]";
                                }
                                else if (author.User == null)
                                {
                                    fullName += " - [Admin]";
                                }

                                string content = commentEntity.DateBanned.HasValue
                                        ? "Reason of ban: " + commentEntity.BanReason.Name
                                        : commentEntity.Text;
                                CommentListDTO commentDTO = new CommentListDTO
                                {
                                    Id                    = encryptor.Encrypt(commentEntity.Id.ToString()),
                                    ArticleId             = encryptedId,
                                    DateCreated           = commentEntity.DateCreated,
                                    Content               = content,
                                    AuthorDisplayFullName = fullName,
                                    IsBanned              = commentEntity.DateBanned.HasValue
                                };

                                return(commentDTO);
                            })
                                           .OrderByDescending(commentEntity => commentEntity.DateCreated)
                                           .ToList()
                        };
                    }
                    else
                    {
                        succeeded = false;
                        errors.Add("Article was not found");
                    }
                }
                catch (Exception ex)
                {
                    succeeded = false;
                    ExceptionMessageBuilder.FillErrors(ex, errors);
                }
            }
            else
            {
                succeeded = false;
                errors.Add("Article was not found");
            }

            return(new DataServiceMessage <ArticleDetailsDTO>
            {
                Errors = errors,
                Succeeded = succeeded,
                Data = data
            });
        }
Beispiel #34
0
        public BaseObject InsertArticle(ArticleEntity param)
        {
            var obj = new BaseObject();

            if (_db.Connection.State != ConnectionState.Open)
            {
                _db.Connection.Open();
            }

            if (_db.Articles.Any(m => m.IsDelete != PublicType.Yes && m.Title == param.Title))
            {
                obj.Tag     = -1;
                obj.Message = "该文章标题已存在!";

                return(obj);
            }

            using (var tran = _db.Connection.BeginTransaction())
            {
                try
                {
                    var article = new Article()
                    {
                        ColumnID        = param.ColumnID,
                        Content         = param.Content,
                        IsPublic        = param.IsPublic,
                        MetaDescription = param.MetaDescription,
                        MetaKeywords    = param.MetaKeywords,
                        Overview        = param.Overview,
                        PageTitle       = param.PageTitle,
                        PageVisits      = 0,
                        Slug            = param.Slug,
                        Title           = param.Title,
                        UpdateTime      = DateTime.Now,
                        UpdateUser      = param.UpdateUser,
                        Source          = param.Source,
                        SortOrder       = param.SortOrder,
                        ShortTitle      = param.ShortTitle,
                        Author          = param.Author,
                        IsDelete        = PublicType.No
                    };

                    _db.Articles.Add(article);
                    _db.SaveChanges();
                    tran.Commit();

                    obj.Tag     = 1;
                    obj.Message = "保存成功!";
                }
                catch (Exception e)
                {
                    tran.Rollback();
                    obj.Tag     = -1;
                    obj.Message = "保存失败!";
                }
                finally
                {
                    tran.Dispose();
                }
            }

            return(obj);
        }