public ContactCore(IContactMutableObject mutableBean, ISdmxObject parent) : base(mutableBean, parent) { this.id = mutableBean.Id; CopyTextTypes(name, mutableBean.Names); CopyTextTypes(role, mutableBean.Names); CopyTextTypes(departments, mutableBean.Departments); if (mutableBean.Email != null) { this.email = new List<string>(mutableBean.Email); } if (mutableBean.Telephone != null) { this.telephone = new List<string>(mutableBean.Telephone); } if (mutableBean.Fax != null) { this.fax = new List<string>(mutableBean.Fax); } if (mutableBean.Uri != null) { this.uri = new List<string>(mutableBean.Uri); } if (mutableBean.X400 != null) { this.x400 = new List<string>(mutableBean.X400); } }
/// <summary> /// Add coordinate type of type <paramref name="coordinateType"/> with <paramref name="coordinateValue"/> to <paramref name="contact"/> /// </summary> /// <param name="contact">The contact</param> /// <param name="coordinateType">The type of communication, e.g. <c>Email</c></param> /// <param name="coordinateValue">The value, e.g. <c>[email protected]</c></param> public static void AddCoordinateType(this IContactMutableObject contact, string coordinateType, string coordinateValue) { switch (coordinateType) { case "Email": contact.AddEmail(coordinateValue); break; case "Telephone": contact.AddTelephone(coordinateValue); break; case "X400": contact.AddX400(coordinateValue); break; case "Fax": contact.AddFax(coordinateValue); break; case "URI": contact.AddUri(coordinateValue); break; } }
public void AddContact(IContactMutableObject contact) { this._contacts.Add(contact); }
/// <summary> /// Handle the elements text for child elements of <paramref name="contact"/> /// </summary> /// <param name="contact"> /// The contact parent. /// </param> /// <param name="localName"> /// The element tag local name. /// </param> /// <returns> /// True if it was handled else false /// </returns> private bool HandleChildText(IContactMutableObject contact, object localName) { if (contact == null) { return false; } if (NameTableCache.IsElement(localName, ElementNameTable.Name)) { contact.AddName(new TextTypeWrapperMutableCore { Locale = this._lang, Value = this._text }); } else if (NameTableCache.IsElement(localName, ElementNameTable.Department)) { contact.Departments.Add(new TextTypeWrapperMutableCore { Locale = this._lang, Value = this._text }); } else if (NameTableCache.IsElement(localName, ElementNameTable.Role)) { contact.AddRole(new TextTypeWrapperMutableCore { Locale = this._lang, Value = this._text }); } else { ElementNameTable element; if (Enum.TryParse(localName as string, out element)) { switch (element) { case ElementNameTable.Telephone: contact.Telephone.Add(this._text); break; case ElementNameTable.Fax: contact.Fax.Add(this._text); break; case ElementNameTable.X400: contact.X400.Add(this._text); break; case ElementNameTable.URI: contact.Uri.Add(this._text); break; case ElementNameTable.Email: contact.Email.Add(this._text); break; } } } return true; }
/// <summary> /// This method populates the Localized Strings (Names, Departments, Roles) /// of a <see cref="IContactMutableObject"/> /// </summary> /// <param name="mappingStoreDb"> /// The <see cref="Database"/> instance for Mapping Store database /// </param> /// <param name="contactSysId"> /// The contact system identifier. In the database the column CONTACT.CONTACT_ID /// </param> /// <param name="contact"> /// The <see cref="IContactMutableObject"/> to be populated in terms of Names, Departments, Roles /// </param> private static void PopulateContactLocalisedStrings(Database mappingStoreDb, long contactSysId, IContactMutableObject contact) { string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter); var sqlCommand = new StringBuilder(); sqlCommand.Append("SELECT HLS.HLS_ID, HLS.TYPE, HLS.HEADER_ID, HLS.PARTY_ID, HLS.CONTACT_ID, HLS.LANGUAGE, HLS.TEXT "); sqlCommand.Append("FROM HEADER_LOCALISED_STRING HLS "); sqlCommand.AppendFormat("WHERE HLS.CONTACT_ID = {0} ", paramId); using (DbCommand command = mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString())) { mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.Int64, contactSysId); using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command)) { while (dataReader.Read()) { var text = new TextTypeWrapperMutableCore { Locale = DataReaderHelper.GetString(dataReader, "LANGUAGE"), Value = DataReaderHelper.GetString(dataReader, "TEXT") }; if (!string.IsNullOrWhiteSpace(text.Value) && !string.IsNullOrWhiteSpace(text.Locale)) { string textType = DataReaderHelper.GetString(dataReader, "TYPE"); if (textType.Equals(NameText, StringComparison.OrdinalIgnoreCase)) { contact.Names.Add(text); } else if (textType.Equals(DepartmentText, StringComparison.OrdinalIgnoreCase)) { contact.Departments.Add(text); } else if (textType.Equals(RoleText, StringComparison.OrdinalIgnoreCase)) { contact.Roles.Add(text); } } } } } }
/// <summary> /// This method populates the contact details of a <see cref="IContactMutableObject"/> /// </summary> /// <param name="mappingStoreDb"> /// The <see cref="Database"/> instance for Mapping Store database /// </param> /// <param name="contactSysId"> /// The contact system identifier. In the database the column CONTACT.CONTACT_ID /// </param> /// <param name="contact"> /// The <see cref="IContactMutableObject"/> for which the details will be populated /// </param> private static void PopulateContactDetails(Database mappingStoreDb, long contactSysId, IContactMutableObject contact) { string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter); var sqlCommand = new StringBuilder(); sqlCommand.Append("SELECT CD.CD_ID, CD.CONTACT_ID, CD.TYPE, CD.VALUE "); sqlCommand.Append("FROM CONTACT_DETAIL CD "); sqlCommand.AppendFormat("WHERE CD.CONTACT_ID = {0} ", paramId); using (DbCommand command = mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString())) { mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.Int64, contactSysId); using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command)) { while (dataReader.Read()) { string coordinateType = DataReaderHelper.GetString(dataReader, "TYPE"); string coordinateData = DataReaderHelper.GetString(dataReader, "VALUE"); contact.AddCoordinateType(coordinateType, coordinateData); } } } }
public ContactCore(IContactMutableObject mutableBean) : this(mutableBean, null) { }