Click or drag to resize

AdministrationClientLoadMemberBatch Method

Submitting a single file or multiple files containing Members.

If more than 1 file is being submitted, the set the value for BatchOStagingMember.Final = 1

Optimum number of Member rows per file is 20.

This method is a step in the workflow for Member File Batch submission.

Remarks
Member File Batch submission workflow:
  • Initialise Batch - call Web Service Method: OpenMemberBatch
  • Submit Member File(s) - call Web Service Method: LoadMemberBatch
  • Monitor submitted Member Batch Progress - call Web Service Method: QueryMemberBatch
  • Stop The Member Batch Processing - call Web Service Method: CancelMemberBatch
  • Analyse the final results of The Member Batch Processing - call Web Service Method: ReportMemberBatch
Syntax
C#
public ResultOfBatch LoadMemberBatch(
	ManagementGroupRequestOfBatchOfStagingMember LoadBatch
)

Parameters

LoadBatch
Type: AdministrationServiceManagementGroupRequestOfBatchOfStagingMember

Return Value

Type: ResultOfBatch
Examples
C#
using (var svc = new AdministrationService.AdministrationClient())
{
  var request = new AdministrationService.ManagementGroupRequestOfBatchOfStagingMember();
  request.Token = "Token";//Required - Token returned from AccountService.ManagementGroupLogin
  request.ManagementGroup = "Management group";//Required - ManagementGroup supplied when calling AccountService.ManagementGroupLogin

  var stagingMemberList = new List<AdministrationService.StagingMember>();

  var batch_RSN = new Guid("a4c7dd6f-3427-4222-91cb-a3b122623bf5");;// Returned from AdministrationService.OpenMemberBatch (ResultOfBatch.Key)        

  for (int i = 0; i < 50; i++) // loop through records for batch creation e.g. 50 records
  {
    var stagingMember = new AdministrationService.StagingMember();
    stagingMember.BatchControlRSN = batch_RSN;//Required - Returned from AdministrationService.OpenMemberBatch (ResultOfBatch.Key)        
    stagingMember.BalanceToLoad = 20.00m;//Optional - loads points against new member
    stagingMember.ImportFile_RowNumber = 0;//Optional
    stagingMember.ConfirmationEmailTemplate = "CONFIRMATION_EMAIL_TEMPLATE";//Optional 
    stagingMember.ProviderID = "";//Optional
    stagingMember.RecipientID = "";//Optional
    stagingMember.SingleViewID = "";//Optional

    //Name info
    stagingMember.Title = "Mr"; // Valid values are : 'Dr', 'Sir', 'Lady', 'Mr', 'Miss', 'Ms' or 'Mrs' (case sensitive)";
    stagingMember.GivenName = "John"; // Required        
    stagingMember.MiddleName = "David"; // Optional
    stagingMember.FamilyName = "Doe"; // Required
    stagingMember.Gender_KeyCode = "MALE"; //Required - Valid values are : 'MALE', 'FEMALE' or 'DONOTKNOW'
    stagingMember.DateOfBirth = new DateTime(1950, 12, 25); // Optional
    stagingMember.CompanyName = "";//Optional

    //Contact Info
    stagingMember.PostalAddress_Line1 = "Level 1, Simplicity Building"; // Required
    stagingMember.PostalAddress_Line2 = "14-22 Triton Drive"; // Optional     
    stagingMember.PostalAddress_Suburb = "Albany"; // Required
    stagingMember.PostalAddress_TownCityState = "Auckland"; // Required
    stagingMember.PostalAddress_PostCode = "0632"; // Required
    stagingMember.PostalAddress_Country = "New Zealand"; // Required     
    stagingMember.ShipToAttentionTo = "";// Optional

    stagingMember.BillingAddress_Line1 = "Level 1, Simplicity Building"; // Optional
    stagingMember.BillingAddress_Line2 = "14-22 Triton Drive"; // Optional     
    stagingMember.BillingAddress_Suburb = "Albany"; // Optional
    stagingMember.BillingAddress_TownCityState = "Auckland"; // Optional
    stagingMember.BillingAddress_PostCode = "0632"; // Optional
    stagingMember.BillingAddress_Country = "New Zealand"; // Optional   
    stagingMember.BillToContact = "";//Optional


    stagingMember.Phone_IDD = "64"; // Country code (optional)
    stagingMember.Phone_STD = "9"; // Entire phone number (excluding IDD) can be placed in Local parameter depending on setup
    stagingMember.Phone_Local = "926 5400";
    stagingMember.EmailAddress = "Email address"; //Must be a valid email address;

    //Opt Ins
    stagingMember.EmailOptIn_KeyCode = "OPTIN"; //'OPTIN' or 'OPTOUT'
    stagingMember.MailOptIn_KeyCode = "OPTIN"; //'OPTIN' or 'OPTOUT'
    stagingMember.SMSOptIn_KeyCode = "OPTIN"; //'OPTIN' or 'OPTOUT'

    //Card
    stagingMember.CardNumber = ""; // Optional - if undefined a new and unique card number will be generated
    stagingMember.CardType = "VIRTUAL"; //Required - valid values are : 'STANDARD', 'INSTORE' or 'VIRTUAL'

    //Membership
    stagingMember.ProgramCode = "Program code"; //Required - A list of Programs (including their ProgramCodes can be retrieved using AdministrationService.SelectProgramList)
    stagingMember.Membership_StartDate = DateTime.Now; //Optional
    stagingMember.Membership_EndDate = DateTime.MinValue; //Optional (leave blank or set to DateTime.Min to have a program membership that does not expire)
    stagingMember.Membership_BranchName = "Branch"; //Optional
    stagingMember.PointsConversionFactor = 0.0m;//Optional
    stagingMember.PromotionalPointsConversionFactor = 0.0m;//Optional

    //Optional Custom Values
    var profileCustomFieldValues = new AdministrationService.ProfileCustomFieldValues();
    profileCustomFieldValues.CustomText_1 = string.Empty; //Optional CustomText_2 - CustomText_15 available
    profileCustomFieldValues.CustomBoolean_1 = false; //Optional CustomBoolean_2 - CustomBoolean_20 available
    profileCustomFieldValues.CustomDate_1 = DateTime.MinValue; //Optional CustomDate_2 - CustomDate_15 available
    profileCustomFieldValues.CustomDecimal_1 = 0.0M; //Optional CustomDecimal_2 - CustomDecimal_5 available
    profileCustomFieldValues.CustomInteger_1 = 0; //Optional CustomInteger_2 - CustomInteger_10 available
    stagingMember.CustomFieldValues = profileCustomFieldValues;

    stagingMemberList.Add(stagingMember);
  }

  bool endOfData = false;
  int j = 0;
  int rowCount = 0;
  while (endOfData == false)
  {
    var stagingMembers = stagingMemberList.Skip(j * 20).Take(20); //It is recommend to queue around 20 records per call

    rowCount += stagingMembers.Count();
    j++;

    var batchOfStagingMember = new AdministrationService.BatchOfStagingMember();
    batchOfStagingMember.Items = stagingMembers.ToArray(); //Required
    batchOfStagingMember.Key = batch_RSN; //Required - Returned from AdministrationService.OpenMemberBatch (ResultOfBatch.Key)        

    if (rowCount == stagingMemberList.Count) // check if this is the last batch of records to send to service
    {
      endOfData = true; // flag to exit loop
      batchOfStagingMember.Final = true; //Set to true when you have finished loading items into a batch.
    }

    // add batchOfStagingMember to request
    request.Value = batchOfStagingMember;

    AdministrationService.ResultOfBatch result = svc.LoadMemberBatch(request);

    if (result.FaultCode == 0)
    {

    }
    else
    {
      endOfData = true; // flag to exit loop

      //Request failed
      throw new Exception(result.FaultDescription);
    }
  }
}
See Also