//MicroService 4 public IActionResult ReadMQ2OPLDNCreateSPNPushTOMQ3() { try { //Read from MQ OPLD opldObject = CommonUtility <OPLD> .PullFromActiveMQ(2); ServicePoint servicePointObject = new ServicePoint(); //CreateServicepoint //Check if opld tracking number matches with dials matching number SakilaContext context = HttpContext.RequestServices.GetService(typeof(SakilaContext)) as SakilaContext; DIALS dialsObject = context.GetMatchingDialsID(opldObject.TrackingNumber); if (dialsObject != null) { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, dialsObject.ConsigneeName, dialsObject.ClarifiedSignature, true); } else { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, "", "", false); } //Push OPLD in to Active MQ2 CommonUtility <ServicePoint> .PushToActiveMQ(servicePointObject, 3); } catch { return(new JsonResult(new { Result = System.Net.HttpStatusCode.InternalServerError })); } return(Ok()); }
public IActionResult MicroServiceServicePointGeneration(OPLD opldObject) { try { log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Read OPLD message and Start processing."); //CreateServicepoint //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=ams;user=root;password=Password123"); log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Getting OPLD tracking number matching DIALS record."); //Check if opld tracking number matches with dials matching number DIALS dialsObject = context.GetMatchingDialsID(opldObject.SHIP_SP_NR); ServicePoint servicePointObject = new ServicePoint(); if (!string.IsNullOrEmpty(dialsObject.TrackingNumber)) { //Match found //Compare OPLD Add1 with SP Add1 and Update timestamp and increase Stop ID ServicePoint servicePoint = context.CompareOPLDAdd1WithSPAddr1(opldObject.SHIP_ADDR_LINE_1_1); if (servicePoint != null && (servicePoint.ServicePointID != 0)) { context.UpdateServicePoint(servicePoint.ServicePointID); } else { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, dialsObject.ConsigneeName, dialsObject.ClarifiedSignature, true); log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Writing ServicePoint in to DB."); //Write Servicepoint to DB context.AddNewServicePoint(servicePointObject); } } else { //Create Service Point with Stop ID = 1 servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, opldObject.SHIP_ATTENTION_NAME_1, "", false); log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Writing ServicePoint in to DB."); //Write Servicepoint to DB context.AddNewServicePoint(servicePointObject); } //Update OPLD Processing Status context.UpdateOPLDProcessingStatus(opldObject.SHIP_SP_NR); } catch (Exception ex) { log.Error(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: " + Convert.ToString(ex.ToString())); return(new JsonResult(new { Result = System.Net.HttpStatusCode.InternalServerError })); } return(Ok(new { Result = "Success" })); }
//MicroService 4 public IActionResult ReadMQ2OPLDNCreateSPNPushTOMQ3() { try { //Read from MQ //OPLD opldObject = CommonUtility<OPLD>.PullFromActiveMQ(2); log.Info(DateTime.Now.ToString() + " AMS-POC: Service point genration process started."); ServicePoint servicePointObject = new ServicePoint(); var opldProcString = Request.Headers["opldProcString"]; OPLD opldObject = Newtonsoft.Json.JsonConvert.DeserializeObject <OPLD>(opldProcString); //CreateServicepoint //Check if opld tracking number matches with dials matching number SakilaContext context = HttpContext.RequestServices.GetService(typeof(SakilaContext)) as SakilaContext; DIALS dialsObject = context.GetMatchingDialsID(opldObject.TrackingNumber); if (dialsObject != null) { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, dialsObject.ConsigneeName, dialsObject.ClarifiedSignature, true); } else { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, "", "", false); } //Push OPLD in to Active MQ2 CommonUtility <ServicePoint> .PushToActiveMQ(servicePointObject, 3); log.Info(DateTime.Now.ToString() + " AMS-POC: Service point Created and Pushed to MQ3."); } 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()); }
public IActionResult MicroServiceServicePointGeneration(OPLD opldObject) { try { log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Read OPLD message and Start processing."); //CreateServicepoint SakilaContext context = new SakilaContext("server=127.0.01;port=3306;database=ams;user=root;password=techM@Ups1");//HttpContext.RequestServices.GetService(typeof(SakilaContext)) as SakilaContext; log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Getting OPLD tracking number matching DIALS record."); //Check if opld tracking number matches with dials matching number DIALS dialsObject = context.GetMatchingDialsID(opldObject.TrackingNumber); ServicePoint servicePointObject = new ServicePoint(); if (!string.IsNullOrEmpty(dialsObject.TrackingNumber)) { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, dialsObject.ConsigneeName, dialsObject.ClarifiedSignature, true); } else { servicePointObject = ServicePointUtility.CreateServicePoint(opldObject, "", "", false); } log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: Writing ServicePoint in to DB."); //Write Servicepoint to DB context.AddNewServicePoint(servicePointObject); //Update OPLD Processing Status context.UpdateOPLDProcessingStatus(opldObject.TrackingNumber); } catch (Exception ex) { log.Error(DateTime.Now.ToString() + " AMS-POC-MicroServiceServicePointGeneration: " + Convert.ToString(ex.Message)); return(new JsonResult(new { Result = System.Net.HttpStatusCode.InternalServerError })); } return(Ok(new { Result = "Success" })); }
public void DIALSFileWatcher() { try { var dialsFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "DIALSFiles"); var files = Directory.GetFiles(dialsFolderPath); if (files.Length > 0) { foreach (string fileName in files) { log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: DIALS file Read in Progress."); FileStream fileStream = new FileStream(Path.Combine(dialsFolderPath, fileName), FileMode.Open); using (BufferedStream bufferedStream = new BufferedStream(fileStream)) { using (StreamReader streamReader = new StreamReader(bufferedStream)) { while (!streamReader.EndOfStream) { string dialsString = streamReader.ReadLine(); if (!string.IsNullOrEmpty(dialsString.Trim()) && dialsString != "\u001a") { //Process DIALS data var dialsObject = DIALSUtility.ProcessDIALSData(dialsString); //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=ams;user=root;password=Password123"); DIALS dials = context.GetMatchingDialsID(dialsObject.TrackingNumber); //Store in to DB if (!string.IsNullOrEmpty(dialsObject.TrackingNumber) && (dialsObject.TrackingNumber != dials.TrackingNumber)) { MicroServiceProcessDIALSFile(dialsObject); } else { log.Warn(DateTime.Now.ToString() + " AMS-MicroServiceProcessOPLDNDIALSFiles: Tracking number already exists."); continue; } } } } } fileStream.Close(); //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); } else { System.IO.File.Delete(fileName); } } } log.Info(DateTime.Now.ToString() + " AMS-POC-MicroServiceProcessOPLDNDIALSFiles: DIALS file processed and data inserted into DB."); } catch (Exception ex) { log.Error(DateTime.Now.ToString() + " AMS-MicroServiceProcessOPLDNDIALSFiles: " + Convert.ToString(ex.Message)); } }