private bool PutValueHelper(string identityId, string datasetName, string key, string value)
{
lock (sqlite_lock)
{
Record record = GetRecord(identityId, datasetName, key);
if (record != null && string.Equals(record.Value, value))
{
return true;
}
if (record == null)
{
string insertRecord = RecordColumns.BuildInsert();
ExecuteMultipleHelper(new List<Statement>{new Statement{
Query = insertRecord,
Parameters = new object[]{identityId,datasetName,key,value,0,DateTime.Now,string.Empty,DateTime.Now,1}
}});
return true;
}
else
{
string insertRecord =
RecordColumns.BuildUpdate(
new string[] {
RecordColumns.IDENTITY_ID, RecordColumns.DATASET_NAME, RecordColumns.KEY,
RecordColumns.VALUE, RecordColumns.MODIFIED, RecordColumns.SYNC_COUNT,
RecordColumns.DEVICE_LAST_MODIFIED_TIMESTAMP
},
RecordColumns.IDENTITY_ID + " = @whereIdentityId AND " +
RecordColumns.DATASET_NAME + " = @whereDatasetName AND " +
RecordColumns.KEY + " = @whereKey "
);
ExecuteMultipleHelper(new List<Statement>{new Statement{
Query = insertRecord,
Parameters = new object[]{identityId,datasetName,key,value,1,record.SyncCount,DateTime.Now,identityId,datasetName,key}
}});
return true;
}
}
}