/// <summary>
 ///     Builds the receivers.
 /// </summary>
 /// <returns>The senders </returns>
 private static IList<IParty> BuildReceivers()
 {
     var receiverNames = new ITextTypeWrapper[] { new TextTypeWrapperImpl("en", "receiver name", null) };
     var mutableContactReceiver = new ContactMutableObjectCore();
     mutableContactReceiver.AddEmail("*****@*****.**");
     IList<IContact> receiverContacts = new IContact[] { new ContactCore(mutableContactReceiver) };
     string timeZone = "+02:00";
     var receiver = new PartyCore(receiverNames, "RC0", receiverContacts, timeZone);
     return new IParty[] { receiver };
 }
Exemplo n.º 2
0
        /// <summary>
        ///     This method initializes the log file name.
        ///     The value for this property is configured in the web.config file in the "appSettings" section
        ///     under the "logFileName" key.
        /// </summary>
        private void InitialiseHeader()
        {
            IList<ITextTypeWrapper> name = new List<ITextTypeWrapper>();
            name.Add(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.name, null));

            IList<ITextTypeWrapper> textTypeWrapperSender = new List<ITextTypeWrapper>();
            textTypeWrapperSender.Add(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.sendername, null));

            IContactMutableObject senderContact = new ContactMutableObjectCore();
            senderContact.AddName(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.sendercontactname));
            senderContact.AddDepartment(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.sendercontactdepartment));
            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);
            }

            // SENDER
            IContact contactImmutableSender = new ContactCore(senderContact);
            IList<IContact> contactsSender = new List<IContact>();
            contactsSender.Add(contactImmutableSender);
            IParty sender = new PartyCore(textTypeWrapperSender, HeaderSettings.Default.senderid, contactsSender, null);

            IList<ITextTypeWrapper> textTypeWrapperReceiver = new List<ITextTypeWrapper>();
            textTypeWrapperReceiver.Add(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.receivername, null));

            IContactMutableObject receiverContact = new ContactMutableObjectCore();

            receiverContact.AddName(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.receivercontactname));
            receiverContact.AddDepartment(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.receivercontactdepartment));
            receiverContact.AddRole(new TextTypeWrapperMutableCore(HeaderSettings.Default.lang, HeaderSettings.Default.receivercontactrole));

            if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontacttelephone))
            {
                receiverContact.AddTelephone(HeaderSettings.Default.receivercontacttelephone);
            }

            if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontactfax))
            {
                receiverContact.AddFax(HeaderSettings.Default.receivercontactfax);
            }

            if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontactx400))
            {
                receiverContact.AddX400(HeaderSettings.Default.receivercontactx400);
            }

            if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontacturi))
            {
                receiverContact.AddUri(HeaderSettings.Default.receivercontacturi);
            }

            if (!string.IsNullOrEmpty(HeaderSettings.Default.receivercontactemail))
            {
                receiverContact.AddEmail(HeaderSettings.Default.receivercontactemail);
            }

            // 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);
            IList<IParty> receiverList = new List<IParty>();
            receiverList.Add(receiver);

            IDictionary<string, string> additionalAttributes = new Dictionary<string, string>();
            additionalAttributes.Add(NameTableCache.GetElementName(ElementNameTable.KeyFamilyRef), HeaderSettings.Default.keyfamilyref);
            additionalAttributes.Add(NameTableCache.GetElementName(ElementNameTable.KeyFamilyAgency), HeaderSettings.Default.keyfamilyagency);
            additionalAttributes.Add(NameTableCache.GetElementName(ElementNameTable.DataSetAgency), HeaderSettings.Default.datasetagency);

            DateTime extracted, prepared, reportingBegin, reportingEnd;
            bool isValid = DateTime.TryParse(HeaderSettings.Default.extracted, out extracted);
            if (!isValid)
            {
                extracted = DateTime.Now;
            }

            isValid = DateTime.TryParse(HeaderSettings.Default.reportingbegin, out reportingBegin);
            if (!isValid)
            {
                reportingBegin = DateTime.Now;
            }

            isValid = DateTime.TryParse(HeaderSettings.Default.reportingend, out reportingEnd);
            if (!isValid)
            {
                reportingEnd = DateTime.Now;
            }

            isValid = DateTime.TryParse(HeaderSettings.Default.prepared, out prepared);
            if (!isValid)
            {
                prepared = DateTime.Now;
            }

            IList<ITextTypeWrapper> source = new List<ITextTypeWrapper>();
            if (!string.IsNullOrEmpty(HeaderSettings.Default.source))
            {
                source.Add(new TextTypeWrapperImpl(HeaderSettings.Default.lang, HeaderSettings.Default.source, null));
            }

            this._header = new HeaderImpl(
                additionalAttributes, 
                null, 
                null, 
                DatasetAction.GetAction(HeaderSettings.Default.datasetaction), 
                HeaderSettings.Default.id, 
                HeaderSettings.Default.datasetid, 
                null, 
                extracted, 
                prepared, 
                reportingBegin, 
                reportingEnd, 
                name, 
                source, 
                receiverList, 
                sender, 
                bool.Parse(HeaderSettings.Default.test));
        }
        /// <summary>
        /// Builds the sender.
        /// </summary>
        /// <returns>
        /// The <see cref="PartyCore"/>.
        /// </returns>
        private static PartyCore BuildSender()
        {
            var senderContact1Mutable = new ContactMutableObjectCore();
            senderContact1Mutable.AddDepartment(new TextTypeWrapperMutableCore("en", "A department"));
            senderContact1Mutable.AddName(new TextTypeWrapperMutableCore("en", "a contact name"));
            senderContact1Mutable.AddName(new TextTypeWrapperMutableCore("it", "a contact name"));
            senderContact1Mutable.AddEmail("*****@*****.**");
            senderContact1Mutable.AddTelephone("+12 (0)34567890");
            var senderContact2Mutable = new ContactMutableObjectCore();
            senderContact2Mutable.AddRole(new TextTypeWrapperMutableCore("en", "A role"));
            senderContact2Mutable.AddRole(new TextTypeWrapperMutableCore("it", "A role"));
            senderContact1Mutable.AddEmail("*****@*****.**");

            IContact senderContact1 = new ContactCore(senderContact1Mutable);
            IContact senderContact2 = new ContactCore(senderContact2Mutable);
            IList<IContact> senderContacts = new[] { senderContact1, senderContact2 };
            var sender = new PartyCore(null, "TestSender", senderContacts, null);
            return sender;
        }