Skip to content

Describes how to send an event through the Whatsnexx.TicketBus from a C# project

Notifications You must be signed in to change notification settings

whatsnexx/C_Sharp_Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Send Events Using C#

Describes how to send an event through the Whatsnexx.TicketBus from a Console application in Visual Studio.

View examples in PHP and Java.

Getting Started

The whatsnexx ticketbus handles REST and SOAP Web Service request to send events. In this example, we will demonstrate how to send and event to the Whatsnexx ticketbus using a WCF client. If you are not familiar with WCF, the MSDN documentation can be found here. You will need following to send a request to the ticketbus service.

AttributeTypeDescription
Account IdGUID Provided by Whatsnexx.
Username:GUIDProvided by Whatsnexx.
Password:GUIDProvided by Whatsnexx.
TermName:stringThis is the name of the event that is to be triggered by the send event.
SubjectCode:stringThe unique identifier for your [subject](). This usually represents who you would like to send the event to.
SubjectTypeId:GUIDA unique identitfier for the subject type. The subject type defines the context under which events are sent.
ExecutionEnvironment:TicketBusService.ExecutionEnvironmentsSpecifies the Whatsnexx environment you are sending the event request. A Constellation must exist in the chosen environment for the event to be triggered. The available Environments are: Test, Stage, and Production.
Attributes:TicketBusService.Attributes[]A list of attributes that are used by the event.
Steps ----------------
  1. Open Visual Studio and create a new Console Application.
    1. In the File menu point to New and click Protect. A New Project dialog box will appear.
    2. In the New Project dialog box, select Visual C# from the Installed Templates box, and select Console Application from the list provided
    3. Enter the 'CSharpExample' in the Name box and enter the location you would like to save the project in the Location box.
    4. Click OK
  2. Add a Service Reference for the Whatsnexx TicketBusService
    1. In the Solution Explorer right click on References in the project CSharpExample and left click on Add Service Reference. The Add Service Reference dialog box will open.
    2. Enter 'https://ticketbus.whatsnexx.com/TicketBusService.svc' in the Address box and click Go. TicketBusService will appear shortly.
    3. Enter 'TicketBusService' in the Namespace box and click OK. The Service Model reference will be added to the the project References and the Service References will appear with TicketBusService added as a service.
      • To view the service API, double click on TicketBusService under Service References. The Object Browser will appear.
      • Expand CSharpExample.TicketBusService and select objects in the explorer to view the methods available.
  3. Modify Program.cs as follows and run the application. A console window will appear showing the service was called successfully.
using System;
using Attribute = CSharpExample.TicketBusService.Attribute;
using CSharpExample.TicketBusService;
namespace CSharpExample
{
    public class SendEvent
    {
        
        public static void Main(string[] args)
        {
            //AccountId: GUID Provided by Whatsnexx. 
            //Username: GUID Provided by Whatsnexx.
            //Password: GUID Provided by Whatsnexx.
            //TermName: String This is the name of the event that is to be triggered by the send event.
            //SubjectCode: (Hash value)The unique identifier for your subject(). This usually represents who you would like to send the event to.
            //SubjectTypeId: GUID A unique identitfier for the subject type. The subject type defines the context under which events are sent.
            //ExecutionEnvironment: TicketbusService.ExecutionEnvironment Specifies the Whatsnexx environment you are sending the event request. A <code>Constellation</code> must exist in the chosen environment for the event to be triggered. The available Environments are: Test, Stage, and Production.
            //Attributes: TicketBusService.AttributeList A list of attributes that are used by the event.

            const string userName = "{Your Username}";
            const string password = "{Your Password}";
            const string accountId = "{Your Account Id}";
            const string subjectTypeId = "{Your Subject Id}";
            const string termName = "{Your TermName}";

            //create out objects
            TicketBusResponse response;
            string transactionId;

            var ticketBusSendEvent = new TicketBusSendEvent
            {
                Attributes = new[] {
                    new Attribute {Name = "Test", Value = "Value1"}, 
                    new Attribute {Name = "Email", Value = "[email protected]"}},
                SubjectCode = "TestCode"
            };

            var client = new TicketBusServiceClient
            {
                ClientCredentials =
                {
                    UserName =
                    {
                        UserName = userName,
                        Password = password
                    }
                }
            };

            var success = client.SendEvent( accountId, ExecutionEnvironments.Stage,
                subjectTypeId, termName, ticketBusSendEvent, out response, out transactionId);

            Console.WriteLine("Worked: " + success + Environment.NewLine + "TransactionId: " + transactionId);
            Console.ReadKey();
        }
    }
}

Getting Help

Whatsnexx Full Documentation
MSDN: Windows Communication Foundation (WCF)


Top

About

Describes how to send an event through the Whatsnexx.TicketBus from a C# project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages