/// <summary> /// Gets the industries. /// </summary> private void BindIndustries() { ContactServiceClient contactService = null; try { contactService = new ContactServiceClient(); CollectionRequest collectionRequest = new CollectionRequest(); IndustrySearchCriteria searchCriteria = new IndustrySearchCriteria(); IndustrySearchReturnValue returnValue = contactService.IndustrySearch(_logonSettings.LogonId, collectionRequest, searchCriteria); if (returnValue.Success) { //Add a blank item AppFunctions.AddDefaultToDropDownList(_ddlIndustry); //Generate the items to be displayed in the Industry drop down list //Get the main items string industryText = string.Empty; foreach (IndustrySearchItem industry in returnValue.Industries.Rows) { if (industry.ParentId == 0) { industryText = industry.Name; _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString())); // Call method to get the sub items GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id); } } } else { throw new Exception(returnValue.Message); } } catch (System.ServiceModel.EndpointNotFoundException) { _lblError.Text = DataConstants.WSEndPointErrorMessage; _lblError.CssClass = "errorMessage"; } catch (Exception ex) { _lblError.Text = ex.Message; _lblError.CssClass = "errorMessage"; } finally { if (contactService != null) { if (contactService.State != System.ServiceModel.CommunicationState.Faulted) { contactService.Close(); } } } }
/// <summary> /// Gets the industries. /// </summary> private void GetIndustries() { ContactServiceClient contactService = null; try { contactService = new ContactServiceClient(); CollectionRequest collectionRequest = new CollectionRequest(); IndustrySearchCriteria searchCriteria = new IndustrySearchCriteria(); IndustrySearchReturnValue returnValue = contactService.IndustrySearch(_logonId, collectionRequest, searchCriteria); if (returnValue.Success) { //Add a blank item _ddlIndustry.Items.Add(new ListItem("", "0")); //Generate the items to be displayed in the Industry drop down list //Get the main items string industryText = string.Empty; foreach (IndustrySearchItem industry in returnValue.Industries.Rows) { if (industry.ParentId == 0) { industryText = industry.Name; _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString())); // Call method to get the sub items GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id); } } } 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> /// Get a list of industries that match the search criteria /// </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">Industry search criteria</param> /// <returns></returns> public IndustrySearchReturnValue IndustrySearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, IndustrySearchCriteria criteria) { IndustrySearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.IndustrySearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new IndustrySearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
/// <summary> /// Get a list of industries that match the search criteria /// </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">Industry search criteria</param> /// <returns></returns> public IndustrySearchReturnValue IndustrySearch(Guid logonId, CollectionRequest collectionRequest, IndustrySearchCriteria criteria) { IndustrySearchReturnValue returnValue = new IndustrySearchReturnValue(); 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 industries DataListCreator<IndustrySearchItem> dataListCreator = new DataListCreator<IndustrySearchItem>(); // Declare an inline event (annonymous delegate) to read the dataset dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvIndustryLookup.GetIndustry(); DataTable dt = Functions.SortDataTable(e.DataSet.Tables[0], "IndustryName"); e.DataSet.Tables.Remove(e.DataSet.Tables[0]); e.DataSet.Tables.Add(dt); }; // Create the data list returnValue.Industries = dataListCreator.Create(logonId, // Give the query a name so it can be cached "IndustrySearch", // 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("Id", "IndustryID"), new ImportMapping("ParentId", "IndustryParentID"), new ImportMapping("Name", "IndustryName") } ); } 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> /// Get a list of industries that match the search criteria /// </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">Industry search criteria</param> /// <returns></returns> public IndustrySearchReturnValue IndustrySearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, IndustrySearchCriteria criteria) { IndustrySearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.IndustrySearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new IndustrySearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }