/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create CampaignRemoteService instance. CampaignRemoteService service = (CampaignRemoteService)user.GetService( DfaService.v1_19.CampaignRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create campaign search criteria structure. CampaignSearchCriteria searchCriteria = new CampaignSearchCriteria(); searchCriteria.pageSize = 10; searchCriteria.searchString = searchString; try { // Get the campaigns. CampaignRecordSet recordSet = service.getCampaignsByCriteria(searchCriteria); // Display campaign names and ids. if (recordSet.records != null) { foreach (Campaign result in recordSet.records) { Console.WriteLine("Campaign with name \"{0}\" and id \"{1}\" was found.", result.name, result.id); } } else { Console.WriteLine("No campaigns found for your search criteria."); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve campaigns. Exception says \"{0}\"", ex.Message); } }
private void GetCampaigns(DropDownList dropDownList) { ContactServiceClient contactService = null; try { contactService = new ContactServiceClient(); CollectionRequest collectionRequest = new CollectionRequest(); CampaignSearchCriteria searchCriteria = new CampaignSearchCriteria(); CampaignSearchReturnValue returnValue = contactService.CampaignSearch(_logonId, collectionRequest, searchCriteria); if (returnValue.Success) { dropDownList.DataSource = returnValue.Campaigns.Rows; dropDownList.DataTextField = "Description"; dropDownList.DataValueField = "CampaignId"; dropDownList.DataBind(); dropDownList.Items.Insert(0, ""); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService != null) { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) { contactService.Close(); } } } }
private void GetCampaigns(DropDownList dropDownList) { ContactServiceClient contactService = null; try { contactService = new ContactServiceClient(); CollectionRequest collectionRequest = new CollectionRequest(); CampaignSearchCriteria searchCriteria = new CampaignSearchCriteria(); CampaignSearchReturnValue returnValue = contactService.CampaignSearch(_logonId, collectionRequest, searchCriteria); if (returnValue.Success) { dropDownList.DataSource = returnValue.Campaigns.Rows; dropDownList.DataTextField = "Description"; dropDownList.DataValueField = "CampaignId"; dropDownList.DataBind(); dropDownList.Items.Insert(0, ""); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (contactService != null) { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) contactService.Close(); } } }
/// <summary> /// Campaigns the search. /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service.</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Campaign search criteria.</param> /// <returns></returns> public CampaignSearchReturnValue CampaignSearch(Guid logonId, CollectionRequest collectionRequest, CampaignSearchCriteria criteria) { CampaignSearchReturnValue returnValue = new CampaignSearchReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: // Can do everything break; default: throw new Exception("Access denied"); } // Create a data list creator for a list of campaigns DataListCreator<CampaignSearchItem> dataListCreator = new DataListCreator<CampaignSearchItem>(); // Declare an inline event (annonymous delegate) to read the dataset dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { //Add the table to the dataset as the lookup is returning a datatable e.DataSet = new System.Data.DataSet(); e.DataSet.Tables.Add(SrvCampaignLookup.GetCampaigns()); DataTable dt = Functions.SortDataTable(e.DataSet.Tables[0], "CampaignDesc"); e.DataSet.Tables.Remove(e.DataSet.Tables[0]); e.DataSet.Tables.Add(dt); }; // Create the data list returnValue.Campaigns = dataListCreator.Create(logonId, // Give the query a name so it can be cached "CampaignSearch", // Tell it the query criteria used so if the cache is accessed // again it knows if it is the same query criteria.ToString(), collectionRequest, // Import mappings to map the dataset row fields to the data // list entity properties new ImportMapping[] { new ImportMapping("CampaignId", "CampaignId"), new ImportMapping("Description", "CampaignDesc"), } ); } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception Ex) { returnValue.Success = false; returnValue.Message = Ex.Message; } return returnValue; }
/// <summary> /// Campaigns the search. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Campaign search criteria.</param> /// <returns></returns> public CampaignSearchReturnValue CampaignSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, CampaignSearchCriteria criteria) { CampaignSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.CampaignSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new CampaignSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Campaigns the search. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Campaign search criteria.</param> /// <returns></returns> public CampaignSearchReturnValue CampaignSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, CampaignSearchCriteria criteria) { CampaignSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.CampaignSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new CampaignSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }