private static string createAction(string vote_id, string user_name, ActionData mat_data) { int next_id = NextIdStore.Next(Warehouse.PapersTable, vote_id); string row_key = Consts.ACTION_ID_CHAR + next_id.ToString("D" + Consts.ACTION_ID_DIGITS); DynamicTableEntity entity = new DynamicTableEntity(vote_id, row_key); entity[Consts.MAT_PROP_NAME] = new EntityProperty(mat_data.mat); entity[Consts.WHO_PROP_NAME] = new EntityProperty(user_name); entity[Consts.TIME_PROP_NAME] = new EntityProperty(DateTimeOffset.UtcNow); if (mat_data.value != null) { entity[Consts.VALUE_PROP_NAME] = new EntityProperty(mat_data.value); } if (mat_data.type != null) { entity[Consts.TYPE_PROP_NAME] = new EntityProperty(mat_data.type); } if (mat_data.pare != null) { entity[Consts.PARE_PROP_NAME] = new EntityProperty(mat_data.pare); } string hp = PaperPond.Get(vote_id).AddMat(entity); // If put this line after inserting into db, when cache miss and the roll is initialized from db, the mat will be added twice. Warehouse.PapersTable.Execute(TableOperation.Insert(entity)); return(hp); }
public static void AddVote(string vote_id, string tag, string title, string user_name) { string partition_key = Consts.TAG_NAME_KEY_PREFIX + tag.ToLowerInvariant(); NextIdStore.CreateIfNotExists(Warehouse.TagScrollsTable, partition_key, 0); int next_id = NextIdStore.Next(Warehouse.TagScrollsTable, partition_key); DynamicTableEntity entity = buildEntity(tag, next_id); entity["voteid"] = new EntityProperty(vote_id); entity["title"] = new EntityProperty(title); entity[Consts.WHO_PROP_NAME] = new EntityProperty(user_name); entity[Consts.TIME_PROP_NAME] = new EntityProperty(DateTimeOffset.UtcNow); Warehouse.TagScrollsTable.Execute(TableOperation.Insert(entity)); Warehouse.TagScrollsPond.AddOrUpdate(entity.PartitionKey, entity.RowKey, entity); }