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; } } }
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"); }
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); }
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; }
private BusinessPremise(XmlDocument message, Settings settings) : base(message, settings, MessageAction.Send) { }
public static BusinessPremise Create(XmlDocument message, Settings settings) { return new BusinessPremise(message, settings); }
private SignMessage(Settings settings) { this.settings = settings; }
public static SignMessage Create(Settings settings) { return new SignMessage(settings); }
public static Echo Create(XmlDocument message, Settings settings) { return new Echo(message, settings); }
private Echo(XmlDocument message, Settings settings) : base(message, settings, MessageAction.Send) { }
private Invoice(XmlDocument message, Settings settings, MessageAction messageAction) : base(message, settings, messageAction) { }
public static Invoice Create(XmlDocument message, Settings settings, MessageAction messageAction) { return new Invoice(message, settings, messageAction); }
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; } } }
public static TaxService Create(Settings settings) { return new TaxService(settings); }
private TaxService(Settings settings) { this.Settings = settings; }