Example #1
0
        /// <summary>
        /// Executes the queue.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        private void ExecuteQueue(string filePath)
        {
            Logger.Info("Verificando si existen procesos en cola...");
            while (Lst_Error_Invoice.Count > 0)
            {
                try
                {
                    var item = Lst_Error_Invoice.Peek();
                    using (StreamWriter oSW = File.AppendText(filePath))
                    {
                        oSW.AutoFlush = true;
                        var message = GeneratFilesbyInvoice(item);
                        if (message.Result != null)
                        {
                            oSW.Write(message?.Result);
                            oSW.Flush();
                        }
                    }

                    Logger.Info($"Factura: {item}, #Proceso: en cola.");
                }
                catch (Exception ex)
                {
                    Logger.Error($"Error en proceso en cola {ex.Message}");
                }
                finally
                {
                    Lst_Error_Invoice.Dequeue();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Executes the queue.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        private void ExecuteQueue(string filePath, int countFile)
        {
            Logger.Info("Verificando si existen procesos en cola...");

            while (Lst_Error_Invoice.Count > 0)
            {
                try
                {
                    var item     = Lst_Error_Invoice.Peek();
                    var message  = GeneratFilesbyInvoice(item);
                    var fileName = filePath;

                    if (message.Result.Value != null)
                    {
                        fileName = filePath.Replace("PNR", message?.Result.Key);
                        fileName = filePath.Replace("##", countFile++.ToString());
                        FileStream fs = new FileStream(fileName, FileMode.Create);

                        using (StreamWriter oSW = new StreamWriter(fs, Encoding.UTF8, 160012))
                        {
                            oSW.AutoFlush = true;
                            oSW.Write(message?.Result);
                            oSW.Flush();
                        }

                        if (fs != null)
                        {
                            fs.Dispose();
                        }
                    }


                    Logger.Info($"Factura: {item}, #Proceso: en cola.");
                }
                catch (Exception ex)
                {
                    Logger.Error($"Error en proceso en cola {ex.Message}");
                }
                finally
                {
                    Lst_Error_Invoice.Dequeue();
                }
            }
        }