示例#1
0
        private static ComicStrip GetComicStripFromContainer(HtmlDocument document)
        {
            HtmlNode container = document.First("article");

            if (container != null)
            {
                ComicStrip comic = new ComicStrip(ComicName.CommitStrip)
                {
                    Title    = container.FirstWithClass("entry-title")?.InnerText?.Trim(),
                    PageUrl  = container.FirstWithClass("entry-meta").FirstHref(),
                    ImageUrl = container.First("img").GetAttr("src"),
                    Author   = "CommitStrip.com",
                    Date     = container.FirstWithClass("entry-date")?.InnerText,
                };
                comic.ComicId = comic.PageUrl;

                if (string.IsNullOrEmpty(comic.ImageUrl))
                {
                    throw new InvalidOperationException("Comic container does not contain image URL.");
                }

                return(comic);
            }
            else
            {
                throw new InvalidOperationException("Comic container not found");
            }
        }
示例#2
0
        protected virtual void RenderTagsSection(ComicStrip comic, MessageCard card)
        {
            if (comic.Tags.Any())
            {
                card.Blocks.Add(new Block()
                {
                    Type = Types.Divider
                });
                card.Blocks.Add(new Block()
                {
                    Type     = Types.Context,
                    Elements = new List <Text>()
                    {
                        new Text()
                        {
                            Type     = Types.Markdown,
                            TextText = RenderTags(),
                        },
                    }
                });
            }
            string RenderTags()
            {
                List <string> tags = new List <string>();

                foreach (Tag tag in comic.Tags)
                {
                    tags.Add($"{BuildLink($"#{tag.Text}", tag.Url)}");
                }
                return(string.Join(", ", tags));
            }
        }
 /// <summary>
 /// Add a new ComicStrip
 /// </summary>
 public ComicStrip Add(ComicStrip s)
 {
     try
     {
         // Add Serie if not exists
         if (!uow.Comicstrips.ExistSerie(s.Serie))
         {
             s.SetSerie(uow.Comicstrips.AddSerie(s.Serie));
         }
         // Fetch existing serie if id is not set
         else if (s.Serie.ID < 0)
         {
             s.SetSerie(uow.Comicstrips.GetSerieByName(s.Serie.Name));
         }
     }
     catch (Exception) { throw new AddException("comicstrip serie"); }
     // Check if comicstrip exists
     if (uow.Comicstrips.Exist(s))
     {
         throw new ExistException("comicstrip");
     }
     try
     {
         // Add comicstrip and return object with generated id
         return(uow.Comicstrips.Add(s));
     }
     catch (Exception) { throw new AddException("comicstrip"); }
 }
示例#4
0
    private IEnumerator Start()
    {
        for (int i = 0; i < this.m_comicStrips.Count; i++)
        {
            ComicStrip comicStrip = this.m_comicStrips[i];
            float      x          = comicStrip.m_strip.GetComponent <UnmanagedSprite>().Size.x;
            this.m_startPos     = -10f * (float)Screen.width / (float)Screen.height + 0.5f * x + 4f * (float)Screen.width / (float)Screen.height;
            this.m_startPos_3_2 = -15f + 0.5f * x + 6f;
            comicStrip.m_strip.transform.position = new Vector3(this.m_startPos, 0f, (float)i);
            float num = 0f;
            this.m_comicStrips[i].m_strip.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 1f, 1f, num));
            this.FadeChildren(num, this.m_comicStrips[i], false);
        }
        this.m_continueButton.SetActive(GameProgress.GetInt(Singleton <GameManager> .Instance.CurrentSceneName + "_played", 0, GameProgress.Location.Local, null) == 1);
        if (ScreenPlacement.IsAspectRatioNarrowerThan(4f, 3f))
        {
            this.m_continueButton.transform.Translate(-2.5f, 0f, 0f);
        }
        base.StartCoroutine(this.UpdateStrips());
        yield return(null);

        if (this.m_soundTrack && this.m_currentStrip == 0)
        {
            Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.m_soundTrack);
        }
        for (int j = 0; j < this.m_currentStrip; j++)
        {
            this.m_time += this.GetComicPageTime(j);
        }
        yield break;
    }
