Example #1
0
        private int NavigateToStringReturnContentAsNumber(string html)
        {
            if (UiSynchronizationContext == SynchronizationContext.Current)
            {
                return(0);
            }

            UiSynchronizationContext.Post(_ => RefreshWebBrowserContents(), null);
            Thread.Sleep(TimeSpan.FromMilliseconds(300));
            var initialContents = HtmlOutputContentDivInnerHtml ?? "..";

            UiSynchronizationContext.Send(_ => HtmlOutput.NavigateToString(html), null);
            Thread.Sleep(TimeSpan.FromMilliseconds(1000));
            string oldContents;
            var    newContents = "";

            do
            {
                UiSynchronizationContext.Post(_ => RefreshWebBrowserContents(), null);
                Thread.Sleep(TimeSpan.FromMilliseconds(300));

                oldContents = newContents;
                newContents = HtmlOutputContentDivInnerHtml ?? "..";
                if (newContents != initialContents)
                {
                    initialContents = "..";
                }
            } while (oldContents != newContents || newContents.Contains("..") || newContents == initialContents);

            int.TryParse(newContents, out var result);
            return(result);
        }
Example #2
0
        protected void Generate_Click(object sender, EventArgs e)
        {
            HtmlOutput output = new HtmlOutput();

            if (this.TidyHtmlCheck.Checked)
            {
                output.HtmlTidy = true;
            }

            output.Angular       = this.AngularJSDropdown.SelectedValue;
            output.Charset       = this.CharacterEncoding.Text;
            output.Dojo          = this.DojoDropdown.SelectedValue;
            output.ExtJS         = this.ExtJsDropdown.SelectedValue;
            output.Jquery        = this.JqueryDropdown.SelectedValue;
            output.JqueryMobile  = this.JqueryMobileDropdown.SelectedValue;
            output.JqueryUI      = this.JqueryUIDropdown.SelectedValue;
            output.MooTools      = this.MooToolsDropdown.SelectedValue;
            output.Protoptype    = this.PrototypeDropdown.SelectedValue;
            output.Scriptaculous = this.ScriptaculousDropdown.SelectedValue;
            output.SWFObject     = this.SWFObjectDropdown.SelectedValue;
            output.ThreeJS       = this.ThreeJsDropdown.SelectedValue;
            output.Title         = this.PageTitle.Text;
            output.WebFontLoader = this.WebFontLoaderDropdown.SelectedValue;

            this.BhtmlOutput.InnerText = output.Generate();
        }
        private async void BackbendWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            await NavigateToMessage($"Starting {Constants.BackbendAppId}…");

            var errorsAndInfos = new ErrorsAndInfos();
            var dvinApp        = await vContainer.Resolve <IDvinRepository>().LoadAsync(Constants.BackbendAppId, errorsAndInfos);

            if (errorsAndInfos.AnyErrors())
            {
                await NavigateToMessage(errorsAndInfos.ErrorsToString());

                return;
            }
            if (dvinApp == null)
            {
                await NavigateToMessage($"{Constants.BackbendAppId} app not found");

                return;
            }

            Wait.Until(() => dvinApp.IsPortListenedTo(), TimeSpan.FromSeconds(5));
            if (!dvinApp.IsPortListenedTo() && !await StartAppAndReturnSuccess(dvinApp))
            {
                return;
            }

            Cursor     = Cursors.Wait;
            Width      = 660;
            Height     = 660;
            vNavigated = false;
            HtmlOutput.Navigate("http://localhost:" + dvinApp.Port);
        }
        private async Task NavigateToMessage(string message)
        {
            vNavigated = false;
            var markup = "<html><head></head><body><p>" + message + "</p></body></html>";

            HtmlOutput.NavigateToString(markup);
            await Task.Run(() => Wait.Until(() => vNavigated, TimeSpan.FromSeconds(5)));
        }
Example #5
0
 /// <summary>
 /// 创建 Html 结果
 /// </summary>
 /// <param name="node"></param>
 public HtmlResult(params IHtmlNode[] node)
 {
     Writer = new HtmlOutput(node);
     Store  = Writer;
 }
Example #6
0
    /// <summary>
    /// Main.
    /// </summary>
    /// <param name="args">Command line arguments</param>
    public static void Main(string[] args)
    {
        GetOpt      opt = new GetOpt(args, "A:O:S:chn:o:r:s:v");
        Reservation res = null;
        bool        v = false, calculate = false;
        string      scOutputDir = null, scName = null, selectors = "cmn", styles = null;
        string      outputFormat = "html";
        char        c;

        while ((c = opt.Next()) != '-')
        {
            switch (c)
            {
            case 'A':
                if (sc.SetAlgorithm(opt.Argument, 0, false) == false)
                {
                    Usage(1);
                }
                break;

            case 'O':
                outputFormat = opt.Argument;
                break;

            case 'S':
                styles = opt.Argument;
                break;

            case 'c':
                calculate = true;
                break;

            case 'h':
                Usage(0);
                break;

            case 'n':
                scName = opt.Argument;
                break;

            case 'o':
                scOutputDir = opt.Argument;
                break;

            case 'r':
                res = new Reservation(opt.Argument);
                break;

            case 's':
                if ((selectors = sc.TrimSelectors(opt.Argument, 0)) == null)
                {
                    Usage(1);
                }
                sc.selectors = selectors;
                break;

            case 'v':
                v = true;
                break;

            case '?':
                Errors.Error(opt.Error);
                Usage(1);
                break;
            }
        }

        if ((args.Length - opt.Index) < 1)
        {
            Usage(1);
        }

        Verbose.verbose = v;

        try {
            sc.Init(args[opt.Index], res, scName, styles, calculate);
            sc.Load();
            sc.Run();

            string       o = outputFormat.ToLower();
            OutputFormat op;
            if (o == "html")
            {
                op = new HtmlOutput(sc, scOutputDir);
            }
            else if (o == "text")
            {
                op = new TextOutput(sc, scOutputDir);
            }
            else
            {
                throw new Exception("Unknown output format: '" + outputFormat + "'");
            }

            op.Output();
        } catch (Exception ex) {
            Console.Error.WriteLine(ex.ToString());
            System.Environment.Exit(1);
        }
    }
Example #7
0
        public static async void Parse(string sUrl)
        {
            ErrorHandling.Clear();

            List <Match> matches   = null;
            Team         team      = null;
            var          tiSuccess = false;
            var          miSuccess = false;

            try
            {
                team = await TeamModel.GetInstanceAsync(sUrl);

                tiSuccess = team.ParseInfo();

                if (!tiSuccess)
                {
                    ErrorHandling.Error("Could not parse the team information");
                }

                // Get all MatchURLs of our team for the divisions they played
                var matchUrls = new Dictionary <Season, List <string> >();
                foreach (var season in team.Seasons)
                {
                    if (season.Key.Number < 6)
                    {
                        // cannot parse matches reliably before season 6
                        continue;
                    }

                    var parsedMatchUrls = await MatchModel.ParseMatchLinksAsync(season, team.Shortname);

                    foreach (var url in parsedMatchUrls)
                    {
                        matchUrls.Add(url.Key, url.Value);
                    }
                }

                // Get Match infos
                matches = await MatchModel.ParseMatchesAsync(matchUrls);

                if (matches.Count == 0)
                {
                    ErrorHandling.Error("No valid matches found");
                    miSuccess = false;
                }

                miSuccess = true;
            }
            catch (Exception x)
            {
                ErrorHandling.Error(x.Message);
            }

            if (!tiSuccess || !miSuccess)
            {
                ErrorHandling.WriteToConsole();
            }
            else
            {
                // output
                var bOutput = HtmlOutput.CreateFile(team, matches, team.Name + ".html");
                if (bOutput)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Write("Successfully wrote ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(team.Name + ".html\n");
                    Console.ResetColor();
                }
                else
                {
                    ErrorHandling.Error("Could not write HTML File");
                    ErrorHandling.WriteToConsole();
                }
            }
        }