2017-04-10 30 views
0

給定一個用戶ID,我正在尋找一種方法來獲取用戶註冊的Cvent中的所有事件。如何通過註冊聯繫人ID獲取所有Cvent事件?

這比獲取全部 Cvent事件更加理想,並篩選出用戶未註冊的事件。

這是我已經嘗試了「搜索」的方法:

  CvSearch userEventSearch = new CvSearch(); 
      userEventSearch.Filter = new Filter[1]; 
      userEventSearch.Filter[0] = new Filter(); 
      userEventSearch.Filter[0].Operator = CvSearchOperatorType.Includes; 

      userEventSearch.Filter[0].Field = <What field to use here?>; 
      userEventSearch.Filter[0].Value = <userid>; 

      ids = _cventClient.Search(ref _sessionHeader, CvObjectType.Event, userEventSearch).ToList(); 

我看,我可以選擇字段這個名單,但我不認爲任何人涉及到信息,我想: http://tek-works.com/cvent-api-event-fields-and-their-format/

此外,還有一個「恢復」的方法,可能是有用的,但我不相信這將是非常有用的對我說:

CvObject[] objects = _cventClient.Retrieve(ref _sessionHeader, CvObjectType.<What CvObjectType to use here?>, new[] { <userid> }); 

我試圖弄清楚是否有解決方法來獲取我需要的信息。 (例如,我是否需要檢索註冊並與他們合作以獲得我需要的活動?)

在此先感謝!

回答

0

爲了後代我想通了。也許這將在未來幫助其他人。您必須先搜索並檢索用戶的所有註冊。

一旦你做到了這一點,你可以使用這些記錄來獲得EventIds:

  // First search for all registrations for this user using their contact id (SourceId). 
      CvSearch userRegistrationSearch = new CvSearch(); 
      userRegistrationSearch.Filter = new Filter[1]; 
      userRegistrationSearch.Filter[0] = new Filter(); 
      userRegistrationSearch.Filter[0].Operator = CvSearchOperatorType.Includes; 

      userRegistrationSearch.Filter[0].Field = "SourceId"; 
      userRegistrationSearch.Filter[0].Value = registeredContactId; 

      var registrationIds = _cventClient.Search(ref _sessionHeader, CvObjectType.Registration, userRegistrationSearch); 

      // Using the results of that search, retrive all the registrations from Cvent 
      var registrations = _cventClient.Retrieve(ref _sessionHeader, CvObjectType.Registration, registrationIds).ToList().ConvertAll(items => (Registration)items); 

      // Return all the event ids from these registrations. 
      return registrations.Select(r => r.EventId).ToList(); 
相關問題