示例#5
0
        private static ComicStrip GetComicStripFromContainer(HtmlDocument document)
        {
            HtmlNode container = document.FirstWithClass("comic-item-container");

            if (container != null)
            {
                ComicStrip comic = new ComicStrip(ComicName.Dilbert)
                {
                    ImageUrl = container.GetAttr("data-image"),
                    Title    = container.GetAttr("data-title"),
                    PageUrl  = container.GetAttr("data-url"),
                    ComicId  = container.GetAttr("data-id"),
                    Author   = container.GetAttr("data-creator"),
                    Date     = container.GetAttr("data-date")
                };

                SetTags(comic, container);

                if (string.IsNullOrEmpty(comic.ImageUrl))
                {
                    throw new InvalidOperationException("Comic container does not contain image URL.");
                }

                return(comic);
            }
            else
            {
                throw new InvalidOperationException("Comic container not found");
            }
        }
示例#6
0
        protected virtual void RenderHeader(ComicStrip comic, MessageCard card)
        {
            string             extraButtonsMarkdown = "";
            List <ExtraButton> inlineButtons        = comic.ExtraButtons.Where(x => x.Location == ExtraButtonLocation.HeaderInline).ToList();

            if (inlineButtons.Any())
            {
                foreach (ExtraButton inlineButton in inlineButtons)
                {
                    extraButtonsMarkdown += $" *|* {BuildLink(inlineButton.Text, inlineButton.Url)}";
                }
            }

            extraButtonsMarkdown += RenderSenderInfo();

            card.Blocks.Add(new Block()
            {
                Type     = Types.Context,
                Elements = new List <Text>()
                {
                    new Text()
                    {
                        Type     = Types.Markdown,
                        TextText = $"{BuildLink($"See on {GetDomain(comic)} :arrow_upper_right:", comic.PageUrl)} *|* " + GetNavigationButtons(comic) + extraButtonsMarkdown
                    }
                }
            });
        }
示例#7
0
        private ComicStrip GetComicStripFromContainer(HtmlDocument document, string finalUrl)
        {
            HtmlNode container = document.FirstWithClass("post");
            var      img       = container?.FirstWithClass("content")?.First("img");

            if (img != null)
            {
                ComicStrip comic = new ComicStrip(ComicName.MonkeyUser)
                {
                    Title    = img.Attributes["title"]?.Value,
                    PageUrl  = UrlHelper.CombineUrls(this.baseUrl, finalUrl),
                    ImageUrl = img.Attributes["src"].Value,
                    Author   = "MonkeyUser.com",
                    Date     = container.First("time")?.InnerText,
                };
                comic.ComicId = comic.PageUrl;

                if (string.IsNullOrEmpty(comic.ImageUrl))
                {
                    throw new InvalidOperationException("Comic container does not contain image URL.");
                }

                return(comic);
            }
            else
            {
                throw new InvalidOperationException("Comic container not found");
            }
        }
示例#8
0
        public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log)
        {
            try
            {
                SubscriptionSettings settings = await this.GetSettings(req);

                IComicRetriever retriever = ComicRetrieverFactory.Get(settings.SubscriptionName);
                ComicStrip      comic     = await retriever.GetComic();

                ComicSendingController sendingController = new ComicSendingController(comic);
                ComicDeliveryResult    result            = await sendingController.Push(settings);

                if (result.IsSuccess)
                {
                    await subscriberRegister.AddSubscriber(settings);

                    return(new OkObjectResult("Subscribed"));
                }
                else
                {
                    return(new BadRequestErrorMessageResult("Error while sending test comic: " + result.Message));
                }
            }
            catch (Exception ex)
            {
                return(new BadRequestErrorMessageResult(ex.Message));
            }
        }
示例#9
0
        public async Task <IActionResult> OnPostComicAsync()
        {
            string response = await DS.GetAsync("user/IsEditorLoggedIn");

            EditorLoggedIn = Newtonsoft.Json.JsonConvert.DeserializeObject <bool>(response);

            if (EditorLoggedIn)
            {
                ComicStrip CS = new ComicStrip();
                CS.DefaultHeight = int.Parse(Request.Form["DefaultHeight"]);
                CS.DefaultWidth  = int.Parse(Request.Form["DefaultWidth"]);
                CS.Description   = Request.Form["Description"];
                CS.Name          = Request.Form["Name"];
                CS.Enabled       = (int.Parse(Request.Form["enabledStatus"]) != 0);
                CS.ImageURL      = Request.Form["imgURLtextbox"];

                HttpResponseMessage message = await DS.PostAsync(CS, "comic/AddComic");

                if (message.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    ResponseMessage = "There was a problem uploading the comic.";
                }
                else
                {
                    string newEpID = await DS.GetAsync("comic/GetLatestComicID");

                    SavedStripID = Newtonsoft.Json.JsonConvert.DeserializeObject <int>(newEpID);
                }
            }

            return(Page());
        }
示例#10
0
 protected virtual void RenderImageSection(ComicStrip comic, MessageCard card)
 {
     card.Sections.Add(new Section()
     {
         Markdown = true,
         Text     = $"![{comic.Title} (if comic is not visible, perhaps it's too 'large/heavy' for Teams, sorry)]({comic.ImageUrl})",
     });
 }
示例#11
0
        public static Strip FromDomain(ComicStrip comicStrip)
        {
            List <Auteurs> Authors = comicStrip.Authors.Select(x => Export_import.DTO.Auteurs.FromDomain(x)).ToList();

            return(new Strip {
                ID = comicStrip.ID, Titel = comicStrip.Titel, Nr = comicStrip.Number, Reeks = Reeks.FromDomain(comicStrip.Serie), Auteurs = Authors, Uitgeverij = Uitgeverij.FromDomain(comicStrip.Publisher)
            });
        }
示例#12
0
 private void AddBookUrl(ComicStrip comic)
 {
     comic.ExtraButtons.Add(new ExtraButton()
     {
         Location = ExtraButtonLocation.HeaderInline,
         Text     = "BUY OUR BOOK",
         Url      = "https://www.kickstarter.com/projects/commitstrip/commitstrip-the-summer-of-code-a-book-about-love?ref=card"
     });
 }
示例#13
0
 private void SetBuyButton(ComicStrip comic)
 {
     comic.ExtraButtons.Add(new ExtraButton()
     {
         Location = ExtraButtonLocation.HeaderInline,
         Text     = "BUY PLUSHIES",
         Url      = "https://store.monkeyuser.com/"
     });
 }
示例#14
0
        private void SetNextAndPreviousUrls(HtmlDocument document, ComicStrip comic)
        {
            string nextUrl = document.FirstWithClass("next")?.FirstHref();

            comic.NextUrl = UrlHelper.CombineUrls(baseUrl, nextUrl);
            string prevUrl = document.FirstWithClass("prev")?.FirstHref();

            comic.PreviousUrl = UrlHelper.CombineUrls(baseUrl, prevUrl);
        }
示例#15
0
        protected virtual string GetNavigationButtons(ComicStrip comic)
        {
            if (!string.IsNullOrEmpty(comic.PreviousUrl))
            {
                return($"{BuildLink(":arrow_left:", comic.PreviousUrl)} {BuildLink(":arrow_right:", comic.NextUrl)}");
            }

            return("");
        }
示例#16
0
        private void SetNextAndPreviousUrls(HtmlDocument document, ComicStrip comic)
        {
            HtmlNode nextUrl = document.FirstWithClass("js-load-comic-newer");

            comic.NextUrl = UrlHelper.CombineUrls(this.baseUrl, nextUrl.GetHref());

            HtmlNode prevUrl = document.FirstWithClass("js-load-comic-older");

            comic.PreviousUrl = UrlHelper.CombineUrls(this.baseUrl, prevUrl.GetHref());
        }
示例#17
0
        private void AddBuyButton(ComicStrip comic)
        {
            var buyButton = new ExtraButton()
            {
                Text     = "BUY",
                Url      = $"https://" + $"dilbert.com/buy?date={comic.ComicId}",
                Location = ExtraButtonLocation.HeaderInline
            };

            comic.ExtraButtons.Add(buyButton);
        }
示例#18
0
        public async Task Run([TimerTrigger("0 0 7 * * 1-5")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"{this.GetType().Name} - Starting function execution");

            ComicStrip comic = await this.retriever.GetComic();

            IEnumerable <SubscriptionSettings> subscriptions = await subscriberProvider.GetSubscribers(subscriptionName);

            ComicSendingController sendingController = new ComicSendingController(comic);
            await sendingController.Push(subscriptions);
        }
示例#19
0
        public async Task Run([TimerTrigger("0 0 12 * * 1-5")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            ComicStrip comic = await this.retriever.GetComic();

            IEnumerable <SubscriptionSettings> subscriptions = await subscriberProvider.GetSubscribers(subscriptionName);

            ComicSendingController sendingController = new ComicSendingController(comic);
            await sendingController.Push(subscriptions);
        }
示例#20
0
 protected virtual string GetDomain(ComicStrip comic)
 {
     try
     {
         Uri uri = new Uri(comic.PageUrl);
         return($"{uri.Host}");
     }
     catch (Exception)
     {
         return("original page");
     }
 }
示例#21
0
 private static void RenderTitle(ComicStrip comic, MessageCard card)
 {
     card.Blocks.Add(new Block()
     {
         Type = Types.Header,
         Text = new Text()
         {
             TextText = $"{comic.Title}",
             Type     = Types.PlainText
         }
     });
 }
示例#22
0
        public virtual MessageCard GetMessageCard(ComicStrip comic)
        {
            MessageCard card = new MessageCard(comic.Title);

            RenderHeader(comic, card);

            RenderImageSection(comic, card);

            RenderTagsSection(comic, card);

            return(card);
        }
 /// <summary>
 /// Update existing ComicStrips
 /// </summary>
 public void Update(ComicStrip s)
 {
     if (!uow.Comicstrips.Exist(s, /* Ignore Id Search */ true))
     {
         throw new ExistException("comicstrip");
     }
     try
     {
         uow.Comicstrips.Update(s);
     }
     catch (Exception) { throw new UpdateException("comicstrip"); }
 }
示例#24
0
 private void FadeChildren(float alpha, ComicStrip currentStrip, bool activateChild)
 {
     for (int i = 0; i < currentStrip.m_strip.transform.childCount; i++)
     {
         Transform transform = currentStrip.m_strip.transform.GetChild(i);
         if (activateChild)
         {
             transform.gameObject.SetActive(true);
         }
         transform.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 1f, 1f, alpha));
     }
 }
示例#25
0
        private void AddRow(ComicStrip comicstrip)
        {
            DataRow row = this.Table.NewRow();

            row[0] = comicstrip.ID;
            row[1] = comicstrip.Titel;
            row[2] = (comicstrip.Serie == null) ? "" :  comicstrip.Serie.Name;
            row[3] = comicstrip.Number;
            row[4] = comicstrip.Publisher.Name;
            row[5] = string.Join(",", comicstrip.Authors.Select(x => x));

            this.Table.Rows.Add(row);
        }
示例#26
0
        public ComicStrip Parse(string pageHtml)
        {
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(pageHtml);

            ComicStrip comic = GetComicStripFromContainer(document);

            this.SetNextAndPreviousUrls(document, comic);

            this.AddBookUrl(comic);

            return(comic);
        }
示例#27
0
 protected virtual void RenderImageSection(ComicStrip comic, MessageCard card)
 {
     card.Blocks.Add(new Block()
     {
         Type  = Types.Image,
         Title = new Title()
         {
             Type = Types.PlainText,
             Text = comic.Date
         },
         ImageUrl = new Uri(comic.ImageUrl),
         AltText  = comic.Title
     });
 }
示例#28
0
 /// <summary>
 /// Check if ComicStrip exist
 /// </summary>
 public bool Exist(ComicStrip s, bool ignoreId = false)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM [dbo].[Comicstrips] WHERE LOWER(Title) = @Title AND Serie_Id = @Serie OR Id = @Id", this.context);
         cmd.Parameters.AddWithValue("@Title", s.Titel.ToLower());
         cmd.Parameters.AddWithValue("@Serie", s.Serie.ID);
         cmd.Parameters.AddWithValue("@Id", (!ignoreId) ? s.ID : -1);
         context.Open();
         int count = (int)cmd.ExecuteScalar();
         context.Close();
         return(count > 0);
     }
     catch (Exception) { throw new QueryException(); }
 }
示例#29
0
        public ComicStrip Parse(string pageHtml, string finalUrl)
        {
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(pageHtml);

            ComicStrip comic = this.GetComicStripFromContainer(document, finalUrl);

            this.SetNextAndPreviousUrls(document, comic);

            this.SetTags(document, comic);

            this.SetBuyButton(comic);

            return(comic);
        }
示例#30
0
 /// <summary>
 /// Update existing ComicStrip
 /// </summary>
 public void Update(ComicStrip s)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("UPDATE [dbo].[Comicstrips] SET Title = @Title, Serie_Id = @Serie, Number = @Number, Publisher_Id = @Publisher  WHERE Id = @Id", this.context);
         cmd.Parameters.AddWithValue("@Titlel", s.Titel);
         cmd.Parameters.AddWithValue("@Serie", s.Serie.ID);
         cmd.Parameters.AddWithValue("@Number", s.Number);
         cmd.Parameters.AddWithValue("@Publisher", s.Publisher.ID);
         cmd.Parameters.AddWithValue("@Id", s.ID);
         context.Open();
         cmd.ExecuteNonQuery();
         context.Close();
     }
     catch (Exception) { throw new QueryException(); }
 }