public static Boolean InsertarError(SVCDocumentosElectronicos.MensajeWCFOfBoolean entidad) { try { Message msg = new Message(); MessageQueue queue = new MessageQueue(@"FormatName:Direct=OS:" + ConfigurationManager.AppSettings["NombreColaMSMQError"]); string queueName = ConfigurationManager.AppSettings["NombreColaMSMQError"]; if (!MessageQueue.Exists(queueName)) { MessageQueue.Create(queueName, true); } msg.Body = entidad; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { queue.Send(msg, MessageQueueTransactionType.Automatic); scope.Complete(); } return(true); } catch (Exception) { return(false); } }
public void OnMessageReceived(Object source, ReceiveCompletedEventArgs e) { XmlSerializer s = new XmlSerializer(typeof(SVCDocumentosElectronicos.EnviosDeDocumentosPendiente)); MessageQueue queue = (MessageQueue)source; SVCDocumentosElectronicos.MensajeWCFOfBoolean respuesta = null; try { Message msg = queue.EndReceive(e.AsyncResult); msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(SVCDocumentosElectronicos.EnviosDeDocumentosPendiente) }); SVCDocumentosElectronicos.EnviosDeDocumentosPendiente documento = (SVCDocumentosElectronicos.EnviosDeDocumentosPendiente)msg.Body; configurador.LogWriter.Write(new LogEntry() { Message = String.Format("Mandando mensaje {0} al cliente", msg.Body), Categories = new List <string> { "eventLog" }, Priority = 1, ProcessName = "Leyendo Queue" }); respuesta = client.EnviarCorreoDocumento(documento); if (respuesta.CodigoError != Util.CODIGO_EXITOSO) { Util.InsertarError(respuesta); configurador.LogWriter.Write(new LogEntry() { Message = String.Format("Error al enviar documento {0}, mensaje de error {1}", documento.DocumentoId.ToString(), respuesta.MensajeError), Categories = new List <string> { "eventLog" }, Priority = 1, ProcessName = "Leyendo Queue" }); } else { configurador.LogWriter.Write(new LogEntry() { Message = String.Format("Documento {0} envíado al cliente, respuesta {1}", documento.DocumentoId.ToString(), respuesta.MensajeHumano), Categories = new List <string> { "eventLog" }, Priority = 1, ProcessName = "Leyendo Queue" }); } } catch (System.Exception ex) { configurador.ExceptionHandler.HandleException(ex, Util.POLITICA_ERRORES, out Exception nExption); } finally { respuesta = null; queue.BeginReceive(); } }
public void OnMessageReceived(Object source, ReceiveCompletedEventArgs e) { XmlSerializer s = new XmlSerializer(typeof(SVCDocumentosElectronicos.EnviosPendientesPosteoDIAN)); MessageQueue queue = (MessageQueue)source; try { Message msg = queue.EndReceive(e.AsyncResult); msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(SVCDocumentosElectronicos.EnviosPendientesPosteoDIAN) }); SVCDocumentosElectronicos.EnviosPendientesPosteoDIAN documento = (SVCDocumentosElectronicos.EnviosPendientesPosteoDIAN)msg.Body; configurador.LogWriter.Write(new LogEntry() { Message = String.Format("Mensaje recibido en la cola, posteando documento a la DIAN {0} a la DIAN", msg.Body), Categories = new List <string> { "eventLog" }, Priority = 1, ProcessName = "Leyendo Queue" }); SVCDocumentosElectronicos.MensajeWCFOfBoolean respuesta = client.PostearDocumentoPendiente(documento); if (respuesta.CodigoError != Util.CODIGO_EXITOSO) { Util.InsertarError(respuesta); configurador.LogWriter.Write(new LogEntry() { Message = String.Format("Error al postear documento {0}, mensaje de error {1}", documento.Id, respuesta.MensajeError), Categories = new List <string> { "eventLog" }, Priority = 1, ProcessName = "Leyendo Queue" }); } else { configurador.LogWriter.Write(new LogEntry() { Message = String.Format("Documento {0} autorizado por la DIAN, respuesta {1}", documento.Id, respuesta.MensajeHumano), Categories = new List <string> { "eventLog" }, Priority = 1, ProcessName = "Leyendo Queue" }); } } catch (System.Exception ex) { configurador.ExceptionHandler.HandleException(ex, Util.POLITICA_ERRORES, out Exception nExption); } finally { queue.BeginReceive(); } }
/// <summary> /// Encargado de Cargar PDF a documento Electrónico /// </summary> /// <param name="docCargado"></param> /// <param name="respuestaCargaPDF"></param> /// <param name="summary"></param> /// <param name="attachment"></param> /// <param name="mime"></param> private void CargarPDF(DocumentoElectronico docCargado, out SVCDocumentosElectronicos.MensajeWCFOfBoolean respuestaCargaPDF, IMessageSummary summary, BodyPartBasic attachment) { MimePart mime = null; this.logger.LogWriter.Write(new LogEntry() { Message = String.Format("Se encuentra PDF adjunto para documento N°:{0}", docCargado.Id.ToString()), Categories = new List <string> { "General" }, Priority = 1, ProcessName = Logger.PROCESS_NAME }); mime = (MimePart)inbox.GetBodyPart(summary.UniqueId, attachment); using (MemoryStream stream = new MemoryStream()) { mime.Content.DecodeTo(stream); stream.Position = 0; respuestaCargaPDF = documentClient.CargarPDFCompra(docCargado.Id, stream.ToArray(), "pdf", -2); if (respuestaCargaPDF.CodigoError != Logger.CODIGO_EXITOSO) { this.logger.LogWriter.Write(new LogEntry() { Message = String.Format("Imposible cargar PDF adjunto para documento N°:{0}, error:{1}", docCargado.Id.ToString(), respuestaCargaPDF.MensajeError), Categories = new List <string> { "General" }, Priority = 1, ProcessName = Logger.PROCESS_NAME }); } else { this.logger.LogWriter.Write(new LogEntry() { Message = String.Format("PDF adjunto cargado para documento N°:{0}", docCargado.Id.ToString()), Categories = new List <string> { "General" }, Priority = 1, ProcessName = Logger.PROCESS_NAME }); } } }