/// <summary> /// This method populates the Localized Strings (Names, Sources) of a <see cref="IHeader"/> /// </summary> /// <param name="mappingStoreDb"> /// The <see cref="Database"/> instance for Mapping Store database /// </param> /// <param name="headerSysId"> /// The header system identifier. In the database the column HEADER.HEADER_ID /// </param> /// <param name="header"> /// The <see cref="IHeader"/> to be populated in terms of Names and Sources /// </param> private static void PopulateHeaderLocalisedStrings(Database mappingStoreDb, long headerSysId, IHeader header) { 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.HEADER_ID = {0} ", paramId); using (DbCommand command = mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString())) { mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.Int64, headerSysId); using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command)) { while (dataReader.Read()) { var text = new TextTypeWrapperMutableCore { Locale = DataReaderHelper.GetString(dataReader, "LANGUAGE"), Value = DataReaderHelper.GetString(dataReader, "TEXT") }; string textType = DataReaderHelper.GetString(dataReader, "TYPE"); // is it a sender or a receiver? if (textType.Equals(NameText, StringComparison.OrdinalIgnoreCase)) { header.AddName(new TextTypeWrapperImpl(text, null)); } else { if (textType.Equals(SourceText, StringComparison.OrdinalIgnoreCase)) { header.AddSource(new TextTypeWrapperImpl(text, null)); } } } } } }
/// <summary> /// Populate the given headerbean object from the apllication settings /// </summary> /// <param name="header"> /// The headerBean to populate /// </param> public static void PopulateHeaderFromSettings(IHeader header) { header.Id = string.IsNullOrEmpty(HeaderSettings.Default.id) ? Resources.DefaultHeaderId : HeaderSettings.Default.id; header.Test = bool.Parse(HeaderSettings.Default.test); if (!string.IsNullOrEmpty(HeaderSettings.Default.name)) { header.AddName(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.name, null)); } //TODO this propery has no setter - please add it // header.Prepared = DateTime.Now.ToString(Resources.SdmxHeaderPreparedDateTimeFormat, CultureInfo.InvariantCulture); IList <ITextTypeWrapper> textTypeWrapperSender = new List <ITextTypeWrapper>(); IContactMutableObject senderContact = new ContactMutableObjectCore(); if (!string.IsNullOrEmpty(HeaderSettings.Default.sendername)) { textTypeWrapperSender.Add(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.sendername, null)); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactname)) { senderContact.AddName(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.sendercontactname)); if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactdepartment)) { senderContact.AddDepartment(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.sendercontactdepartment)); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactrole)) { senderContact.AddRole(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.sendercontactrole)); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontacttelephone)) { senderContact.AddTelephone(HeaderSettings.Default.sendercontacttelephone); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactfax)) { senderContact.AddFax(HeaderSettings.Default.sendercontactfax); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactx400)) { senderContact.AddX400(HeaderSettings.Default.sendercontactx400); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontacturi)) { senderContact.AddUri(HeaderSettings.Default.sendercontacturi); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactemail)) { senderContact.AddEmail(HeaderSettings.Default.sendercontactemail); } } IContact contactImmutable = new ContactCore(senderContact); IList <IContact> contacts = new List <IContact>(); contacts.Add(contactImmutable); // SENDER var sender = new PartyCore(textTypeWrapperSender, HeaderSettings.Default.senderid, contacts, null); header.Sender = sender; IList <ITextTypeWrapper> textTypeWrapperReceiver = new List <ITextTypeWrapper>(); IContactMutableObject receiverContact = new ContactMutableObjectCore(); if (!string.IsNullOrEmpty(HeaderSettings.Default.receiverid)) { if (!string.IsNullOrEmpty(HeaderSettings.Default.receivername)) { textTypeWrapperReceiver.Add(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.receivername, null)); } if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontactname)) { receiverContact.AddName(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.receivercontactname)); if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontactdepartment)) { receiverContact.AddDepartment(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.receivercontactdepartment)); } if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontactrole)) { receiverContact.AddRole(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.receivercontactrole)); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontacttelephone)) { receiverContact.AddTelephone(HeaderSettings.Default.sendercontacttelephone); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactfax)) { receiverContact.AddFax(HeaderSettings.Default.sendercontactfax); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactx400)) { receiverContact.AddX400(HeaderSettings.Default.sendercontactx400); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontacturi)) { receiverContact.AddUri(HeaderSettings.Default.sendercontacturi); } if (!string.IsNullOrEmpty(HeaderSettings.Default.sendercontactemail)) { receiverContact.AddEmail(HeaderSettings.Default.sendercontactemail); } } // RECEIVER IContact contactImmutableReceiver = new ContactCore(receiverContact); IList <IContact> contactsReceiver = new List <IContact>(); contactsReceiver.Add(contactImmutableReceiver); IParty receiver = new PartyCore(textTypeWrapperReceiver, HeaderSettings.Default.receiverid, contactsReceiver, null); header.AddReciever(receiver); } if (!string.IsNullOrEmpty(HeaderSettings.Default.source)) { header.AddSource(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.source, null)); } }