/// <summary>
            /// This method is called when a message is posted to the Azure Service Bus.
            /// </summary>
            /// <param name="context">Data for the request.</param>
            /// <returns>A string of information to be returned to the CRM Online Azure-aware plugin.</returns>
            public string Execute(RemoteExecutionContext context)
            {
                string studentId    = null;
                string returnString = null;

                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    var entity = context.InputParameters["Target"] as Entity;
                    if (entity.Attributes.Contains("demo_studentid"))
                    {
                        studentId = entity.Attributes["demo_studentid"].ToString();
                    }
                }

                if (studentId != null)
                {
                    returnString = GetStudentInfo(studentId);
                }
                else
                {
                    returnString = "false,Student ID not provided.";
                }

                return(returnString);
            }
 public static void Listener(RemoteExecutionContext context)
 {
     try
     {
         IEnumerable <Type> classList = GetClasses();
         if (classList != null)
         {
             foreach (Type cls in classList.Where(x => x.Namespace == ConfigurationManager.AppSettings["Namespace"]))
             {
                 if (cls.Name == context.PrimaryEntityName)
                 {
                     Object obj = GetInstance(cls);
                     if (obj != null)
                     {
                         MethodInfo methodInfo = cls.GetMethod("Execute");
                         if (methodInfo != null)
                         {
                             object[] parametersArray = new object[] { context };
                             methodInfo.Invoke(obj, parametersArray);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Inside Listener: Error[" + ex.Message + "]");
     }
 }
Ejemplo n.º 3
0
            /// <summary>
            /// This method is called when a message is posted to the Azure Service Bus.
            /// </summary>
            /// <param name="context">Data for the request.</param>
            /// <returns>A 'Success' string.</returns>
            public string Execute(RemoteExecutionContext context)
            {
                Utility.Print(context);

                // This is the return value that can be used within Dynamics
                return("Success");
            }
Ejemplo n.º 4
0
        public void ProcessMessages()
        {
            MyRawMessageTB.Text += "メッセージの受信を待っています。" + Environment.NewLine;

            queueClient.OnMessage(message =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    RemoteExecutionContext context = message.GetBody <RemoteExecutionContext>();

                    MyRawMessageTB.Text += "--------------------------------" + Environment.NewLine;
                    MyRawMessageTB.Text += string.Format("Message received: Id = {0}", message.MessageId) + Environment.NewLine;
                    // Display message properties that are set on the brokered message.
                    MyRawMessageTB.Text += Utility.GetPrintMessageProperties(message.Properties);
                    // Display body details.
                    MyRawMessageTB.Text += Utility.GetPrint(context);
                    MyRawMessageTB.Text += "--------------------------------" + Environment.NewLine;
                    MySV.ScrollToBottom();

                    messageList.Add(new MessageFromCRM
                    {
                        MessageId       = message.MessageId,
                        EnqueuedTimeUtc = message.EnqueuedTimeUtc,
                        Size            = message.Size,
                        Properties      = message.Properties,
                        InputEntity     = (Entity)context.InputParameters["Target"],
                        PreEntity       = context.PreEntityImages.Keys.Contains("Target") ? context.PreEntityImages?["Target"]: null,
                        PostEntity      = context.PostEntityImages.Keys.Contains("Target") ? context.PostEntityImages["Target"]: null
                    });
                }));
            });
        }
Ejemplo n.º 5
0
        public string Execute(RemoteExecutionContext executionContext)
        {
            Log($"\nMessage received at {DateTime.Now}");
            var rv = new Response {
                Message = "Unknown Error", Result = "0", Status = 500
            };
            var operation = "Unknown";

            try
            {
                operation = (string)executionContext.SharedVariables["Operation"];
                Log($"processing Operation: {operation}");

                if (MessageProcessors.ContainsKey(operation))
                {
                    rv = MessageProcessors[operation].ProcessMessage(executionContext);
                }
                else
                {
                    Log($"Unknown operation request {operation}");
                    rv.Message = $"unknown operation: {operation}";
                    rv.Status  = 501;
                }
            }
            catch (Exception ex)
            {
                Log($"Error processing operation {operation}");
                rv.Message = $"Error processing: {operation} {ex.Message}";
            }

            Log($"\nMessage processing completed received at {DateTime.Now}");
            return(rv.ToJson());
        }
        public void TestEventTelemetry()
        {
            var telemetry = new Microsoft.ApplicationInsights.TelemetryClient {
                InstrumentationKey = "2119853a-bc51-429e-962d-4b7f9cda9a3f"
                                     .ToString()
            };

            for (int i = 0; i < 1000; i++)
            {
                EventTelemetry         eventTelemetry = new EventTelemetry();
                DateTime               dt             = DateTime.Now;
                RemoteExecutionContext context        = new RemoteExecutionContext();
                eventTelemetry.Name = "TestEventTelemetry";
                //eventTelemetry.Properties.Add(new KeyValuePair<string, string>("", ));
                eventTelemetry.Properties.Add("InitiatingUserId", context.InitiatingUserId.ToString());
                eventTelemetry.Properties.Add("RequestId", context.RequestId.ToString());
                eventTelemetry.Properties.Add("OperationId", context.OperationId.ToString());
                eventTelemetry.Properties.Add("CorrelationId", context.CorrelationId.ToString());
                eventTelemetry.Properties.Add("MessageName", context.MessageName);
                eventTelemetry.Properties.Add("OrganizationId", context.OrganizationId.ToString());
                eventTelemetry.Properties.Add("PrimaryEntityId", context.PrimaryEntityId.ToString());
                eventTelemetry.Properties.Add("Stage", context.Stage.ToString());
                eventTelemetry.Properties.Add("UserId", context.UserId.ToString());
                telemetry.TrackEvent(eventTelemetry);
            }
            telemetry.Flush();
        }
        public override Task ExecuteAsync()
        {
            TokenProvider credentials = TokenProvider.CreateSharedSecretTokenProvider(IssuerName, IssuerSecret);

            MessagingFactory factory       = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", ServiceNamespace, string.Empty), credentials);
            QueueClient      myQueueClient = factory.CreateQueueClient(QueueName);

            //Get the message from the queue
            BrokeredMessage message;

            while ((message = myQueueClient.Receive(new TimeSpan(0, 0, 5))) != null)
            {
                RemoteExecutionContext ex = message.GetBody <RemoteExecutionContext>();

                Entity pushNotification = (Entity)ex.InputParameters["Target"];

                //Make sure Recipient is populated
                var ownerId = pushNotification.GetAttributeValue <EntityReference>("lat_recipient").Id.ToString();
                var subject = pushNotification.GetAttributeValue <string>("lat_message");

                SendNotificationAsync(subject, ownerId);
                message.Complete();
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 8
0
        static async Task ProcessMessagesAsync(Message message, CancellationToken token)
        {
            string keyRoot = "http://schemas.microsoft.com/xrm/2011/Claims/";
            string entityLogicalNameKey = "EntityLogicalName";
            string requestNameKey       = "RequestName";
            object entityLogicalNameValue;
            object requestNameValue;

            message.UserProperties.TryGetValue(keyRoot + entityLogicalNameKey, out entityLogicalNameValue);
            message.UserProperties.TryGetValue(keyRoot + requestNameKey, out requestNameValue);

            if (entityLogicalNameValue != null && requestNameValue != null)
            {
                if (entityLogicalNameValue.ToString() == "new_searchengine" && requestNameValue.ToString() == "Create")
                {
                    Console.WriteLine(string.Format("Message received: Id = {0}", message.MessageId));

                    Utility.PrintMessageProperties(message.UserProperties);

                    Console.WriteLine($"Content Type:{message.ContentType}");

                    if (message.ContentType == "application/msbin1")
                    {
                        DataContractSerializer serializer = new DataContractSerializer(typeof(RemoteExecutionContext));

                        using (MemoryStream ms = new MemoryStream(message.Body))
                        {
                            XmlDictionaryReader    reader  = XmlDictionaryReader.CreateBinaryReader(ms, XmlDictionaryReaderQuotas.Max);
                            RemoteExecutionContext context = (RemoteExecutionContext)serializer.ReadObject(reader);
                            Utility.Print(context);
                        }
                    }
                    else if (message.ContentType == "application/json")
                    {
                        var ctx = Activator.CreateInstance <RemoteExecutionContext>();

                        using (MemoryStream ms = new MemoryStream(message.Body))
                        {
                            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RemoteExecutionContext));
                            ctx = (RemoteExecutionContext)serializer.ReadObject(ms);
                            Utility.Print(ctx);
                        }
                    }
                    else
                    {
                        throw new NotImplementedException($"Content type: {message.ContentType} has not been implemented.");
                    }
                }
            }

            // Complete the message so that it is not received again.
            // This can be done only if the queueClient is created in ReceiveMode.PeekLock mode (which is default).
            await queueClient.CompleteAsync(message.SystemProperties.LockToken);

            // Note: Use the cancellationToken passed as necessary to determine if the queueClient has already been closed.
            // If queueClient has already been Closed, you may chose to not call CompleteAsync() or AbandonAsync() etc. calls
            // to avoid unnecessary exceptions.
        }
        protected override Response ProcessSpecificMessage(RemoteExecutionContext context)
        {
            Log($"Starting processing Ping request");
            var value = context.SharedVariables[SharedVariables.PingVal] as string;

            Log($"Ping value {value}");

            return(new Response {
                Result = value
            });
        }
Ejemplo n.º 10
0
        public ContactCreate(RemoteExecutionContext context)
        {
            ContactId   = context.PrimaryEntityId;
            CreatedById = context.InitiatingUserId;
            CreateDate  = context.OperationCreatedOn;

            //We can cast the 'Target' to a late bound CRM Entity type to parse it a bit easier.
            Entity entity = (Entity)context.InputParameters["Target"];

            FullName  = entity.GetCrmValue("fullname");
            FirstName = entity.GetCrmValue("firstname");
            LastName  = entity.GetCrmValue("lastname");
            Address   = entity.GetCrmValue("address1_composite");
            Email     = entity.GetCrmValue("emailaddress1");
        }
Ejemplo n.º 11
0
        public static void Run([ServiceBusTrigger("cpsisvsbsqueue", AccessRights.Listen, Connection = "AzureServiceBusConnection")] BrokeredMessage myQueueItem, TraceWriter log)
        {
            log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");


            RemoteExecutionContext contextFromJSON = myQueueItem.GetBody <RemoteExecutionContext>(
                new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(RemoteExecutionContext)));

            EntityImageCollection entityImageCollection = contextFromJSON.PostEntityImages;

            Entity entityobject = (Entity)contextFromJSON.InputParameters["Target"];

            BaseEntity baseentity             = null;
            object     _entity                = null;
            string     entityPrimaryKeyColumn = string.Empty;

            switch (entityobject.LogicalName.ToLower())
            {
            case "lead":
                baseentity             = new TransformLeadEntity();
                _entity                = (LeadEntity)baseentity.TransformEntity(entityobject);
                entityPrimaryKeyColumn = "LeadId";
                break;

            default:
                break;
            }


            SQLHelper sqlhelper = new SQLHelper(entityPrimaryKeyColumn);

            sqlhelper.Execute(_entity, baseentity.EntityName);


            //foreach (KeyValuePair<string, object> parameter in entityobject.Attributes)
            //{

            //    //Write code here to transform the data into SQL
            //}

            //EntityImageCollection entityImageCollection = contextFromJSON.PostEntityImages;

            //foreach (KeyValuePair<string, Entity> entityImage in entityImageCollection)
            //{
            //    //Write code here to transform the data into SQL
            //}
        }
Ejemplo n.º 12
0
            public static string GetPrint(RemoteExecutionContext context)
            {
                string text = "";

                if (context == null)
                {
                    text += "Context is null." + Environment.NewLine;
                    return(text);
                }

                text += string.Format("UserId: {0}\n", context.UserId);
                text += string.Format("OrganizationId: {0}\n", context.OrganizationId);
                text += string.Format("OrganizationName: {0}\n", context.OrganizationName);
                text += string.Format("MessageName: {0}\n", context.MessageName);
                text += string.Format("Stage: {0}\n", context.Stage);
                text += string.Format("Mode: {0}\n", context.Mode);
                text += string.Format("PrimaryEntityName: {0}\n", context.PrimaryEntityName);
                text += string.Format("SecondaryEntityName: {0}\n", context.SecondaryEntityName);

                text += string.Format("BusinessUnitId: {0}\n", context.BusinessUnitId);
                text += string.Format("CorrelationId: {0}\n", context.CorrelationId);
                text += string.Format("Depth: {0}\n", context.Depth);
                text += string.Format("InitiatingUserId: {0}\n", context.InitiatingUserId);
                text += string.Format("IsExecutingOffline: {0}\n", context.IsExecutingOffline);
                text += string.Format("IsInTransaction: {0}\n", context.IsInTransaction);
                text += string.Format("IsolationMode: {0}\n", context.IsolationMode);
                text += string.Format("Mode: {0}\n", context.Mode);
                text += string.Format("OperationCreatedOn: {0}\n", context.OperationCreatedOn.ToString());
                text += string.Format("OperationId: {0}\n", context.OperationId);
                text += string.Format("PrimaryEntityId: {0}\n", context.PrimaryEntityId);
                text += string.Format("OwningExtension LogicalName: {0}\n", context.OwningExtension.LogicalName);
                text += string.Format("OwningExtension Name: {0}\n", context.OwningExtension.Name);
                text += string.Format("OwningExtension Id: {0}\n", context.OwningExtension.Id);
                text += string.Format("SharedVariables: {0}\n", (context.SharedVariables == null ? "NULL" :
                                                                 SerializeParameterCollection(context.SharedVariables)));
                text += string.Format("InputParameters: {0}\n", (context.InputParameters == null ? "NULL" :
                                                                 SerializeParameterCollection(context.InputParameters)));
                text += string.Format("OutputParameters: {0}\n", (context.OutputParameters == null ? "NULL" :
                                                                  SerializeParameterCollection(context.OutputParameters)));
                text += string.Format("PreEntityImages: {0}\n", (context.PreEntityImages == null ? "NULL" :
                                                                 SerializeEntityImageCollection(context.PreEntityImages)));
                text += string.Format("PostEntityImages: {0}\n", (context.PostEntityImages == null ? "NULL" :
                                                                  SerializeEntityImageCollection(context.PostEntityImages)));

                return(text);
            }
