/// <summary> /// 判断core.db是否异常 /// </summary> public static void JudeCoreDb() { string path = Path.Combine(@"C:\Users\Administrator\Desktop\db", "core.db"); //string path = Path.Combine(RootPath, "db", "core.db"); if (File.Exists(path)) { SQLiteConnection conn; bool b = SqLiteHelper.TryOpen(path, out conn); if (b) { string sql = "select * from registrations order by RowID desc limit 1"; object obj = SqLiteHelper.ExecuteScalar(conn, sql); if (obj == null) { string s = "delete from registrations"; //string s = "delete from registrations where RowID=(select RowID from registrations order by RowID desc limit 1)"; SqLiteHelper.ExecuteNonquery(conn, s); } sql = "select * from complete order by RowID desc limit 1"; obj = SqLiteHelper.ExecuteScalar(conn, sql); if (obj == null) { string s = "delete from complete"; //string s = "delete from registrations where RowID=(select RowID from registrations order by RowID desc limit 1)"; SqLiteHelper.ExecuteNonquery(conn, s); } sql = "select * from interfaces order by RowID desc limit 1"; obj = SqLiteHelper.ExecuteScalar(conn, sql); if (obj == null) { string s = "delete from interfaces"; //string s = "delete from registrations where RowID=(select RowID from registrations order by RowID desc limit 1)"; SqLiteHelper.ExecuteNonquery(conn, s); } } else { File.Delete(path); } } }
private void NewUserCommandHandler(object obj) { if (!string.IsNullOrWhiteSpace(TxtUserId) && !string.IsNullOrWhiteSpace(TxtPassword)) { string Credential = TxtUserId + ":" + TxtPassword; SqLiteHelper sql1 = new SqLiteHelper(); string query1 = "select Count(*) from Users where UserName='******'"; int count = Convert.ToInt32(sql1.ExecuteScalar(query1)); if (TxtUserId != null && TxtPassword != null) { if (count == 0) { string query = "INSERT INTO Users(UserName,Password,FacebookId) values('" + TxtUserId + "','" + TxtPassword + "','" + TxtUserId + TxtPassword + "')"; int yy = sql.ExecuteNonQuery(query); NewUserNameInfoList.Add(new FacebookUserLoginInfo { LoginUserName = TxtUserId }); MessageBox.Show("Save successfully"); } } UserAdded(new SocialUser { InboxUserName = TxtUserId, Password = TxtPassword }); //UserAdded(new SocialUser { InboxUserName = TxtUserId }); TxtUserId = null; TxtPassword = null; } else { MessageBox.Show("Please enter valid username and password..!"); } }
/// <summary> /// 获取级联集合 /// </summary> /// <returns></returns> public static void GetCascadings(out List <Cascading> list) { list = new List <Cascading>(); string mysql = "select CascadingID,Data_key,Data,Remark from ipvt_cascadingtable"; MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(mysql); while (reader != null && reader.Read()) { var model = new Cascading(); model.Id = EvaluationHelper.ObjectToInt(reader["CascadingID"]); model.Key = reader["Data_key"].ToString(); model.Ip = reader["Data"].ToString(); model.Remark = reader["Remark"].ToString(); var con = SqLiteHelper.Open(_dbPath); string sql = string.Format( "select RowID from db_data where realm='hy_extern_domain' and data_key='{0}' and data='{1}'", model.Key, model.Ip); model.RowId = EvaluationHelper.ObjectToInt(SqLiteHelper.ExecuteScalar(con, sql)); list.Add(model); con.Close(); } } catch (Exception ex) { LogHelper.MainLog(ex.ToString()); } finally { if (reader != null) { reader.Close(); } } }
public static void InsertFacebookCommentToDb(List <FbUserMessageInfo> messagingFbpageListInfo) { for (int i = 0; i < messagingFbpageListInfo.Count; i++) { var chatFb = messagingFbpageListInfo[i].Message; var imagesrcFb = messagingFbpageListInfo[i].loginguserimage; var otherimagesrc = messagingFbpageListInfo[i].otheruserimage; string query1 = "select Count(*) from TblJobFb where Message='" + chatFb + "'and ImageSource='" + imagesrcFb + "'"; SqLiteHelper sql1 = new SqLiteHelper(); int count = Convert.ToInt32(sql1.ExecuteScalar(query1)); if (count == 0) { string query = "INSERT INTO TblJobFb(PlateformType,Message,ImageSource) values('1" + "','" + chatFb + "','" + imagesrcFb + "')"; SqLiteHelper sql = new SqLiteHelper(); int yy = sql.ExecuteNonQuery(query); } } }