Advertisement
mr_robd_lon_1

SO_PreserveReferencesHandling_D

Sep 18th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.82 KB | None | 0 0
  1. using Configuration.Dependency;
  2. using Contracts.Enumerations;
  3. using Contracts.Interfaces;
  4. using Contracts.Interfaces.Templating;
  5. using Contracts.Models;
  6. using Contracts.Models.SalesForce;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Threading.Tasks;
  10. using Contracts.Helpers;
  11.  
  12. namespace ClientConsole
  13. {
  14.     public class Program
  15.     {
  16.         #region Methods
  17.  
  18.         private static void Main(string[] args)
  19.         {
  20.             // Block on the async method to keep the console alive.
  21.             MainAsync(args).Wait();
  22.         }
  23.  
  24.         private static async Task MainAsync(string[] args)
  25.         {
  26.             IocContainer iocContainer = new IocContainer();
  27.            
  28.                 Console.WriteLine("Type a message and press Enter to send.");
  29.                 while (true)
  30.                 {                  
  31.                     var message = new Message();
  32.                    
  33.             message.UseTemplate = useTemplate;
  34.                     message.TemplateName = "NotificationServerTest";
  35.                     string contactId = "003g0000xxx1h3";      
  36.                     string participantId = "a2qg0000xxx8m";  
  37.                     message.TemplateDataDefinition = getTemplateDataDefinition(participantId, contactId);  
  38.  
  39.                     string messageString = SerialisationHelper.Serialise, message, true);
  40.  
  41.             ITemplateDataQuery deserialisedObject = SerialisationHelper.Deserialise(messageString, true);
  42.                 }            
  43.         }
  44.  
  45.         private static ITemplateDataQuery getTemplateDataDefinition(string particpantId, string contactId)
  46.         {
  47.             ITemplateDataQuery topLevelQuery = (ITemplateDataQuery)new TemplateDataQuery();
  48.  
  49.             topLevelQuery.RootModelObjectQueries.Add((ITemplateDataQueryElement)new TemplateDataQueryElement("Contact")
  50.             {
  51.                 EntityName = "Contact",
  52.                 RecordId = contactId
  53.             });
  54.  
  55.             topLevelQuery.RootModelObjectQueries.Add(new TemplateDataQueryElement("Participant__c")
  56.             {
  57.                 EntityName = "Participant__c",
  58.                 RecordId = particpantId
  59.             }.AddChild(new TemplateDataQueryElement("Class__c")
  60.             {
  61.                 EntityName = "Class__c",
  62.                 ParentForeignKeyName = "Class__c"
  63.             }.AddChildren(new List<TemplateDataQueryElement> {
  64.                     new TemplateDataQueryElement("Topic__c"){
  65.                     EntityName = "Topic__c",
  66.                     ParentForeignKeyName = "Topic__c"},
  67.                     new TemplateDataQueryElement("Training_Location__c"){
  68.                     EntityName = "Training_Location__c",
  69.                     ParentForeignKeyName = "Location__c"
  70.                     },
  71.                 }
  72.                 )));
  73.  
  74.             return topLevelQuery;
  75.         }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement