/// <summary> /// 読込ボタン /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "edmx files (*.edmx)|*.edmx|All files (*.*)|*.*"; dlg.FilterIndex = 0; if (dlg.ShowDialog() != DialogResult.OK) return; _filename = dlg.FileName; _doc = new EXDocument(); _doc.Load(_filename); _tables = new List<TableMapping>(); var els = _doc * "edmx:Mappings" * "EntitySetMapping"; foreach (var el in els) { TableMapping tm = new TableMapping(); _tables.Add(tm); tm.EntityName = el / "EntityTypeMapping" % "TypeName"; tm.EntityName = tm.EntityName.Substring(tm.EntityName.IndexOf('.') + 1); tm.EntitySetName = el % "Name"; tm.StoreName = el / "EntityTypeMapping" / "MappingFragment" % "StoreEntitySet"; } listBox1.DataSource = _tables; EXElement el2 = _doc * "EntitySet"; string name = el2 % "EntityType"; _modelName = name.Substring(0, name.IndexOf('.') ); }
/// <summary> /// 実行ボタン /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGo_Click(object sender, EventArgs e) { if (accessToken == "") { // 初期設定の場合 oauth.Initialize(consumerKey, consumerSecret, "", "", username); Uri authUri = new Uri("http://twitter.com/"); oauth.AuthenticatePinFlowRequest( "https://twitter.com/oauth/request_token", "https://twitter.com/oauth/authorize", ref requestToken, ref authUri); Process pro = new Process(); accessTokenUrl = authUri.ToString(); pro.StartInfo.FileName = authUri.ToString(); pro.Start(); return; } startTime = DateTime.Now; // 通常の取得 username = textBox1.Text.Trim(); if (username == "") return; labelTweets.Text = "0"; pictureBox1.Image = null; // ツイート数を取得 string xml = GetUserInfo(username); if (xml == "") { MessageBox.Show("ユーザーが見つかりませんでした", APPTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } EXDocument doc = new EXDocument(); doc.LoadXML(xml); string profile_image_url = doc * "profile_image_url"; string statuses_count = doc * "statuses_count"; max_id = doc * "status" / "id"; tweet_count = int.Parse(statuses_count); labelTweets.Text = tweet_count.ToString("#,##0"); // 画像表示 WebClient cl = new WebClient(); byte[] pic = cl.DownloadData(profile_image_url); MemoryStream st = new MemoryStream(pic); pictureBox1.Image = new Bitmap(st); st.Close(); _tweets = new List<Tweet>(); worker.RunWorkerAsync(); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { int err_count = 5; EXDocument doc = new EXDocument(); int count = 0; while (count < tweet_count) { if (worker.CancellationPending == true) break; // 直近の200件を取得 string xml = GetTweets(username, max_id); if (xml == "") { err_count--; if (err_count < 0) { MessageBox.Show("取得エラー発生", APPTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); worker.CancelAsync(); return; } // 1秒待つ System.Threading.Thread.Sleep(1000); continue; } doc.LoadXML(xml); EXElements items = doc * "status"; foreach (EXElement status in items) { string id = status / "id"; if (max_id == id) continue; count++; Tweet twi = new Tweet() { Num = count, ID = status / "id", text = status / "text", created_at = status / "created_at" }; _tweets.Add(twi); max_id = twi.ID; } worker.ReportProgress(count * 100 / tweet_count); if (items.Count < 200) break; } }
public EXElement(EXDocument doc) { _document = doc; Attributes = new Dictionary <string, EXAttr>(); ChildNodes = new List <EXElement>(); }