public ArticleApplication(IArticle article, IMapper mapper, IArticleLikes articleLikes, IUser user)
 {
     _article      = article;
     _mapper       = mapper;
     _articleLikes = articleLikes;
     _user         = user;
 }
Пример #2
0
        public ProcessedArticle Process(IArticle article)
        {
            IEnumerable <IToken>       tokenized = _tokenizer.Tokenize(article.Text);
            Dictionary <IToken, TfIdf> tfIdfs    = _tfIdfCalculator.Calculate(tokenized);

            return(new ProcessedArticle(tfIdfs));
        }
Пример #3
0
        public static async Task <IArticle> InlineImagesAsync(IArticle article)
        {
            var articleContent = new HtmlDocument();

            articleContent.LoadHtml(article.Content);

            var articleImages = articleContent.DocumentNode.SelectNodes("//img");

            if (articleImages == null)
            {
                return(article);
            }

            var articleImageConversionTasks = new List <Task>();

            foreach (var articleImage in articleImages)
            {
                articleImageConversionTasks.Add(InlineImageAsync(articleImage));
            }

            await Task.WhenAll(articleImageConversionTasks);

            article.Content = articleContent.DocumentNode.InnerHtml;
            return(article);
        }
 private Dictionary <string, IArticle> .ValueCollection IterateThroughAllItemsAndUploadThem(Dictionary <string, IArticle> dictionary,
                                                                                            EbayArticleCSVWriter ebaySingleArticleCsvWriter, double amount,
                                                                                            string template)
 {
     foreach (var articleToUpload in WheelListFlat)
     {
         IArticle result = null;
         try
         {
             result = ebayUploader.RefreshOrCreateEbayArticle(articleToUpload,
                                                              ebaySingleArticleCsvWriter, amount,
                                                              template);
             var key = ArticleKeyGenerator.GetKeyFromArticle(articleToUpload);
             if (dictionary.ContainsKey(key))
             {
                 dictionary.Remove(key);
             }
             dictionary[key] = result;
         }
         catch (ApiException e)
         {
             logger.Warn(
                 "Fehler bei Ebay Kommunikation von Datensatz ID:" + articleToUpload.ArticleId, e);
         }
         catch (Exception e)
         {
             logger.Error("Unknown Exception On Uploading articles", e);
             break;
         }
         CountOfCurrentUploadedItems++;
     }
     return(dictionary.Values);
 }
Пример #5
0
        public string AddArticle(IArticle article, string authorId)
        {
            // In a real DB using scenario this might be handled by the DB if it supports auto-increment/identity columns. This should ensure no collision for our test
            article.Id = Guid.NewGuid().ToString();

            if (string.IsNullOrWhiteSpace(article.Topic))
            {
                throw new Exception("Topic must be set for article");
            }

            if (string.IsNullOrWhiteSpace(article.ArticleBody))
            {
                throw new Exception("Body must be set for article");
            }

            if (string.IsNullOrWhiteSpace(authorId))
            {
                throw new Exception("Author must be set for article");
            }

            article.Author = CheckAuthor(authorId);
            DataStorage.Articles.Add(article);

            return(article.Id);
        }
Пример #6
0
 public override string GetTextLineFromArticle(IArticle articleToWrite)
 {
     return(string.Format(CSVConstants.DataFormatLine,
                          articleToWrite.Id,
                          articleToWrite.ArticleId,
                          articleToWrite.Description,
                          articleToWrite.Description2,
                          GetNumberFormatForDecimal(articleToWrite.Price),
                          GetNumberFormatForDecimal(articleToWrite.Price4),
                          GetNumberFormatForDecimal(articleToWrite.AvgPrice),
                          GetNumberFormatForDecimal(articleToWrite.AnonymPrice),
                          GetNumberFormatForDecimal(articleToWrite.RvoPrice),
                          articleToWrite.Availability,
                          articleToWrite.ManufactorerNumber,
                          articleToWrite.ImageLink,
                          articleToWrite.ImageTnLink,
                          articleToWrite.InfoLink,
                          articleToWrite.Manufactorer,
                          articleToWrite.DirectLink,
                          articleToWrite.TyreLabelLink,
                          GetEbayIdForArticle(articleToWrite, 1),
                          GetEbayIdForArticle(articleToWrite, 2),
                          GetEbayIdForArticle(articleToWrite, 4),
                          DateTime.Now));
 }
Пример #7
0
        /// <summary>
        ///
        ///     return true when valid
        ///
        ///     Exception      =
        ///                    = Calories cant be more than 2000
        ///                    = Name cant be more than 50
        ///
        /// </summary>
        private bool validation(IArticle article)
        {
//            if (!article.NutrientIntakes.Any()) return false;
//            foreach (var nutrientIntake in article.NutrientIntakes)
//            {
//                if (_nutrientRepository.GetBy(nutrientIntake.Nutrient) == null) return false;
//            }


            if (article.Calories > 2000)
            {
                return(false);
            }
            if (article.Name != null)
            {
                if (article.Name.Length > 50)
                {
                    return(false);
                }
            }



            return(true);
        }
Пример #8
0
 public override string GetTextLineFromArticle(IArticle articleToWrite)
 {
     return string.Format(CSVConstants.DataFormatLine,
         articleToWrite.Id,
         articleToWrite.ArticleId,
         articleToWrite.Description,
         articleToWrite.Description2,
         GetNumberFormatForDecimal(articleToWrite.Price),
         GetNumberFormatForDecimal(articleToWrite.Price4),
         GetNumberFormatForDecimal(articleToWrite.AvgPrice),
         GetNumberFormatForDecimal(articleToWrite.AnonymPrice),
         GetNumberFormatForDecimal(articleToWrite.RvoPrice),
         articleToWrite.Availability,
         articleToWrite.ManufactorerNumber,
         articleToWrite.ImageLink,
         articleToWrite.ImageTnLink,
         articleToWrite.InfoLink,
         articleToWrite.Manufactorer,
         articleToWrite.DirectLink,
         articleToWrite.TyreLabelLink,
         GetEbayIdForArticle(articleToWrite, 1),
         GetEbayIdForArticle(articleToWrite, 2),
         GetEbayIdForArticle(articleToWrite, 4),
         DateTime.Now);
 }
Пример #9
0
 public void Add(IArticle article)
 {
     if (!allArticles.Contains(article))
     {
         allArticles.Add(article);
     }
 }
        public IArticleEbook Render(IArticle a)
        {
            log.Debug("Rendering article '" + a.Metadata.Title + "' to html....");

            var doc = new HtmlDocument();
            doc.LoadHtml(CreateHtml(a));
            var body = doc.DocumentNode.SelectSingleNode("//body");
            (body.SelectNodes("//img[string-length(@src) > 0]") ?? EmptyNodes).Where(n => n != null).ToList().ForEach(n =>
            {
                var src = n.Attributes["src"].Value;
                if (src.StartsWith("/"))
                    src = "https://decorrespondent.nl" + src;
                try
                {
                    if (src.EndsWith(".svg"))
                    {
                        var svg = resources.Read(src);
                        n.ParentNode.ReplaceChild(HtmlNode.CreateNode(svg), n);
                    }
                    else
                    {
                        var image = resources.ReadBinary(src);
                        var extension = src.Split('.').LastOrDefault();
                        n.Attributes["src"].Value = string.Format("data:image/{1};base64,{0}", Convert.ToBase64String(image), extension);
                    }
                }
                catch (WebException e)
                {
                    log.Info("Ignoring error reading image source: '" + src + "', error: " + e.Message );
                }
            });
            (body.SelectNodes("//iframe") ?? EmptyNodes).Where(n => n != null).ToList().ForEach(n => n.ParentNode.ReplaceChild(HtmlNode.CreateNode(@"<img src=""data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAABpISURBVHhe7Z3dryTHWcZ3bSd2AsYiSITM6Zk5X7sLyspcLMJry+BA1rB2luXGjhLB/+IrwgVccAdxIP8JttcfEZEiQ8T/gByCcoONZEO81Nsz1dtd9fR0fXVX9fTzSI+Oz+nfdtc7VfWed7pfz7nioKsPHz68uv/vQyKHRQ6LHFYuztbrr7/++EsvvfSEfN3/CIocFjkscli5OKhbt2594e7du0/K1/2PoMhhkcMih5WLQ7qqssZT9+7d+7KcYP8zJHJY5LDIYeXirrzxxhuP7f+z0VX5h/fv33/6tdde+5J8v/uxJXJY5LDIYeXirqgkYb81kMwh//jll1/+FfVt70Xk+J07d54h1xE5LHJY2Ti18b8o7lQA8l5BssdQhkk9GHJQ5LDIYTlzsr9v3779JakA9j/b3S2U9wv79wyzDY4cFDmsRXJq4/+q/Pbf/6yW3DR4YuBu4SyCI2eJHNZiuX2F/0jSJGDdDOhqNsGR64gcFjkPHUtw5LDIYS2NgzqW4MhhkcNaGgd1LMGRwyKHtTQO6liCI4dFDmtpXH8n4BEERw6LHNbSuKSdgHISySSmH3/hhReefvHFF39dvsr3xnFy5BbP5UgS0gcg9uoEvHHjxtNVVX339HT9w81m/eF2e/KLqjr53/X65CHydrtujI5rk8Mmh31s3GZTfV5Vq1+on32o/E9V9bW/OD8/f2a/7ZJvfu9OwPV6fbFer36gBveJb3DkuiaHTc706n/U13+8fv36s6krBOdOwO12+9Rms/pr9Vv+MxnU8KB3JodNDpsc9p75bLvd/F1VVd3uvUfyrhCcOgE3m82ZKkX+1RiM66DJGSaHTQ7b5lY/VXvyfL89tbw3/wC3U1V99ab6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K1bt2594d69e1+W54RSCazXu7cDPYNxHTQ5w+SwyWHvmX+7efP6b6ttGr35rU5AkZQCd+/efVKsvq3/8e6ewOqv2k8HPAdNzjA5bHLYcrdfbvgles9fc1YnoNJVyQZSAey/72iz2ZypJPAP2231ScrgyGGTw14Wt/pYnvMnfNTXcFYn4MOHD+U9QfdmQFf1P759+3dPzs42fynJQA3wx2qg/6n++zP1tflb6SqoQ39HvTE5bHLYR8z9Uv6XXvm/+uR/7JHefvX12zdv3kzT4beTKweV+iLksMhhkcNKzUEdS3DksMhhLY2DOpbgyGGRw1oaB3UswZHDIoe1NM7uBFS6Kr0ARxAcOSxyWEvj+jsB79+///TEgyGHRQ6LHJYzJ30A4t5OQPXtbIMjB0UOa3Gccycg0NG8COSgyGEdFefdCbjXLIIjZ4kc1mK54E7AOQRHriNyWOQ8dCzBkcMih7U0DupYgiOHRQ5raRxUfbdQbhgMPRUgB0UOixxWLg5L7hLKowLzbqEpcljksMhh5eJQJ6DuEPqifN3/CIocFjkscliZue7Nf8kI8kOYGVoih0UOixxWbu7KlStX/x9mud7hOAnZwQAAAABJRU5ErkJggg==""/>"), n));
            return new ArticleEbook(FormatName(string.Format("{0} {1} ({2})", a.Metadata.ReadingTime.Select(i => (int?)i).LastOrDefault(), a.Metadata.Title, a.Metadata.AuthorLastname)).Trim() + ".html", doc.Encoding.GetBytes(doc.DocumentNode.OuterHtml));
        }
Пример #11
0
 public HomeController(ILogger <HomeController> logger, ITagArticle tagArticle, ICategotyArticle categoty, IArticle article)
 {
     _logger          = logger;
     _article         = article;
     _categotyArticle = categoty;
     _tagArticle      = tagArticle;
 }
Пример #12
0
 private void InitReplaceMap(IArticle article)
 {
     this.replaceMap = new Dictionary <string, string>();
     replaceMap.Add(Placeholder.ArticlePlaceholder.NamePlaceholder, article.Description);
     replaceMap.Add(Placeholder.ArticlePlaceholder.DescriptionPlaceholder, article.Description + " " + article.Description2);
     replaceMap.Add(Placeholder.ArticlePlaceholder.ManufactorPlaceholder, article.Manufactorer);
 }
Пример #13
0
        public ArticleContext(IArticle article) : base()
        {
            Article = article;

            (Article as IObservableArticle).Changed += ArticleContext_Changed;
            (Article as IObservableArticle).Moved   += ArticleContext_Moved;
        }
Пример #14
0
 public void RemoveArticle(IArticle article)
 {
     if (article != null)
     {
         this.Articles.Remove(article);
     }
 }
Пример #15
0
 public void Update(IArticle data)
 {
     CategoryId    = data.CategoryId;
     ArticleTypeId = data.ArticleType.ArticleTypeId;
     SiteId        = data.SiteId;
     State         = data.State;
 }
Пример #16
0
 private void InitReplaceMap(IArticle article)
 {
     this.replaceMap = new Dictionary<string, string>();
     replaceMap.Add(Placeholder.ArticlePlaceholder.NamePlaceholder, article.Description);
     replaceMap.Add(Placeholder.ArticlePlaceholder.DescriptionPlaceholder,article.Description + " " + article.Description2);
     replaceMap.Add(Placeholder.ArticlePlaceholder.ManufactorPlaceholder, article.Manufactorer);
 }
Пример #17
0
        public string GetItemSummary(IArticle article)
        {
            string summary = HttpUtility.HtmlDecode(article.Summary);

            summary = SearchSummaryUtil.GetTruncatedSearchSummary(article.Summary);
            return(HttpUtility.HtmlDecode(summary));
        }
Пример #18
0
        private ProcessedArticle GetProcessedArticle(string url)
        {
            IArticle         unprocessedArticle = _articleProvider.Get(url);
            ProcessedArticle result             = _articleProcessor.Process(unprocessedArticle);

            return(result);
        }
Пример #19
0
        public string GetLegacyPublicationText(IArticle article)
        {
            var legacyText             = TextTranslator.Translate("Article.LegacyPublications");
            var legacyPublicationsText = GetLegacyPublicationNames(article).JoinWithFinal(", ", "&");

            return(legacyText.Replace("{Legacy Publications}", legacyPublicationsText));
        }
Пример #20
0
        protected string BuildPreviewUrl(IArticle article)
        {
            string previewUrl = HttpContext.Current.Request.Url.Scheme + "://" + WebUtil.GetHostName() + "/?sc_itemid={" + article._Id + "}&sc_mode=preview&sc_lang=en";
            string fullLink   = $"/VWB/Util/LoginRedirectToPreview.aspx?redirect={HttpUtility.UrlEncode(previewUrl)}";

            return(fullLink);
        }
Пример #21
0
        public IArticle RefreshOrCreateEbayArticle(IArticle article, EbayArticleCSVWriter cswWriter, double amount, string template)
        {
            IArticle newArticle = null;

            currentAmount = amount;

            var availabilityMap = GetAvailabilityMap(article);

            foreach (var availabilityPair in availabilityMap)
            {
                if (article.EbayIds.ContainsKey(availabilityPair.Key))
                {
                    newArticle = ReviseEbayArticle(article, availabilityPair);
                    continue;
                }
                if (availabilityPair.Value == 0)
                {
                    continue;
                }
                newArticle = LoadUpNewSingleArticle(article, template, availabilityPair);
            }

            cswWriter.WriteToCSVFile(newArticle);
            return(newArticle);
        }
Пример #22
0
 public ArticleCategoryController(IPermissionProvider permissionProvider,
                                  IAdminUser adminUserRepository, IArticleCategory articleCategoryService, IArticle articleService)
     : base(permissionProvider, adminUserRepository)
 {
     _articleCategoryService = articleCategoryService;
     _articleService         = articleService;
 }
Пример #23
0
 public static DateTime GetDate(this IArticle article)
 {
     return(Sitecore.Context.PageMode.IsPreview &&
            !article.Planned_Publish_Date.Equals(DateTime.MinValue)
                         ? article.Planned_Publish_Date
                         : article.Actual_Publish_Date);
 }
Пример #24
0
 private void DeleteArticle(IArticle articleToDelete, int index)
 {
     if (articleToDelete.EbayIds.ContainsKey(index))
     {
         facade.DeleteEbayItem(articleToDelete.EbayIds[index]);
     }
 }
Пример #25
0
 // Класс отвечает за создание статьи, передаем строителю заголовок и текст статьи через интерфейс IBuilder
 public static void layoutArticle(IBuilder builder, string Title, string Text)
 {
     builder.reset();
     builder.setTitle(Title);
     builder.setText(Text);
     article = builder.GetArticle();
 }
Пример #26
0
        /// <summary>
        /// Clears all articles from the stock model.
        /// </summary>
        public void Clear()
        {
            _articleMap.Clear();
            _selectedArticle = null;

            UpdateModel();
        }
Пример #27
0
        protected string GetArticlePriceFormat(IArticle articleToWrite)
        {
            double calculatedPrice = articleToWrite.Price + priceMarge;

            return(calculatedPrice.ToString("N"));
            //return String.Format("{0:0.00}", calculatedPrice);
        }
Пример #28
0
        public PreviewWindow(IArticle article)
        {
            InitializeComponent();

            Article = article;
            Loaded += PreviewWindow_Loaded;
        }
Пример #29
0
 private static IArticle CheckIfIdIsNotEmptyAndSetId(string ebayId, int ebayKey, IArticle article)
 {
     if (!string.IsNullOrEmpty(ebayId))
     {
         article.EbayIds[ebayKey] = ebayId;
     }
     return article;
 }
Пример #30
0
        //todo migrate to razor
        private void AddInterfaceLinks(IArticle parsedArticle, string id, string token)
        {
            var interfaceLinksHtml = string.Join("", $"<br><a href=\"https://{_serviceDomain}/api/report?url={parsedArticle.Url}\">Report</a><br>",
                                                 $"<a href=\"https://{_serviceDomain}/api/archive?articleId={id}&token={token}\">Archive</a><br>",
                                                 $"<a href=\"https://{_serviceDomain}/api/star?articleId={id}&token={token}\">Star</a><br>");

            parsedArticle.Content = $"<html><body><h1>{parsedArticle.Title}</h1><h3>{parsedArticle.DatePublished}</h3>{parsedArticle.Content}{interfaceLinksHtml}</body></html>";
        }
Пример #31
0
 private static string GetEbayIdForArticle(IArticle articleToWrite, int key)
 {
     if (articleToWrite.EbayIds.ContainsKey(key))
     {
         return articleToWrite.EbayIds[key];
     }
     return "";
 }
Пример #32
0
        public ArticleContext(IArticle article)
            : base()
        {
            Article = article;

            (Article as IObservableArticle).Changed += ArticleContext_Changed;
            (Article as IObservableArticle).Moved   += ArticleContext_Moved  ;
        }
 private static string ExternalMediaList(IArticle article)
 {
     if (!article.Metadata.ExternalMedia.Any())
         return string.Empty;
     return string.Format("<ul>{0}</ul>",
         string.Join("", article.Metadata.ExternalMedia.Select(l => string.Format(@"<li>{0}</li>", ExternalMediaHtml(l, article))))
         );
 }
