/// <summary> /// Set standing in the database to the specified value. /// </summary> /// <param name="toID"></param> /// <param name="fromID"></param> /// <param name="standing"></param> public static void SetStanding(long toID, long fromID, decimal standing) { EMMADataSet.StandingsDataTable table = new EMMADataSet.StandingsDataTable(); tableAdapter.FillByIDs(table, toID, fromID); EMMADataSet.StandingsRow dataRow = table.FindBytoIDfromID(toID, fromID); bool newRow = false; if (dataRow == null) { dataRow = table.NewStandingsRow(); dataRow.toID = toID; dataRow.fromID = fromID; newRow = true; } dataRow.standing = standing; if (newRow) { table.AddStandingsRow(dataRow); } tableAdapter.Update(table); }
static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<string, decimal> args) { EMMADataSet.StandingsDataTable table = new EMMADataSet.StandingsDataTable(); lock (tableAdapter) { char[] delim = { '|' }; long toID = 0, fromID = 0; string[] ids = args.Key.Split(delim); toID = long.Parse(ids[0]); fromID = long.Parse(ids[1]); tableAdapter.FillByIDs(table, toID, fromID); } if (table.Count > 0) { args.Data = table[0].standing; } else { args.Data = 0; } }