Exemple #1
0
 public Article(uint productId_, string productName_, double productPrice_)
 {
     productId = productId_;
     productName = productName_;
     productPrice = productPrice_;
     enumArticleType = ArticleType.Chemical;
 }
Exemple #2
0
 public Article(String prodid, String prodname, float prodprice, ArticleType arttype)
 {
     this.ProductID = prodid;
     this.ProductName = prodname;
     this.ProductPrice = prodprice;
     this.ArtType = arttype;
 }
Exemple #3
0
 public Article(long articleID, string articleName, double articlePrice, ArticleType articleType)
 {
     this.articleID = articleID;
     this.articleName = articleName;
     this.articlePrice = articlePrice;
     this.articleType = articleType;
 }
Exemple #4
0
 public Article(int id, string name, double price, int vat, ArticleType type)
     : base(id)
 {
     Name = name;
     Price = price;
     VAT = vat;
     Type = type;
 }
 public ActionResult NewsList(string publishDate, ArticleType newsType = ArticleType.News)
 {
     var format = new CultureInfo("uk-UA");
     DateTime publish = publishDate == null ? DateTime.Now : DateTime.Parse(publishDate, format);
     var modelDb = _context.GetNewsByDateType(publish, newsType);
     var model = Mapper.Map<List<ArticleBaseVm>>(modelDb);
     return PartialView("_NewsList", model);
 }
Exemple #6
0
 public List <Article> GetLastArticlesByType(int page, int pageCount, ArticleType type, string category = null)
 {
     return(_context.Articles
            .Include(i => i.Pictures)
            .Where(w => w.DatePublish <= DateTime.Now && w.Category.Type == type && (category == null || w.Category.TranslitUrl == category))
            .OrderByDescending(o => o.DatePublish).Skip((page - 1) * pageCount)
            .Take(pageCount)
            .ToList());
 }
 public List<Article> GetLastArticlesByType(int page, int pageCount, ArticleType type, string category = null)
 {
     return _context.Articles
         .Include(i => i.Pictures)
         .Where(w => w.DatePublish <= DateTime.Now && w.Category.Type == type && (category == null || w.Category.TranslitUrl == category))
         .OrderByDescending(o => o.DatePublish).Skip((page - 1) * pageCount)
         .Take(pageCount)
         .ToList();
 }
Exemple #8
0
 public ActionResult Edit([Bind(Include = "Code,Name,Id,InsertedBy,InsertedOn,UpdatedBy,UpdatedOn")] ArticleType articletype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articletype).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(articletype));
 }
Exemple #9
0
        /// <summary>
        /// 修改文章类型数据
        /// </summary>
        /// <returns></returns>
        public static int UpdateArticleType(ArticleType obj)
        {
            int n = DBHelper.ExecuteNonQuery("Update_ArticleType", CommandType.StoredProcedure,
                                             new SqlParameter[] {
                new SqlParameter("@At_Name", obj.At_Name),
                new SqlParameter("@At_No", obj.At_No)
            });

            return(n);
        }
 //constructor
 public Article(string name,
                decimal price,
                int quantity,
                ArticleType type)
 {
     this.name     = name;
     this.price    = price;
     this.quantity = quantity;
     tpArticleType = type;
 }
Exemple #11
0
        /// <summary>
        /// 装载dbo.ArticleType实体
        /// </summary>
        /// <param name="dr">记录集</param>
        /// <returns>返回对象</returns>
        private ArticleType LoadModel(IDataReader dr)
        {
            ArticleType model = new ArticleType();

            model.Id          = Convert.ToInt32(dr["Id"]);
            model.TypeName    = dr["TypeName"].ToString();
            model.ParentId    = Convert.ToInt32(dr["ParentId"]);
            model.OrderNumber = Convert.ToInt32(dr["OrderNumber"]);
            return(model);
        }
Exemple #12
0
        public void Test2()
        {
            var data = new ArticleType
            {
                Name       = "Test",
                EditerName = "admin",
            };

            Assert.Equal("admin", data.EditerName);
        }
        public void CreateArticle(string articleName, ArticleType articleType, string description)
        // create a new article
        {
            ArticleType type = articleType;
            Article     newArticle;

            newArticle             = Article.CreateArticle(articleName, articleType, description);
            newArticle.Description = description;
            articlesDictionary.Add(articleName, newArticle);
        }
Exemple #14
0
        public void Test1()
        {
            var articleType = new ArticleType
            {
                Name       = "Test",
                EditerName = "admin",
            };

            Assert.Contains("Test", articleType.Name);
        }
Exemple #15
0
 public void AddDataTest()
 {
     var mockSet     = new Mock <DbSet <Article> >();
     var mockContext = new Mock <TestDBContext>();
     var data        = new ArticleType()
     {
         Name = "233", EditerName = "test", CreateTime = DateTime.Now
     };
     var svc = new ArticleTypeSvc(mockContext.Object, new DbContextExtendSvc());
 }
 public ActionResult Edit([Bind(Include = "ArticleTypeID,ArticleType1")] ArticleType articleType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articleType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(articleType));
 }
 /// <summary>
 /// An article with given HTML extractor, title, HTML text and article type
 /// </summary>
 /// <param name="htmlPlainTextExtractor">The specified HTML extractor</param>
 /// <param name="title">Title of article</param>
 /// <param name="htmlText">HTML text of article</param>
 /// <param name="titlePath">File path of title</param>
 /// <param name="summaryPath">File path of summary</param>
 /// <param name="typePath">File path of type</param>
 /// <param name="type">Type of article</param>
 public Article(IHtmlPlainTextExtractor htmlPlainTextExtractor, string title, string htmlText, string titlePath, string summaryPath, string typePath, ArticleType type = ArticleType.NotSpecified)
 {
     this.htmlPlainTextExtractor = htmlPlainTextExtractor;
     this.Title = title;
     this.HtmlText = htmlText;
     this.TitlePath = titlePath;
     this.SummaryPath = summaryPath;
     this.TypePath = typePath;
     this.Type = type;
 }
        public ActionResult Edit(int?id)
        {
            ArticleType articletype = _articleTypeService.Find(id);

            if (articletype == null)
            {
                return(BadRequest());
            }
            return(View(articletype));
        }
Exemple #19
0
        public void Test3()
        {
            var data = new ArticleType
            {
                Name       = "Test",
                EditerName = "admin",
            };

            Assert.IsType <ArticleType>(data);
        }
Exemple #20
0
 public Telescope()
 {
     this.article     = ArticleType.Telescope;
     this.description = "The telescope can only be used while " +
                        "its owner is stopped on a space. It cannot be used while " +
                        "just passing through. A hero may turn over and reveal all " +
                        "tokens on spaces adjacent to the one he is on. This does not, " +
                        "however, activate these tokens. This can also be done when it " +
                        "isn’t the hero’s turn.";
 }
        public ActionResult Create(ArticleType articletype)
        {
            if (ModelState.IsValid)
            {
                articletype.Id = Guid.NewGuid();
                ArticleTypeService.Insert(articletype);
                return RedirectToAction("Index");
            }

            return View(articletype);
        }
Exemple #22
0
 public void LoadData(ArticleType articleType)
 {
     HideAllArticleItems();
     for (int i = 0; i < articles.Count; i++)
     {
         if (articles[i].articleType == articleType)
         {
             GetBagGrid().SetArticleItem(LoadArticleItem(articles[i]));
         }
     }
 }
Exemple #23
0
 /// <summary>
 /// 创建ArticleTypeDto对象
 /// </summary>
 /// <param name="articleType">文章类型</param>
 /// <param name="user">用户</param>
 /// <returns></returns>
 public ArticleTypeDto CreaetArticleTypeDto(ArticleType articleType, User user)
 {
     return(new ArticleTypeDto()
     {
         Id = articleType.Id,
         TypeName = articleType.TypeName,
         IsShow = articleType.IsShow,
         UserId = user.Id,
         UserName = user.UserName
     });
 }
Exemple #24
0
    protected UserControl GetArticleHTML(Article article, ArticleType articleType)
    {
        UserControl objControl    = (UserControl)Page.LoadControl("~/Controls/News/Article.ascx");
        var         parsedControl = objControl as IStyledArticleObjectControl;

        parsedControl.Object = article;
        parsedControl.Type   = articleType;
        parsedControl.DataBind();

        return(objControl);
    }