Ejemplo n.º 13
0
        public static void ProcessMessages(RemoteExecutionContext context, IOrganizationService service)
        {
            Guid   entityId   = new Guid(context.SharedVariables["EntityId"].ToString());
            string entityType = context.SharedVariables["EntityType"].ToString();
            Guid   campaignId = new Guid(context.SharedVariables["CampaignId"].ToString());
            Guid   activityId = new Guid(context.SharedVariables["ActivityId"].ToString());

            Entity campresp = new Entity(EntityName.CampaignResponse);

            campresp[CampaignResponseAttributes.RegardingObjectId] = new EntityReference(EntityName.Campaign, campaignId);
            Entity customer = new Entity(EntityName.ActivityParty);

            customer[ActivityPartyAttributes.PartyId]     = new EntityReference(entityType, entityId);
            campresp[CampaignResponseAttributes.Customer] = new EntityCollection(new Entity[] { customer });
            campresp[CampaignResponseAttributes.Subject]  = "Response via matchpoint";
            service.Create(campresp);
        }
        // This function will get triggered/executed when a new message is written
        // on an Azure Queue called queue.

        /*  public static void processservicebus(
         * [ServiceBusTrigger("messages")]string myQueueItem,
         * ILogger log)
         * {
         *  log.LogInformation(myQueueItem);
         * }*/

        public static void processServiceBus(
            [ServiceBusTrigger("messages")] RemoteExecutionContext remoteExecutionContext,
            ILogger log)
        {
            log.LogInformation("===================Message Start========================");
            Contact contact = ((Entity)remoteExecutionContext.InputParameters["Target"]).ToEntity <Contact>();

            log.LogInformation("==================Contact Details======================");
            log.LogInformation("Client Name:\t" + contact.abc_IndividualClientName == null && contact.abc_IndividualClientName == "" ? contact.abc_CorporateClientName : contact.abc_IndividualClientName);
            log.LogInformation("Joining Date\t" + contact.abc_JoiningDate.ToString());
            log.LogInformation("Maturity Date\t" + contact.abc_MaturityDate.ToString());
            log.LogInformation("Initial Investment\t" + contact.abc_InitialInvestment.Value.ToString());
            log.LogInformation("Investment Period\t" + contact.abc_InvestmentPeriod.ToString());
            log.LogInformation("Interest Rate\t" + contact.abc_InterestRate.ToString());
            log.LogInformation("Estimated Return \t" + contact.abc_EstimatedReturn.Value.ToString());
            log.LogInformation("===================Message End========================");
        }
Ejemplo n.º 15
0
        private async Task PassContextToPlugins(RemoteExecutionContext executionContext)
        {
            foreach (var plugin in Plugins)
            {
                var serviceProvider = new CrmServiceProvider(CrmPluginBrokerRole.Crm, executionContext);

                try
                {
                    await Task.Run(() => plugin.Execute(serviceProvider));
                }
                catch (Exception)
                {
                    Trace.TraceError(String.Format("Failed processing plugin: {0}", plugin.GetType()));

                    throw;
                }
            }
        }
Ejemplo n.º 16
0
            /// <summary>
            /// Writes out the RemoteExecutionContext to the Console.
            /// </summary>
            /// <param name="context"></param>
            public static void Print(RemoteExecutionContext context)
            {
                Console.WriteLine("----------");
                if (context == null)
                {
                    Console.WriteLine("Context is null.");
                    return;
                }

                Console.WriteLine("UserId: {0}", context.UserId);
                Console.WriteLine("OrganizationId: {0}", context.OrganizationId);
                Console.WriteLine("OrganizationName: {0}", context.OrganizationName);
                Console.WriteLine("MessageName: {0}", context.MessageName);
                Console.WriteLine("Stage: {0}", context.Stage);
                Console.WriteLine("Mode: {0}", context.Mode);
                Console.WriteLine("PrimaryEntityName: {0}", context.PrimaryEntityName);
                Console.WriteLine("SecondaryEntityName: {0}", context.SecondaryEntityName);

                Console.WriteLine("BusinessUnitId: {0}", context.BusinessUnitId);
                Console.WriteLine("CorrelationId: {0}", context.CorrelationId);
                Console.WriteLine("Depth: {0}", context.Depth);
                Console.WriteLine("InitiatingUserId: {0}", context.InitiatingUserId);
                Console.WriteLine("IsExecutingOffline: {0}", context.IsExecutingOffline);
                Console.WriteLine("IsInTransaction: {0}", context.IsInTransaction);
                Console.WriteLine("IsolationMode: {0}", context.IsolationMode);
                Console.WriteLine("Mode: {0}", context.Mode);
                Console.WriteLine("OperationCreatedOn: {0}", context.OperationCreatedOn.ToString());
                Console.WriteLine("OperationId: {0}", context.OperationId);
                Console.WriteLine("PrimaryEntityId: {0}", context.PrimaryEntityId);
                Console.WriteLine("OwningExtension LogicalName: {0}", context.OwningExtension.LogicalName);
                Console.WriteLine("OwningExtension Name: {0}", context.OwningExtension.Name);
                Console.WriteLine("OwningExtension Id: {0}", context.OwningExtension.Id);
                Console.WriteLine("SharedVariables: {0}", (context.SharedVariables == null
                    ? "NULL" : SerializeParameterCollection(context.SharedVariables)));
                Console.WriteLine("InputParameters: {0}", (context.InputParameters == null
                    ? "NULL" : SerializeParameterCollection(context.InputParameters)));
                Console.WriteLine("OutputParameters: {0}", (context.OutputParameters == null
                    ? "NULL" : SerializeParameterCollection(context.OutputParameters)));
                Console.WriteLine("PreEntityImages: {0}", (context.PreEntityImages == null
                    ? "NULL" : SerializeEntityImageCollection(context.PreEntityImages)));
                Console.WriteLine("PostEntityImages: {0}", (context.PostEntityImages == null
                    ? "NULL" : SerializeEntityImageCollection(context.PostEntityImages)));
                Console.WriteLine("----------");
            }
        public static RemoteExecutionContext CopyContext(this IPluginExecutionContext context)
        {
            if (context == null)
            {
                return(null);
            }

            var executionContext = new RemoteExecutionContext {
                BusinessUnitId   = context.BusinessUnitId,
                CorrelationId    = context.CorrelationId,
                Depth            = context.Depth,
                InitiatingUserId = context.InitiatingUserId
            };

            CopyParameterCollection(context.InputParameters, executionContext.InputParameters);
            executionContext.IsExecutingOffline = context.IsExecutingOffline;
            executionContext.IsOfflinePlayback  = context.IsOfflinePlayback;
            executionContext.IsInTransaction    = context.IsInTransaction;
            executionContext.IsolationMode      = context.IsolationMode;
            executionContext.MessageName        = context.MessageName;
            executionContext.Mode = context.Mode;
            executionContext.OperationCreatedOn = context.OperationCreatedOn;
            executionContext.OperationId        = context.OperationId;
            executionContext.OrganizationId     = context.OrganizationId;
            executionContext.OrganizationName   = context.OrganizationName;
            CopyParameterCollection(context.OutputParameters, executionContext.OutputParameters);
            executionContext.OwningExtension = context.OwningExtension;
            CopyEntityImageCollection(context.PreEntityImages, executionContext.PreEntityImages);
            CopyEntityImageCollection(context.PostEntityImages, executionContext.PostEntityImages);
            executionContext.PrimaryEntityId     = context.PrimaryEntityId;
            executionContext.PrimaryEntityName   = context.PrimaryEntityName;
            executionContext.SecondaryEntityName = context.SecondaryEntityName;
            CopyParameterCollection(context.SharedVariables, executionContext.SharedVariables);
            executionContext.UserId        = context.UserId;
            executionContext.RequestId     = context.RequestId;
            executionContext.Stage         = context.Stage;
            executionContext.ParentContext = CopyContext(context.ParentContext);
            return(executionContext);
        }
Ejemplo n.º 18
0
        /// This Execute method will execute automatically whenever a message has been passed
        /// to the service bus.
        /// In realworld scenarios this would become a backend worker role and will call the
        /// third party services to get the details.
        /// We can use the executionContext Object to get the details of the CRM object
        public string Execute(RemoteExecutionContext executionContext)
        {
            string result = string.Empty;

            Console.WriteLine("----------");
            string message = "";

            if (executionContext.SharedVariables.Contains("Account"))
            {
                Console.WriteLine("Get Account Information...");
                Entity account = executionContext.SharedVariables["Account"] as Entity;

                if (executionContext.MessageName.Equals("create", StringComparison.OrdinalIgnoreCase))
                {
                    result  = CreateAccount(account);
                    message = result; // "Account Record Created";
                }
                else if (executionContext.MessageName.Equals("create", StringComparison.OrdinalIgnoreCase))
                {
                    result  = UpdateAccount(account);
                    message = result; // "Account Record Update";
                }
                else
                {
                    message = "No Action performed on Account Record";
                    result  = message;
                }
            }


            Console.WriteLine($"result - {message}");
            EventLog.WriteEntry("CDSWDXListenerSource", $"result - {message}", EventLogEntryType.Information);
            Console.WriteLine("----------");


            return(message);
        }
