public override void Save(JToken jObject, string path) { foreach (JObject j in jObject) { Dictionary <string, string> selectWhere = new Dictionary <string, string>(); selectWhere.Add("addr", j["address"].ToString()); DataTable dt = MysqlConn.ExecuteDataSet("address", selectWhere).Tables[0]; if (dt.Rows.Count != 0) { Dictionary <string, string> dirs = new Dictionary <string, string>(); dirs.Add("lastuse", Helper.blockTime.ToString()); dirs.Add("txcount", (int.Parse(dt.Rows[0]["txcount"].ToString()) + 1) + ""); Dictionary <string, string> where = new Dictionary <string, string>(); where.Add("addr", dt.Rows[0]["addr"].ToString()); MysqlConn.Update("address", dirs, where); } else { JObject result = new JObject(); result["addr"] = j["address"]; result["firstuse"] = Helper.blockTime; result["lastuse"] = Helper.blockTime; result["txcount"] = 1; List <string> slist = new List <string>(); slist.Add(j["address"].ToString()); slist.Add(Helper.blockTime.ToString()); slist.Add(Helper.blockTime.ToString()); slist.Add("1"); MysqlConn.ExecuteDataInsert("address", slist); } } }
public void ChangeUTXO(string txid, string voutNum) { Dictionary <string, string> dirs = new Dictionary <string, string>(); dirs.Add("used", "1"); dirs.Add("useHeight", Helper.blockHeight.ToString()); Dictionary <string, string> where = new Dictionary <string, string>(); where.Add("txid", txid); where.Add("n", voutNum); MysqlConn.Update("utxo", dirs, where); //JObject result = JObject.Parse(File.ReadAllText(path, Encoding.UTF8)); //result["used"] = 1; //result["useHeight"] = Helper.blockHeight; //File.WriteAllText(path, result.ToString(), Encoding.UTF8); }