Example #1
0
        public bool End(usrc_FVI_SLO_MessageBox xusrc_FVI_SLO_MessageBox)
        {
            FiscalSettings = null;
            taxService = null;

            usrc_FVI_SLO_Message xusrc_FVI_SLO_Message_END = new usrc_FVI_SLO_Message(0,usrc_FVI_SLO_Message.eMessage.NONE, null);
            Thread_FVI_Message fvi_message_END = new Thread_FVI_Message(0,Thread_FVI_Message.eMessage.END, null);
            message_box.Post(fvi_message_END);
            long StartTicks = DateTime.Now.Ticks;

            for (;;)
            {
                if (xusrc_FVI_SLO_MessageBox.Get(ref xusrc_FVI_SLO_Message_END)== Result_MessageBox_Get.OK)
                {
                    if (xusrc_FVI_SLO_Message_END.Message == usrc_FVI_SLO_Message.eMessage.Thread_FVI_END)
                    {
                        return true;
                    }
                }
                if ((DateTime.Now.Ticks- StartTicks)>100000000)
                {
                    return false;
                }
            }
        }
Example #2
0
 private SendMessage(Settings settings)
 {
     this.settings = settings;
       this.soapActions = new Dictionary<MessageType, string>();
       this.soapActions.Add(MessageType.Invoice, @"SOAPAction: /invoices");
       this.soapActions.Add(MessageType.BusinessPremise, @"SOAPAction: /invoices/register");
       this.soapActions.Add(MessageType.Echo, @"SOAPAction: /echo");
 }
Example #3
0
        public static Echo Create(string message, Settings settings)
        {
            string xmlEcho = @"<?xml version='1.0' encoding='UTF-8'?><fu:EchoRequest xmlns:fu='http://www.fu.gov.si/' />";
              XmlDocument echoDoc = XmlHelperFunctions.CreateNewXmlDocument();
              echoDoc.LoadXml(xmlEcho);

              XmlNode xmlMessage = echoDoc.CreateTextNode(message);
              echoDoc.DocumentElement.AppendChild(xmlMessage);
              return new Echo(echoDoc, settings);
        }
Example #4
0
        public BaseMessage(XmlDocument message, Settings settings, MessageAction messageAction)
        {
            this.Message = message;
              this.MessageAction = messageAction;

              this.Settings = settings;
              this.signMessage = SignMessage.Create(this.Settings);

              Dictionary<string, MessageType> types = new Dictionary<string, MessageType>();
              types.Add("InvoiceRequest", MessageType.Invoice);
              types.Add("BusinessPremiseRequest", MessageType.BusinessPremise);
              types.Add("EchoRequest", MessageType.Echo);

              string root = this.Message.DocumentElement.LocalName;
              if (types.ContainsKey(root))
            this.MessageType = types[root];
              else
            this.MessageType = MessageType.Unknown;
        }
Example #5
0
 private BusinessPremise(XmlDocument message, Settings settings) :
   base(message, settings, MessageAction.Send)
 {
 }
Example #6
0
 public static BusinessPremise Create(XmlDocument message, Settings settings)
 {
   return new BusinessPremise(message, settings);
 }
Example #7
0
 private SignMessage(Settings settings)
 {
   this.settings = settings;
 }
Example #8
0
 public static SignMessage Create(Settings settings)
 {
   return new SignMessage(settings);
 }
Example #9
0
 public static Echo Create(XmlDocument message, Settings settings)
 {
     return new Echo(message, settings);
 }
Example #10
0
 private Echo(XmlDocument message, Settings settings)
     : base(message, settings, MessageAction.Send)
 {
 }
Example #11
0
 private Invoice(XmlDocument message, Settings settings, MessageAction messageAction) :
   base(message, settings, messageAction)
 {
 }
Example #12
0
 public static Invoice Create(XmlDocument message, Settings settings, MessageAction messageAction)
 {
   return new Invoice(message, settings, messageAction);
 }
Example #13
0
        private void Run(object othdata)
        {
            ThreadData thdata = (ThreadData)othdata;
            usrc_FVI_SLO_MessageBox xusrc_FVI_SLO_MessageBox = thdata.m_usrc_FVI_SLO_MessageBox;
            Thread_FVI_Message fvi_message = new Thread_FVI_Message(0,Thread_FVI_Message.eMessage.NONE,null);
            usrc_FVI_SLO_Message xusrc_FVI_SLO_Message = new usrc_FVI_SLO_Message(0,usrc_FVI_SLO_Message.eMessage.Thread_FVI_START, null);
            xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);

            try
            {
                if (File.Exists(thdata.certificateFileName))
                {
                    X509Certificate2 certificate = GetCertFromFile(thdata.certificateFileName, thdata.CertPass);
                    FiscalSettings = Settings.Create(certificate, thdata.fursWebServiceURL, thdata.fursXmlNamespace, thdata.timeOutInSec);
                    taxService = TaxService.Create(FiscalSettings);  //create service with settings
                }
                else
                {
                    xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.ERROR,null, lngRPM.sFileDoesNotExist.s + ":" + thdata.certificateFileName,MessageType.Unknown,null,false,null,null,null);
                    xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                    return;
                }
            }
            catch (Exception ex)
            {
                xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.ERROR, null, ex.Message, MessageType.Unknown, null, false, null, null, null);
                xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                return;
            }

            for (;;)
            {
                ReturnValue rv = null;
                string xml_returned = null;
                switch (message_box.Get(ref fvi_message))
                {
                    case Result_MessageBox_Get.OK:
                        switch (fvi_message.Message)
                        {

                            case Thread_FVI_Message.eMessage.POST_ECHO:
                                rv = taxService.Send(fvi_message.XML_Data);
                                xml_returned = prettyXml(rv.originalMessage);
                                xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.FVI_RESPONSE_ECHO, xml_returned);
                                xusrc_FVI_SLO_Message.Success = rv.Success;
                                xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                                break;

                            case Thread_FVI_Message.eMessage.POST_SINGLE_INVOICE:
                                rv = taxService.Send(fvi_message.XML_Data);
                                xml_returned = prettyXml(rv.originalMessage);
                                if (rv.BarCodes!=null)
                                {
                                    string BarCodeValue = rv.BarCodes.BarCodeValue;
                                    if (BarCodeValue != null)
                                    {
                                        Image img_QRCode = rv.BarCodes.DrawQRCode(Properties.Settings.Default.QRImageWidth, System.Drawing.Imaging.ImageFormat.Png);
                                        xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.FVI_RESPONSE_SINGLE_INVOICE,
                                                                  xml_returned,
                                                                  rv.ErrorMessage,
                                                                  rv.MessageType,
                                                                  rv.ProtectedID,
                                                                  rv.Success,
                                                                  rv.UniqueInvoiceID,
                                                                  BarCodeValue,
                                                                  img_QRCode);

                                    }
                                    else
                                    {
                                        xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.FVI_RESPONSE_SINGLE_INVOICE,
                                                                 xml_returned,
                                                                 rv.ErrorMessage,
                                                                 rv.MessageType,
                                                                 rv.ProtectedID,
                                                                 rv.Success,
                                                                 rv.UniqueInvoiceID,
                                                                 null,
                                                                 null);
                                    }
                                }
                                else
                                {
                                    xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.FVI_RESPONSE_SINGLE_INVOICE,
                                                                xml_returned,
                                                                rv.ErrorMessage,
                                                                rv.MessageType,
                                                                rv.ProtectedID,
                                                                rv.Success,
                                                                rv.UniqueInvoiceID,
                                                                null,
                                                                null);
                                }

                                xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                                break;

                            case Thread_FVI_Message.eMessage.POST_BUSINESSPREMISE:
                                rv = taxService.Send(fvi_message.XML_Data);
                                xml_returned = prettyXml(rv.originalMessage);
                                xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.FVI_RESPONSE_PP, xml_returned);
                                xusrc_FVI_SLO_Message.Success = rv.Success;
                                xusrc_FVI_SLO_Message.ErrorMessage  = rv.ErrorMessage;
                                xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                                break;

                            case Thread_FVI_Message.eMessage.POST_MANY_INVOICES:
                                rv = taxService.Send(fvi_message.XML_Data);
                                xml_returned = prettyXml(rv.originalMessage);
                                xusrc_FVI_SLO_Message.Set(fvi_message.Message_ID, usrc_FVI_SLO_Message.eMessage.FVI_RESPONSE_SINGLE_INVOICE, xml_returned);
                                xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                                break;

                            case Thread_FVI_Message.eMessage.END:
                                xusrc_FVI_SLO_Message.Set(0,usrc_FVI_SLO_Message.eMessage.Thread_FVI_END, null);
                                xusrc_FVI_SLO_MessageBox.Post(xusrc_FVI_SLO_Message);
                                return;
                        }
                        break;
                    case Result_MessageBox_Get.TIMEOUT:
                        break;
                }
            }
        }
Example #14
0
 public static TaxService Create(Settings settings)
 {
     return new TaxService(settings);
 }
Example #15
0
 private TaxService(Settings settings)
 {
     this.Settings = settings;
 }