예제 #1
0
 /// <summary>
 ///  Constructor asociado a los Hilos tipo Socket
 /// </summary>
 public ServiceWorkerTPVCOFO(ServiceConfigTPVCOFO.Socket pSK, int iPidxThread, ServiceBatchTPVCOFO pHilobatch, ServiceConfigTPVCOFO.Batch pbatchConfig)
 {
     idxThread   = iPidxThread;
     SK          = pSK;
     batchH      = pHilobatch;
     batchConfig = pbatchConfig;
 }
예제 #2
0
 ///
 public ServiceWorkerTPVCOFO(ServiceConfigTPVCOFO.Library pLib, int iPidxThread, ServiceBatchTPVCOFO pHilobatch, ServiceConfigTPVCOFO.Batch pbatchConfig)
 {
     idxThread   = iPidxThread;
     lib         = pLib;
     batchH      = pHilobatch;
     batchConfig = pbatchConfig;
 }
예제 #3
0
 /// <summary>
 ///  Constructor asociado a los Hilos tipo Servicio Web
 /// </summary>
 ///
 public ServiceWorkerTPVCOFO(ServiceConfigTPVCOFO.ServicioWeb pSW, int iPidxThread, ServiceBatchTPVCOFO pHilobatch, ServiceConfigTPVCOFO.Batch pbatchConfig)
 {
     idxThread   = iPidxThread;
     SW          = pSW;
     batchH      = pHilobatch;
     batchConfig = pbatchConfig;
 }
예제 #4
0
 /// <summary>
 ///  Constructor asociado a los Hilos tipo Host
 /// </summary>
 ///
 public ServiceWorkerTPVCOFO(ServiceConfigTPVCOFO.Host phost, ServiceConfigTPVCOFO.Usage[] pusage, int iPidxThread, ServiceBatchTPVCOFO pHilobatch, ServiceConfigTPVCOFO.Batch pbatchConfig)
 {
     idxThread   = iPidxThread;
     host        = phost;
     usage       = pusage;
     batchH      = pHilobatch;
     batchConfig = pbatchConfig;
 }
예제 #5
0
        /// <summary>
        /// Método que se encargará de determinará el manejo de la respuesta en relación de la configuración BATCH para el Hilo
        /// </summary>
        /// <param name="iTipoRespuesta">Tipo de control de Respuesta --> No Controlado, Tiempo Real o batch  </param>
        /// <param name="bt"></param>
        /// <param name="strNombreArchBatch"></param>
        private void SendMessageByTipoRespuesta(int iTipoRespuesta, ServiceConfigTPVCOFO.Batch bt, String strNombreArchBatch, string strCarpetaOrigen = "", string strCarpetaDestino = "BatchEnviados", bool bolConFecha = true, bool pbolVolumen = false, bool pbolenParalelo = true)
        {
            switch (iTipoRespuesta)
            {
            case (int)TipoRespuesta.RPT_NO_MANAGE:
                // no se realiza nada
                break;

            case (int)TipoRespuesta.RPT_REALTIME:
                ServiceLogTPVCOFO.Instance.WriteLine("Ejecución de Envío de respuesta en Línea" + host.HostName);
                // configurar para realtime
                // invocación de servicio
                break;

            case (int)TipoRespuesta.RPT_BATCH:
                // armar el batch y verificar si está en ejecución
                SendMessageToBatch(bt, strNombreArchBatch, strCarpetaOrigen, strCarpetaDestino, bolConFecha, pbolVolumen, pbolenParalelo);
                break;
            }
        }
