示例#1
0
        public ActionResult RedirectToINow()
        {
            if (!Context.DistrictId.HasValue)
            {
                throw new Exception("District id should be defined for redirect to SIS");
            }
            var schoolYearId = GetCurrentSchoolYearId();
            var url          = UrlTools.UrlCombine(Context.SisRedirectUrl, $"TokenLogin.aspx?Token={Context.SisToken}&AcadSessionId={schoolYearId}");

            return(Redirect(url));
        }
示例#2
0
        public StartSessionResponse StartViewSession(StartViewSessionRequestModel model)
        {
            var wc        = new WebClient();
            var nameValue = new NameValueCollection
            {
                { TOKEN, GetToken() },
                { UUID, model.Uuid },
                { EDITABLE, model.CanAnnotate.ToString().ToLower() },
                { USER, string.Format("{0},{1}", model.PersonId, model.PersonName) },
                { ADMIN, model.IsOwner.ToString().ToLower() }
            };
            var str = Encoding.ASCII.GetString(wc.UploadValues(UrlTools.UrlCombine(GetCrocodocApiUrl(), SESSION_CREATE), nameValue));

            return(Deserialize <StartSessionResponse>(str));
        }
示例#3
0
    void OutputUrl(string url)
    {
        var result = WebToIrc.WebInfo(url);

        if (result.Success)
        {
            if (result.PrintTitle)
            {
                irc.SendMessage(Channel, UrlTools.Filter(result.Title));
            }

            log.Message(result.Messages);
            log.Message("{0} -- {1}", result.Requested, result.Title);
        }
        else
        {
            log.Message(ReportError(result));
        }
    }
示例#4
0
    void ProcessMessage(MessageItem item)
    {
        string[] urls = UrlTools.Extract(item.Message);
        if (urls.Length > 0)
        {
            log.Verbose("{0}/{1} {2}", Channel, item.Nick, item.Message);

            if (!DisabledNicks.Contains(item.Nick))
            {
                foreach (string url in urls)
                {
                    ProcessUrl(item.Nick, url);
                }
            }
            else
            {
                log.Message("Titling disabled for {0}.", item.Nick);
            }
        }
    }
示例#5
0
 private void Hyperlink_Click(object sender, RoutedEventArgs e)
 {
     UrlTools.Hyperlink_Click(sender, e);
 }
示例#6
0
        public static string BuildIconUrl(Application application, bool large)
        {
            var url = UrlTools.UrlCombine(application.Url, large ? ICON_47_FILE : ICON_17_FILE);

            return(url);
        }
        private async void BtnGo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string url = txtUrl.Text;
                Uri    uri = new Uri(url);

                // download the html
                string originalHtml = await GetHtml(uri);

                // create the document
                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(originalHtml);

                // filter out parts of little interest
                HtmlFilter filter = new HtmlFilter();
                filter.CleanHtml(doc.DocumentNode);

                // convert html into lines of text (and images)
                HtmlConverter converter = new HtmlConverter();
                var           lines     = converter.GetLines(doc.DocumentNode, new ConvertOptions());

                StringBuilder htmlContent = new StringBuilder();

                // create html from lines
                foreach (var textLine in lines)
                {
                    // is an image line so add image here
                    if (textLine is HtmlImageLine imageLine)
                    {
                        string src = UrlTools.MakeAbsoluteUrl(uri.Host, imageLine.Src);
                        string alt = SystemPlus.Net.HtmlTools.HtmlEncode(imageLine.Text);

                        if (!string.IsNullOrWhiteSpace(src))
                        {
                            string img = $"<img src=\"{src}\" alt=\"{alt}\" width=\"150\" />";
                            htmlContent.AppendLine(img);
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(textLine.Text))
                    {
                        string text = textLine.Text.Trim();

                        text = SystemPlus.Net.HtmlTools.HtmlEncode(text);

                        text = text.Replace("\r\n", "<br/>");
                        text = SystemPlus.Net.HtmlTools.WrapContent(text, textLine.Node);

                        htmlContent.Append(text);
                    }

                    htmlContent.Append("<br style=\"clear:both; \" />");
                }

                webBrowser.NavigateToString(htmlContent.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }