예제 #1
0
        public override void BuildBody()
        {
            // do the building logic for the Body of a SubmitRequest

            #region old
            //GovTalkMessageBody Body = new GovTalkMessageBody();
            //IR68 ir68 = new IR68(_localData);
            //IRenvelope ire = new IRenvelope();
            //ire = ir68.CreateIRBody();
            #endregion old

            IRenvelopeCreator irEnvelopeCreator = new IRenvelopeCreator(new CompressedIRenvelopeBuilder(_loggingService), _loggingService);
            irEnvelopeCreator.CreateIRenvelope();

            hmrcclasses.IRenvelope ire = irEnvelopeCreator.GetIRenvelope();

            XmlElement   xe = XmlSerializationHelpers.SerializeIREnvelope(ire);
            XmlElement[] XmlElementIRenvelope = new XmlElement[1];
            XmlElementIRenvelope[0] = xe;

            Body.Any = XmlElementIRenvelope;

            _loggingService.LogInfo(this, "Built a SubmitRequestBody");

            // throw new NotImplementedException();
        }
        public static XmlElement SerializeIREnvelope(IRenvelope ire)
        {
            try
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                    ns.Add(String.Empty, "http://www.govtalk.gov.uk/taxation/charities/r68/1");

                    var knownTypes = new Type[] { typeof(IRenvelope), typeof(R68Claim) };

                    XmlSerializer serializer =
                        new XmlSerializer(typeof(IRenvelope),knownTypes);

                    XmlTextWriter tw = new XmlTextWriter(memStream, UTF8Encoding.UTF8);

                    XmlDocument doc = new XmlDocument();
                    tw.Formatting = Formatting.Indented;
                    tw.IndentChar = ' ';
                    serializer.Serialize(tw, ire, ns);
                    memStream.Seek(0, SeekOrigin.Begin);
                    doc.Load(memStream);
                    XmlElement returnVal = doc.DocumentElement;

                    log.Debug("IRenvelope messages serialized in memory");

                    return returnVal;
                }
            }
            catch (Exception ex)
            {
                log.Debug("IRenvelope message not serialised in memory");
                log.Error(ex);
                throw;
            }
        }
예제 #3
0
 public void InitialiseIRenvelope(ILoggingService loggingService)
 {
     _irEnvelope = new hmrcclasses.IRenvelope();
     _loggingService = loggingService;
 }
예제 #4
0
        public XmlElement SerializeIREnvelope(IRenvelope irEnvelope)
        {
            // Always the same regardless of nature of IRenvelope, right?
            // Is this the right place for it - does the builder of IRenvelopes also serialize them?

            using (MemoryStream memStream = new MemoryStream())
            {
                XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                ns.Add(String.Empty, "http://www.govtalk.gov.uk/taxation/charities/r68/1");

                var knownTypes = new Type[] { typeof(IRenvelope), typeof(R68Claim) };

                XmlSerializer serializer =
                    new XmlSerializer(typeof(IRenvelope), knownTypes);

                XmlTextWriter tw = new XmlTextWriter(memStream, UTF8Encoding.UTF8);

                XmlDocument doc = new XmlDocument();
                tw.Formatting = Formatting.Indented;
                tw.IndentChar = ' ';
                serializer.Serialize(tw, irEnvelope, ns);
                memStream.Seek(0, SeekOrigin.Begin);
                doc.Load(memStream);
                XmlElement returnVal = doc.DocumentElement;

                return returnVal;
            }
        }
예제 #5
0
 public void InitialiseIRenvelope(ILoggingService loggingService)
 {
     _irEnvelope     = new hmrcclasses.IRenvelope();
     _loggingService = loggingService;
 }