static void Generate1(synapse_client <data_processors.waypoints> client, string source, uint yy, uint mm, uint dd) { var contests = new ContestsType(); var contest = new ContestType(); contest.set_competition("Australian Racing"); contest.set_contestNumber(1); contest.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint"); contest.set_sportCode(SportEnum.SportEnum_gp); contest.set_datasource(source); contest.set_startDate(new DateType()).set_Value(utils.EncodeDate(yy, mm, dd)); //// var participant = new ParticipantType(); participant.set_number("1"); participant.set_barrier(new IntegerType()).set_Value(3); var entities = new EntitiesType(); var horse = entities.set_horse_element("horse", new HorseType()); horse.set_name("Small Runner"); horse.set_countryBorn(new TextType()).set_Value("AUS"); var jockey = entities.set_jockey_element("jockey", new PersonType()); jockey.set_name("S Clipperton"); jockey.set_sid("S Clipperton"); participant.set_entities(entities); contest.set_participants_element("1", participant); //// participant = new ParticipantType(); participant.set_number("1A"); participant.set_barrier(new IntegerType()).set_Value(2); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner"); participant.set_entities(entities); contest.set_participants_element("1A", participant); //// participant = new ParticipantType(); participant.set_number("2"); participant.set_barrier(new IntegerType()).set_Value(1); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Large Runner"); participant.set_entities(entities); contest.set_participants_element("2", participant); // contests.set_contest_element(source + "|" + yy.ToString() + mm.ToString() + dd.ToString() + ";1000001", contest); var waypoints = new waypoints(); var waypoint = new waypoint(); waypoint.set_timestamp(data_processors.federated_serialisation.utils.EncodeDateTime(DateTime.UtcNow)); waypoint.set_tag("contests_1.example.csharp.1"); waypoints.add_path_element(waypoint); client.publish("test." + source, contests, waypoints, false); }
static void Generate2(synapse_client <data_processors.waypoints> client) { var contests_20150401 = new ContestsType(); var contests_20150402 = new ContestsType(); var qt_contest1 = new ContestType(); qt_contest1.set_competition("Australian Racing"); qt_contest1.set_contestNumber(1); qt_contest1.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint"); qt_contest1.set_sportCode(SportEnum.SportEnum_gp); qt_contest1.set_datasource("qt"); qt_contest1.set_startDate(new DateType()).set_Value(utils.EncodeDate(2015, 04, 01)); //// var participant = new ParticipantType(); participant.set_number("1"); participant.set_barrier(new IntegerType()).set_Value(3); var entities = new EntitiesType(); var horse = entities.set_horse_element("horse", new HorseType()); horse.set_name("Small Runner"); horse.set_countryBorn(new TextType()).set_Value("AUS"); var jockey = entities.set_jockey_element("jockey", new PersonType()); jockey.set_name("S Clipperton"); jockey.set_sid("S Clipperton"); participant.set_entities(entities); qt_contest1.set_participants_element("1", participant); //// participant = new ParticipantType(); participant.set_number("1A"); participant.set_barrier(new IntegerType()).set_Value(2); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("1A", participant); //// participant = new ParticipantType(); participant.set_number("2"); participant.set_barrier(new IntegerType()).set_Value(1); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Large Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("2", participant); // contests_20150401.set_contest_element("qt|20150401;1000001", qt_contest1); client.publish("test.qt", contests_20150401, null, false, Encoding.ASCII.GetBytes("contests_20150401")); //////////////////////////////////////////////////////////////// qt_contest1 = new ContestType(); qt_contest1.set_competition("Australian Racing"); qt_contest1.set_contestNumber(1); qt_contest1.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint"); qt_contest1.set_sportCode(SportEnum.SportEnum_gp); qt_contest1.set_datasource("qt"); qt_contest1.set_startDate(new DateType()).set_Value(utils.EncodeDate(2015, 04, 02)); //// participant = new ParticipantType(); participant.set_number("1"); participant.set_barrier(new IntegerType()).set_Value(3); entities = new EntitiesType(); horse = entities.set_horse_element("horse", new HorseType()); horse.set_name("Small Runner"); horse.set_countryBorn(new TextType()).set_Value("AUS"); jockey = entities.set_jockey_element("jockey", new PersonType()); jockey.set_name("S Clipperton"); jockey.set_sid("S Clipperton"); participant.set_entities(entities); qt_contest1.set_participants_element("1", participant); //// participant = new ParticipantType(); participant.set_number("1A"); participant.set_barrier(new IntegerType()).set_Value(2); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("1A", participant); //// participant = new ParticipantType(); participant.set_number("2"); participant.set_barrier(new IntegerType()).set_Value(1); entities = new EntitiesType(); entities.set_horse_element("horse", new HorseType()).set_name("Large Runner"); participant.set_entities(entities); qt_contest1.set_participants_element("2", participant); // contests_20150402.set_contest_element("qt|20150402;1000001", qt_contest1); client.publish("test.qt", contests_20150402, null, false, Encoding.ASCII.GetBytes("contests_20150402")); //////////////////////////////////////////////////////////////// ////// Jockey change - publish delta ///// var a_contest = contests_20150401.get_contest_element("qt|20150401;1000001"); if (a_contest != null) { var a_participant = a_contest.get_participants_element("1"); if (a_participant != null) { var a_entities = a_participant.get_entities(); if (a_entities != null) { var a_jockey = a_entities.get_jockey_element("jockey"); if (a_jockey != null) { a_jockey.set_name("D J Browne"); a_jockey.set_sid("4317"); } else { Console.WriteLine("Jockey not found!"); } } else { Console.WriteLine("Entities not found!"); } } else { Console.WriteLine("Participant 1 not found!"); } } else { Console.WriteLine("Contest not found!"); } client.publish("test.qt", contests_20150401, null, true, Encoding.ASCII.GetBytes("contests_20150401")); /////////////////////////////////////////////////////////////// ///// Jockey change - publish delta ///// a_contest = contests_20150402.get_contest_element("qt|20150402;1000001"); if (a_contest != null) { var a_participant = a_contest.get_participants_element("1"); if (a_participant != null) { var a_entities = a_participant.get_entities(); if (a_entities != null) { var a_jockey = a_entities.get_jockey_element("jockey"); if (a_jockey != null) { a_jockey.set_name("D J Browne"); a_jockey.set_sid("4317"); } else { Console.WriteLine("Jockey not found!"); } } else { Console.WriteLine("Entities not found!"); } } else { Console.WriteLine("Participant 1 not found!"); } } else { Console.WriteLine("Contest not found!"); } client.publish("test.qt", contests_20150402, null, true, Encoding.ASCII.GetBytes("contests_20150402")); }
print_contest_msg(ContestsType msg) { foreach (var contest_i in new SortedDictionary <string, ContestType>(msg.get_contest())) { var contest = contest_i.Value; var dt = utils.DecodeDate((uint)contest.get_startDate().get_Value()); var tm = (contest.get_startTime() != null) ? utils.DecodeTime((uint)contest.get_startTime().get_Value()) : "time-NA"; string ts; if (contest.get_actualStart() != null) { ts = utils.DecodeTimestamp((ulong)contest.get_actualStart().get_Value()); } else { ts = ""; } string locDescr; if (contest.get_location() != null) { locDescr = contest.get_location().get_name().PadRight(20); // NOTE -- no 'null' testing should be required if used thrift's schema marks field as required... locDescr += (contest.get_location().get__ID() != null ? contest.get_location().get__ID().ToString() : "").PadRight(4) + ' '; if (contest.get_location().get_field() != null) { locDescr += contest.get_location().get_field().get__ID().ToString().PadRight(4); } else { locDescr += " "; } } else { locDescr = " "; } Console.WriteLine((contest.get__ID() != null ? contest.get__ID().ToString() : "") + " " + dt + " " + tm + " " + locDescr + " R" + contest.get_contestNumber().ToString().PadRight(2) + " actual=" + ts); if (contest.get_participants() != null) { foreach (var participant_i in new SortedDictionary <string, ParticipantType>(contest.get_participants())) { var participant = participant_i.Value; Console.WriteLine(" PARTICIPANT: " + " " + participant.get_number()); if (participant.get_entities() != null) { if (participant.get_entities().get_horse() != null) { foreach (var horse_i in new SortedDictionary <string, HorseType>(participant.get_entities().get_horse())) { Console.WriteLine(" HORSE: " + horse_i.Value.get_name()); } } if (participant.get_entities().get_dog() != null) { foreach (var dog_i in new SortedDictionary <string, DogType>(participant.get_entities().get_dog())) { Console.WriteLine(" DOG: " + dog_i.Value.get_name()); } } if (participant.get_entities().get_jockey() != null) { foreach (var jockey_i in new SortedDictionary <string, PersonType>(participant.get_entities().get_jockey())) { Console.WriteLine(" JOCKEY: " + jockey_i.Value.get_name()); } } } } } } }