Beispiel #1
0
        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" }));
        }