Exemple #25
0
        private async Task DownloadPublication(string symbol, ArticleType type)
        {
            //IEnumerable<Article> articles = await StorehouseService.Instance.GetArticlesAsync();

            foreach (var article in await WolDownloader.WolDownloader.GeneratePublicationAsync(symbol, type))
            {
                await StorehouseService.Instance.AddArticleAsync(article.ToArticle());

                WolDownloader.WolDownloader.DebugArticleOutput(article);
            }
        }
Exemple #26
0
        public ActionResult Create([Bind(Include = "Code,Name,Id,InsertedBy,InsertedOn,UpdatedBy,UpdatedOn")] ArticleType articletype)
        {
            if (ModelState.IsValid)
            {
                db.ArticleType.Add(articletype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(articletype));
        }
Exemple #27
0
        public double GetOrderedCount(ObjectId articleId, ArticleType articleType)
        {
            Guid id = articleId.ToGuid();

            if (articleType == ArticleType.Card)
            {
                return(Enumerable.Sum(ArticleOrders.Where(ao => ao.ArticleId == id), item => item.Count));
            }

            return(Enumerable.Sum(ProductArticleOrders.Where(pao => pao.ProductArticle.ArticleId == id), item => item.Count));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,CreateDateTime,IsDelete,Type")] ArticleType articleType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(articleType).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(articleType));
        }
Exemple #29
0
 public Falcon()
 {
     article          = ArticleType.Falcon;
     this.description = "Two heroes can exchange as many small articles (including a helm, witch’s brew, or poison), gold, or " +
                        "gemstones at one time as they like even if they are not standing on the same space. One of them must be in possession of " +
                        "the falcon. Large articles (shield or bow) cannot be traded in this way. The falcon can only be used once per day." +
                        "Then the token is flipped onto its rear side, and at sunrise it is flipped back onto its front side. " +
                        "The falcon can also be used in the mine in Legend 4.However, it cannot fly on or over spaces with rubble.The falcon " +
                        "cannot be used during a battle.";
     usedToday = false;
 }
Exemple #30
0
        public Article(Guid id, Guid creatorId, string title, string text, ArticleType articleType)
        {
            ValidateDomain(id, creatorId, title, text);

            Id          = id;
            CreatorId   = creatorId;
            Title       = title;
            Text        = text;
            ArticleType = articleType;
            CreatedAt   = DateTimeOffset.Now;
        }
        public ServiceResult <ArticleType> Update(ArticleType articleType)
        {
            var validResult = ValidParentId(articleType);

            if (validResult.HasViolation)
            {
                return(validResult);
            }

            return(_articleTypeService.Update(articleType));
        }
Exemple #32
0
        public static int CountByUserID(ArticleType articleType, string userID)
        {
            using (var db = OnlineStoreDbContext.Entity)
            {
                var query = from item in db.Articles
                            where item.ArticleType == articleType && item.UserID == userID
                            select item;

                return(query.Count());
            }
        }
Exemple #33
0
        public ActionResult Create([Bind(Include = "Id,ArticleTypeName,ArticleCounts,DelFlag")] ArticleType articleType)
        {
            if (ModelState.IsValid)
            {
                db.ArticleType.Add(articleType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(articleType));
        }
Exemple #34
0
        public ArticleType Add(ArticleTypeDto dto)
        {
            var data = new ArticleType();

            dto.CreateTime = DateTime.Now;
            data           = _mapper.Map <ArticleType>(dto);
            _testDB.Add(data);
            var flag = _testDB.SaveChanges();

            return(data);
        }
Exemple #35
0
 /// <summary>
 /// 新增一个稿件种类
 /// </summary>
 /// <param name="articleType"></param>
 /// <returns></returns>
 public static int AddArticleTyjpe(ArticleType articleType)
 {
     DBVisit.ObjDBAccess.CommandStr = "insert into ArticleType value(@id,@name)"; //SQL插入语句
     SqlParameter[] sqlPm = new SqlParameter[]                                    //SQLCommand的插入参数
     {
         new SqlParameter("@id", articleType.Id),
         new SqlParameter("@name", articleType.Name)
     };
     DBVisit.ObjDBAccess.CmdParas.AddRange(sqlPm);            //加入到SqlCommand的参数列表中
     return(DBVisit.ObjDBAccess.ExecuteUnSelectSqlCommand()); //执行插入语句
 }
Exemple #36
0
 /// <summary>
 /// 修改稿件种类方法
 /// </summary>
 /// <param name="articleState">稿件种类实体</param>
 /// <returns>受影响的行数</returns>
 public static int UpdataArticele(ArticleType articleType)
 {
     DBVisit.ObjDBAccess.CommandStr = "update ArticleType set ArticleType_Name=@name where ArticleType_ID=@id";
     SqlParameter[] sqlPm = new SqlParameter[]   //参数列表
     {
         new SqlParameter("@name", articleType.Name),
         new SqlParameter("@id", articleType.Id)
     };
     DBHelper.DBVisit.ObjDBAccess.CmdParas.AddRange(sqlPm);
     return(DBHelper.DBVisit.ObjDBAccess.ExecuteUnSelectSqlCommand());  //调用DBhelp执行修改
 }
        public ActionResult Create([Bind(Include = "ArticleTypeID,ArticleType1")] ArticleType articleType)
        {
            if (ModelState.IsValid)
            {
                db.ArticleTypes.Add(articleType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(articleType));
        }
Exemple #38
0
        public async Task <IActionResult> Create([Bind("Id,Type")] ArticleType articleType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(articleType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(articleType));
        }
Exemple #39
0
 /// <summary>
 /// Overloaded Constructor
 /// </summary>
 /// <param name="aType">ArticleType</param>
 /// <param name="ArticleTypeCriteria">Search Criteria</param>
 public StoryCollection(ArticleType aType,
                        string ArticleTypeCriteria)
 {
     if (aType == ArticleType.byUserDiggs)
     {
         foreach (string id in Parser.GetStoryIDsByUser(ArticleTypeCriteria))
              Parser.populateStoryCollection(this, BuildUrl(ArticleType.byId, id));
     }
     else
     {
         Parser.populateStoryCollection(this, BuildUrl(aType, ArticleTypeCriteria));
     }
 }
        public ArticleOld(ArticleType articleType, IArticleValidator validator, ArticlePublishingRules publishingRules)
        {
            ArticleType = articleType;
            if (validator == null)
            {
                throw new ArgumentNullException("validator");
            }
            _validator = validator;

            if (publishingRules == null)
            {
                throw new ArgumentNullException("publishingRules");
            }

            _publishingRules = publishingRules;
        }
Exemple #41
0
 public List<Template> GetTemplates(ArticleType articleType, TemplateType templateType)
 {
     List<Template> templates = new List<Template>();
     DbCommand command = DbProviderHelper.CreateCommand("SelectTemplatesByArticleTypeAndTemplateType", CommandType.StoredProcedure);
     command.Parameters.Add(DbProviderHelper.CreateParameter("@ArticleType", DbType.Int16, articleType));
     command.Parameters.Add(DbProviderHelper.CreateParameter("@TemplateType", DbType.Int16, templateType));
     DbDataReader dataReader = DbProviderHelper.ExecuteReader(command);
     while (dataReader.Read())
     {
         Template template = new Template();
         template.TemplateId = Convert.ToInt32(dataReader["TemplateId"]);
         template.TemplateGuid = (Guid)dataReader["TemplateGuid"];
         template.Title = Convert.ToString(dataReader["Title"]);
         template.TemplatePath = Convert.ToString(dataReader["TemplatePath"]);
         template.TemplateType = (TemplateType)System.Enum.Parse(typeof(TemplateType), dataReader[ViewReleaseTemplateField.TemplateType].ToString(), true);
         template.ArticleType = Convert.ToSByte(dataReader["ArticleType"]);
         templates.Add(template);
     }
     dataReader.Close();
     return templates;
 }
Exemple #42
0
        /// <summary>
        /// Updates the type of an article.
        /// </summary>
        /// <param name="article"></param>
        /// <param name="articleNewType"></param>
        /// <returns></returns>
        public static bool UpdateArticleType(WikiArticle article, ArticleType articleNewType)
        {
            // Check that the new type is not Code or Site, since article of those types are generated automatically and cannot be set manually.
            if (articleNewType == ArticleType.Code || articleNewType == ArticleType.Site)
                throw new NotSupportedException(string.Format("The title of articles of type {0} cannot be edited.", articleNewType.ToString()));

            // Checks that there is not already an article with the same type in the target new category.
            if (DataModule.DoesIdenticalArticleExist(Tools.GetArticleFullTitle(articleNewType, article.Title), article.Id))
                return false;

            // Refresh the type of the current article.
            article.Type = articleNewType;

            // Update the type of the article in DB.
            string query = string.Format("UPDATE tbl_articles SET art_type = '{0}' WHERE art_id_pkey = {1}", (int)articleNewType, article.Id);
            return Convert.ToBoolean(DataAccess.ExecuteOwnStatement(query));
        }
 public List<Article> GetNewsByDateType(DateTime date, ArticleType articleType)
 {
     return _context.Articles.Include("Pictures").Where(w => w.DatePublish.Year == date.Year && w.DatePublish.Month == date.Month && w.DatePublish.Day == date.Day && w.Category.Type == articleType).ToList();
 }
Exemple #44
0
        /// <summary>
        /// Gets a list of the approved child pages of a certain type in a Category.
        /// </summary>
        /// <param name="categoryId">The ID of an article. Supposedly, only categories can have sub-pages.</param>
        /// <param name="pagesType">The type of the pages in the Category.</param>
        /// <param name="mustUseApproved">Set to true if only the approved versions of the articles must be returned.</param>
        /// <returns>A list of all the child pages of a certain type in a Category.</returns>
        public static List<WikiArticleInfo> GetChildPages(int categoryId, ArticleType pagesType, bool mustUseApproved)
        {
            if (categoryId <= 0)
                return null;

            string query = string.Empty;
            if (mustUseApproved)
                query = string.Format(@"SELECT {2} FROM tbl_article_approved INNER JOIN (SELECT app_art_id_fkey LastId, MAX(app_approval_date) AS LastDate FROM tbl_article_approved GROUP BY app_art_id_fkey) LatestApproved ON LastId = app_art_id_fkey AND LastDate = app_approval_date INNER JOIN tbl_article_hierarchy ON ahe_child_art_fkey = app_art_id_fkey WHERE ahe_parent_art_fkey = {0} AND app_type = {1} ORDER BY app_title", categoryId, (int)pagesType, APPROVED_ARTICLE_INFO_FIELDS);
            else
                query = string.Format(@"SELECT {2} FROM tbl_articles INNER JOIN tbl_article_hierarchy ON ahe_child_art_fkey = art_id_pkey WHERE ahe_parent_art_fkey = {0} AND art_type = {1} ORDER BY art_title", categoryId, (int)pagesType, ARTICLE_INFO_FIELDS);
            return GetArticleInfosFromQuery(query);
        }
Exemple #45
0
 /// <summary>
 /// Returns a list of all the articles of the given type. To get a list of Code articles, use method GetCodeArticles() instead.
 /// </summary>
 /// <param name="articleType">A type of article.</param>
 /// <returns>A list of all the articles of the given type.</returns>
 public static List<WikiArticleInfo> GetArticles(ArticleType articleType)
 {
     if (articleType == ArticleType.Code || articleType == ArticleType.Site)
         throw new NotSupportedException(string.Format("This method cannot be used to get an article of type {0}.", articleType.ToString()));
     string query = string.Format(@"SELECT {1} FROM tbl_articles WHERE art_type = {0} ORDER BY art_title", (int)articleType, ARTICLE_INFO_FIELDS);
     return GetArticleInfosFromQuery(query);
 }
Exemple #46
0
        /// <summary>
        /// Gets a list of all the Approved copies of a certain type of articles.
        /// </summary>
        /// <param name="articletype">A type of articles.</param>
        /// <returns>A list of all the Approved copies of a certain type of articles.</returns>
        public static List<WikiArticleInfo> GetApprovedArticles(ArticleType articletype)
        {
            if (articletype == ArticleType.Code || articletype == ArticleType.Site)
                throw new NotImplementedException("This method cannot be called for articles of type Code or Site");

            string query = string.Empty;
            // TODO.
            //if (articletype == ArticleType.Category)

            //    query = string.Format(@"SELECT {0} FROM tbl_articles INNER JOIN tbl_article_hierarchy ON art_id_pkey = ahe_parent_art_fkey INNER JOIN tbl_article_approved ON ahe_child_art_fkey = app_art_id_fkey WHERE art_type = {1}", ARTICLE_FIELDS, (int)articletype);
            //else
            //query = string.Format(@"SELECT {0} FROM tbl_articles INNER JOIN tbl_article_approved ON app_art_id_fkey = art_id_pkey WHERE app_type = {1} ORDER BY art_title", APPROVED_ARTICLE_FIELDS, (int)articletype);
            query = string.Format(@"SELECT {0} FROM tbl_article_approved INNER JOIN (SELECT app_art_id_fkey LastId, MAX(app_approval_date) AS LastDate FROM tbl_article_approved GROUP BY app_art_id_fkey) LatestApproved ON LastId = app_art_id_fkey AND LastDate = app_approval_date WHERE app_type = {1} ORDER BY app_title", APPROVED_ARTICLE_FIELDS, (int)articletype);
            return GetArticleInfosFromQuery(query);
        }
Exemple #47
0
 /// <summary>
 /// Return the approved version of an article by the title of its latest version.
 /// Note that this methods exists because the title of an article can be modified once it has been approved.
 /// </summary>
 /// <param name="articleType">The type of the article.</param>
 /// <param name="articleTitle">The exact title of the article.</param>
 /// <returns>An approved article by the title and type of its latest version.</returns>
 public static WikiArticle GetApprovedArticleByLatest(string articleTitle, ArticleType articleType)
 {
     if (!DoesArticleHaveApprovedVersion(articleType, articleTitle))
         return null;
     string query = string.Format(@"SELECT {2} FROM tbl_articles INNER JOIN tbl_article_approved ON art_id_pkey = app_art_id_fkey WHERE art_title = '{0}' AND art_type = {1} ORDER BY app_approval_date DESC", articleTitle, (int)articleType, APPROVED_ARTICLE_FIELDS);
     return GetArticleFromQuery(query);
 }
Exemple #48
0
 /// <summary>
 /// Returns an approved article by the title of its approved version.
 /// </summary>
 /// <param name="articleTitle">The title of an approve article.</param>
 /// <param name="articleType">The type of an approved article.</param>
 /// <returns>An approved article.</returns>
 public static WikiArticle GetApprovedArticle(string articleTitle, ArticleType articleType)
 {
     if (!DoesApprovedArticleExist(articleType, articleTitle))
         return null;
     string query = string.Format(@"SELECT {2} FROM tbl_article_approved WHERE app_title = '{0}' AND app_type = {1} ORDER BY app_approval_date DESC", articleTitle, (int)articleType, APPROVED_ARTICLE_FIELDS);
     return GetArticleFromQuery(query);
 }
Exemple #49
0
        /// <summary>
        /// Checks whether an article has an approved version, i.e. it has a validated copy visible to external users.
        /// </summary>        
        /// <param name="articleType">The type of the article.</param>
        /// <param name="articleTitle">The title of the article.</param>
        /// <returns>True if there exists an approved version of the article.</returns>
        public static bool DoesArticleHaveApprovedVersion(ArticleType articleType, string articleTitle)
        {
            if (articleType == ArticleType.Code || articleType == ArticleType.Site)
                return false;

            string query = string.Empty;
            //TODO
            //if (articleType == ArticleType.Category)
            //
            //    query = string.Format(@"SELECT COUNT(*) FROM tbl_articles INNER JOIN tbl_article_hierarchy ON art_id_pkey = ahe_parent_art_fkey INNER JOIN tbl_article_approved ON ahe_child_art_fkey = app_art_id_fkey WHERE art_title = '{0}' AND art_type = {1}", Tools.TextToSQL(articleTitle), (int)articleType);
            //else
            query = string.Format(@"SELECT COUNT(*) FROM tbl_article_approved INNER JOIN tbl_articles ON app_art_id_fkey = art_id_pkey WHERE art_title = '{0}' AND art_type = {1}", Tools.TextToSQL(articleTitle), (int)articleType);
            return Convert.ToInt32(DataAccess.GetOwnScalar(query)) > 0;
        }
Exemple #50
0
        /// <summary>
        /// Checks whether an article exists, given its title and type. Cannot be used to check the presence of an article of type Code.
        /// </summary>
        /// <param name="articleTitle">The title of an article.</param>
        /// <param name="articleType">The type of an article.</param>
        /// <returns></returns>
        public static bool DoesArticleExist(string articleTitle, ArticleType articleType)
        {
            if (articleType == ArticleType.Code || articleType == ArticleType.Site)
                return true;    // Assume good faith.
                //throw new NotSupportedException(string.Format("This method cannot be used to check the presence of an article of type {0}.", articleType.ToString()));

            if (articleTitle == Tools.LATEST_PAGE_KEYWORD || articleTitle == Tools.RANDOM_PAGE_KEYWORD)
                return true;

            string query = string.Format(@"SELECT COUNT(*) FROM tbl_articles LEFT JOIN tbl_article_approved ON app_art_id_fkey = art_id_pkey WHERE (art_title LIKE '{0}' AND art_type = {1}) OR (app_title LIKE '{0}' AND app_type = {1})",
                Tools.TextToSQL(articleTitle), (int)articleType);
            return Convert.ToInt32(DataAccess.GetOwnScalar(query)) > 0;
        }
Exemple #51
0
        /// <summary>
        /// Checks whether an approved article given by its approved type and title exists.
        /// </summary>
        /// <param name="articleType">The type of an approved article.</param>
        /// <param name="articleTitle">The title of an approved article.</param>
        /// <returns>True if an approved article with the given type and title exists.</returns>
        public static bool DoesApprovedArticleExist(ArticleType articleType, string articleTitle)
        {
            if (articleType == ArticleType.Code || articleType == ArticleType.Site)
                return true;    // Assume good faith.

            string query = string.Format(@"SELECT COUNT(*) FROM tbl_article_approved WHERE app_title = '{0}' AND app_type = {1}", Tools.TextToSQL(articleTitle), (int)articleType);
            return Convert.ToInt32(DataAccess.GetOwnScalar(query)) > 0;
        }
Exemple #52
0
        /// <summary>
        /// Insert a new article in database, with preliminary verification that it does not exist yet.
        /// </summary>
        /// <param name="articleTitle">The title of the new article (that will be checked for duplicates).</param>
        /// <param name="articleText">The text of the new article.</param>
        /// <param name="articleType">The type of the new article.</param>
        /// <param name="user">The user who is creating the article.</param>
        /// <param name="error">A reference parameter filled upon encountering an error.</param>
        /// <returns>The new article if the article was correctly created or null otherwise.</returns>
        public static WikiArticle CreateArticle(string articleTitle, ArticleType articleType, string articleText, User user, ref string error)
        {
            if (articleType == ArticleType.Code || articleType == ArticleType.Site)
                throw new NotSupportedException(string.Format("This method cannot be used to create an article of type {0}.", articleType.ToString()));

            // Check user rights.
            if (!user.CanCreate)
            {
                error = "You don't have the right to create articles.";
                return null;
            }

            // Check that the article doesn't exist yet.
            if (DoesArticleExist(articleTitle, articleType))
            {
                error = "An article with the same title already exists.";
                return null;
            }

            // Limit the size of the summary to its maximal length.
            string articleSummary = WikiParser.GetSummary(articleText);
            if (articleSummary.Length > Tools.SUMMARY_MAX_LENGTH)
                articleSummary = articleSummary.Remove(Tools.SUMMARY_MAX_LENGTH);

            string query = string.Format(@"INSERT INTO tbl_articles
                (art_title, art_text, art_type, art_creation_date, art_creation_user, art_modification_date, art_modification_user, art_status, art_locked_by, art_summary)
                VALUES ('{0}', '{1}', {2}, GETDATE(), '{3}', GETDATE(), '{3}', {4}, '{3}', '{5}')",
                Tools.TextToSQL(articleTitle), Tools.TextToSQL(articleText), (int)articleType, user.UserLogin, (int)ArticleStatus.Internal, Tools.TextToSQL(articleSummary));
            DataAccess.ExecuteOwnStatement(query);

            return GetArticle(articleType, articleTitle);
        }
Exemple #53
0
        /// <summary>
        /// Returns an article based on the exact title of one of its approved version.
        /// </summary>
        /// <param name="approvedArticleType">The type of the approved version of the article.</param>
        /// <param name="approvedArticleTitle">The exact title of an approved version of the article.</param>        
        /// <returns>The article matching exactly the title of its approved version.</returns>
        private static WikiArticle GetArticleByApproved(ArticleType approvedArticleType, string approvedArticleTitle)
        {
            if (approvedArticleType == ArticleType.Code || approvedArticleType == ArticleType.Site)
                throw new NotSupportedException(string.Format("This method cannot be used to get an article of type {0}.", approvedArticleType.ToString()));

            string query = string.Format(@"SELECT {2} FROM tbl_articles INNER JOIN tbl_article_approved ON app_art_id_fkey = art_id_pkey WHERE app_title = '{0}' AND app_type = {1}", Tools.TextToSQL(approvedArticleTitle), (int)approvedArticleType, ARTICLE_FIELDS);
            return GetArticleFromQuery(query);
        }
Exemple #54
0
        public double tax; // Steuer

        public AbstractArticle(ArticleType type, string number, string name, double price)
        {
            this.number = number;
            this.name = name;
            this.price = price;
        }
Exemple #55
0
 public RequestItem(long articleID, string articleName, double articlePrice, ArticleType articleType, int requestItemQuantity)
 {
     requestItemArticle = new Article(articleID, articleName, articlePrice, articleType);
     this.requestItemQuantity = requestItemQuantity;
 }
Exemple #56
0
 public int GetCountLastArticlesByType(ArticleType type, string category)
 {
     return _context.Articles.Count(w => w.DatePublish <= DateTime.Now && w.Category.Type == type && (category == null || w.Category.TranslitUrl == category));
 }
Exemple #57
0
        /// <summary>
        /// Returns an article based on its exact title and its type.
        /// This method can also be used to get an approved article (see third parameter).
        /// To get a Code article, use method GetCodeArticle() instead.
        /// </summary>
        /// <param name="articleType">The type of the article.</param>
        /// <param name="articleTitle">The exact title of the article.</param>
        /// <returns>The article matching exactly the title.</returns>
        private static WikiArticle GetArticle(ArticleType articleType, string articleTitle)
        {
            if (articleType == ArticleType.Code || articleType == ArticleType.Site)
                throw new NotSupportedException(string.Format("This method cannot be used to get an article of type {0}.", articleType.ToString()));

            string query = string.Format(@"SELECT {2} FROM tbl_articles WHERE art_title = '{0}' AND art_type = {1}", Tools.TextToSQL(articleTitle), (int)articleType, ARTICLE_FIELDS);
            return GetArticleFromQuery(query);
        }
 public ActionResult Edit(ArticleType articletype)
 {
     if (ModelState.IsValid)
     {
         ArticleTypeService.Update(articletype);
         return RedirectToAction("Index");
     }
     return View(articletype);
 }
        private static IDictionary<string, Schema> GenerateTypeProperties(ArticleType templateType)
        {
            var typeProperties = new Dictionary<string, Schema>();
            var restrictedFieldNames = new[] {"id", "parentid", "parenttype"};
            foreach (var field in templateType.Fields.Where(field => !restrictedFieldNames.Contains(field.Name)))
            {
                typeProperties[field.Name] = new Schema
                {
                    type = ConvertType(field),
                    format = ConvertFormat(field),
                    description = ""
                };

                if (field.Type == DataType.SingleValue)
                    typeProperties[field.Name].@ref = "SingleReference";
                if (field.Type == DataType.MultiValue)
                    typeProperties[field.Name].@ref = "MultiReference";
            }

            return typeProperties;
        }
 public IList<Article> ReadByType(ArticleType type)
 {
     return _context.Articles.Include(a => a.Author).Include(p => p.Publisher).Where(a => a.ArticleType == type).ToList();
 }