Esempio n. 1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (isBusy)
            {
                MessageBox.Show("実行中です");
                return;
            }
            tokenSource = new CancellationTokenSource();
            object obj = null;
            string xaml = textEditor.Text;
            var insertParameter = new Tool.InsertParameterWindow();
            if (insertParameter.Analyze(textEditor.Text) == true)
            {
                xaml = insertParameter.Xaml;
            }
            else
            {
                return;
            }

            try
            {
                obj = System.Xaml.XamlServices.Parse(xaml);
            }
            catch (Exception ex)
            {
                ReportManage.ErrReport(new RawlerBase(), "XAMLの形式がおかしいです" + ex.Message);

            }
            if (obj == null)
            {
                return;
            }
            if ((obj is Rawler.Tool.RawlerBase)==false)
            {
                ReportManage.ErrReport(new RawlerBase(), "キャストできませんでした。XAMLの形式がおかしいです");
            }
            try
            {
                rawler = (obj as Rawler.Tool.RawlerBase);
                ReportManage.RowCount = 0;
                rawler.SetParent();
                startDate = DateTime.Now;
                foreach (var item in rawler.GetConectAllRawler())
                {
                    item.BeginRunEvent += (o, arg) =>
                    {
                        tokenSource.Token.ThrowIfCancellationRequested();
                        while (pause)
                        {
                            System.Threading.Thread.Sleep(1000);
                        }
                    };
                }
                isBusy = true;
                Task.Factory.StartNew(() => rawler.Run(), tokenSource.Token).ContinueWith((t) => { StopWatch(); isBusy = false; });
            }
            catch (OperationCanceledException oce)
            {
                ReportManage.ErrReport(new RawlerBase(), "キャンセルされました");
                MessageBox.Show("キャンセルされました");
            }
            catch (Exception ex)
            {
                ReportManage.ErrReport(new RawlerBase(), ex.Message);
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (isBusy)
            {
                MessageBox.Show("実行中です");
                return;
            }
            tokenSource = new CancellationTokenSource();
            object obj             = null;
            string xaml            = textEditor.Text;
            var    insertParameter = new Tool.InsertParameterWindow();

            if (insertParameter.Analyze(textEditor.Text) == true)
            {
                xaml = insertParameter.Xaml;
            }
            else
            {
                return;
            }

            try
            {
                obj = System.Xaml.XamlServices.Parse(xaml);
            }
            catch (Exception ex)
            {
                ReportManage.ErrReport(new RawlerBase(), "XAMLの形式がおかしいです" + ex.Message);
            }
            if (obj == null)
            {
                return;
            }
            if ((obj is Rawler.Tool.RawlerBase) == false)
            {
                ReportManage.ErrReport(new RawlerBase(), "キャストできませんでした。XAMLの形式がおかしいです");
            }
            try
            {
                rawler = (obj as Rawler.Tool.RawlerBase);
                ReportManage.RowCount = 0;
                rawler.SetParent();
                startDate = DateTime.Now;
                foreach (var item in rawler.GetConectAllRawler())
                {
                    item.BeginRunEvent += (o, arg) =>
                    {
                        tokenSource.Token.ThrowIfCancellationRequested();
                        while (pause)
                        {
                            System.Threading.Thread.Sleep(1000);
                        }
                    };
                }
                isBusy = true;
                Task.Factory.StartNew(() => rawler.Run(), tokenSource.Token).ContinueWith((t) => { StopWatch(); isBusy = false; });
            }
            catch (OperationCanceledException oce)
            {
                ReportManage.ErrReport(new RawlerBase(), "キャンセルされました");
                MessageBox.Show("キャンセルされました");
            }
            catch (Exception ex)
            {
                ReportManage.ErrReport(new RawlerBase(), ex.Message);
            }
        }