Ejemplo n.º 1
0
        public void OPLDFileWatcher()
        {
            try
            {
                var opldFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "OPLDFiles");

                var files = Directory.GetFiles(opldFolderPath);

                if (files.Length > 0)
                {
                    foreach (string fileName in files)
                    {
                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Read in Progress.");

                        string opldString = System.IO.File.ReadAllText(Path.Combine(opldFolderPath, fileName));

                        //Process OPLD data
                        var opldObject = OPLDUtility.ProcessOPLD(opldString);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Processed.");

                        //Push OPLD to Queue
                        MicroServiceProcessOPLDFile(opldObject);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD Message Pushed to MQ.");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(DateTime.Now.ToString() + " AMS-MicroServiceProcessOPLDNDIALSFiles: " + Convert.ToString(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public IActionResult ProcessOPLDNPushTOMQ1()
        {
            try
            {
                string opldFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "OPLDFiles");

                if (Directory.Exists(opldFolderPath))
                {
                    var files = Directory.GetFiles(opldFolderPath);

                    if (files.Length > 0)
                    {
                        foreach (string fileName in files)
                        {
                            string opldString = System.IO.File.ReadAllText(Path.Combine(opldFolderPath, fileName));

                            //Process OPLD data
                            var opldObject = OPLDUtility.ProcessOPLD(opldString);

                            //Push OPLD in to Active MQ1
                            if (!string.IsNullOrEmpty(opldObject.TrackingNumber))
                            {
                                CommonUtility <OPLD> .PushToActiveMQ(opldObject, 1);
                            }
                        }
                    }
                }
            }
            catch {
                return(new JsonResult(new { Result = System.Net.HttpStatusCode.InternalServerError }));
            }

            return(Ok());
        }
Ejemplo n.º 3
0
        public void OPLDFileWatcher()
        {
            try
            {
                var opldFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "OPLDFiles");

                var files = Directory.GetFiles(opldFolderPath);

                if (files.Length > 0)
                {
                    foreach (string fileName in files)
                    {
                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Read in Progress.");

                        string opldString = System.IO.File.ReadAllText(Path.Combine(opldFolderPath, fileName));

                        //Process OPLD data
                        var opldObject = OPLDUtility.ProcessOPLD(opldString);

                        //Check is File already Processed
                        //SakilaContext context = new SakilaContext("server=127.0.01;port=3306;database=ams;user=root;password=techM@Ups1");
                        SakilaContext context = new SakilaContext("server=techm.cooavdyjxzoz.us-east-1.rds.amazonaws.com;port=3306;database=sakila;user=root;password=Password123");

                        //bool trackResult = context.CheckIsTrackingNumberAlreadyExists(opldObject.TrackingNumber);
                        //if (trackResult)
                        //{
                        //    log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Read already processed.");
                        //    continue;
                        //}

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Processed.");

                        //Push OPLD to Queue
                        MicroServiceProcessOPLDFile(opldObject);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD Message Pushed to MQ.");

                        var archiveFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "Archive");

                        DirectoryInfo directoryInfo = Directory.CreateDirectory(archiveFolderPath);

                        if (!System.IO.File.Exists(archiveFolderPath + fileName.Substring(fileName.LastIndexOf("\\"))))
                        {
                            System.IO.File.Move(fileName, archiveFolderPath + fileName.Substring(fileName.LastIndexOf("\\")));
                        }
                        else
                        {
                            System.IO.File.Delete(fileName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(DateTime.Now.ToString() + " AMS-MicroServiceProcessOPLDNDIALSFiles: " + Convert.ToString(ex.Message));
            }
        }
        public void OPLDFileWatcher()
        {
            try
            {
                var opldFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "OPLDFiles");

                var files = Directory.GetFiles(opldFolderPath);

                if (files.Length > 0)
                {
                    foreach (string fileName in files)
                    {
                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Read in Progress.");

                        string opldString = System.IO.File.ReadAllText(Path.Combine(opldFolderPath, fileName));

                        //opldString = opldString.Replace("'", "\'");

                        //Process OPLD data
                        List <OPLD> opldObjectList = new List <OPLD>();
                        OPLDUtility.ProcessOPLDMessage(opldString, ref opldObjectList);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Processed.");

                        //Push OPLD to Queue
                        MicroServiceProcessOPLDFile(opldObjectList);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD Message Pushed to MQ.");

                        //Move File to archive folder
                        var           archiveFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "Archive");
                        DirectoryInfo directoryInfo     = Directory.CreateDirectory(archiveFolderPath);

                        var destFile      = Path.Combine(archiveFolderPath, fileName.Substring(fileName.LastIndexOf("/")));
                        var destAPath     = fileName.Substring(0, fileName.LastIndexOf("/"));
                        var destFinalPath = destAPath.Substring(0, destAPath.LastIndexOf("/")) + "/Archive/" + destFile;

                        if (!System.IO.File.Exists(destFinalPath))
                        {
                            System.IO.File.Move(fileName, destFinalPath);
                            log.Info(DateTime.Now.ToString() + " Source OPLD File delted from opldFiles");
                        }
                        else
                        {
                            System.IO.File.Delete(fileName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(DateTime.Now.ToString() + " AMS-MicroServiceProcessOPLDNDIALSFiles: " + Convert.ToString(ex.Message));
            }
        }
        public void OPLDFileWatcher()
        {
            try
            {
                var opldFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "OPLDFiles");

                var files = Directory.GetFiles(opldFolderPath);

                if (files.Length > 0)
                {
                    foreach (string fileName in files)
                    {
                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Read in Progress.");

                        string opldString = System.IO.File.ReadAllText(Path.Combine(opldFolderPath, fileName));

                        //Process OPLD data
                        var opldObject = OPLDUtility.ProcessOPLD(opldString);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD file Processed.");

                        //Push OPLD to Queue
                        MicroServiceProcessOPLDFile(opldObject);

                        log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: OPLD Message Pushed to MQ.");

//                        var archiveFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "Archive");
//
//                     DirectoryInfo directoryInfo =  Directory.CreateDirectory(archiveFolderPath);
//
//                       if (!System.IO.File.Exists(archiveFolderPath + fileName.Substring(fileName.LastIndexOf("\\"))))
//                      {
//                         System.IO.File.Move(fileName, archiveFolderPath + fileName.Substring(fileName.LastIndexOf("\\")));
//                     }
//                    else
//                   {
                        System.IO.File.Delete(fileName);
                        //                 }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(DateTime.Now.ToString() + " AMS-MicroServiceProcessOPLDNDIALSFiles: " + Convert.ToString(ex.Message));
            }
        }
        //MicroService 1
        //[HttpPost]
        public IActionResult ProcessOPLDNPushTOMQ1()
        {
            try
            {
                string opldFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "OPLDFiles");

                if (Directory.Exists(opldFolderPath))
                {
                    var files = Directory.GetFiles(opldFolderPath);

                    if (files.Length > 0)
                    {
                        foreach (string fileName in files)
                        {
                            log.Info(DateTime.Now.ToString() + " AMS-POC: OPLD file processing in progress.");
                            string opldString = System.IO.File.ReadAllText(Path.Combine(opldFolderPath, fileName));

                            //Process OPLD data
                            var opldObject = OPLDUtility.ProcessOPLD(opldString);

                            log.Info(DateTime.Now.ToString() + " AMS-POC: OPLD file processing completed.");

                            //Push OPLD in to Active MQ1
                            if (!string.IsNullOrEmpty(opldObject.TrackingNumber))
                            {
                                CommonUtility <OPLD> .PushToActiveMQ(opldObject, 1);

                                log.Info(DateTime.Now.ToString() + " AMS-POC: OPLD message pushed to MQ1.");
                            }
                            else
                            {
                                log.Warn(DateTime.Now.ToString() + " AMS-POC: Tracking number not found in OPLD message.");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(DateTime.Now.ToString() + " AMS-POC: " + Convert.ToString(ex.Message));
                return(new JsonResult(new { Result = System.Net.HttpStatusCode.InternalServerError }));
            }

            return(Ok());
        }