Exemplo n.º 1
0
        private async void 2_Click (object sender, RoutedEventArgs e)
        {
            SelectFileCount.ClearValue(TextBlock.TextProperty);
            try
            {
                var    getCount = string.Format(@"document.querySelector('#attachbtn').childElementCount.toString();");
                string reNum    = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCount });

                int count = Convert.ToInt32(reNum);

                var sendComm = string.Format(@"document.querySelector('#attachbtn').querySelectorAll('.fldt')[{0}].click();", count - 1);
                await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { sendComm });

                await Task.Delay(1000);

                var    checkVaild = string.Format(@"document.querySelectorAll('.alert_error').length.toString();");
                string result     = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { checkVaild });

                if (result == "1")
                {
                    SelectFileCount.Text = "不支持上传此类附件!";
                    return;
                }

                SelectFileCount.Text = "您已选择了" + count + "个文件,点击上传按钮上传您的文件";
            }
            catch (Exception)
            {
                SelectFileCount.Text = "操作已取消";
            }
        }
Exemplo n.º 2
0
        private async void 开始2_Click(object sender, RoutedEventArgs e)
        {
            SelectFileCount.ClearValue(TextBlock.TextProperty);
            UploadFileCount.ClearValue(TextBlock.TextProperty);
            try
            {
                var    getCount = string.Format(@"document.querySelector('#attachbtn').childElementCount.toString();");
                string reNum    = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCount });

                if (reNum == "1")
                {
                    SelectFileCount.Text = "您还没有选择文件";
                    return;
                }

                var get = string.Format(@"document.getElementsByClassName('pn pnc vm')[1].click();");
                await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { get });

                a2();
            }
            catch (Exception)
            {
            }
        }