Exemple #1
0
        /// <summary>
        /// This method populates the Senders and Receivers 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 Senders and Receivers
        /// </param>
        private static void PoulateHeaderSendersAndReceivers(Database mappingStoreDb, long headerSysId, IHeader header)
        {
            string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter);

            var sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT PARTY.PARTY_ID, PARTY.ID, PARTY.HEADER_ID, PARTY.TYPE ");
            sqlCommand.Append("FROM PARTY ");
            sqlCommand.AppendFormat("WHERE PARTY.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    id         = DataReaderHelper.GetString(dataReader, "ID");
                        long   partySysId = DataReaderHelper.GetInt64(dataReader, "PARTY_ID");
                        string partyType  = DataReaderHelper.GetString(dataReader, "TYPE");

                        var names = new List <ITextTypeWrapper>();
                        PopulatePartyLocalisedStrings(mappingStoreDb, partySysId, names);

                        var contacts = new List <IContact>();
                        PopulatePartyContacts(mappingStoreDb, partySysId, contacts);

                        var party = new PartyCore(names, id, contacts, null);

                        // is it a sender or a receiver?
                        if (partyType.Equals(SenderText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.Sender = party;
                        }
                        else if (partyType.Equals(ReceiverText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.AddReciever(party);
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <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));
            }
        }
        /// <summary>
        /// This method populates the Senders and Receivers 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 Senders and Receivers
        /// </param>
        private static void PoulateHeaderSendersAndReceivers(Database mappingStoreDb, long headerSysId, IHeader header)
        {
            string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter);

            var sqlCommand = new StringBuilder();
            sqlCommand.Append("SELECT PARTY.PARTY_ID, PARTY.ID, PARTY.HEADER_ID, PARTY.TYPE ");
            sqlCommand.Append("FROM PARTY ");
            sqlCommand.AppendFormat("WHERE PARTY.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 id = DataReaderHelper.GetString(dataReader, "ID");
                        long partySysId = DataReaderHelper.GetInt64(dataReader, "PARTY_ID");
                        string partyType = DataReaderHelper.GetString(dataReader, "TYPE");

                        var names = new List<ITextTypeWrapper>();
                        PopulatePartyLocalisedStrings(mappingStoreDb, partySysId, names);

                        var contacts = new List<IContact>();
                        PopulatePartyContacts(mappingStoreDb, partySysId, contacts);

                        var party = new PartyCore(names, id, contacts, null);

                        // is it a sender or a receiver?
                        if (partyType.Equals(SenderText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.Sender = party;
                        }
                        else if (partyType.Equals(ReceiverText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.AddReciever(party);
                        }
                    }
                }
            }
        }