/// <summary> /// Gets the associations for the matter. /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service.</param> /// <param name="collectionRequest">The collection request.</param> /// <param name="criteria">The criteria.</param> /// <returns></returns> public MatterAssociationReturnValue MatterAssociationSearch(Guid logonId, CollectionRequest collectionRequest, MatterAssociationSearchCriteria criteria) { MatterAssociationReturnValue returnValue = new MatterAssociationReturnValue(); try { Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } // Create a data list creator for a list of associations DataListCreator<MatterAssociationSearchItem> dataListCreator = new DataListCreator<MatterAssociationSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object sender, ReadDataSetEventArgs e) { DataSet dataSet = SrvAssociationLookup.GetMatterAssociations(criteria.ProjectId, criteria.ApplicationId); // Perform Sorting on Role DataView dvContacts = new DataView(dataSet.Tables[0]); dvContacts.Sort = "AssociationRoleDescription asc"; DataSet dsSorted = new DataSet(); dsSorted.Tables.Add(dvContacts.ToTable()); e.DataSet = dsSorted; e.DataSet.Tables[0].Columns.Add("Email"); e.DataSet.Tables[0].Columns.Add("WorkTel"); }; // Create the data list DataList<MatterAssociationSearchItem> matterAssociations = dataListCreator.Create(logonId, // Give the query a name so it can be cached "MatterAssociationSearch", // 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("Role", "AssociationRoleDescription"), new ImportMapping("Title", "PersonTitle"), new ImportMapping("Name", "PersonName"), new ImportMapping("Surname", "PersonSurname"), new ImportMapping("Description", "ProjectMapDescription"), new ImportMapping("MemberId", "MemberId"), new ImportMapping("OrgId", "OrgId") } ); DataSet dsMatterAssociations; matterAssociations.Rows.ForEach(delegate(MatterAssociationSearchItem item) { if (item.MemberId == DataConstants.DummyGuid) { dsMatterAssociations = SrvAddressLookup.GetOrganisationAddresses(item.OrgId); } else { dsMatterAssociations = SrvAddressLookup.GetMemberAddresses(item.MemberId); } SrvAddress srvAddress; int intCtr; foreach (DataRow dr in dsMatterAssociations.Tables[0].Rows) { srvAddress = new SrvAddress(); if (item.MemberId == DataConstants.DummyGuid) { srvAddress.OrganisationId = item.OrgId; } else { srvAddress.MemberId = item.MemberId; } srvAddress.Load(int.Parse(dr["addressId"].ToString())); for (intCtr = 0; intCtr < srvAddress.AdditionalInfoElements.Count; intCtr++) { AdditionalAddressElement additionalAddressElement = new AdditionalAddressElement(); if (srvAddress.AdditionalInfoElements[intCtr].AddressElTypeId == 8) { item.WorkEmail = srvAddress.AdditionalInfoElements[intCtr].AddressElementText; } if (srvAddress.AdditionalInfoElements[intCtr].AddressElTypeId == 2) { item.WorkTelephone = srvAddress.AdditionalInfoElements[intCtr].AddressElementText; } } } }); returnValue.Associations = matterAssociations; } finally { 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> /// Gets the associations for the matter. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">The collection request.</param> /// <param name="criteria">The criteria.</param> /// <returns></returns> public MatterAssociationReturnValue MatterAssociationSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, MatterAssociationSearchCriteria criteria) { MatterAssociationReturnValue returnValue = new MatterAssociationReturnValue(); if (Functions.ValidateIWSToken(oHostSecurityToken)) { oMatterService = new MatterService(); returnValue = oMatterService.MatterAssociationSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new MatterAssociationReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }