Exemple #1
0
        private void getProtectedID(XmlDocument checkedDocument)
        {
            XmlNode id = XmlHelperFunctions.GetSubNode(checkedDocument.DocumentElement, "fu:ProtectedID");

            this.ProtectedID = (id == null) ? string.Empty : id.InnerText;
            this.BarCodes    = (id == null) ? null : BarCodes.Create(checkedDocument);
        }
Exemple #2
0
        private void processSend()
        {
            this.getProtectedID(this.originalMessage);
            if (this.MessageReceivedFromFurs == null)
            {
                this.Success            = false;
                this.ErrorMessage       = "Unknown error";
                this.ErrorMessageSource = ErrorMessageSource.System;
            }

            XmlNode errMsgNode     = XmlHelperFunctions.GetSubNode(this.MessageReceivedFromFurs.DocumentElement, "fu:ErrorMessage");
            XmlNode errMsgCodeNode = XmlHelperFunctions.GetSubNode(this.MessageReceivedFromFurs.DocumentElement, "fu:ErrorCode");

            if (errMsgNode != null)
            {
                this.Success = false;
                string id = (errMsgCodeNode == null) ? string.Empty : string.Format("[{0}]: ", errMsgCodeNode.InnerText);
                this.ErrorMessage       = id + errMsgNode.InnerText;
                this.ErrorMessageSource = ErrorMessageSource.Furs;
            }

            XmlNode uniqueInvoiceIDNode = XmlHelperFunctions.GetSubNode(this.MessageReceivedFromFurs.DocumentElement, "fu:UniqueInvoiceID");

            if (uniqueInvoiceIDNode != null)
            {
                this.UniqueInvoiceID = uniqueInvoiceIDNode.InnerText;
            }
        }
Exemple #3
0
        private void checkData()
        {
            XmlNode businessPremise = XmlHelperFunctions.GetSubNode(this.Message.DocumentElement, "fu:BusinessPremise");

            if (businessPremise == null)
            {
                throw new ArgumentNullException("BusinessPremise");
            }
        }
Exemple #4
0
        private string getNodeValue(XmlElement parentElement, string nodeName)
        {
            XmlNode node = XmlHelperFunctions.GetSubNode(parentElement, nodeName);

            if (node == null)
            {
                return(string.Empty);
            }

            return(node.InnerText);
        }
Exemple #5
0
    protected void checkHeader()
    {
      XmlNode header = XmlHelperFunctions.GetSubNode(this.Message.DocumentElement, "fu:Header");
      if (header != null) return;

      XmlNode headerNode = XmlHelperFunctions.CreateElement(this.Message, this.Settings.FursXmlNamespace, "Header");
      headerNode.AppendChild(XmlHelperFunctions.CreateElement(this.Message, this.Settings.FursXmlNamespace, "MessageID", Guid.NewGuid().ToString()));
      headerNode.AppendChild(XmlHelperFunctions.CreateElement(this.Message, this.Settings.FursXmlNamespace, "DateTime", DateTime.Now.ToString("s")));

      this.Message.DocumentElement.InsertBefore(headerNode, this.Message.DocumentElement.FirstChild);
    }
Exemple #6
0
        public void testInvoice2()
        {
            XmlDocument xmlDoc = this.getXml("OKInvoice4.xml");
            BarCodes    bc     = BarCodes.Create(xmlDoc);

            Assert.AreEqual(bc.BarCodeValue, "069869408702625034879475616534770898107101290141508071305245");

            string xmlTaxNumber  = XmlHelperFunctions.GetSubNode(xmlDoc.DocumentElement, "fu:TaxNumber").InnerText;
            string codeTaxNumber = bc.BarCodeValue.Substring(39, 8);

            Assert.AreEqual(xmlTaxNumber, codeTaxNumber);
        }
Exemple #7
0
        private XmlNode getMainNode(XmlDocument message, MessageType messageType)
        {
            switch (messageType)
            {
            case MessageType.Invoice:
                return(XmlHelperFunctions.GetSubNode(message.DocumentElement, "fu:InvoiceRequest"));

            case MessageType.BusinessPremise:
                return(XmlHelperFunctions.GetSubNode(message.DocumentElement, "fu:BusinessPremiseRequest"));
            }

            return(null);
        }
Exemple #8
0
        private void checkData()
        {
            XmlNode invoice = XmlHelperFunctions.GetSubNode(this.Message.DocumentElement, "fu:Invoice");

            if (invoice != null)
            {
                this.checkAndCalculateProtectedID(this.Message, invoice);
                return;
            }

            XmlNode salesBookInvoice = XmlHelperFunctions.GetSubNode(this.Message.DocumentElement, "fu:SalesBookInvoice");

            if (salesBookInvoice == null)
            {
                throw new ArgumentNullException("Invoice");
            }
        }
Exemple #9
0
    public void SurroundWithSoap()
    {
      string emptySoap = string.Format(
        @"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " +
         "                  xmlns:fu='{0}' " +
         "                  xmlns:xd='http://www.w3.org/2000/09/xmldsig#' " +
         "                  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> " +
         "    <soapenv:Header /> " +
         "    <soapenv:Body /> " +
         "</soapenv:Envelope>", this.Settings.FursXmlNamespace);

      this.MessageSendToFurs = XmlHelperFunctions.CreateNewXmlDocument();
      this.MessageSendToFurs.Schemas = this.Settings.Schemas;
      this.MessageSendToFurs.LoadXml(emptySoap);

      XmlNode body = this.MessageSendToFurs.ImportNode(this.Message.DocumentElement, true);
      XmlNode soapBody = XmlHelperFunctions.GetSubNode(this.MessageSendToFurs.DocumentElement, "soapenv:Body");
      soapBody.AppendChild(body);
    }
Exemple #10
0
        private BarCodes(XmlDocument invoice)
        {
            // People at FURS say that modulo is just easy modulo 10 and not luhn!
            IModulo modulo = new Modulo10_Easy();

            this.invoice = invoice;

            XmlNode protectedIDNode = XmlHelperFunctions.GetSubNode(invoice.DocumentElement, "fu:ProtectedID");
            XmlNode taxNumberNode   = XmlHelperFunctions.GetSubNode(invoice.DocumentElement, "fu:TaxNumber");
            XmlNode timeStampNode   = XmlHelperFunctions.GetSubNode(invoice.DocumentElement, "fu:IssueDateTime");

            if ((protectedIDNode == null) || (taxNumberNode == null) || (timeStampNode == null))
            {
                this.BarCodeValue = string.Empty;
            }
            else
            {
                this.BarCodeValue = BarCodesHelpers.GenerateCode(protectedIDNode.InnerText, taxNumberNode.InnerText, Convert.ToDateTime(timeStampNode.InnerText), modulo);
            }
        }
Exemple #11
0
        public ReturnValue Send(XmlDocument message)
        {
            string root = message.DocumentElement.LocalName;

            XmlNode node = XmlHelperFunctions.GetSubNode(message.DocumentElement, "fu:InvoiceRequest");

            if (string.Compare(root, "InvoiceRequest", true) == 0)
            {
                return(this.SendInvoice(message));
            }
            if (string.Compare(root, "BusinessPremiseRequest", true) == 0)
            {
                return(this.SendBusinessPremise(message));
            }
            if (string.Compare(root, "EchoRequest", true) == 0)
            {
                return(this.SendEcho(message));
            }

            return(ReturnValue.Error(SendingStep.MessageReceived, null, "Neznani dokument / Unknown document"));
        }