internal void GetDetail(string html) { string place = Regex.Match(html, "(R.*?)\"", RegexOptions.Singleline).Groups[1].ToString(); MatchCollection matches = Regex.Matches(html, "\"(MK.*?)\".*?\"(.*?)\"", RegexOptions.Singleline); foreach (Match mac in matches) { string iphone_name = mac.Groups[1].ToString().Trim(); string have = mac.Groups[2] .ToString().Trim(); IPhone iphone = new IPhone(); iphone.Name = iphone_name; iphone.Have = have; iphone.Place = place; iphone_list.Add(iphone); } }
internal void GetDetail(string html) { string place = Regex.Match(html, "(R.*?)\"", RegexOptions.Singleline).Groups[1].ToString(); MatchCollection matches = Regex.Matches(html, "\"(MK.*?)\".*?\"(.*?)\"", RegexOptions.Singleline); foreach (Match mac in matches) { string iphone_name = mac.Groups[1].ToString().Trim(); string have = mac.Groups[2].ToString().Trim(); IPhone iphone = new IPhone(); iphone.Name = iphone_name; iphone.Have = have; iphone.Place = place; iphone_list.Add(iphone); } }
internal void Insert(IPhone iphone) { string sql = string.Format("insert into iphone (place,size,storage,datetime) values ('{0}','{1}','{2}','{3}')",iphone.Place,iphone.Size,iphone.Storge,DateTime.Now); string error = null; MySqlConnection conn = null; try { conn = new MySqlConnection(connStr); conn.Open(); MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn); DataSet testDataSet = new DataSet(); adapter.Fill(testDataSet, "result_data"); conn.Close(); } catch (Exception e) { conn.Close(); error = e.Message; Console.WriteLine("insert error"); } }
internal void Insert(IPhone iphone) { string sql = string.Format("insert into iphone (place,size,storage,datetime) values ('{0}','{1}','{2}','{3}')", iphone.Place, iphone.Size, iphone.Storge, DateTime.Now); string error = null; MySqlConnection conn = null; try { conn = new MySqlConnection(connStr); conn.Open(); MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn); DataSet testDataSet = new DataSet(); adapter.Fill(testDataSet, "result_data"); conn.Close(); } catch (Exception e) { conn.Close(); error = e.Message; Console.WriteLine("insert error"); } }
private void SendMessage(IPhone iphone,string title) { try { foreach (Mail mail in mail_list) { if (mail.Status != 1) { if ((DateTime.Now - mail.DateTime).Minutes > 3) { mail.Status = 1; mail.DateTime = DateTime.Now; } } if (mail.Status == 1) { MailMessage emailMessage; MailMessage message = new MailMessage("*****@*****.**",mail.Name, title, iphone.Place + iphone.Storge); string fuwuqi = "smtp.sina.com"; SmtpClient smtp = new SmtpClient(fuwuqi); smtp.Credentials = new NetworkCredential("*****@*****.**", "550804648"); smtp.Send(message); mail.Status = -1; } } } catch (Exception t) { Console.WriteLine(t.Message); } }