public AlertMsg AddOAuthSymmetricCryptoKey(OAuthSymmetricCryptoKey cryptoKey) { var helper = new SQLiteHelper(); var bucketParam = new SQLiteParameter("bucket", cryptoKey.Bucket); var handleParam = new SQLiteParameter("handle", cryptoKey.Handle); var secretParam = new SQLiteParameter("secret", Encoding.Unicode.GetString(cryptoKey.Secret)); var expiresUtcParam = new SQLiteParameter("expiresUtc", cryptoKey.ExpiresUtc.Ticks); var effResult = helper.ExecNonQuery("INSERT INTO OAuthSymmetricCryptoKey (Bucket, Handle, Secret, ExpiresUtc) VALUES (@bucket, @handle, @secret, @expiresUtc);", bucketParam, handleParam, secretParam, expiresUtcParam); AlertMsg result = effResult; result.IsSuccess = effResult.EffectLines == 1; return(result); }
public List <OAuthSymmetricCryptoKey> GetSymmetricCryptoKeys(string bucket) { var helper = new SQLiteHelper(); var bucketParam = new SQLiteParameter("bucket", bucket); var resultTab = helper.GetDataTable("SELECT OAuthSymmetricCryptoKey.ID, OAuthSymmetricCryptoKey.Bucket, OAuthSymmetricCryptoKey.Handle, OAuthSymmetricCryptoKey.Secret, OAuthSymmetricCryptoKey.ExpiresUtc FROM OAuthSymmetricCryptoKey WHERE OAuthSymmetricCryptoKey.Bucket = @bucket", bucketParam); var result = new List <OAuthSymmetricCryptoKey>(); foreach (DataRow row in resultTab.Rows) { var model = new OAuthSymmetricCryptoKey(); model.ID = Convert.ToInt64(row["ID"]); model.Bucket = row["Bucket"].ToString(); model.Handle = row["Handle"].ToString(); model.Secret = Encoding.Unicode.GetBytes(row["Secret"].ToString()); model.ExpiresUtc = new DateTime(Convert.ToInt64(row["ExpiresUtc"])); result.Add(model); } return(result); }
public OAuthSymmetricCryptoKey GetSymmetricCryptoKey(string bucket, string handle) { var helper = new SQLiteHelper(); var bucketParam = new SQLiteParameter("bucket", bucket); var handleParam = new SQLiteParameter("handle", bucket); var resultTab = helper.GetDataTable("SELECT OAuthSymmetricCryptoKey.ID, OAuthSymmetricCryptoKey.Bucket, OAuthSymmetricCryptoKey.Handle, OAuthSymmetricCryptoKey.Secret, OAuthSymmetricCryptoKey.ExpiresUtc FROM OAuthSymmetricCryptoKey WHERE OAuthSymmetricCryptoKey.Bucket = @bucket AND OAuthSymmetricCryptoKey.Handle = @handle LIMIT 0,1", bucketParam, handleParam); if (resultTab.Rows.Count > 0) { var row = resultTab.Rows[0]; var model = new OAuthSymmetricCryptoKey(); model.ID = Convert.ToInt64(row["ID"]); model.Bucket = row["Bucket"].ToString(); model.Handle = row["Handle"].ToString(); model.Secret = Encoding.Unicode.GetBytes(row["Secret"].ToString()); model.ExpiresUtc = new DateTime(Convert.ToInt64(row["ExpiresUtc"])); return(model); } return(null); }
public AlertMsg AddOAuthSymmetricCryptoKey(OAuthSymmetricCryptoKey cryptoKey) { return(_dataAccess.AddOAuthSymmetricCryptoKey(cryptoKey)); }