コード例 #1
0
ファイル: IR68.cs プロジェクト: umair-me/ASA-API
 public IR68(PeriodData periodData, VAT100 vat100Data)
 {
     this._periodData = periodData;
     this._vat100Data = vat100Data;
 }
コード例 #2
0
        public GovTalkMessage CreateGovTalkMessage(Sender sender, Business business, PeriodData periodData, VAT100 vat100Data, bool testInLive)
        {
            string classType   = !testInLive ? "HMRC-VAT-DEC" : "HMRC-VAT-DEC-TIL";
            string gatewayTest = !testInLive ? "0" : "1";

            //Gov Talk message
            GovTalkMessage govTalkMessage = new GovTalkMessage();
            //Gov Talk header
            GovTalkMessageHeader header = new GovTalkMessageHeader();
            //sender details
            GovTalkMessageHeaderSenderDetails senderDetails          = new GovTalkMessageHeaderSenderDetails();
            GovTalkMessageHeaderSenderDetailsIDAuthentication idauth = new GovTalkMessageHeaderSenderDetailsIDAuthentication();

            idauth.SenderID = sender.SenderId;
            GovTalkMessageHeaderSenderDetailsIDAuthenticationAuthentication aauth = new GovTalkMessageHeaderSenderDetailsIDAuthenticationAuthentication();

            aauth.Method = GovTalkMessageHeaderSenderDetailsIDAuthenticationAuthenticationMethod.clear;
            aauth.Role   = "principal";
            aauth.Item   = sender.SenderPassword;
            GovTalkMessageHeaderSenderDetailsIDAuthenticationAuthentication[] authentications = new GovTalkMessageHeaderSenderDetailsIDAuthenticationAuthentication[1];
            authentications[0]             = aauth;
            idauth.Authentication          = authentications;
            senderDetails.IDAuthentication = idauth;
            senderDetails.EmailAddress     = sender.Email;
            //message details
            GovTalkMessageHeaderMessageDetails messagedetails = new GovTalkMessageHeaderMessageDetails();

            messagedetails.Class                   = classType;
            messagedetails.Qualifier               = GovTalkMessageHeaderMessageDetailsQualifier.request;
            messagedetails.Function                = GovTalkMessageHeaderMessageDetailsFunction.submit;
            messagedetails.FunctionSpecified       = true;
            messagedetails.CorrelationID           = "";
            messagedetails.Transformation          = GovTalkMessageHeaderMessageDetailsTransformation.XML;
            messagedetails.GatewayTest             = gatewayTest;
            messagedetails.TransformationSpecified = true;
            header.MessageDetails                  = messagedetails;
            header.SenderDetails                   = senderDetails;
            //Gov Talk details
            GovTalkMessageGovTalkDetails govTalkDetails = new GovTalkMessageGovTalkDetails();
            //keys
            GovTalkMessageGovTalkDetailsKey key = new GovTalkMessageGovTalkDetailsKey();

            key.Type  = ConfigurationManager.AppSettings["GovTalkDetailsKeyType"];
            key.Value = ConfigurationManager.AppSettings["GovTalkDetailsKey"];
            GovTalkMessageGovTalkDetailsKey[] keys = new GovTalkMessageGovTalkDetailsKey[1];
            keys[0] = key;
            //Channel routing
            GovTalkMessageGovTalkDetailsChannelRoutingChannel channel = new GovTalkMessageGovTalkDetailsChannelRoutingChannel();

            channel.Version         = ConfigurationManager.AppSettings["ChannelVersion"];
            channel.Product         = ConfigurationManager.AppSettings["ChannelProduct"];
            channel.ItemElementName = ItemChoiceType.URI;
            channel.Item            = ConfigurationManager.AppSettings["ChannelUri"];
            GovTalkMessageGovTalkDetailsChannelRouting channelRouting = new GovTalkMessageGovTalkDetailsChannelRouting();

            channelRouting.Channel = channel;
            GovTalkMessageGovTalkDetailsChannelRouting[] channelRoutings = new GovTalkMessageGovTalkDetailsChannelRouting[1];
            channelRoutings[0]            = channelRouting;
            govTalkDetails.Keys           = keys;
            govTalkDetails.ChannelRouting = channelRoutings;

            //Gov Talk Body
            GovTalkMessageBody body = new GovTalkMessageBody();
            //populate body content with ir68 data
            IR68       ir68       = new IR68(periodData, vat100Data);
            IRenvelope iRenvelope = ir68.CreateIREnvelopeBody(sender, business);
            //serialse ir object data into xml elements and add to Gov Talk body
            XElement   xe       = XElement.Parse(SerializeIrEnvelope(iRenvelope));
            XmlElement xelement = ToXmlElement(xe);

            XmlElement[] xmlElements = new XmlElement[1];
            xmlElements[0] = xelement;
            body.Any       = xmlElements;
            govTalkMessage.EnvelopeVersion = ConfigurationManager.AppSettings["GovTalkMessageEnvelopeVersion"];
            govTalkMessage.Header          = header;
            govTalkMessage.GovTalkDetails  = govTalkDetails;
            govTalkMessage.Body            = body;
            return(govTalkMessage);
        }