Пример #34
0
        public async Task AddWordsFromArticle(IArticle article)
        {
            var words = converter.GetWords(article);

            wordRepository.Create(words.Cast<Word>());

            await wordRepository.SaveAsync();
        }
Пример #35
0
 internal ArticleModel(IArticle article)
 {
     this.Id          = article.Id;
     this.Title       = article.Title;
     this.Body        = article.Body;
     this.PublishDate = article.PublishDate;
     this.ExpireDate  = article.ExpireDate;
 }
Пример #36
0
        public bool Equals(IArticle other)
        {
            var local = other as LocalArticle;

            return local      != null
                && local.Path != null
                && local.Path == Path;
        }
Пример #37
0
        public void CleanTestDefaultCleaner()
        {
            var cleaner = new HtmlCleaner(Enumerable.Empty <ISiteHtmlCleaner>());

            IArticle cleaned = cleaner.Clean("url", @"<body>Some text</body>");

            Assert.AreEqual("Some text", cleaned.Text);
        }
Пример #38
0
 public static ArticleContext Build(IArticle article)
 {
     if (article == null)
     {
         return(null);
     }
     return(new ArticleContext(article));
 }
Пример #39
0
 public AdminController(ICategory Category, IProfile Profile, IArticle Article, ITag Tag, INews News)
 {
     _Category = Category;
     _Profile  = Profile;
     _Article  = Article;
     _Tag      = Tag;
     _News     = News;
 }
Пример #40
0
        public void AddTo(IEnumerable<Component> fragments, Control container, IArticle article)
        {
            if (fragments == null) throw new ArgumentNullException("fragments");
            if (container == null) throw new ArgumentNullException("container");
            if (article == null) throw new ArgumentNullException("article");

            AddTo(fragments, container, article, new Dictionary<string, object>());
        }
        public void ApplyDiscount(IDiscount discount, ref IArticle article)
        {
            ValidateInput(discount, article);
            string userInput       = GetUserInput();
            var    discountHandler = new DiscountHandler(r => userInput == "Yes", ExecuteDiscount);

            discountHandler.Discount(discount, article);
        }
Пример #42
0
        public async Task AddExpressionsFromArticle(IArticle article)
        {
            var expressions = statManager.GetExpressions(article);
            
            repository.Create(expressions.Cast<Stat>());

            await repository.SaveAsync();
        }
 public IPropertyExtractor GetPropertyExtractor(IArticle article)
 {
     IWheel wheel = article as IWheel;
     if (wheel != null)
     {
         return GetPropertyExtractor(wheel);
     }
     return new PrestoshopPropertyExtractor(article, marge);
 }
Пример #44
0
 public static string GetKeyFromArticle(IArticle article)
 {
     return article.Description + article.Description2;
     //key = key.Replace(",", "");
     //key = key.Replace(" ", "");
     //key = key.Replace("/", "");
     //key = key.Replace("\\", "");
     //return key;
 }
Пример #45
0
 public void AddArticle(IArticle article)
 {
     if (article != null)
     {
         if (this.Articles.All(a => a.Make != article.Make || a.Model != article.Model))// TODO: Check 
         {
             this.Articles.Add(article);
         }
     }
 }
Пример #46
0
 public void WriteToCSVFile(IArticle articleToWrite)
 {
     if (articleToWrite == null)
     {
         logger.Warn("Article in Write To CSV was null");
         return;
     }
     string csvTextLine = GetTextLineFromArticle(articleToWrite);
     WriteTextToFile(csvTextLine, true);
 }
Пример #47
0
        public void AddArticle(IArticle article)
        {
            if (article == null)
            {
                throw new ArgumentNullException("Parameter cannot be null.");
            }

            this.ArticlesByBarcode.Add(article.Barcode, article);
            this.ArticlesByPrice.Add(article.Price, article);
        }
Пример #48
0
 public override string GetTextLineFromArticle(IArticle articleToWrite)
 {
     return string.Format(CSVConstants.GambioFormatLine,
                          articleToWrite.Id, articleToWrite.ArticleId, articleToWrite.Availability,
                          GetArticlePriceFormat(articleToWrite), articleToWrite.Manufactorer, DateTime.Now,
                          GetImageLink(articleToWrite), "", "",
                          "", "", "product-" + articleToWrite.Id,
                          GetNameFromArticle(articleToWrite), GetDescriptionFromArticle(articleToWrite), articleToWrite.Description,
                          articleToWrite.Description2, GetCategoryFromArticle(articleToWrite), articleToWrite.Description,
                          GetCategoryFromArticle(articleToWrite));
 }
Пример #49
0
 public bool AreBothArticleEqual(IArticle originalArticle, IArticle newArticle)
 {
     foreach (var compareCriteria in criterias)
     {
         if (!compareCriteria.IsCriteriaSatisfied(originalArticle, newArticle))
         {
             return false;
         }
     }
     return true;
 }
Пример #50
0
 private void SetFacebookHeaders(IArticle article)
 {
     var tagsService = ServiceLocator.Instance.Locate<IOpenGraphTagsService>();
     tagsService.AddOpenTags(this, new OpenGraphTags
     {
         Type = "article",
         Section = "Articles",
         Url = library.NiceUrl(article.Id),
         Title = article.Title,
         Description = Regex.Replace(article.Text.Substring(0, Math.Min(150, article.Text.Length)), @"<[^>]+>|&nbsp;", "").Trim(),
     });
 }
Пример #51
0
 private void SetButtonText(HtmlAnchor link, IArticle article)
 {
     if (article == null)
     {
         link.Visible = false;
     }
     else
     {
         link.InnerText = article.Title;
         link.HRef = library.NiceUrl(article.Id);
     }
 }
Пример #52
0
        internal DerDieDasData(string dataToParse, IArticleFactory articleFactory)
        {
            ParamValidator.EnsureParametersAreValid(new NullValidatorWithValue<IArticleFactory>(() => articleFactory, articleFactory));
            ParamValidator.EnsureParametersAreValid(new StringValidatorWithValue(() => dataToParse, dataToParse));

            var dataParsed = dataToParse.Split(new[]{','}, StringSplitOptions.RemoveEmptyEntries);
            if (dataParsed.Length != 3)
                throw new InvalidDataException(string.Format("Invalid data to parse: {0}", dataToParse));

            _article = articleFactory.CreateArticle(dataParsed[0]);
            _verb = dataParsed[1].Trim();
            _verbPlural = dataParsed[2].Trim();
        }
Пример #53
0
        private string FormatDescription(IArticle article)
        {
            string text = Regex.Replace(article.Text + "...", "<.*?>", string.Empty);

            if (text.Length > TextSnippetLength)
            {
                int spaceIndex = text.Substring(TextSnippetLength, text.Length - TextSnippetLength).IndexOfAny(new[] { ' ', '\t', '\r', '\n' }) + TextSnippetLength;

                text = text.Substring(0, spaceIndex) + "...";
            }

            return text;
        }
Пример #54
0
 public override string GetTextLineFromArticle(IArticle articleToWrite)
 {
     return String.Format(CSVConstants.PrestoFormatLine,
         articleToWrite.ArticleId,
         GetNameFromArticle(articleToWrite),
         GetCategoryFromArticle(articleToWrite),
         GetArticlePriceFormat(articleToWrite),
         20,
         articleToWrite.Manufactorer,
         articleToWrite.Availability,
         GetShortDescription(articleToWrite),
         GetDescriptionFromArticle(articleToWrite),
         GetTagsFromArticle(articleToWrite),
         GetImageUrls(articleToWrite)
         );
 }
Пример #55
0
 protected string GetCategoryFromArticle(IArticle articleToWrite)
 {
     IWheel wheel = (IWheel)articleToWrite;
     if (wheel == null)
     {
         return "Sonstiges";
     }
     if (wheel.IsWinter)
     {
         return "Winterreifen";
     }
     if (wheel.IsMudSnow)
     {
         return "Ganzjahresreifen";
     }
     return "Sommerreifen";
 }
 private static string ExternalMediaHtml(IExternalMedia l, IArticle article)
 {
     var description = l.Description;
     if (string.IsNullOrEmpty(l.Description))
     {
         if (l.Type == ExternalMediaType.YouTube)
             description = "video";
         if (l.Type == ExternalMediaType.Vimeo)
             description = "video";
         if (l.Type == ExternalMediaType.Soundcloud)
             description = "audio";
     }
     var url = l.Type == ExternalMediaType.Vimeo
         ? article.Metadata.Url //rechtstreeks naar Vimeo linken werkt niet: link naar artikel
         : l.Url;
     return string.Format(@"<a href=""{0}"">{1}</a>", url, description.EscapeHtml());
 }
Пример #57
0
 public Wheel(IArticle article)
 {
     Id = article.Id;
     ArticleId = article.ArticleId;
     Description = article.Description;
     Description2 = article.Description2;
     Price = article.Price;
     Price4 = article.Price4;
     AvgPrice = article.AvgPrice;
     AnonymPrice = article.AnonymPrice;
     RvoPrice = article.RvoPrice;
     Availability = article.Availability;
     ImageLink = article.ImageLink;
     InfoLink = article.InfoLink;
     Manufactorer = article.Manufactorer;
     ManufactorerNumber = article.ManufactorerNumber;
     DirectLink = article.DirectLink;
     TyreLabelLink = article.TyreLabelLink;
 }
Пример #58
0
        protected virtual void AddTo(IEnumerable<Component> fragments, Control container, IArticle article, IDictionary<string, object> state)
        {
            var list = fragments.ToList();
            for (int i = 0; i < list.Count; i++)
            {
                var f = list[i];
                var ctx = new ViewContext { Renderer = this, Article = article, Fragment = f, State = state };
                if (i > 0)
                    ctx.Previous = list[i - 1];
                if (i < list.Count - 1)
                    ctx.Next = list[i + 1];

                if (Renderers.ContainsKey(f.Command))
                {
                    Control c = Renderers[f.Command].AddTo(container, ctx);
                }
                else if (FallbackRenderer != null)
                {
                    FallbackRenderer.AddTo(container, ctx);
                }
            }
        }
Пример #59
0
        public IEnumerable<IStat> GetExpressions(IArticle article)
        {
            var statDict = new Dictionary<KeyValuePair<string, string>, int>();
            var words = converter.GetWords(article.Text);

            var pairs = words.GetPairs(
                converter.GetPrefix,
                converter.GetSuffix,
                (word, prefix, suffix) =>
                    new KeyValuePair<string, string>(prefix, suffix)
            );

            foreach (var pair in pairs)
            {
                int count;

                if (statDict.TryGetValue(pair, out count))
                {
                    statDict[pair]++;
                }
                else
                {
                    statDict[pair] = 1;
                }
            }

            var result = statDict.Keys.Select((key, value) =>
                new Stat
                {
                    ArticleID = article.ID,
                    Prefix = key.Key,
                    Suffix = key.Value,
                    Count = value,
                });

            return result;
        }
Пример #60
0
        public IArticle RefreshOrCreateEbayArticle(IArticle article, EbayArticleCSVWriter cswWriter, double amount, string template)
        {
            IArticle newArticle = null;
            currentAmount = amount;

            var availabilityMap = GetAvailabilityMap(article);

            foreach (var availabilityPair in availabilityMap)
            {
                if (article.EbayIds.ContainsKey(availabilityPair.Key))
                {
                    newArticle = ReviseEbayArticle(article, availabilityPair);
                    continue;
                }
                if (availabilityPair.Value == 0)
                {
                    continue;
                }
                newArticle = LoadUpNewSingleArticle(article, template, availabilityPair);
            }

            cswWriter.WriteToCSVFile(newArticle);
            return newArticle;
        }