private static void Main(string[] args)
        {
            string login = string.Empty;
            string password = string.Empty;

            Console.WriteLine("Enter your RegOnline login followed by [Enter] to begin.");
            login = Console.ReadLine();
            Console.WriteLine("Enter your RegOnline password followed by [Enter].");
            password = Console.ReadLine();

            try
            {
                using (
                    RegOnlineAPIProxy.RegOnlineAPISoapClient service =
                        new RegOnlineAPIProxy.RegOnlineAPISoapClient("RegOnline APISoap"))
                {
                    RegOnlineAPIProxy.ResultsOfLoginResults loginResults = service.Login(login, password);

                    if (loginResults.Success
                        && loginResults.Data != null
                        && !string.IsNullOrEmpty(loginResults.Data.APIToken))
                    {
                        string apiToken = loginResults.Data.APIToken;
                        Console.WriteLine("{0}apiToken = {1}", System.Environment.NewLine, apiToken);

                        using (OperationContextScope scope = new OperationContextScope(service.InnerChannel))
                        {
                            //add APIToken HTTP Header
                            HttpRequestMessageProperty apiTokenHeader = new HttpRequestMessageProperty();
                            apiTokenHeader.Headers.Add("APIToken", apiToken);
                            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                                apiTokenHeader;

                            createCustomFieldResponses(service);

                            service.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error{0}{1}", System.Environment.NewLine, ex);
            }

            Console.WriteLine(System.Environment.NewLine);
            Console.WriteLine("Press [Enter] to exit.");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string login = string.Empty;
            string password = string.Empty;

            Console.WriteLine("Enter your RegOnline login followed by [Enter] to begin.");
            login = Console.ReadLine();
            Console.WriteLine("Enter your RegOnline password followed by [Enter].");
            password = Console.ReadLine();

            try
            {
                using (RegOnlineAPIProxy.RegOnlineAPISoapClient service = new RegOnlineAPIProxy.RegOnlineAPISoapClient("RegOnline APISoap"))
                {
                    RegOnlineAPIProxy.ResultsOfLoginResults loginResults = service.Login(login, password);

                    if (loginResults.Success 
                        && loginResults.Data != null 
                        && !string.IsNullOrEmpty(loginResults.Data.APIToken))
                    {
                        string apiToken = loginResults.Data.APIToken;
                        Console.WriteLine("{0}apiToken = {1}", System.Environment.NewLine, apiToken);

                        using (OperationContextScope scope = new OperationContextScope(service.InnerChannel))
                        {
                            //add APIToken HTTP Header
                            HttpRequestMessageProperty apiTokenHeader = new HttpRequestMessageProperty();
                            apiTokenHeader.Headers.Add("APIToken", apiToken);
                            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = apiTokenHeader;

                            #region GetEvents example

                            // Call GetEvents for events with active status created after 1/1/2012, sorted by ID ascending.
                            // With the API Token passed as an HTTP Header (above) instead of a SOAP Header, the first parameter for GetEvents below can be null.
                            RegOnlineAPIProxy.ResultsOfListOfEvent getEventResults = service.GetEvents(null, "IsActive && AddDate >= DateTime(2012, 1, 1)", "ID ASC");

                            if (getEventResults.Success)
                            {
                                foreach (var result in getEventResults.Data)
                                {
                                    Console.WriteLine("Event: {0} (ID: {1}) - MediaType: {2}", result.Title, result.ID, result.MediaType);
                                }

                                Console.WriteLine(System.Environment.NewLine);
                            }
                            else
                            {
                                Console.WriteLine("{0}{1}{0}Error retreiving GetEvents results: {2}{0}{1}{0}"
                                    , System.Environment.NewLine, "*****", getEventResults.Message);
                            }

                            #endregion

                            Console.WriteLine("Would you like to upsert a registrant's custom field response for a multiple choice custom field?  Press y followed by [Enter] to continue or [Enter] to exit.");
                            bool updateCustomFieldResponse = (Console.ReadLine() == "y");

                            if (updateCustomFieldResponse)
                            {
                                UpsertMultipleChoiceCustomFieldResponse(service);                                
                            }
                            else
                            {
                                return;
                            }

                            service.Close();
                        }
                    }
                    else
                    {
                        Console.WriteLine("{0}{1}{0}Login failure: {2}{0}{1}{0}"
                            , System.Environment.NewLine, "*****", loginResults.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error{0}{1}", System.Environment.NewLine, ex);
            }

            Console.WriteLine(System.Environment.NewLine);
            Console.WriteLine("Press [Enter] to exit.");
            Console.ReadLine();
        }