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 5 public IActionResult ReadMQ3ServicePointNWriteToDB() { try { //Read from MQ //ServicePoint servicePointObject = CommonUtility<ServicePoint>.PullFromActiveMQ(3); var spProcString = Request.Headers["servicePointString"]; ServicePoint servicePointObject = Newtonsoft.Json.JsonConvert.DeserializeObject <ServicePoint>(spProcString); //Write Servicepoint to DB SakilaContext context = HttpContext.RequestServices.GetService(typeof(SakilaContext)) as SakilaContext; context.AddNewServicePoint(servicePointObject); log.Info(DateTime.Now.ToString() + " AMS-POC: Service point inserted in to database."); } 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()); }
//MicroService 5 public IActionResult ReadMQ3ServicePointNWriteToDB() { try { //Read from MQ ServicePoint servicePointObject = CommonUtility <ServicePoint> .PullFromActiveMQ(3); //Write Servicepoint to DB SakilaContext context = HttpContext.RequestServices.GetService(typeof(SakilaContext)) as SakilaContext; context.AddNewServicePoint(servicePointObject); } 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");//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" })); }