Пример #1
0
        public static void RunRawler(string xaml)
        {
            if (isBusy)
            {
                MessageBox.Show("実行中です");
                return;
            }
            string err    = string.Empty;
            var    rawler = Rawler.Tool.RawlerBase.Parse(xaml, out err);

            if (rawler != null)
            {
                try
                {
                    ReportManage.ResetRowCount();
                    //       rowCount = 0;
                    rawler.SetParent();
                    startDate = DateTime.Now;
                    foreach (var item in rawler.GetConectAllRawler())
                    {
                        item.BeginRunEvent += (o, arg) =>
                        {
                            tokenSource.Token.ThrowIfCancellationRequested();
                        };
                    }
                    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);
                }
            }
            else
            {
                Rawler.Tool.ReportManage.ErrReport(null, err);
            }
        }