Ejemplo n.º 19
0
        private static void Consumer_RemoteCall(object sender, RemoteExecutionContext context)
        {
            Entity entity = context.InputParameters["Target"] as Entity;

            if (entity != null)
            {
                if (context.PrimaryEntityName == "account")
                {
                    var name = entity.GetAttributeValue <string>("name");
                    Balloon.Show("New account!", name);
                }
                else if (context.PrimaryEntityName == "contact")
                {
                    var name = entity.GetAttributeValue <string>("fullname");
                    Balloon.Show("New contact!", name);
                }
                else if (context.PrimaryEntityName == "opportunity")
                {
                    var    est   = entity.GetAttributeValue <Money>("estimatedvalue");
                    string value = est == null ? "unknown value":est.Value.ToString("C", CultureInfo.CurrentCulture);
                    Balloon.Show(entity.GetAttributeValue <string>("name"), value);
                }
            }
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");


            //Read webhook data into a string
            string data = await new StreamReader(req.Body).ReadToEndAsync();

            //convert to remote execution Entity Object
            RemoteExecutionContext remoteExecutionContext = DeserializeJsonString <RemoteExecutionContext>(data);
            Entity entityInContext = (Entity)remoteExecutionContext.InputParameters["Target"];

            Guid entityId = entityInContext.Id;

            var entityRecordFromCrm = _processInfo.ReturnMyRequestedEntity(entityId);

            string responseMessage = string.IsNullOrEmpty(entityRecordFromCrm.LogicalName)
                ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello, user. This HTTP triggered function executed successfully.";

            return(new OkObjectResult(responseMessage));
        }
Ejemplo n.º 21
0
 /// <summary>
 /// This method is called when a message is posted to the Azure Service Bus.
 /// </summary>
 /// <param name="context">Data for the request.</param>
 /// <returns>A 'Success' string.</returns>
 public string Execute(RemoteExecutionContext context)
 {
     Utility.Print(context);
     return("Success");
 }
Ejemplo n.º 22
0
 /// <summary>
 /// This method is called when a message is posted to the Azure Service Bus.
 /// </summary>
 /// <param name="context">Data for the request.</param>
 /// <returns>A 'Success' string.</returns>
 public string Execute(RemoteExecutionContext context)
 {
     Utility.Print(context);
     return "Success";
 }
 public void Execute(RemoteExecutionContext context)
 {
     Utility.Print(context);
 }
Ejemplo n.º 24
0
        public static void Print(RemoteExecutionContext context)
        {
            Console.WriteLine("----------");
            if (context == null)
            {
                Console.WriteLine("Context is null.");
                return;
            }

            Console.WriteLine("UserId: {0}", context.UserId);
            Console.WriteLine("OrganizationId: {0}", context.OrganizationId);
            Console.WriteLine("OrganizationName: {0}", context.OrganizationName);
            Console.WriteLine("MessageName: {0}", context.MessageName);
            Console.WriteLine("Stage: {0}", context.Stage);
            Console.WriteLine("Mode: {0}", context.Mode);
            Console.WriteLine("PrimaryEntityName: {0}", context.PrimaryEntityName);
            Console.WriteLine("SecondaryEntityName: {0}", context.SecondaryEntityName);

            Console.WriteLine("BusinessUnitId: {0}", context.BusinessUnitId);
            Console.WriteLine("CorrelationId: {0}", context.CorrelationId);
            Console.WriteLine("Depth: {0}", context.Depth);
            Console.WriteLine("InitiatingUserId: {0}", context.InitiatingUserId);
            Console.WriteLine("IsExecutingOffline: {0}", context.IsExecutingOffline);
            Console.WriteLine("IsInTransaction: {0}", context.IsInTransaction);
            Console.WriteLine("IsolationMode: {0}", context.IsolationMode);
            Console.WriteLine("Mode: {0}", context.Mode);
            Console.WriteLine("OperationCreatedOn: {0}", context.OperationCreatedOn.ToString());
            Console.WriteLine("OperationId: {0}", context.OperationId);
            Console.WriteLine("PrimaryEntityId: {0}", context.PrimaryEntityId);
            Console.WriteLine("OwningExtension LogicalName: {0}", context.OwningExtension.LogicalName);
            Console.WriteLine("OwningExtension Name: {0}", context.OwningExtension.Name);
            Console.WriteLine("OwningExtension Id: {0}", context.OwningExtension.Id);
            Console.WriteLine("SharedVariables: {0}", (context.SharedVariables == null ? "NULL" :
                SerializeParameterCollection(context.SharedVariables)));
            Console.WriteLine("InputParameters: {0}", (context.InputParameters == null ? "NULL" :
                SerializeParameterCollection(context.InputParameters)));
            Console.WriteLine("OutputParameters: {0}", (context.OutputParameters == null ? "NULL" :
                SerializeParameterCollection(context.OutputParameters)));
            Console.WriteLine("PreEntityImages: {0}", (context.PreEntityImages == null ? "NULL" :
                SerializeEntityImageCollection(context.PreEntityImages)));
            Console.WriteLine("PostEntityImages: {0}", (context.PostEntityImages == null ? "NULL" :
                SerializeEntityImageCollection(context.PostEntityImages)));
            Console.WriteLine("----------");
        }
Ejemplo n.º 25
0
 public void Execute(RemoteExecutionContext context)
 {
     Utility.Print(context);
 }
 public void Execute(RemoteExecutionContext executionContext)
 {
 }
Ejemplo n.º 27
0
 void PrintExecutionContext(RemoteExecutionContext context)
 {
 }
Ejemplo n.º 28
0
 public Response ProcessMessage(RemoteExecutionContext context)
 {
     Log($"Starting generic ProcessMessage");
     return(ProcessSpecificMessage(context));
 }
Ejemplo n.º 29
0
 protected abstract Response ProcessSpecificMessage(RemoteExecutionContext context);
Ejemplo n.º 30
-1
 public void Execute(RemoteExecutionContext executionContext)
 {
     Console.WriteLine("Event received");
 }