예제 #6
0
        /// <summary>
        /// Método creado para mover el archivo donde almacenan los resultados a la carpeta BatchEnviados,  simular la ejecución BATCH.
        /// </summary>
        /// <param name="bt"> Variable tipo BATCH que contiene información requerida para la ejecución del proceso </param>
        /// <param name="fileName">Nombre del archivo BATCH</param>
        public void MoverArchivoBatch(ServiceConfigTPVCOFO.Batch bt, string sFileName, string strCarpetaOrigen = "", string strCarpetaDestino = "BatchEnviados", bool bolConFecha = true, bool bolVolumen = false)
        {
            string sourceFile = "";
            string destFile   = "";
            int    pos        = 0;
            string ModuleName = "";
            string sourcePath = "";
            string targetPath = "";
            string path       = "";
            string strError   = "";

            try
            {
                path       = Assembly.GetExecutingAssembly().Location;
                pos        = path.IndexOf("\\");
                path       = path.Substring(0, pos);
                targetPath = path + @"\CETEL\ServiceTPVCOFO_Files\" + strCarpetaDestino;


                //if (bolTargeDir)
                //{
                //    path = Assembly.GetExecutingAssembly().Location;
                //    pos = path.IndexOf("\\");
                //    path = path.Substring(0, pos) + @"\CETEL\ServiceTPVCOFO_Files\";
                //    sourcePath = path + strCarpetaOrigen;
                //}
                //else
                //{
                path       = Assembly.GetExecutingAssembly().Location;
                pos        = path.IndexOf("\\");
                path       = path.Substring(0, pos);
                sourcePath = path + @"\CETEL\ServiceTPVCOFO_Files\" + strCarpetaOrigen;
                //}

                if (!File.Exists(sFileName))
                {
                    sourceFile = System.IO.Path.Combine(sourcePath, sFileName + ".log");
                    destFile   = System.IO.Path.Combine(targetPath, sFileName + ".log");
                }
                else
                {
                    sourceFile = sFileName;
                    pos        = sFileName.LastIndexOf("\\");
                    ModuleName = sFileName.Substring(pos + 1);
                    destFile   = System.IO.Path.Combine(targetPath, ModuleName);
                }

                if (!Directory.Exists(targetPath))
                {
                    Directory.CreateDirectory(targetPath);
                }
                try
                {
                    if (File.Exists(sourceFile))
                    {
                        long length = new System.IO.FileInfo(sourceFile).Length;
                        if (length > 200)
                        {
                            ServiceLogTPVCOFO.Instance.WriteLine("Copia de Archivo Origen" + sourceFile + " Destino: " + destFile + "\r\n" + "---------------------------------------------------", true);

                            if (bolVolumen == false)
                            {
                                string destFileName = bolConFecha == false ? destFile : destFile.Replace(".log", "_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".log");
                                File.Move(sourceFile, destFileName);
                            }
                            else
                            {
                                fnMoveFileAll(sourcePath, sFileName, targetPath, bolConFecha);
                            }
                        }
                    }
                    else
                    {
                        if (bolVolumen)
                        {
                            fnMoveFileAll(sourcePath, sFileName, targetPath, bolConFecha);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (e.InnerException != null)
                    {
                        strError = e.InnerException.Message;
                    }
                    else
                    {
                        strError = e.Message;
                    }

                    ServiceLogTPVCOFO.Instance.WriteLine("Mover Archivo: " + strError + "\r\n" + "---------------------------------------------------", true);
                }
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    strError = e.InnerException.Message;
                }
                else
                {
                    strError = e.Message;
                }

                ServiceLogTPVCOFO.Instance.WriteLine("Error MoverArchivoBatch: " + strError + "\r\n" + "---------------------------------------------------", true);
            }
        }
예제 #7
0
        /// <summary>
        /// Método creado para simular la ejecución BATCH, si cumple las condiciones validadas se simulará el copiado de las Respuestas a la carpeta BatchEnviados.
        /// </summary>
        /// <param name="bt"> Variable tipo BATCH que contiene información requerida para la ejecución del proceso </param>
        /// <param name="strNombreArchBatch">Nombre del archivo BATCH</param>
        public void SendMessageToBatch(ServiceConfigTPVCOFO.Batch bt, string strNombreArchBatch, string strCarpetaOrigen = "", string strCarpetaDestino = "BatchEnviados", bool bolConFecha = true, bool pbolVolumen = false, bool pbolenParalelo = true)
        {
            DateTime fechaActual;
            string   strError = "";

            try
            {
                if (pbolenParalelo)
                {
                    if (bt != null)
                    {
                        DateTime curDate = DateTime.Now;
                        string   date    = ((bt.sNextExecutionDatetime == "") ? curDate.ToString("dd/MM/yyyy HH:mm:ss") : bt.sNextExecutionDatetime);

                        DateTime executionDate = Convert.ToDateTime(date);

                        if (DateTime.Now >= executionDate)
                        {
                            switch (bt.iExecutionState)
                            {
                            case (int)TipoExecuteBatch.NO_EXECUTE:

                                if (bt.sNextExecutionDatetime == string.Empty)
                                {
                                    bt.sNextExecutionDatetime = curDate.AddMinutes(bt.TimeMinuteBatchCycle).ToString("dd/MM/yyyy HH:mm:ss");
                                    ServiceLogTPVCOFO.Instance.WriteLine("\r\n" + "Asignación de Valores Iniciales y Ejecución de Primer Batch, sino existe configuración previa: " + bt.sNextExecutionDatetime + " " + strNombreArchBatch + "\r\n");
                                }
                                else
                                {
                                    //bt.sNextExecutionDatetime = curDate.AddMinutes(bt.TimeMinuteBatchCycle).ToString("dd/MM/yyyy HH:mm:ss");
                                    DateTime fechaEjecucion = Convert.ToDateTime(bt.sNextExecutionDatetime);
                                    fechaActual = DateTime.Now;

                                    ServiceLogTPVCOFO.Instance.WriteLine("RptaBatch" + strNombreArchBatch + "\r\n RESPONSE: Fecha Actual : " + fechaActual.ToString() + " - Fecha Ejecucion : " + fechaEjecucion.ToString() + "\r\n");

                                    if (fechaActual > fechaEjecucion)
                                    {
                                        ServiceLogTPVCOFO.Instance.WriteLine("RptaBatch" + strNombreArchBatch + "\r\n RESPONSE 2: " + fechaActual.ToString() + "\r\n");
                                        bt.sNextExecutionDatetime = fechaActual.AddMinutes(bt.TimeMinuteBatchCycle).ToString("dd/MM/yyyy HH:mm:ss");
                                        bt.iExecutionState        = (int)TipoExecuteBatch.EXECUTING;
                                        ServiceLogTPVCOFO.Instance.WriteLine("\r\n RptaBatch" + strNombreArchBatch + "Ejecución de Batch " + strNombreArchBatch + "\r\n");
                                        //Hacer traslado de archivo
                                        MoverArchivoBatch(bt, strNombreArchBatch, strCarpetaOrigen, strCarpetaDestino, bolConFecha, pbolVolumen);
                                        bt.iExecutionState = (int)TipoExecuteBatch.NO_EXECUTE;
                                    }
                                }
                                break;

                            case (int)TipoExecuteBatch.EXECUTED:
                                bt.iExecutionState = (int)TipoExecuteBatch.NO_EXECUTE;
                                break;
                            }
                        }
                        else
                        {
                            bt.iExecutionState = (int)TipoExecuteBatch.NO_EXECUTE;
                            ServiceLogTPVCOFO.Instance.WriteLine("\r\n" + "No se encuentra Fichero " + strNombreArchBatch + "\r\n");
                        }
                    }
                }
                else
                {
                    if (bt != null)
                    {
                        bt.iExecutionState = (int)TipoExecuteBatch.EXECUTING;
                        ServiceLogTPVCOFO.Instance.WriteLine("\r\n RptaBatch" + strNombreArchBatch + ": Ejecución de Batch Secuencial: " + strNombreArchBatch + " | Carpeta Origen: " + strCarpetaOrigen + " - " + "Carpeta Destino: " + strCarpetaDestino + "\r\n", true);
                        MoverArchivoBatch(bt, strNombreArchBatch, strCarpetaOrigen, strCarpetaDestino, bolConFecha, pbolVolumen);
                        ServiceLogTPVCOFO.Instance.WriteLine("\r\n RptaBatch" + strNombreArchBatch + ": Fin de Batch Secuencial " + strNombreArchBatch + "\r\n", true);
                        bt.iExecutionState = (int)TipoExecuteBatch.NO_EXECUTE;
                    }
                }
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    strError = e.InnerException.Message;
                }
                else
                {
                    strError = e.Message;
                }

                bt.iExecutionState = (int)TipoExecuteBatch.NO_EXECUTE;
                ServiceLogTPVCOFO.Instance.WriteLine("\r\n" + "Error en SendMessageToBatch: " + strError + "\r\n", true);
            }
        }