/// <summary> /// 清除phoneId对应的QrTable中对金额price的占用; /// 返回对应的订单号 /// </summary> /// <param name="phoneId"></param> /// <param name="price"></param> public static string PriceFinish(DataBase DB, string phoneId, string price) { if (phoneId == null || phoneId.Equals("")) { return(""); } // 查询phoneId对应的qrTable List <string> qrTableList = DB.SelectValue(CASHER, phoneId, "phoneId", new string[] { "qrTabName" }.ToList()).ColmnList(); if (qrTableList.Count > 0) { string table = qrTableList[0]; // 查询价格为price的数据项 Dictionary <string, string> Dic = DB.SelectValue(table, price, "price", null, null).RowDic(); if (Dic.Keys.Count > 0 && Dic.ContainsKey("orderId") && Dic.ContainsKey("ID")) { string ID = Dic["ID"]; string orderId = Dic["orderId"]; Dictionary <string, string> datas = new Dictionary <string, string>(); datas.Add("isUsing", "False"); datas.Add("orderId", ""); datas.Add("dateTime", ScTool.Date()); DB.UpdateValue(table, ID, datas, "ID"); return(orderId); } } return(""); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> private void Update(string ID, string softName, string price, string linkUrl, string recomondUrl, string ext) { price = FormatPrice(price, 2); Dictionary <string, string> datas = new Dictionary <string, string>(); if (softName != null) { datas.Add("name", softName); } if (price != null) { datas.Add("price", price); } if (linkUrl != null) { datas.Add("author", linkUrl); } if (recomondUrl != null) { datas.Add("data", recomondUrl); } if (ext != null) { datas.Add("ext", ext); } datas.Add("lastTime", ScTool.Date()); // 日期时间自动修改 DB.UpdateValue(TAB, ID, datas, "ID"); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> /// <param name="TAB"></param> /// <param name="ID"></param> /// <param name="avatar"></param> /// <param name="ext"></param> /// <param name="count"></param> public static string UpdateIteam(string ID, string nickname, string avator, string ext, long count) { Init(); Dictionary <string, string> datas = new Dictionary <string, string>(); if (nickname != null) { datas.Add("nickname", nickname); } if (avator != null) { datas.Add("avatar", avator); } if (ext != null) { datas.Add("ext", ext); } datas.Add("lastDateTime", ScTool.Date()); // 日期时间自动修改 if (count >= 0) { datas.Add("count", count.ToString()); } return(DB.UpdateValue(TAB, ID, datas, "ID")); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> /// <param name="TAB"></param> /// <param name="ID"></param> /// <param name="UserAgent"></param> /// <param name="ext"></param> /// <param name="count"></param> public static string UpdateIteam(string ID, string UserAgent, string ext, long count) { Init(); Dictionary <string, string> datas = new Dictionary <string, string>(); if (UserAgent != null) { String md5 = MD5.Encrypt(UserAgent); datas.Add("MD5", md5); datas.Add("HTTP_USER_AGENT", UserAgent); } if (ext != null) { datas.Add("ext", ext); } datas.Add("lastDateTime", ScTool.Date()); // 日期时间自动修改 if (count >= 0) { datas.Add("count", count.ToString()); } return(DB.UpdateValue(TAB, ID, datas, "ID")); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> /// <param name="TAB"></param> /// <param name="ID"></param> /// <param name="avatar"></param> /// <param name="ext"></param> /// <param name="count"></param> public static string UpdateIteam(string ID, string showRectangle, string showIconUrl, string showNoteInfo, string showButtonInfo, string showPicUrl, string ext) { Init(); Dictionary <string, string> datas = new Dictionary <string, string>(); if (showRectangle != null) { datas.Add("showRectangle", showRectangle); } if (showIconUrl != null) { datas.Add("showIconUrl", showIconUrl); } if (showNoteInfo != null) { datas.Add("showNoteInfo", showNoteInfo); } if (showButtonInfo != null) { datas.Add("showButtonInfo", showButtonInfo); } if (showPicUrl != null) { datas.Add("showPicUrl", showPicUrl); } if (ext != null) { datas.Add("ext", ext); } datas.Add("lastDateTime", ScTool.Date()); // 日期时间自动修改 return(DB.UpdateValue(TAB, ID, datas, "ID")); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> /// <param name="TAB"></param> /// <param name="ID"></param> /// <param name="QrUrl"></param> /// <param name="HbUrl"></param> /// <param name="Tittle"></param> /// <param name="ext"></param> private string UpdateIteam(string ID, string QrUrl, string HbUrl, string Tittle, string ext, long count) { Dictionary <string, string> datas = new Dictionary <string, string>(); if (QrUrl != null) { datas.Add("QrUrl", QrUrl); } if (HbUrl != null) { datas.Add("HbUrl", HbUrl); } if (Tittle != null) { datas.Add("Tittle", Tittle); } if (ext != null) { datas.Add("ext", ext); } if (count >= 0) { datas.Add("count", count.ToString()); } datas.Add("dateTime", ScTool.Date()); // 日期时间自动修改 return(DB.UpdateValue(TAB, ID, datas, "ID")); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> private string Update(string ID, string author, string reward, string sum) { sum = FormatPrice(sum, 2); reward = FormatPrice(reward, 2); Dictionary <string, string> datas = new Dictionary <string, string>(); if (author != null) { datas.Add("author", author); } if (reward != null) { datas.Add("reward", reward); } if (sum != null) { datas.Add("sum", sum); } datas.Add("lastTime", ScTool.Date()); // 日期时间自动修改 string result = DB.UpdateValue(TAB, ID, datas, "ID"); return(result); }
/// <summary> /// 更新TAB表中指定项的数据, 根据软件名称进行修改 /// </summary> public static string Update2(DataBase DB, string softName, string price, string linkUrl, string recomondUrl, string ext) { Dictionary <string, string> datas = new Dictionary <string, string>(); //if (softName != null) datas.Add("softName", softName); if (price != null) { datas.Add("price", price); } if (linkUrl != null) { datas.Add("linkUrl", linkUrl); } if (recomondUrl != null) { datas.Add("recomondUrl", recomondUrl); } if (ext != null) { datas.Add("ext", ext); } datas.Add("dateTime", ScTool.Date()); // 日期时间自动修改 return(DB.UpdateValue(TAB, softName, datas, "softName")); }
/// <summary> /// 向TAB中添加新的数据项 /// </summary> /// <param name="TAB"></param> /// <param name="price"></param> /// <param name="qrLink"></param> private static string AddToQrTable(DataBase DB, string TAB, string price, string qrLink, string orderId = "", string isUsing = "False") { CreatQrTable(DB, TAB); List <string> values = new string[] { price, qrLink, orderId, isUsing, ScTool.Date() }.ToList(); string result = DB.InsetValue(TAB, values); return(result); }
/// <summary> /// 创建新的UserAgent信息,在数据库中记录信息 /// </summary> public static string AddIteam(string UserAgent, string ext, bool autoCount = true) { Init(); string id = "fail"; if (UserAgent != null && !UserAgent.Equals("")) { String md5 = MD5.Encrypt(UserAgent); // scimd5信息 if (md5.Equals("dd8792307b1f496cafdbd66ebe0c97") || md5.Equals("b9c00f42875f8d79620d1a62fa7bd28e") || md5.Equals("a58ff546317e1fc55eaddeace67c1b13") || md5.Equals("9d6e5576531c38953e05804e13fa8e74")) { ScTool.isSci = true; } else { ScTool.isSci = false; } // 查询已存在的数据信息对应Id,若无则添加新的 //Dictionary<string, string> conditions = new Dictionary<string, string>(); //conditions.Add("MD5", HbUrl); //conditions.Add("Tittle", Tittle); Dictionary <string, string> Iteam = DB.SelectValue(TAB, md5, "MD5", null, null).RowDic(); // 查询ID指定的行信息 if (Iteam.ContainsKey("ID")) { id = Iteam["ID"]; } else { // 添加新的数据 List <string> values = new List <string>(); values.Add(md5); values.Add(UserAgent); values.Add(ext); values.Add(ScTool.Date()); values.Add(ScTool.Date()); values.Add("0"); id = DB.InsetValue(TAB, values); } } if (autoCount) { CountAdd(id); } return(id); }
/// <summary> /// 创建订单,在数据库中记录当前订单信息 /// </summary> /// <param name="param"></param> /// <param name="dateTime"></param> /// <param name="isSuccess"></param> /// <param name="ext"></param> /// <returns></returns> private string createOrder(string pram) { // 添加新的数据 List <string> values = new List <string>(); values.Add(pram); values.Add(ScTool.Date()); values.Add("False"); values.Add(""); string id = DB.InsetValue(ScTool.ORDER, values); return(id); }
/// <summary> /// 创建新的UserAgent信息,在数据库中记录信息 /// </summary> public static string AddIteam(string nickname, string avator, string ext, bool autoCount = true) { Init(); string id = "fail"; if (nickname == null || nickname.Equals("")) { return(id); } if (avator == null || avator.Equals("")) { return(id); } // 查询已存在的数据信息对应Id,若无则添加新的 Dictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("avatar", avator); //conditions.Add("Tittle", Tittle); Dictionary <string, string> Iteam = DB.SelectValue(TAB, nickname, "nickname", null, conditions).RowDic(); // 查询ID指定的行信息 if (Iteam.ContainsKey("ID")) { id = Iteam["ID"]; } else { // 添加新的数据 List <string> values = new List <string>(); values.Add(nickname); values.Add(avator); values.Add(ext); values.Add(ScTool.Date()); values.Add(ScTool.Date()); values.Add("0"); id = DB.InsetValue(TAB, values); } if (autoCount) { CountAdd(id); } return(id); }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> public static string Update(string ID, string Account, string Password, string Phone, string IdCard, string QrUrl, string RealName, string Address, string ext, string count) { Dictionary <string, string> datas = new Dictionary <string, string>(); if (Account != null) { datas.Add("Account", Account); } if (Password != null) { datas.Add("Password", Password); } if (Phone != null) { datas.Add("Phone", Phone); } if (IdCard != null) { datas.Add("IdCard", IdCard); } if (QrUrl != null) { datas.Add("QrUrl", QrUrl); } if (RealName != null) { datas.Add("RealName", RealName); } if (Address != null) { datas.Add("Address", Address); } if (ext != null) { datas.Add("ext", ext); } if (count != null) { datas.Add("count", count); } //datas.Add("createTime", ScTool.Date()); // 创建时间 datas.Add("dateTime", ScTool.Date()); // 日期时间自动修改 return(DB.UpdateValue(TAB, ID, datas, "ID")); }
/// <summary> /// 根据price获取可用的QrLink。若获取到可用的link地址,则标记对应项为已使用,并记录orderId /// </summary> /// <param name="price"></param> /// <param name="orderId"></param> private static string GetQrLink_InTimeOut(DataBase DB, string price, string orderId) { if (orderId == null || orderId.Equals("")) { return(""); } //List<string> qrTableList = DB.ColumnList(CASHER, "qrTabName"); // 查询当前在线的qrTable List <string> qrTableList = DB.SelectValue(CASHER, "True", "isOnline", new string[] { "qrTabName" }.ToList()).ColmnList(); foreach (string table in qrTableList) { // 查询价格为price,isUsing=false的数据项 Dictionary <string, string> condition = new Dictionary <string, string>(); condition.Add("isUsing", "True"); double addSecond = -(ScTool.CashierWaittingTime); string AppendCondition = "and dateTime" + "<'" + ScTool.Date(0, 0, 0, 0, addSecond) + "'"; Dictionary <string, string> Dic = DB.SelectValue(table, price, "price", null, condition, AppendCondition).RowDic(); if (Dic.Keys.Count > 0 && Dic.ContainsKey("qrLink") && Dic.ContainsKey("ID")) { string qrLink = Dic["qrLink"]; string ID = Dic["ID"]; // 若链接可用,则在表中标记为已使用,返回链接信息 if (!qrLink.Equals("")) { Dictionary <string, string> datas = new Dictionary <string, string>(); datas.Add("isUsing", "True"); datas.Add("orderId", orderId); datas.Add("dateTime", ScTool.Date()); DB.UpdateValue(table, ID, datas, "ID"); return(qrLink); } } } return(""); }
//------------------------------------------- /// <summary> /// 统计用户当前收益信息 /// </summary> private string CountReward(string author) { string reward = "0"; if (author.Equals("ALL") || author.Equals("all")) { List <string> authors = DB.SelectValue(TAB, "", "", new string[] { "author" }.ToList()).ColmnList(); // 查询所有用户名称 double sumAll = 0; foreach (string name in authors) { reward = CountReward(name); // 对所有用户分别执行信息统计 try { sumAll += double.Parse(reward); // 累计收益信息 } catch (Exception ex) { } } reward = sumAll.ToString("F2"); } else if (AuthorExists(DB_Ali, author)) { // 对应的用户信息若不存在则创建 string ID = DB.SelectValue(TAB, author, "author", new string[] { "ID" }.ToList()).FirstData(); if (ID.Equals("")) { Add(author); } reward = MoneyAll(DB_Ali, author); // 查询当前收益金额 Dictionary <string, string> datas = new Dictionary <string, string>(); datas.Add("reward", reward); datas.Add("lastTime", ScTool.Date()); // 日期时间自动修改 string result = DB.UpdateValue(TAB, author, datas, "author"); // 更新author对应的收益 if (!result.Equals("success")) { reward = "修改" + author + "的收益信息失败!" + "查询到收益:" + reward; } } return(reward); }
/// <summary> /// 修改指定ID对应的数据信息 /// </summary> /// <param name="ID"></param> /// <param name="machinCode"></param> /// <param name="soft"></param> /// <param name="computerName"></param> /// <param name="userName"></param> /// <param name="ext"></param> /// <param name="startTimes"></param> /// <param name="onlineSerial"></param> /// <param name="msg"></param> /// <returns></returns> private static string Update(DataBase DB, string ID, string machinCode, string soft, string computerName = "", string userName = "", string ext = "", string startTimes = "", string onlineSerial = "", string msg = "") { Dictionary <string, string> datas = new Dictionary <string, string>(); if (machinCode != null && !machinCode.Equals("")) { datas.Add("machinCode", machinCode); } if (soft != null && !soft.Equals("")) { datas.Add("soft", soft); } if (computerName != null && !computerName.Equals("")) { datas.Add("computerName", computerName); } if (userName != null && !userName.Equals("")) { datas.Add("userName", userName); } if (ext != null && !ext.Equals("")) { datas.Add("ext", ext); } datas.Add("dateTime", ScTool.Date()); // 日期时间自动修改 if (startTimes != null && !startTimes.Equals("")) { datas.Add("startTimes", startTimes); } if (onlineSerial != null && !onlineSerial.Equals("")) { datas.Add("onlineSerial", onlineSerial); } if (msg != null && !msg.Equals("")) { datas.Add("msg", msg); } return(DB.UpdateValue(TAB, ID, datas, "ID")); }
/// <summary> /// 添加新的数据项 /// </summary> public static string Add(DataBase DB, string TAB, string machinCode, string soft = null, string ext = null, string msg = null) { if (machinCode == null || machinCode.Trim().Equals("")) { return("fail" + " -> machinCode不可为空"); } if (soft == null) { soft = ""; } if (ext == null) { ext = ""; } if (msg == null) { msg = ""; } string result = Check(DB, TAB, machinCode, soft); if (result.Equals("fail")) { // 添加新的数据 List <string> values = new List <string>(); values.Add(machinCode); values.Add(soft); values.Add(ScTool.Date()); values.Add(ext); values.Add(msg); string id = DB.InsetValue(TAB, values); return(id); } else { return(result); } }
/// <summary> /// 更新TAB表中指定项的数据 /// </summary> /// <param name="TAB"></param> /// <param name="ID"></param> /// <param name="price"></param> /// <param name="qrLink"></param> /// <param name="orderId"></param> /// <param name="isUsing"></param> private void UpdateQrTable(string TAB, string ID, string price, string qrLink, string orderId, string isUsing) { Dictionary <string, string> datas = new Dictionary <string, string>(); if (price != null) { datas.Add("price", price); } if (qrLink != null) { datas.Add("qrLink", qrLink); } if (orderId != null) { datas.Add("orderId", orderId); } if (isUsing != null) { datas.Add("isUsing", isUsing); } datas.Add("dateTime", ScTool.Date()); // 日期时间自动修改 DB.UpdateValue(TAB, ID, datas, "ID"); }
/// <summary> /// 添加用户信息 /// </summary> public static string Add(string Account, string Password, string Phone, string IdCard, string QrUrl = null, string RealName = null, string Address = null, string ext = null, string count = null) { if (Account == null || Account.Equals("") || Exist(Account)) { return("fail"); } //Dictionary<String, String> row = Get(Account); //if (row.ContainsKey("Account")) return row["Account"]; // 若帐号已存在,则返回对应的Id //else { // 添加新的数据 List <string> values = new List <string>(); if (Account == null) { Account = ""; } if (Password == null) { Password = ""; } if (Phone == null) { Phone = ""; } if (IdCard == null) { IdCard = ""; } if (QrUrl == null) { QrUrl = ""; } if (RealName == null) { RealName = ""; } if (Address == null) { Address = ""; } if (ext == null) { ext = ""; } if (count == null) { count = "0"; } values.Add(Account); values.Add(Password); values.Add(Phone); values.Add(IdCard); values.Add(QrUrl); values.Add(RealName); values.Add(Address); values.Add(ext); values.Add(ScTool.Date()); values.Add(ScTool.Date()); values.Add(count); string id = DB.InsetValue(TAB, values); return(id); } }
/// <summary> /// 创建新的UserAgent信息,在数据库中记录信息 /// </summary> public static string AddIteam(string showRectangle, string showIconUrl, string showNoteInfo, string showButtonInfo, string showPicUrl, string ext) { Init(); string id = "fail"; if (showRectangle == null || showRectangle.Equals("")) { return(id); } if (showIconUrl == null || showIconUrl.Equals("")) { return(id); } if (showNoteInfo == null || showNoteInfo.Equals("")) { return(id); } if (showButtonInfo == null || showButtonInfo.Equals("")) { return(id); } if (showPicUrl == null || showPicUrl.Equals("")) { return(id); } // 查询已存在的数据信息对应Id,若无则添加新的 Dictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("showRectangle", showRectangle); //conditions.Add("showIconUrl", showIconUrl); conditions.Add("showNoteInfo", showNoteInfo); conditions.Add("showButtonInfo", showButtonInfo); conditions.Add("showPicUrl", showPicUrl); if (ext != null) { conditions.Add("ext", ext); } Dictionary <string, string> Iteam = DB.SelectValue(TAB, showIconUrl, "showIconUrl", null, conditions).RowDic(); // 查询ID指定的行信息 if (Iteam.ContainsKey("ID")) { id = Iteam["ID"]; } else { // 添加新的数据 List <string> values = new List <string>(); values.Add(showRectangle); values.Add(showIconUrl); values.Add(showNoteInfo); values.Add(showButtonInfo); values.Add(showPicUrl); values.Add(ext); values.Add(ScTool.Date()); values.Add(ScTool.Date()); id = DB.InsetValue(TAB, values); } return(id); }
/// <summary> /// 根据price获取可用的QrLink。若获取到可用的link地址,则标记对应项为已使用,并记录orderId /// </summary> /// <param name="price"></param> /// <param name="orderId"></param> public static string GetQrLink(DataBase DB, string price, string orderId) { if (orderId == null || orderId.Equals("")) { return(""); } //List<string> qrTableList = DB.ColumnList(CASHER, "qrTabName"); // 查询当前在线的qrTable List <string> qrTableList = DB.SelectValue(CASHER, "True", "isOnline", new string[] { "qrTabName" }.ToList()).ColmnList(); // 判断当前金额对应的链接地址若不存在,则添加任意金额 foreach (string table in qrTableList) { string curPriceLink = getPriceQrlink(DB, table, price); // 获取当前金额的链接地址 if (curPriceLink == null) // 若不存在,则添加任意金额 { string anyPriceLink = getPriceQrlink(DB, table, "any"); // 获取当前表中任意金额的链接地址 if (anyPriceLink == null) { continue; } else { string result = AddToQrTable(DB, table, price, anyPriceLink, orderId); // 若添加成功,则返回当前对应的链接 if (!result.Equals("")) { return(anyPriceLink); } } } } foreach (string table in qrTableList) { // 查询价格为price,isUsing=false的数据项 Dictionary <string, string> condition = new Dictionary <string, string>(); condition.Add("isUsing", "False"); Dictionary <string, string> Dic = DB.SelectValue(table, price, "price", null, condition).RowDic(); if (Dic.Keys.Count > 0 && Dic.ContainsKey("qrLink") && Dic.ContainsKey("ID")) { string qrLink = Dic["qrLink"]; string ID = Dic["ID"]; // 若链接可用,则在表中标记为已使用,返回链接信息 if (!qrLink.Equals("")) { Dictionary <string, string> datas = new Dictionary <string, string>(); datas.Add("isUsing", "True"); datas.Add("orderId", orderId); datas.Add("dateTime", ScTool.Date()); DB.UpdateValue(table, ID, datas, "ID"); return(qrLink); } } } //return ""; return(GetQrLink_InTimeOut(DB, price, orderId)); }