static void Main(string[] args) { SQLiteHelper sqliteHelper = new SQLiteHelper(); var list = sqliteHelper.Query <Stock>("select * from Stock"); sqliteHelper.Add(new Valuation() { Price = 100, StockId = 1, Time = DateTime.Now }); var list2 = sqliteHelper.Query <Valuation>("select * from Valuation"); var list3 = sqliteHelper.Query <Valuation>("select * from Valuation INDEXED BY ValuationStockId2 WHERE StockId > 2");//使用索引ValuationStockId2查询 try { sqliteHelper.Execute("drop index ValuationStockId");//删除索引,因为该索引已被删除,所以抛异常 } catch (Exception ex) { } }
void imgurUpload() { if (InvokeRequired && IsHandleCreated) { Invoke(new Action(() => { try { var client = new RestClient("https://api.imgur.com/3/upload"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", imgurConfig.Authorization); request.AddFile("image", activePicture.Path); var response = client.Execute(request); var smms = JsonConvert.DeserializeObject <Imgur>(response.Content); if (smms == null) { MessageBox.Show("服务器连接失败"); return; } txtMD.Text = String.Format("![{0}]({1})", smms.data.id, smms.data.link); txtUrl.Text = smms.data.link; ImgRecord record = new ImgRecord(); record.name = smms.data.id; record.url = smms.data.link; record.deleteUrl = smms.data.deletehash; record.type = ImgType.IMGUR; SQLiteHelper.Add(record); getData(); } catch (Exception e) { MessageBox.Show(e.ToString()); } })); } }
private void smmsupload() { if (InvokeRequired && IsHandleCreated) { Invoke(new Action(() => { try { var client = new RestClient("https://sm.ms/api/upload"); var request = new RestRequest(Method.POST); request.AddFile("smfile", activePicture.Path); var response = client.Execute(request); var smms = JsonConvert.DeserializeObject <SMMS>(response.Content); txtUrl.Text = smms.data.url; txtMD.Text = String.Format("![{0}]({1})", smms.data.filename, smms.data.url); ImgRecord record = new ImgRecord(); record.name = smms.data.filename; record.url = smms.data.url; record.deleteUrl = smms.data.delete; record.type = ImgType.SMMS; SQLiteHelper.Add(record); getData(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } })); } }