static void Main(string[] args) { Rawler.Tool.ReportManage.ErrReportEvent += ReportManage_ErrReportEvent; Rawler.Tool.ReportManage.ReportEvnet += ReportManage_ReportEvnet; // args = new List<string>() { @"C:\Users\kiichi\Documents\TwitterData\hamano_satoshi\tweet.xaml" }.ToArray(); if (args.Length > 0) { try { Dictionary <string, string> dic = new Dictionary <string, string>(); foreach (var item in args.Skip(1)) { var d = item.Split('='); if (d.Length > 1) { dic[d[0]] = d[1]; Rawler.Tool.TempVar.SetVar(d[0], d[1]); } } RawlerBase rawler = (RawlerBase)System.Xaml.XamlServices.Load(args[0]); rawler.SetParent(); rawler.Run(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }
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); } }
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); } }
public RawlerAutoNextLink() : base() { autoNextLink = LoadXAML(); autoNextLink.SetParent(this); }