Exemplo n.º 1
0
        public ShipmentDataResponse UpdateShipmentStatusById(ShipmentDataRequest shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();
                optionsBuilder.EnableSensitiveDataLogging(true);

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    ShipmentDataRequest data = context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                    data.ID         = shipmentDataRequest.ID;
                    data.WFL_ID     = shipmentDataRequest.WFL_ID;
                    data.SMT_STA_NR = shipmentDataRequest.SMT_STA_NR;
                    context.shipmentDataRequests.Update(data);
                    context.Entry(shipmentDataRequest).State = EntityState.Detached;
                    context.SaveChanges();
                    shipmentDataResponse.ShipmentDataRequest = context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                    shipmentDataResponse.Success             = true;
                    return(shipmentDataResponse);
                }
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
Exemplo n.º 2
0
        public ShipmentDataResponse UpdateShipmentAddressById(ShipmentDataRequest shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    ShipmentDataRequest data = context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                    int?shipmentStaus        =
                        data.SHP_ADR_TR_TE.ToLower() != shipmentDataRequest.SHP_ADR_TR_TE.ToLower()
                       ? ((int)Enums.ATStatus.Curated)
                       : (data.SMT_STA_NR);

                    data.SHP_ADR_TR_TE = shipmentDataRequest.SHP_ADR_TR_TE;
                    data.COD_TE        = shipmentDataRequest.COD_TE;
                    data.POD_RTN_SVC   = shipmentDataRequest.POD_RTN_SVC;
                    data.SMT_STA_NR    = shipmentStaus;
                    context.shipmentDataRequests.Update(data);
                    context.Entry(shipmentDataRequest).State = EntityState.Detached;
                    context.SaveChanges();
                    shipmentDataResponse.ShipmentDataRequest = context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                    shipmentDataResponse.Success             = true;
                    return(shipmentDataResponse);
                }
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
Exemplo n.º 3
0
        public ShipmentDataResponse DeleteShipment(ShipmentDataRequest shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();


                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

                var context = new ApplicationDbContext(optionsBuilder.Options);

                ShipmentDataRequest data = context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                context.shipmentDataRequests.Remove(data);
                context.Entry(shipmentDataRequest).State = EntityState.Deleted;
                context.SaveChanges();
                shipmentDataResponse.Shipments = context.shipmentDataRequests;
                shipmentDataResponse.Success   = true;
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
Exemplo n.º 4
0
        public ShipmentDataResponse UpdateShipmentStatusById(ShipmentDataRequest shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                data.ID         = shipmentDataRequest.ID;
                data.WFL_ID     = shipmentDataRequest.WFL_ID;
                data.SMT_STA_NR = shipmentDataRequest.SMT_STA_NR;
                this.context.shipmentDataRequests.Update(data);
                this.context.Entry(shipmentDataRequest).State = EntityState.Detached;
                this.context.SaveChanges();
                shipmentDataResponse.ShipmentDataRequest = this.context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                shipmentDataResponse.Success             = true;
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }

            return(shipmentDataResponse);
        }
Exemplo n.º 5
0
        public int CreateShipment(ShipmentDataRequest shipmentData)
        {
            optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            using (var context = new ApplicationDbContext(optionsBuilder.Options))
            {
                ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                shipmentDataRequest.BIL_TYP_TE        = shipmentData.BIL_TYP_TE;
                shipmentDataRequest.CCY_VAL_TE        = shipmentData.CCY_VAL_TE;
                shipmentDataRequest.COD_TE            = shipmentData.COD_TE;
                shipmentDataRequest.CSG_CTC_TE        = shipmentData.CSG_CTC_TE;
                shipmentDataRequest.DIM_WGT_DE        = shipmentData.DIM_WGT_DE;
                shipmentDataRequest.DST_CTY_TE        = shipmentData.DST_CTY_TE;
                shipmentDataRequest.DST_PSL_TE        = shipmentData.DST_PSL_TE;
                shipmentDataRequest.EXP_SLC_CD        = shipmentData.EXP_SLC_CD;
                shipmentDataRequest.EXP_TYP           = shipmentData.EXP_TYP;
                shipmentDataRequest.FST_INV_LN_DES_TE = shipmentData.FST_INV_LN_DES_TE;
                shipmentDataRequest.IMP_NR            = shipmentData.IMP_NR;
                shipmentDataRequest.IMP_SLC_TE        = shipmentData.IMP_SLC_TE;
                shipmentDataRequest.IN_FLG_TE         = shipmentData.IN_FLG_TE;
                shipmentDataRequest.ORG_CTY_TE        = shipmentData.ORG_CTY_TE;
                shipmentDataRequest.ORG_PSL_CD        = shipmentData.ORG_PSL_CD;
                shipmentDataRequest.OU_FLG_TE         = shipmentData.OU_FLG_TE;
                shipmentDataRequest.PCS_QTY_NR        = shipmentData.PCS_QTY_NR;
                shipmentDataRequest.PH_NR             = shipmentData.PH_NR;
                shipmentDataRequest.PKG_NR_TE         = shipmentData.PKG_NR_TE;
                shipmentDataRequest.PKG_WGT_DE        = shipmentData.PKG_WGT_DE;
                shipmentDataRequest.PK_UP_TM          = shipmentData.PK_UP_TM;
                shipmentDataRequest.PYM_MTD           = shipmentData.PYM_MTD;
                shipmentDataRequest.PY_MT_TE          = shipmentData.PY_MT_TE;
                shipmentDataRequest.QQS_TRA_LG_ID     = shipmentData.QQS_TRA_LG_ID;
                shipmentDataRequest.RCV_ADR_TE        = shipmentData.RCV_ADR_TE;
                shipmentDataRequest.RCV_CPY_TE        = shipmentData.RCV_CPY_TE;
                shipmentDataRequest.SF_TRA_LG_ID      = shipmentData.SF_TRA_LG_ID;
                shipmentDataRequest.SHP_ADR_TE        = shipmentData.SHP_ADR_TE;
                shipmentDataRequest.SHP_ADR_TR_TE     = shipmentData.SHP_ADR_TR_TE;
                shipmentDataRequest.SHP_CPY_NA        = shipmentData.SHP_CPY_NA;
                shipmentDataRequest.SHP_CTC_TE        = shipmentData.SHP_CTC_TE;
                shipmentDataRequest.SHP_DT            = shipmentData.SHP_DT;
                shipmentDataRequest.SHP_NR            = shipmentData.SHP_NR;
                shipmentDataRequest.SHP_PH_TE         = shipmentData.SHP_PH_TE;
                shipmentDataRequest.SMT_NR_TE         = shipmentData.SMT_NR_TE;
                shipmentDataRequest.SMT_STA_NR        = shipmentData.SMT_STA_NR;
                shipmentDataRequest.SMT_VAL_DE        = shipmentData.SMT_VAL_DE;
                shipmentDataRequest.SMT_WGT_DE        = shipmentData.SMT_WGT_DE;
                shipmentDataRequest.SVL_NR            = shipmentData.SVL_NR;
                shipmentDataRequest.WFL_ID            = shipmentData.WFL_ID;
                shipmentDataRequest.WGT_UNT_TE        = shipmentData.WGT_UNT_TE;
                shipmentDataRequest.ACY_TE            = shipmentData.ACY_TE;
                shipmentDataRequest.CON_NR            = shipmentData.CON_NR;
                shipmentDataRequest.SPC_SLIC_NR       = shipmentData.SPC_SLIC_NR;
                shipmentDataRequest.POD_RTN_SVC       = shipmentData.POD_RTN_SVC;
                context.shipmentDataRequests.Add(shipmentDataRequest);
                context.Entry(shipmentDataRequest).State = EntityState.Added;
                context.SaveChanges();
            }

            return(0);
        }
        public async Task <ActionResult> UpdateShipmentStatusById([FromBody] ShipmentDataRequest shipmentDataRequest)
        {
            //shipmentService = new ShipmentService();
            ShipmentDataResponse shipmentDataResponse = _shipmentService.UpdateShipmentStatusById(shipmentDataRequest);

            if (!shipmentDataResponse.Success)
            {
                //AuditEventEntry.WriteEntry(new Exception(shipmentDataResponse.OperationExceptionMsg));
            }
            return(Ok(shipmentDataResponse));
        }
Exemplo n.º 7
0
        public async Task <ActionResult> UpdateShipmentAddressById([FromBody] ShipmentDataRequest shipmentDataRequest)
        {
            shipmentService = new ShipmentService();
            ShipmentDataResponse shipmentDataResponse = shipmentService.UpdateShipmentAddressById(shipmentDataRequest);

            //we need to update the workflow status
            int?workflowstatus = shipmentService.SelectShipmentTotalStatusByWorkflowId(shipmentDataRequest.WFL_ID);
            WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();

            workflowDataRequest.ID         = shipmentDataRequest.WFL_ID;
            workflowDataRequest.WFL_STA_TE = workflowstatus;
            workflowService.UpdateWorkflowStatusById(workflowDataRequest);

            return(Ok(shipmentDataResponse));
        }
Exemplo n.º 8
0
        //public ShipmentDataResponse UpdateShipmentAddressByIds(List<ShipmentDataRequest> shipmentDataRequest)
        //{
        //    ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();
        //    try
        //    {
        //        optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();


        //        optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();

        //        var this.context = new ApplicationDbContext(optionsBuilder.Options);

        //        List<ShipmentDataRequest> shipmentDetailsToUpdate = new List<ShipmentDataRequest>();
        //        foreach (ShipmentDataRequest request in shipmentDataRequest)
        //        {
        //            ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == request.ID).FirstOrDefault();
        //            data.ID = request.ID;
        //            data.WFL_ID = request.WFL_ID;
        //            data.SHP_ADR_TR_TE = request.SHP_ADR_TR_TE;
        //            data.SMT_STA_NR = request.SMT_STA_NR;
        //            data.ACY_TE = request.ACY_TE;
        //            data.CON_NR = request.CON_NR;
        //            data.POD_RTN_SVC = request.POD_RTN_SVC;
        //            shipmentDetailsToUpdate.Add(data);
        //            //this.context.shipmentDataRequests.Update(data);
        //            //this.context.Entry(request).State = EntityState.Detached;
        //            //this.context.SaveChanges();
        //            shipmentDataResponse.Shipments = this.context.shipmentDataRequests;
        //        }
        //        this.context.BulkUpdate(shipmentDetailsToUpdate);
        //        //shipmentDataResponse.Shipments = this.context.shipmentDataRequests;
        //        shipmentDataResponse.Success = true;
        //        return shipmentDataResponse;
        //    }
        //    catch (Exception ex)
        //    {
        //        shipmentDataResponse.Success = false;
        //        shipmentDataResponse.OperationExceptionMsg = ex.Message;
        //    }
        //    return shipmentDataResponse;
        //}

        public ShipmentDataResponse DeleteShipments(List <ShipmentDataRequest> shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                int?workflowID    = shipmentDataRequest?.FirstOrDefault().WFL_ID;
                int shipmentCount = 0;

                foreach (ShipmentDataRequest request in shipmentDataRequest)
                {
                    ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == request.ID).FirstOrDefault();
                    this.context.shipmentDataRequests.Remove(data);
                    this.context.Entry(request).State = EntityState.Detached;
                    this.context.SaveChanges();
                }

                if (workflowID.HasValue)
                {
                    shipmentCount = this.context.shipmentDataRequests.Where(ship => ship.WFL_ID == workflowID).Count();
                }

                if (shipmentCount == 0)
                {
                    WorkflowService      workflowService      = new WorkflowService(this.context, this.addressBookService, this.entityValidationService);
                    WorkflowDataResponse workflowDataResponse = workflowService.DeleteWorkflowById(workflowID.Value);
                    if (workflowDataResponse.Success)
                    {
                        shipmentDataResponse.HasWorkflow = false;
                    }
                }
                else
                {
                    shipmentDataResponse.HasWorkflow = true;
                }

                shipmentDataResponse.Success = true;
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
        private ShipmentDataRequest CreateShipmentAddressUpdateRequest(ShipmentDataRequest shipmentDataRequest, Geocode geocode)
        {
            shipmentDataRequest.SHP_ADR_TR_TE    = geocode.translated_adddress;
            shipmentDataRequest.ACY_TE           = geocode.accuracy;
            shipmentDataRequest.CON_NR           = geocode.confidence;
            shipmentDataRequest.TranslationScore = geocode.translation_score;

            if (
                !string.IsNullOrEmpty(geocode.translated_adddress)

                )
            {
                shipmentDataRequest.SMT_STA_NR = ((int)Enums.ATStatus.Translated);
            }
            else
            {
                shipmentDataRequest.SMT_STA_NR = shipmentDataRequest.SMT_STA_NR;
            }

            return(shipmentDataRequest);
        }
Exemplo n.º 10
0
        public ShipmentDataResponse DeleteShipment(ShipmentDataRequest shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                this.context.shipmentDataRequests.Remove(data);
                this.context.Entry(shipmentDataRequest).State = EntityState.Deleted;
                this.context.SaveChanges();
                shipmentDataResponse.Shipments = this.context.shipmentDataRequests;
                shipmentDataResponse.Success   = true;
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
Exemplo n.º 11
0
        public ShipmentDataResponse UpdateShipmentAddressByIds(List <ShipmentDataRequest> shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();


                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

                var context = new ApplicationDbContext(optionsBuilder.Options);

                foreach (ShipmentDataRequest request in shipmentDataRequest)
                {
                    ShipmentDataRequest data = context.shipmentDataRequests.Where(s => s.ID == request.ID).FirstOrDefault();
                    data.ID            = request.ID;
                    data.WFL_ID        = request.WFL_ID;
                    data.SHP_ADR_TR_TE = request.SHP_ADR_TR_TE;
                    data.SMT_STA_NR    = request.SMT_STA_NR;
                    data.ACY_TE        = request.ACY_TE;
                    data.CON_NR        = request.CON_NR;
                    data.POD_RTN_SVC   = request.POD_RTN_SVC;
                    context.shipmentDataRequests.Update(data);
                    context.Entry(request).State = EntityState.Detached;
                    context.SaveChanges();
                    shipmentDataResponse.Shipments = context.shipmentDataRequests;
                }
                shipmentDataResponse.Success = true;
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }
            return(shipmentDataResponse);
        }
Exemplo n.º 12
0
        private List <ShipmentDataRequest> ExtractShipmentDataRequest(List <ExcelDataObject> excelDataObjects, int workflowID, string addressBookEnable, out int?workflowStatus)
        {
            List <ShipmentDataRequest> shipmentData = new List <ShipmentDataRequest>();
            List <AddressBook>         addressBooks = this.addressBookService.GetAddressBooks();
            int?wfStatus = 0;

            //foreach (ExcelDataObject excelDataObject in excelDataObjects)
            excelDataObjects.ForEach(excelDataObject =>
            {
                bool allPropertiesNull = !excelDataObject.GetType().GetProperties().Any(prop => prop == null);
                if (allPropertiesNull)
                {
                    ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();

                    if (!string.IsNullOrWhiteSpace(excelDataObject.S_shipmentno))
                    {
                        shipmentDataRequest.BIL_TYP_TE = excelDataObject.S_billtype;
                        shipmentDataRequest.CCY_VAL_TE = string.Empty;
                        shipmentDataRequest.COD_TE     = string.Empty;
                        shipmentDataRequest.CSG_CTC_TE = excelDataObject.S_cneectc;

                        decimal decimalvalue           = 0;
                        shipmentDataRequest.DIM_WGT_DE = 0;
                        if (!string.IsNullOrEmpty(excelDataObject.S_dimwei))
                        {
                            if (decimal.TryParse(excelDataObject.S_dimwei, out decimalvalue))
                            {
                                shipmentDataRequest.DIM_WGT_DE = decimalvalue;
                            }
                        }

                        //shipmentDataRequest.DIM_WGT_DE = null; //Convert.ToDecimal(excelDataObject.S_dimwei);
                        shipmentDataRequest.DST_CTY_TE = excelDataObject.S_dstcity;
                        shipmentDataRequest.DST_PSL_TE = excelDataObject.S_dstpsl != null && excelDataObject.S_dstpsl.Contains('.') ? excelDataObject.S_dstpsl.Split('.')[0] : excelDataObject.S_dstpsl;
                        shipmentDataRequest.EXP_SLC_CD = excelDataObject.S_expslic;
                        shipmentDataRequest.EXP_TYP    = "顺丰即日";//excelDataObject.S_expslic;
                        shipmentDataRequest.IMP_NR     = excelDataObject.S_impr;
                        shipmentDataRequest.IMP_SLC_TE = excelDataObject.S_impslic;
                        shipmentDataRequest.IN_FLG_TE  = excelDataObject.S_inflight;
                        shipmentDataRequest.ORG_CTY_TE = excelDataObject.S_orgcity;

                        string pststring = Convert.ToString(excelDataObject.S_orgpsl);
                        if (InputValidations.IsDecimalFormat(pststring))
                        {
                            shipmentDataRequest.ORG_PSL_CD = Decimal.ToInt32(Decimal.Parse(pststring)).ToString();
                        }
                        else
                        {
                            shipmentDataRequest.ORG_PSL_CD = pststring;
                        }

                        // OU_FLG_TE = Convert.ToString(excelDataObject.S_outflight),

                        int intvalue = 0;
                        shipmentDataRequest.PCS_QTY_NR = 0;
                        if (!string.IsNullOrEmpty(excelDataObject.pcs))
                        {
                            if (int.TryParse(excelDataObject.pcs, out intvalue))
                            {
                                shipmentDataRequest.PCS_QTY_NR = intvalue;
                            }
                        }

                        //shipmentDataRequest.PCS_QTY_NR = null;//Convert.ToInt32(Convert.ToDouble(excelDataObject.pcs));
                        shipmentDataRequest.PH_NR      = excelDataObject.S_ph != null && excelDataObject.S_ph.Contains('.') ? excelDataObject.S_ph.Split('.')[0] : excelDataObject.S_ph;
                        shipmentDataRequest.PKG_NR_TE  = excelDataObject.S_packageno;
                        shipmentDataRequest.PKG_WGT_DE = Convert.ToDecimal(excelDataObject.S_pkgwei);
                        shipmentDataRequest.PK_UP_TM   = null;   //Convert.ToString(excelDataObject.S_pkuptime),
                        shipmentDataRequest.PYM_MTD    = "寄付月结"; //excelDataObject.pymt;
                        shipmentDataRequest.RCV_ADR_TE = excelDataObject.S_address1;
                        shipmentDataRequest.RCV_CPY_TE = excelDataObject.S_receivercompany;
                        shipmentDataRequest.SHP_ADR_TE = excelDataObject.address;

                        if (addressBookEnable.ToLower() == "true")
                        {
                            AddressBook translatedAddress =
                                addressBooks
                                ?.FirstOrDefault(
                                    (AddressBook address) =>
                                    address.ConsigneeAddress.Replace(" ", "").ToLower().Trim().Equals(
                                        excelDataObject.S_address1.Replace(" ", "").ToLower().Trim(), StringComparison.OrdinalIgnoreCase));

                            if (translatedAddress != null)
                            {
                                shipmentDataRequest.SHP_ADR_TR_TE = translatedAddress.ConsigneeTranslatedAddress;
                                shipmentDataRequest.SMT_STA_NR    = (int)Enums.ATStatus.Translated;
                                wfStatus = shipmentDataRequest.SMT_STA_NR;
                                shipmentDataRequest.SMT_STA_TE       = Convert.ToString(Enums.ATStatus.Translated);
                                shipmentDataRequest.CON_NR           = translatedAddress.Confidence;
                                shipmentDataRequest.ACY_TE           = translatedAddress.Accuracy;
                                shipmentDataRequest.TranslationScore = translatedAddress.TranslationScore;
                            }
                            else
                            {
                                shipmentDataRequest.SHP_ADR_TR_TE = string.Empty;
                                shipmentDataRequest.SMT_STA_NR    = (int)Enums.ATStatus.Uploaded;
                                shipmentDataRequest.SMT_STA_TE    = Convert.ToString(Enums.ATStatus.Uploaded);
                            }
                        }
                        else if (addressBookEnable.ToLower() == "false")
                        {
                            shipmentDataRequest.SHP_ADR_TR_TE = string.Empty;
                            shipmentDataRequest.SMT_STA_NR    = (int)Enums.ATStatus.Uploaded;
                            shipmentDataRequest.SMT_STA_TE    = Convert.ToString(Enums.ATStatus.Uploaded);
                        }

                        shipmentDataRequest.SHP_CPY_NA = excelDataObject.S_shippercompany;
                        shipmentDataRequest.SHP_CTC_TE = excelDataObject.S_shptctc;

                        DateTime dDate;
                        int intdate;
                        shipmentDataRequest.SHP_DT = null;
                        if (!string.IsNullOrEmpty(excelDataObject.S_shipdate))
                        {
                            if (int.TryParse(excelDataObject.S_shipdate, out intdate))
                            {
                                shipmentDataRequest.SHP_DT = null;
                            }
                            else if (DateTime.TryParse(excelDataObject.S_shipdate, out dDate))
                            {
                                shipmentDataRequest.SHP_DT = Convert.ToDateTime(excelDataObject.S_shipdate);
                            }
                        }
                        //if(!string.IsNullOrEmpty(excelDataObject.S_shipdate))
                        //{
                        //    if (DateTime.TryParse(excelDataObject.S_shipdate, out dDate))
                        //    {
                        //        shipmentDataRequest.SHP_DT = Convert.ToDateTime(excelDataObject.S_shipdate);
                        //    }
                        //}
                        shipmentDataRequest.SHP_DT    = null; //Convert.ToDateTime(excelDataObject.S_shipdate);
                        shipmentDataRequest.SHP_NR    = excelDataObject.S_shpr;
                        shipmentDataRequest.SHP_PH_TE = excelDataObject.S_shptph != null && excelDataObject.S_shptph.Contains('.') ? excelDataObject.S_shptph.Split('.')[0] : excelDataObject.S_shptph;
                        shipmentDataRequest.SMT_NR_TE = excelDataObject.S_shipmentno;

                        shipmentDataRequest.SMT_VAL_DE        = 0;
                        shipmentDataRequest.SMT_WGT_DE        = Convert.ToDecimal(excelDataObject.S_shptwei);
                        shipmentDataRequest.SVL_NR            = Convert.ToString(excelDataObject.svl);
                        shipmentDataRequest.WGT_UNT_TE        = excelDataObject.S_weiunit;
                        shipmentDataRequest.WFL_ID            = workflowID;
                        shipmentDataRequest.SF_TRA_LG_ID      = null;
                        shipmentDataRequest.QQS_TRA_LG_ID     = null;
                        shipmentDataRequest.FST_INV_LN_DES_TE = excelDataObject.S_1stinvoicelinedesc;
                        shipmentDataRequest.POD_RTN_SVC       = "0";

                        shipmentData.Add(shipmentDataRequest);
                    }
                }
            });
            workflowStatus = wfStatus;
            return(shipmentData);
        }
        public async Task <ActionResult> UpdateShipmentAddressById([FromBody] ShipmentDataRequest shipmentDataRequest)
        {
            //shipmentService = new ShipmentService();
            string id = HttpContext.User.Claims.FirstOrDefault(x => x.Type == JwtConstant.UserId)?.Value;

            int userId = !string.IsNullOrEmpty(id) ? Convert.ToInt32(id) : 0;
            ShipmentDataResponse shipmentDataResponse = _shipmentService.UpdateShipmentAddressById(shipmentDataRequest);

            if (shipmentDataResponse.Success && !string.IsNullOrEmpty(shipmentDataResponse.BeforeAddress))
            {
                try
                {
                    //AddressAuditLog Update
                    AddressAuditLogRequest addressAuditLogRequest = new AddressAuditLogRequest();
                    addressAuditLogRequest.SMT_ID  = shipmentDataRequest.ID;
                    addressAuditLogRequest.CSG_ADR = shipmentDataRequest.RCV_ADR_TE;
                    addressAuditLogRequest.BFR_ADR = shipmentDataResponse.BeforeAddress;
                    addressAuditLogRequest.AFR_ADR = shipmentDataResponse.ShipmentDataRequest.SHP_ADR_TR_TE;
                    addressAuditLogRequest.UPD_BY  = userId;
                    addressAuditLogRequest.UPD_FRM = "Shipment";
                    addressAuditLogRequest.UPD_DT  = DateTime.Parse(DateTime.Now.ToString()).ToLocalTime();
                    addressAuditLogRequest.WFL_ID  = shipmentDataResponse.ShipmentDataRequest.WFL_ID;
                    AddressAuditLogResponse addressAuditLogResponse = addressAuditLogService.Insert(addressAuditLogRequest);
                    if (addressAuditLogResponse.Success)
                    {
                        // TO DO
                    }
                    else
                    {
                        // Log the error here
                    }
                }
                catch (Exception ex)
                {
                }
            }

            //we need to update the workflow status
            int?workflowstatus = _shipmentService.SelectShipmentTotalStatusByWorkflowId(shipmentDataRequest.WFL_ID);
            WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();

            workflowDataRequest.ID         = shipmentDataRequest.WFL_ID;
            workflowDataRequest.WFL_STA_TE = workflowstatus;
            _workflowService.UpdateWorkflowStatusById(workflowDataRequest);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
            {
                apiTypes       = UPS.DataObjects.LogData.APITypes.EFCoreContext,
                apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 6),
                dateTime       = System.DateTime.Now,
                LogInformation = new UPS.DataObjects.LogData.LogInformation()
                {
                    LogException = null,
                    LogRequest   = JsonConvert.SerializeObject(shipmentDataRequest),
                    LogResponse  = JsonConvert.SerializeObject(shipmentDataResponse)
                }
            }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            return(Ok(shipmentDataResponse));
        }
Exemplo n.º 14
0
        public ShipmentDataResponse CreateShipments(List <ShipmentDataRequest> shipmentData)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    foreach (ShipmentDataRequest Data in shipmentData)
                    {
                        ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                        shipmentDataRequest.BIL_TYP_TE        = Data.BIL_TYP_TE;
                        shipmentDataRequest.CCY_VAL_TE        = Data.CCY_VAL_TE;
                        shipmentDataRequest.COD_TE            = Data.COD_TE;
                        shipmentDataRequest.CSG_CTC_TE        = Data.CSG_CTC_TE;
                        shipmentDataRequest.DIM_WGT_DE        = Data.DIM_WGT_DE;
                        shipmentDataRequest.DST_CTY_TE        = Data.DST_CTY_TE;
                        shipmentDataRequest.DST_PSL_TE        = Data.DST_PSL_TE;
                        shipmentDataRequest.EXP_SLC_CD        = Data.EXP_SLC_CD;
                        shipmentDataRequest.EXP_TYP           = Data.EXP_TYP;
                        shipmentDataRequest.FST_INV_LN_DES_TE = Data.FST_INV_LN_DES_TE;
                        shipmentDataRequest.IMP_NR            = Data.IMP_NR;
                        shipmentDataRequest.IMP_SLC_TE        = Data.IMP_SLC_TE;
                        shipmentDataRequest.IN_FLG_TE         = Data.IN_FLG_TE;
                        shipmentDataRequest.ORG_CTY_TE        = Data.ORG_CTY_TE;
                        shipmentDataRequest.ORG_PSL_CD        = Data.ORG_PSL_CD;
                        shipmentDataRequest.OU_FLG_TE         = Data.OU_FLG_TE;
                        shipmentDataRequest.PCS_QTY_NR        = Data.PCS_QTY_NR;
                        shipmentDataRequest.PH_NR             = Data.PH_NR;
                        shipmentDataRequest.PKG_NR_TE         = Data.PKG_NR_TE;
                        shipmentDataRequest.PKG_WGT_DE        = Data.PKG_WGT_DE;
                        shipmentDataRequest.PK_UP_TM          = null; //Data.PK_UP_TM;
                        shipmentDataRequest.PYM_MTD           = Data.PYM_MTD;
                        shipmentDataRequest.PY_MT_TE          = Data.PY_MT_TE;
                        shipmentDataRequest.QQS_TRA_LG_ID     = Data.QQS_TRA_LG_ID;
                        shipmentDataRequest.RCV_ADR_TE        = Data.RCV_ADR_TE;
                        shipmentDataRequest.RCV_CPY_TE        = Data.RCV_CPY_TE;
                        shipmentDataRequest.SF_TRA_LG_ID      = Data.SF_TRA_LG_ID;
                        shipmentDataRequest.SHP_ADR_TE        = Data.SHP_ADR_TE;
                        shipmentDataRequest.SHP_ADR_TR_TE     = Data.SHP_ADR_TR_TE;
                        shipmentDataRequest.SHP_CPY_NA        = Data.SHP_CPY_NA;
                        shipmentDataRequest.SHP_CTC_TE        = Data.SHP_CTC_TE;
                        shipmentDataRequest.SHP_DT            = null; //Data.SHP_DT;
                        shipmentDataRequest.SHP_NR            = Data.SHP_NR;
                        shipmentDataRequest.SHP_PH_TE         = Data.SHP_PH_TE;
                        shipmentDataRequest.SMT_NR_TE         = Data.SMT_NR_TE;
                        shipmentDataRequest.SMT_STA_NR        = Data.SMT_STA_NR;
                        shipmentDataRequest.SMT_VAL_DE        = Data.SMT_VAL_DE;
                        shipmentDataRequest.SMT_WGT_DE        = Data.SMT_WGT_DE;
                        shipmentDataRequest.SVL_NR            = Data.SVL_NR;
                        shipmentDataRequest.WFL_ID            = Data.WFL_ID;
                        shipmentDataRequest.WGT_UNT_TE        = Data.WGT_UNT_TE;
                        shipmentDataRequest.POD_RTN_SVC       = Data.POD_RTN_SVC;
                        context.shipmentDataRequests.Add(shipmentDataRequest);
                        context.Entry(shipmentDataRequest).State = EntityState.Added;
                    }

                    context.SaveChanges();
                    shipmentDataResponse.Shipments = shipmentData; //context.shipmentDataRequests.ToList();
                    shipmentDataResponse.Success   = true;
                    return(shipmentDataResponse);
                }

                //return shipmentDataResponse;
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 15
0
        //[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
        //[HttpPost]
        public ShipmentDataResponse CreateShipments(List <ExcelDataObject> excelDataObjects, int workflowID)
        {
            //int i = 0;
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                List <ShipmentDataRequest> shipmentData = new List <ShipmentDataRequest>();
                foreach (ExcelDataObject excelDataObject in excelDataObjects)
                {
                    bool allPropertiesNull = !excelDataObject.GetType().GetProperties().Any(prop => prop == null);
                    if (allPropertiesNull)
                    {
                        ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();

                        if (!string.IsNullOrWhiteSpace(excelDataObject.S_shipmentno))
                        {
                            shipmentDataRequest.BIL_TYP_TE = excelDataObject.S_billtype;
                            shipmentDataRequest.CCY_VAL_TE = string.Empty;
                            shipmentDataRequest.COD_TE     = string.Empty;
                            shipmentDataRequest.CSG_CTC_TE = excelDataObject.S_cneectc;

                            decimal decimalvalue = 0;
                            shipmentDataRequest.DIM_WGT_DE = 0;
                            if (!string.IsNullOrEmpty(excelDataObject.S_dimwei))
                            {
                                if (decimal.TryParse(excelDataObject.S_dimwei, out decimalvalue))
                                {
                                    shipmentDataRequest.DIM_WGT_DE = decimalvalue;
                                }
                            }

                            //shipmentDataRequest.DIM_WGT_DE = null; //Convert.ToDecimal(excelDataObject.S_dimwei);
                            shipmentDataRequest.DST_CTY_TE = excelDataObject.S_dstcity;
                            shipmentDataRequest.DST_PSL_TE = excelDataObject.S_dstpsl;
                            shipmentDataRequest.EXP_SLC_CD = excelDataObject.S_expslic;
                            shipmentDataRequest.EXP_TYP    = "顺丰即日";//excelDataObject.S_expslic;
                            shipmentDataRequest.IMP_NR     = excelDataObject.S_impr;
                            shipmentDataRequest.IMP_SLC_TE = excelDataObject.S_impslic;
                            shipmentDataRequest.IN_FLG_TE  = excelDataObject.S_inflight;
                            shipmentDataRequest.ORG_CTY_TE = excelDataObject.S_orgcity;

                            string pststring = Convert.ToString(excelDataObject.S_orgpsl);
                            if (InputValidations.IsDecimalFormat(pststring))
                            {
                                shipmentDataRequest.ORG_PSL_CD = Decimal.ToInt32(Decimal.Parse(pststring)).ToString();
                            }
                            else
                            {
                                shipmentDataRequest.ORG_PSL_CD = pststring;
                            }

                            // OU_FLG_TE = Convert.ToString(excelDataObject.S_outflight),

                            int intvalue = 0;
                            shipmentDataRequest.PCS_QTY_NR = 0;
                            if (!string.IsNullOrEmpty(excelDataObject.pcs))
                            {
                                if (int.TryParse(excelDataObject.pcs, out intvalue))
                                {
                                    shipmentDataRequest.PCS_QTY_NR = intvalue;
                                }
                            }

                            //shipmentDataRequest.PCS_QTY_NR = null;//Convert.ToInt32(Convert.ToDouble(excelDataObject.pcs));
                            shipmentDataRequest.PH_NR         = excelDataObject.S_ph;
                            shipmentDataRequest.PKG_NR_TE     = excelDataObject.S_packageno;
                            shipmentDataRequest.PKG_WGT_DE    = Convert.ToDecimal(excelDataObject.S_pkgwei);
                            shipmentDataRequest.PK_UP_TM      = null;   //Convert.ToString(excelDataObject.S_pkuptime),
                            shipmentDataRequest.PYM_MTD       = "寄付月结"; //excelDataObject.pymt;
                            shipmentDataRequest.RCV_ADR_TE    = excelDataObject.S_address1;
                            shipmentDataRequest.RCV_CPY_TE    = excelDataObject.S_receivercompany;
                            shipmentDataRequest.SHP_ADR_TE    = excelDataObject.address;
                            shipmentDataRequest.SHP_ADR_TR_TE = string.Empty;
                            shipmentDataRequest.SHP_CPY_NA    = excelDataObject.S_shippercompany;
                            shipmentDataRequest.SHP_CTC_TE    = excelDataObject.S_shptctc;

                            DateTime dDate;
                            int      intdate;
                            shipmentDataRequest.SHP_DT = null;
                            if (!string.IsNullOrEmpty(excelDataObject.S_shipdate))
                            {
                                if (int.TryParse(excelDataObject.S_shipdate, out intdate))
                                {
                                    shipmentDataRequest.SHP_DT = null;
                                }
                                else if (DateTime.TryParse(excelDataObject.S_shipdate, out dDate))
                                {
                                    shipmentDataRequest.SHP_DT = Convert.ToDateTime(excelDataObject.S_shipdate);
                                }
                            }
                            //if(!string.IsNullOrEmpty(excelDataObject.S_shipdate))
                            //{
                            //    if (DateTime.TryParse(excelDataObject.S_shipdate, out dDate))
                            //    {
                            //        shipmentDataRequest.SHP_DT = Convert.ToDateTime(excelDataObject.S_shipdate);
                            //    }
                            //}
                            shipmentDataRequest.SHP_DT            = null; //Convert.ToDateTime(excelDataObject.S_shipdate);
                            shipmentDataRequest.SHP_NR            = excelDataObject.S_shpr;
                            shipmentDataRequest.SHP_PH_TE         = excelDataObject.S_shptph;
                            shipmentDataRequest.SMT_NR_TE         = excelDataObject.S_shipmentno;
                            shipmentDataRequest.SMT_STA_NR        = 0;
                            shipmentDataRequest.SMT_STA_TE        = "Uploaded";
                            shipmentDataRequest.SMT_VAL_DE        = 0;
                            shipmentDataRequest.SMT_WGT_DE        = Convert.ToDecimal(excelDataObject.S_shptwei);
                            shipmentDataRequest.SVL_NR            = Convert.ToString(excelDataObject.svl);
                            shipmentDataRequest.WGT_UNT_TE        = excelDataObject.S_weiunit;
                            shipmentDataRequest.WFL_ID            = workflowID;
                            shipmentDataRequest.SF_TRA_LG_ID      = null;
                            shipmentDataRequest.QQS_TRA_LG_ID     = null;
                            shipmentDataRequest.FST_INV_LN_DES_TE = excelDataObject.S_1stinvoicelinedesc;
                            shipmentDataRequest.POD_RTN_SVC       = "0";

                            shipmentData.Add(shipmentDataRequest);
                        }
                    }
                }
                shipmentService              = new ShipmentService();
                shipmentDataResponse         = shipmentService.CreateShipments(shipmentData);
                shipmentDataResponse.Success = true;
                return(shipmentDataResponse);
            }
            catch (Exception exception)
            {
                shipmentDataResponse.OperationExceptionMsg = exception.Message;
                shipmentDataResponse.Success = true;
                AuditEventEntry.WriteEntry(new Exception(exception.Message));
            }
            return(shipmentDataResponse);
        }
Exemplo n.º 16
0
        public async Task <ActionResult> CreateOrderShipment([FromBody] List <UIOrderRequestBodyData> uIOrderRequestBodyDatas)
        {
            _workflowID = uIOrderRequestBodyDatas[0].wfL_ID;
            CreateOrderShipmentResponse createOrderShipmentResponse = new CreateOrderShipmentResponse();

            createOrderShipmentResponse.FailedToProcessShipments = new List <string>();
            createOrderShipmentResponse.ProcessedShipments       = new List <string>();
            ShipmentService shipmentService = new ShipmentService();

            //List<UIOrderRequestBodyData> uIOrderRequestBodyDatas = new List<UIOrderRequestBodyData>();

            foreach (var orderRequest in uIOrderRequestBodyDatas)
            {
                string XMLMessage = string.Empty;

                XMLMessage  = "<Request lang=\"zh-CN\" service=\"OrderService\">";
                XMLMessage += "<Head>LJ_T6NVV</Head>";
                XMLMessage += "<Body>";
                XMLMessage += "<Order orderid=\"" + orderRequest.pkG_NR_TE + "\" custid=\"" + 7551234567 + "\"";
                XMLMessage += " j_tel=\"" + orderRequest.shP_CTC_TE + "\"";
                XMLMessage += " j_address=\"" + orderRequest.shP_ADR_TE + "\"";
                XMLMessage += " d_tel=\"" + orderRequest.pH_NR + "\"";
                XMLMessage += " d_address=\"" + orderRequest.shP_ADR_TR_TE + "\" cargo_total_weight=\"" + orderRequest.pkG_WGT_DE + "\"";
                XMLMessage += " pay_method=\"1\" is_docall=\"" + 1 + "\" need_return_tracking_no=\"" + orderRequest.poD_RTN_SVC + "\" express_type=\"6\"";
                XMLMessage += " >";
                XMLMessage += " </Order></Body></Request>";


                SFCreateOrderServiceRequest sFCreateOrderServiceRequest = new SFCreateOrderServiceRequest()
                {
                    AccessNumber           = configuration["SFExpress:Access Number"],
                    BaseURI                = configuration["SFExpress:Base URI"],
                    Checkword              = configuration["SFExpress:Checkword"],
                    RequestURI             = configuration["SFExpress:Place Order URI"],
                    RequestOrderXMLMessage = XMLMessage,
                };

                GetSFCreateOrderServiceResponse getSFCreateOrderServiceResponse = QuincusService.SFExpressCreateOrder(sFCreateOrderServiceRequest);

                //shipmentDataResponse = shipmentService.UpdateShipmentStatusById(shipmentDataRequest);
                //if (!shipmentDataResponse.Success)
                //{
                //    AuditEventEntry.WriteEntry(new Exception(shipmentDataResponse.OperationExceptionMsg));
                //}

                if (getSFCreateOrderServiceResponse.Response)
                {
                    XmlDocument xmlDocumentShipmentResponse = new XmlDocument();
                    xmlDocumentShipmentResponse.LoadXml(getSFCreateOrderServiceResponse.OrderResponse);

                    string xmlDocumentShipmentResponseParser = xmlDocumentShipmentResponse.InnerXml;

                    if (xmlDocumentShipmentResponseParser.Contains("<ERROR"))
                    {
                        if (xmlDocumentShipmentResponseParser.Contains("8019"))
                        {
                            createOrderShipmentResponse.FailedToProcessShipments.Add("Customer order number(" + orderRequest.pkG_NR_TE + ") is already confirmed");
                        }
                        else if (xmlDocumentShipmentResponseParser.Contains("8016"))
                        {
                            createOrderShipmentResponse.FailedToProcessShipments.Add("Repeat order numbers ( " + orderRequest.pkG_NR_TE + " )");
                        }
                        else
                        {
                            createOrderShipmentResponse.FailedToProcessShipments.Add(orderRequest.pkG_NR_TE);
                        }
                    }
                    else
                    {
                        createOrderShipmentResponse.ProcessedShipments.Add(orderRequest.pkG_NR_TE);

                        ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                        shipmentDataRequest.ID         = orderRequest.id;
                        shipmentDataRequest.WFL_ID     = orderRequest.wfL_ID;
                        shipmentDataRequest.SMT_STA_NR = ((int)Enums.ATStatus.Completed);
                        shipmentDataRequest.SMT_STA_TE = "Completed";
                        _workflowID = orderRequest.wfL_ID;

                        shipmentService.UpdateShipmentStatusById(shipmentDataRequest);
                    }

                    createOrderShipmentResponse.Response = true;
                }
                else
                {
                    createOrderShipmentResponse.Response = false;
                    if (getSFCreateOrderServiceResponse.exception != null)
                    {
                        AuditEventEntry.WriteEntry(new Exception(getSFCreateOrderServiceResponse.exception.ToString()));
                    }
                }
            }
            //we need to update the workflow status
            int?                workflowstatus      = shipmentService.SelectShipmentTotalStatusByWorkflowId(_workflowID);
            WorkflowService     workflowService     = new WorkflowService();
            WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();

            workflowDataRequest.ID         = _workflowID;
            workflowDataRequest.WFL_STA_TE = workflowstatus;
            workflowService.UpdateWorkflowStatusById(workflowDataRequest);
            return(Ok(createOrderShipmentResponse));
        }
Exemplo n.º 17
0
        public List <ShipmentDataRequest> GetShipment(int workflowID)
        {
            optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            List <ShipmentDataRequest> shipmentDataRequests = null;

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    shipmentDataRequests = new List <ShipmentDataRequest>();
                    var anonymousList =
                        (
                            from s in context.shipmentDataRequests
                            where s.WFL_ID == workflowID &&
                            s.SMT_STA_NR != (int)Enums.ATStatus.Completed &&
                            s.SMT_STA_NR != (int)Enums.ATStatus.Inactive
                            orderby s.ID
                            select new
                    {
                        s.ID,
                        s.WFL_ID,
                        s.ACY_TE,
                        s.BIL_TYP_TE,
                        s.CCY_VAL_TE,
                        s.COD_TE,
                        s.CON_NR,
                        s.CSG_CTC_TE,
                        s.DIM_WGT_DE,
                        s.DST_CTY_TE,
                        s.DST_PSL_TE,
                        s.EXP_SLC_CD,
                        s.EXP_TYP,
                        s.FST_INV_LN_DES_TE,
                        s.IMP_NR,
                        s.IMP_SLC_TE,
                        s.IN_FLG_TE,
                        s.ORG_CTY_TE,
                        s.ORG_PSL_CD,
                        s.OU_FLG_TE,
                        s.PCS_QTY_NR,
                        s.PH_NR,
                        s.PKG_NR_TE,
                        s.PKG_WGT_DE,
                        s.PK_UP_TM,
                        s.PYM_MTD,
                        s.PY_MT_TE,
                        s.QQS_TRA_LG_ID,
                        s.RCV_ADR_TE,
                        s.RCV_CPY_TE,
                        s.SF_TRA_LG_ID,
                        s.SHP_ADR_TE,
                        s.SHP_ADR_TR_TE,
                        s.SHP_CPY_NA,
                        s.SHP_CTC_TE,
                        s.SHP_DT,
                        s.SHP_NR,
                        s.SHP_PH_TE,
                        s.SMT_NR_TE,
                        s.SMT_STA_NR,
                        s.SMT_VAL_DE,
                        s.SMT_WGT_DE,
                        s.SPC_SLIC_NR,
                        s.SVL_NR,
                        s.WGT_UNT_TE,
                        s.POD_RTN_SVC
                    }).ToList();

                    foreach (var shipmentData in anonymousList)
                    {
                        ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                        shipmentDataRequest.ID                = shipmentData.ID;
                        shipmentDataRequest.BIL_TYP_TE        = shipmentData.BIL_TYP_TE;
                        shipmentDataRequest.CCY_VAL_TE        = shipmentData.CCY_VAL_TE;
                        shipmentDataRequest.COD_TE            = shipmentData.COD_TE;
                        shipmentDataRequest.CSG_CTC_TE        = shipmentData.CSG_CTC_TE;
                        shipmentDataRequest.DIM_WGT_DE        = shipmentData.DIM_WGT_DE;
                        shipmentDataRequest.DST_CTY_TE        = shipmentData.DST_CTY_TE;
                        shipmentDataRequest.DST_PSL_TE        = shipmentData.DST_PSL_TE;
                        shipmentDataRequest.EXP_SLC_CD        = shipmentData.EXP_SLC_CD;
                        shipmentDataRequest.EXP_TYP           = shipmentData.EXP_TYP;
                        shipmentDataRequest.FST_INV_LN_DES_TE = shipmentData.FST_INV_LN_DES_TE;
                        shipmentDataRequest.IMP_NR            = shipmentData.IMP_NR;
                        shipmentDataRequest.IMP_SLC_TE        = shipmentData.IMP_SLC_TE;
                        shipmentDataRequest.IN_FLG_TE         = shipmentData.IN_FLG_TE;
                        shipmentDataRequest.ORG_CTY_TE        = shipmentData.ORG_CTY_TE;
                        shipmentDataRequest.ORG_PSL_CD        = shipmentData.ORG_PSL_CD;
                        shipmentDataRequest.OU_FLG_TE         = shipmentData.OU_FLG_TE;
                        shipmentDataRequest.PCS_QTY_NR        = shipmentData.PCS_QTY_NR;
                        shipmentDataRequest.PH_NR             = shipmentData.PH_NR;
                        shipmentDataRequest.PKG_NR_TE         = shipmentData.PKG_NR_TE;
                        shipmentDataRequest.PKG_WGT_DE        = shipmentData.PKG_WGT_DE;
                        shipmentDataRequest.PK_UP_TM          = shipmentData.PK_UP_TM;
                        shipmentDataRequest.PYM_MTD           = shipmentData.PYM_MTD;
                        shipmentDataRequest.PY_MT_TE          = shipmentData.PY_MT_TE;
                        shipmentDataRequest.QQS_TRA_LG_ID     = shipmentData.QQS_TRA_LG_ID;
                        shipmentDataRequest.RCV_ADR_TE        = shipmentData.RCV_ADR_TE;
                        shipmentDataRequest.RCV_CPY_TE        = shipmentData.RCV_CPY_TE;
                        shipmentDataRequest.SF_TRA_LG_ID      = shipmentData.SF_TRA_LG_ID;
                        shipmentDataRequest.SHP_ADR_TE        = shipmentData.SHP_ADR_TE;
                        shipmentDataRequest.SHP_ADR_TR_TE     = shipmentData.SHP_ADR_TR_TE;
                        shipmentDataRequest.SHP_CPY_NA        = shipmentData.SHP_CPY_NA;
                        shipmentDataRequest.SHP_CTC_TE        = shipmentData.SHP_CTC_TE;
                        shipmentDataRequest.SHP_DT            = shipmentData.SHP_DT;
                        shipmentDataRequest.SHP_NR            = shipmentData.SHP_NR;
                        shipmentDataRequest.SHP_PH_TE         = shipmentData.SHP_PH_TE;
                        shipmentDataRequest.SMT_NR_TE         = shipmentData.SMT_NR_TE;
                        shipmentDataRequest.SMT_STA_NR        = shipmentData.SMT_STA_NR;

                        switch (shipmentDataRequest.SMT_STA_NR)
                        {
                        case 0:
                            shipmentDataRequest.SMT_STA_TE = "Uploaded";
                            break;

                        case 1:
                            shipmentDataRequest.SMT_STA_TE = "Curated";
                            break;

                        case 2:
                            shipmentDataRequest.SMT_STA_TE = "Translated";
                            break;

                        case 3:
                            shipmentDataRequest.SMT_STA_TE = "Completed";
                            break;

                        case 4:
                            shipmentDataRequest.SMT_STA_TE = "Inactive";
                            break;

                        default:
                            shipmentDataRequest.SMT_STA_TE = "Uploaded";
                            break;
                        }

                        shipmentDataRequest.SMT_VAL_DE  = shipmentData.SMT_VAL_DE;
                        shipmentDataRequest.SMT_WGT_DE  = shipmentData.SMT_WGT_DE;
                        shipmentDataRequest.SVL_NR      = shipmentData.SVL_NR;
                        shipmentDataRequest.WFL_ID      = shipmentData.WFL_ID;
                        shipmentDataRequest.WGT_UNT_TE  = shipmentData.WGT_UNT_TE;
                        shipmentDataRequest.ACY_TE      = shipmentData.ACY_TE;
                        shipmentDataRequest.CON_NR      = shipmentData.CON_NR;
                        shipmentDataRequest.SPC_SLIC_NR = shipmentData.SPC_SLIC_NR;
                        shipmentDataRequest.POD_RTN_SVC = shipmentData.POD_RTN_SVC;

                        shipmentDataRequests.Add(shipmentDataRequest);
                    }
                }
            }
            catch
            {
            }

            return(shipmentDataRequests);
        }
Exemplo n.º 18
0
        public async Task <ActionResult> GetTranslationAddress([FromBody] List <ShipmentWorkFlowRequest> shipmentWorkFlowRequest)
        {
            int     wid          = 0;
            decimal requestCount = 0m;

            if (shipmentWorkFlowRequest.Any())
            {
                wid = shipmentWorkFlowRequest.FirstOrDefault().wfL_ID;
            }
            QuincusTranslatedAddressResponse quincusTranslatedAddressResponse = new QuincusTranslatedAddressResponse();

            QuincusTokenDataResponse quincusTokenDataResponse = QuincusService.GetToken(new UPS.Quincus.APP.Configuration.QuincusParams()
            {
                endpoint = configuration["Quincus:TokenEndPoint"],
                password = configuration["Quincus:Password"],
                username = configuration["Quincus:UserName"],
            });

            if (quincusTokenDataResponse.ResponseStatus)
            {
                //quincusTranslatedAddressResponse = QuincusService.GetTranslationAddress(new UPS.Quincus.APP.Request.QuincusAddressTranslationRequest()
                //{
                //    endpoint = configuration["Quincus:GeoCodeEndPoint"],
                //    shipmentWorkFlowRequests = shipmentWorkFlowRequest,
                //    token = quincusTokenDataResponse.quincusTokenData.token
                //});
                this._quincusAddressTranslationRequest.shipmentWorkFlowRequests = shipmentWorkFlowRequest;
                this._quincusAddressTranslationRequest.token = quincusTokenDataResponse.quincusTokenData.token;

                List <List <ShipmentWorkFlowRequest> > shipmentWorkFlowRequests = new List <List <ShipmentWorkFlowRequest> >();
                shipmentWorkFlowRequests = QuincusProxy.ChunkBy(shipmentWorkFlowRequest, 20);

                foreach (List <ShipmentWorkFlowRequest> requests in shipmentWorkFlowRequests)
                {
                    requestCount = requests.Count();

                    quincusTranslatedAddressResponse = QuincusService.GetTranslationAddress(this._quincusAddressTranslationRequest);

                    if (quincusTranslatedAddressResponse.Response)
                    {
                        //return Ok(quincusTranslatedAddressResponse.ResponseData);

                        var getAddressTranslation = quincusTranslatedAddressResponse.ResponseData;

                        var QuincusResponse = QuincusService.GetGeoCodeReponseFromQuincus(new UPS.Quincus.APP.Request.QuincusGeoCodeDataRequest()
                        {
                            endpoint         = configuration["Quincus:GeoCodeEndPoint"],
                            id               = quincusTranslatedAddressResponse.ResponseData.batch_id,
                            quincusTokenData = quincusTokenDataResponse.quincusTokenData
                        }, requestCount);

                        if (QuincusResponse.ResponseStatus)
                        {
                            ShipmentDataRequest        shipment             = new ShipmentDataRequest();
                            List <Geocode>             geocodes             = (List <Geocode>)((QuincusReponseData)QuincusResponse.QuincusReponseData).geocode;
                            List <ShipmentDataRequest> shipmentsDataRequest = new List <ShipmentDataRequest>(geocodes.Count);
                            for (int i = 0; i < geocodes.Count; i++)
                            {
                                ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                                shipmentDataRequest.ID            = Convert.ToInt32(geocodes[i].id);
                                shipmentDataRequest.WFL_ID        = wid;
                                shipmentDataRequest.SHP_ADR_TR_TE = geocodes[i].translated_adddress;
                                shipmentDataRequest.ACY_TE        = geocodes[i].accuracy;
                                shipmentDataRequest.CON_NR        = geocodes[i].confidence;

                                if (
                                    !string.IsNullOrEmpty(geocodes[i].translated_adddress)
                                    //&&  geocodes[i].translated_adddress != "NA"
                                    //&& !string.Equals(shipmentWorkFlowRequest.Where(s => s.id == shipmentDataRequest.ID).FirstOrDefault().rcV_ADR_TE.Trim(),
                                    //    geocodes[i].translated_adddress.Trim())
                                    )
                                {
                                    shipmentDataRequest.SMT_STA_NR = ((int)Enums.ATStatus.Translated);
                                    shipmentDataRequest.SMT_STA_TE = "Translated";
                                }
                                else
                                {
                                    shipmentDataRequest.SMT_STA_NR = Convert.ToInt32(shipmentWorkFlowRequest.Where(s => s.id == shipmentDataRequest.ID).FirstOrDefault().smT_STA_NR);
                                    shipmentDataRequest.SMT_STA_TE = Convert.ToString(shipmentWorkFlowRequest.Where(s => s.id == shipmentDataRequest.ID).FirstOrDefault().smT_STA_TE);
                                }
                                shipmentsDataRequest.Add(shipmentDataRequest);
                            }
                            ShipmentService shipmentService = new ShipmentService();
                            shipmentService.UpdateShipmentAddressByIds(shipmentsDataRequest);
                            _workflowID = shipmentsDataRequest.FirstOrDefault().WFL_ID;
                            //we need to update the workflow status
                            int?workflowstatus = shipmentService.SelectShipmentTotalStatusByWorkflowId(_workflowID);
                            WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();
                            workflowDataRequest.ID         = _workflowID;
                            workflowDataRequest.WFL_STA_TE = workflowstatus;
                            workflowService.UpdateWorkflowStatusById(workflowDataRequest);
                        }
                        else
                        {
                            if (QuincusResponse.Exception == null)
                            {
                                AuditEventEntry.WriteEntry(new Exception("Translation failed..."));
                            }
                            else
                            {
                                AuditEventEntry.WriteEntry(new Exception(QuincusResponse.Exception.ToString()));
                            }
                            return(Ok(QuincusResponse?.Exception));
                        }
                    }
                    else
                    {
                        if (quincusTranslatedAddressResponse.exception == null)
                        {
                            AuditEventEntry.WriteEntry(new Exception("Translation failed..."));
                        }
                        else
                        {
                            AuditEventEntry.WriteEntry(new Exception(quincusTranslatedAddressResponse.exception.ToString()));
                        }
                        return(Ok(quincusTranslatedAddressResponse?.exception));
                    }
                }

                return(Ok(quincusTranslatedAddressResponse.ResponseData));
            }
            else
            {
                if (quincusTokenDataResponse.exception == null)
                {
                    AuditEventEntry.WriteEntry(new Exception("Translation failed..."));
                }
                else
                {
                    AuditEventEntry.WriteEntry(new Exception(quincusTokenDataResponse.exception.ToString()));
                }
                return(Ok(quincusTokenDataResponse?.exception));
            }
        }
        public async Task <ActionResult> GetTranslationAddress([FromBody] List <ShipmentDataRequest> _shipmentDataRequest)
        {
            int wid = 0;

            if (_shipmentDataRequest.Any())
            {
                wid = _shipmentDataRequest.FirstOrDefault().WFL_ID;
            }
            QuincusTranslatedAddressResponse quincusTranslatedAddressResponse = new QuincusTranslatedAddressResponse();
            QuincusParams quincusParams = new UPS.Quincus.APP.Configuration.QuincusParams()
            {
                endpoint  = configuration["Quincus:TokenEndPoint"],
                password  = configuration["Quincus:Password"],
                username  = configuration["Quincus:UserName"],
                chunkSize = int.TryParse(configuration["Quincus:BatchSize"], out int size) == true ? size : 10,
            };

            QuincusTokenDataResponse quincusTokenDataResponse = QuincusService.GetToken(quincusParams);

            if (quincusTokenDataResponse.ResponseStatus)
            {
                List <ShipmentWorkFlowRequest> shipmentWorkFlowRequests =
                    _shipmentDataRequest.Select(_ =>
                                                new ShipmentWorkFlowRequest()
                {
                    id         = _.ID,
                    rcV_ADR_TE = _.RCV_ADR_TE,
                    dsT_CTY_TE = _.DST_CTY_TE,
                    wfL_ID     = _.WFL_ID,
                    pkG_NR_TE  = _.PKG_NR_TE,
                    rcV_CPY_TE = _.RCV_CPY_TE,
                    dsT_PSL_TE = _.DST_PSL_TE
                }).ToList();

                this._quincusAddressTranslationRequest.shipmentWorkFlowRequests = shipmentWorkFlowRequests;
                this._quincusAddressTranslationRequest.token = quincusTokenDataResponse.quincusTokenData.token;

                quincusTranslatedAddressResponse = QuincusService.GetTranslationAddress(this._quincusAddressTranslationRequest, quincusParams);

                if (quincusTranslatedAddressResponse.Response)
                {
                    var getAddressTranslation = quincusTranslatedAddressResponse.ResponseData;

                    List <string> batchIds = new List <string>();

                    Dictionary <string, string> shipmentDetailsDictionary = new Dictionary <string, string>();
                    quincusTranslatedAddressResponse.ResponseData.ForEach(batches =>
                    {
                        batchIds.Add(batches.batch_id);

                        batches.addresses.ForEach(address =>
                        {
                            shipmentDetailsDictionary.Add(address.id, address.rcV_CPY_TE);
                        });
                    });

                    var QuincusResponse = QuincusService.GetGeoCodeReponseFromQuincus(new UPS.Quincus.APP.Request.QuincusGeoCodeDataRequest()
                    {
                        endpoint                  = configuration["Quincus:GeoCodeEndPoint"],
                        batchIDList               = batchIds,
                        quincusTokenData          = quincusTokenDataResponse.quincusTokenData,
                        ShipmentDetailsDictionary = shipmentDetailsDictionary
                    });

                    if (QuincusResponse.ResponseStatus)
                    {
                        // Insert Address into AddressBook
                        _addressBookService.InsertAddress(QuincusResponse.QuincusReponseDataList, shipmentDetailsDictionary);

                        try
                        {
                            var requestIds = _shipmentDataRequest.Select(_ => _.ID).ToList();
                            List <ShipmentDataRequest> existingShipmentDetails =
                                this._context.shipmentDataRequests
                                .Where(ShpDetail =>
                                       ShpDetail.WFL_ID == wid
                                       &&
                                       (ShpDetail.SMT_STA_NR == ((int)Enums.ATStatus.Uploaded)) &&
                                       (!requestIds.Contains(ShpDetail.ID))
                                       )
                                .ToList();


                            QuincusResponse.QuincusReponseDataList.ForEach(datalist =>
                            {
                                List <Geocode> geocodes = (List <Geocode>)((QuincusReponseData)datalist).geocode;
                                List <ShipmentDataRequest> shipmentDataRequestList = new List <ShipmentDataRequest>(geocodes.Count);

                                foreach (Geocode geocode in geocodes)
                                {
                                    ShipmentDataRequest currentShipmentDataRequest =
                                        _shipmentDataRequest.FirstOrDefault(_ => _.PKG_NR_TE == geocode.id);
                                    ShipmentDataRequest shipmentDataRequest = CreateShipmentAddressUpdateRequest(currentShipmentDataRequest, geocode);

                                    shipmentDataRequestList.Add(shipmentDataRequest);

                                    // Checking any same address are avaible, If there then updating those address also

                                    List <ShipmentDataRequest> sameAddressShpRequest =
                                        existingShipmentDetails.Where(
                                            (ShipmentDataRequest data) =>
                                            data.RCV_ADR_TE.ToLower().Replace(" ", "")
                                            .Equals(currentShipmentDataRequest.RCV_ADR_TE.ToLower().Replace(" ", ""))
                                            )
                                        .ToList();
                                    if (sameAddressShpRequest.Any())
                                    {
                                        sameAddressShpRequest.ForEach(shpDetails =>
                                        {
                                            var sameaddressRequest = CreateShipmentAddressUpdateRequest(shpDetails, geocode);
                                            shipmentDataRequestList.Add(sameaddressRequest);
                                        });
                                    }
                                }

                                shipmentDataRequestList = shipmentDataRequestList.GroupBy(x => x.ID).Select(x => x.First()).ToList();
                                _shipmentService.UpdateShipmentAddressByIds(shipmentDataRequestList);

                                //we need to update the workflow status
                                int?workflowstatus = _shipmentService.SelectShipmentTotalStatusByWorkflowId(wid);
                                WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();
                                workflowDataRequest.ID         = wid;
                                workflowDataRequest.WFL_STA_TE = workflowstatus;
                                _workflowService.UpdateWorkflowStatusById(workflowDataRequest);
                            });
                        }
                        catch (Exception exception)
                        {
                            AuditEventEntry.WriteEntry(exception);
                        }



#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                        {
                            apiTypes       = UPS.DataObjects.LogData.APITypes.QuincusAPI_Translation,
                            apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 4),
                            dateTime       = System.DateTime.Now,
                            LogInformation = new UPS.DataObjects.LogData.LogInformation()
                            {
                                LogException = null,
                                LogRequest   = quincusTranslatedAddressResponse.QuincusContentRequest,
                                LogResponse  = JsonConvert.SerializeObject(QuincusResponse.QuincusReponseDataList)
                            }
                        }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                        return(Ok(QuincusResponse.QuincusReponseDataList));
                    }
                    else
                    {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                        {
                            apiTypes       = UPS.DataObjects.LogData.APITypes.QuincusAPI_Translation,
                            apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 4),
                            dateTime       = System.DateTime.Now,
                            LogInformation = new UPS.DataObjects.LogData.LogInformation()
                            {
                                LogException = QuincusResponse.Exception.InnerException.ToString(),
                                LogRequest   = quincusTranslatedAddressResponse.QuincusContentRequest,
                                LogResponse  = null
                            }
                        }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        return(Ok(QuincusResponse.Exception));
                    }
                }
                else
                {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                    {
                        apiTypes       = UPS.DataObjects.LogData.APITypes.QuincusAPI_Translation,
                        apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 4),
                        dateTime       = System.DateTime.Now,
                        LogInformation = new UPS.DataObjects.LogData.LogInformation()
                        {
                            LogException = quincusTranslatedAddressResponse.exception.InnerException.ToString(),
                            LogRequest   = JsonConvert.SerializeObject(_shipmentDataRequest),
                            LogResponse  = null
                        }
                    }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    return(Ok(quincusTranslatedAddressResponse.exception));
                }
            }
            else
            {
                return(Ok(quincusTokenDataResponse.exception));
            }
        }
Exemplo n.º 20
0
        public ShipmentDataResponse UpdateShipmentAddressById(ShipmentDataRequest shipmentDataRequest)
        {
            ShipmentDataResponse shipmentDataResponse = new ShipmentDataResponse();

            try
            {
                //Shipment Update
                ShipmentDataRequest data = this.context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();

                string beforeAddress = data.SHP_ADR_TR_TE;
                int?   shipmentStaus =
                    data.SHP_ADR_TR_TE.ToLower() != shipmentDataRequest.SHP_ADR_TR_TE.ToLower()
                   ? ((int)Enums.ATStatus.Curated)
                   : (data.SMT_STA_NR);

                data.SHP_ADR_TR_TE = shipmentDataRequest.SHP_ADR_TR_TE;
                data.COD_TE        = shipmentDataRequest.COD_TE;
                data.POD_RTN_SVC   = shipmentDataRequest.POD_RTN_SVC;
                data.SMT_STA_NR    = shipmentStaus;

                switch (shipmentStaus)
                {
                case 0:
                    shipmentDataRequest.SMT_STA_TE = "Uploaded";
                    break;

                case 1:
                    shipmentDataRequest.SMT_STA_TE = "Curated";
                    break;

                case 2:
                    shipmentDataRequest.SMT_STA_TE = "Translated";
                    break;

                case 3:
                    shipmentDataRequest.SMT_STA_TE = "Completed";
                    break;

                case 4:
                    shipmentDataRequest.SMT_STA_TE = "Inactive";
                    break;

                default:
                    shipmentDataRequest.SMT_STA_TE = "Uploaded";
                    break;
                }

                this.context.shipmentDataRequests.Update(data);
                this.context.Entry(shipmentDataRequest).State = EntityState.Detached;
                this.context.SaveChanges();
                shipmentDataResponse.ShipmentDataRequest = this.context.shipmentDataRequests.Where(s => s.ID == shipmentDataRequest.ID).FirstOrDefault();
                shipmentDataResponse.Success             = true;
                shipmentDataResponse.BeforeAddress       = string.Empty;
                if (!string.Equals(beforeAddress, data.SHP_ADR_TR_TE))
                {
                    shipmentDataResponse.BeforeAddress = beforeAddress;
                    if (shipmentDataRequest.RCV_ADR_TE != null)
                    {
                        var matchedShipments = this.context.shipmentDataRequests.Where(s => s.RCV_ADR_TE == shipmentDataRequest.RCV_ADR_TE).ToList();
                        if (matchedShipments.Any())
                        {
                            matchedShipments.ForEach(shipment =>
                            {
                                shipment.SHP_ADR_TR_TE = data.SHP_ADR_TR_TE;
                                shipment.SMT_STA_NR    = shipmentStaus;
                            });

                            this.context.BulkUpdate(matchedShipments);
                        }


                        List <AddressBook> addressBookElements = this.context.AddressBooks.Where(s => s.ConsigneeAddress == shipmentDataRequest.RCV_ADR_TE).ToList();

                        if (addressBookElements.Any())
                        {
                            addressBookElements.FirstOrDefault().ConsigneeTranslatedAddress = data.SHP_ADR_TR_TE;
                            addressBookElements.FirstOrDefault().ModifiedDate = DateTime.Parse(DateTime.Now.ToString()).ToLocalTime();

                            this.context.BulkUpdate(addressBookElements);
                        }
                    }
                }
                return(shipmentDataResponse);
            }
            catch (Exception ex)
            {
                shipmentDataResponse.Success = false;
                shipmentDataResponse.OperationExceptionMsg = ex.Message;
            }

            return(shipmentDataResponse);
        }
Exemplo n.º 21
0
        public ShipmentDataResponse SelectCompletedShipments(int workflowID)

        {
            ShipmentDataResponse       mappedShipAndShipperCompanyResponse = new ShipmentDataResponse();
            List <ShipmentDataRequest> shipmentDataRequests = null;

            try
            {
                optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

                using (var context = new ApplicationDbContext(optionsBuilder.Options))
                {
                    shipmentDataRequests = new List <ShipmentDataRequest>();
                    var anonymousList =
                        (
                            from s in context.shipmentDataRequests
                            join c in context.shipperCompanyRequests on s.DST_PSL_TE equals c.SPC_PSL_CD_TE where s.WFL_ID == workflowID
                            where s.WFL_ID == workflowID &&
                            s.SMT_STA_NR == ((int)Enums.ATStatus.Completed)
                            orderby s.ID
                            select new
                    {
                        s.ID,
                        s.WFL_ID,
                        s.ACY_TE,
                        s.BIL_TYP_TE,
                        s.CCY_VAL_TE,
                        s.COD_TE,
                        s.CON_NR,
                        s.CSG_CTC_TE,
                        s.DIM_WGT_DE,
                        s.DST_CTY_TE,
                        s.DST_PSL_TE,
                        s.EXP_SLC_CD,
                        s.EXP_TYP,
                        s.FST_INV_LN_DES_TE,
                        s.IMP_NR,
                        s.IMP_SLC_TE,
                        s.IN_FLG_TE,
                        ORG_CTY_TE = c.SPC_CTY_TE,
                        ORG_PSL_CD = c.SPC_PSL_CD_TE,
                        s.OU_FLG_TE,
                        s.PCS_QTY_NR,
                        s.PH_NR,
                        s.PKG_NR_TE,
                        s.PKG_WGT_DE,
                        s.PK_UP_TM,
                        s.PYM_MTD,
                        s.PY_MT_TE,
                        s.QQS_TRA_LG_ID,
                        s.RCV_ADR_TE,
                        s.RCV_CPY_TE,
                        s.SF_TRA_LG_ID,
                        SHP_ADR_TE = c.SPC_ADR_TE,
                        s.SHP_ADR_TR_TE,
                        SHP_CPY_NA = c.SPC_CPY_TE,
                        SHP_CTC_TE = c.SPC_NA,
                        s.SHP_DT,
                        s.SHP_NR,
                        SHP_PH_TE = c.SPC_SND_PTY_CTC_TE,
                        s.SMT_NR_TE,
                        s.SMT_STA_NR,
                        s.SMT_VAL_DE,
                        s.SMT_WGT_DE,
                        SPC_SLIC_NR = c.SPC_SLIC_NR,
                        s.SVL_NR,
                        s.WGT_UNT_TE,
                        s.POD_RTN_SVC
                    }).ToList();

                    foreach (var shipmentData in anonymousList)
                    {
                        ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                        shipmentDataRequest.ID                = shipmentData.ID;
                        shipmentDataRequest.BIL_TYP_TE        = shipmentData.BIL_TYP_TE;
                        shipmentDataRequest.CCY_VAL_TE        = shipmentData.CCY_VAL_TE;
                        shipmentDataRequest.COD_TE            = shipmentData.COD_TE;
                        shipmentDataRequest.CSG_CTC_TE        = shipmentData.CSG_CTC_TE;
                        shipmentDataRequest.DIM_WGT_DE        = shipmentData.DIM_WGT_DE;
                        shipmentDataRequest.DST_CTY_TE        = shipmentData.DST_CTY_TE;
                        shipmentDataRequest.DST_PSL_TE        = shipmentData.DST_PSL_TE;
                        shipmentDataRequest.EXP_SLC_CD        = shipmentData.EXP_SLC_CD;
                        shipmentDataRequest.EXP_TYP           = shipmentData.EXP_TYP;
                        shipmentDataRequest.FST_INV_LN_DES_TE = shipmentData.FST_INV_LN_DES_TE;
                        shipmentDataRequest.IMP_NR            = shipmentData.IMP_NR;
                        shipmentDataRequest.IMP_SLC_TE        = shipmentData.IMP_SLC_TE;
                        shipmentDataRequest.IN_FLG_TE         = shipmentData.IN_FLG_TE;
                        shipmentDataRequest.ORG_CTY_TE        = shipmentData.ORG_CTY_TE;
                        shipmentDataRequest.ORG_PSL_CD        = shipmentData.ORG_PSL_CD;
                        shipmentDataRequest.OU_FLG_TE         = shipmentData.OU_FLG_TE;
                        shipmentDataRequest.PCS_QTY_NR        = shipmentData.PCS_QTY_NR;
                        shipmentDataRequest.PH_NR             = shipmentData.PH_NR;
                        shipmentDataRequest.PKG_NR_TE         = shipmentData.PKG_NR_TE;
                        shipmentDataRequest.PKG_WGT_DE        = shipmentData.PKG_WGT_DE;
                        shipmentDataRequest.PK_UP_TM          = shipmentData.PK_UP_TM;
                        shipmentDataRequest.PYM_MTD           = shipmentData.PYM_MTD;
                        shipmentDataRequest.PY_MT_TE          = shipmentData.PY_MT_TE;
                        shipmentDataRequest.QQS_TRA_LG_ID     = shipmentData.QQS_TRA_LG_ID;
                        shipmentDataRequest.RCV_ADR_TE        = shipmentData.RCV_ADR_TE;
                        shipmentDataRequest.RCV_CPY_TE        = shipmentData.RCV_CPY_TE;
                        shipmentDataRequest.SF_TRA_LG_ID      = shipmentData.SF_TRA_LG_ID;
                        shipmentDataRequest.SHP_ADR_TE        = shipmentData.SHP_ADR_TE;
                        shipmentDataRequest.SHP_ADR_TR_TE     = shipmentData.SHP_ADR_TR_TE;
                        shipmentDataRequest.SHP_CPY_NA        = shipmentData.SHP_CPY_NA;
                        shipmentDataRequest.SHP_CTC_TE        = shipmentData.SHP_CTC_TE;
                        shipmentDataRequest.SHP_DT            = shipmentData.SHP_DT;
                        shipmentDataRequest.SHP_NR            = shipmentData.SHP_NR;
                        shipmentDataRequest.SHP_PH_TE         = shipmentData.SHP_PH_TE;
                        shipmentDataRequest.SMT_NR_TE         = shipmentData.SMT_NR_TE;
                        shipmentDataRequest.SMT_STA_NR        = shipmentData.SMT_STA_NR;

                        switch (shipmentDataRequest.SMT_STA_NR)
                        {
                        case 0:
                            shipmentDataRequest.SMT_STA_TE = "Uploaded";
                            break;

                        case 1:
                            shipmentDataRequest.SMT_STA_TE = "Curated";
                            break;

                        case 2:
                            shipmentDataRequest.SMT_STA_TE = "Translated";
                            break;

                        case 3:
                            shipmentDataRequest.SMT_STA_TE = "Completed";
                            break;

                        case 4:
                            shipmentDataRequest.SMT_STA_TE = "Inactive";
                            break;

                        default:
                            shipmentDataRequest.SMT_STA_TE = "Uploaded";
                            break;
                        }

                        shipmentDataRequest.SMT_VAL_DE  = shipmentData.SMT_VAL_DE;
                        shipmentDataRequest.SMT_WGT_DE  = shipmentData.SMT_WGT_DE;
                        shipmentDataRequest.SVL_NR      = shipmentData.SVL_NR;
                        shipmentDataRequest.WFL_ID      = shipmentData.WFL_ID;
                        shipmentDataRequest.WGT_UNT_TE  = shipmentData.WGT_UNT_TE;
                        shipmentDataRequest.ACY_TE      = shipmentData.ACY_TE;
                        shipmentDataRequest.CON_NR      = shipmentData.CON_NR;
                        shipmentDataRequest.SPC_SLIC_NR = shipmentData.SPC_SLIC_NR;
                        shipmentDataRequest.POD_RTN_SVC = shipmentData.POD_RTN_SVC;

                        shipmentDataRequests.Add(shipmentDataRequest);
                    }
                    //shipmentDataRequests = anonymousList.Cast<ShipmentDataRequest>().ToList();
                    mappedShipAndShipperCompanyResponse.Success   = true;
                    mappedShipAndShipperCompanyResponse.Shipments = shipmentDataRequests;
                }
            }
            catch (Exception ex)
            {
                mappedShipAndShipperCompanyResponse.Success = false;
                mappedShipAndShipperCompanyResponse.OperationExceptionMsg = ex.Message;
            }
            return(mappedShipAndShipperCompanyResponse);
        }
        public async Task <ActionResult> CreateOrderShipment([FromBody] List <UIOrderRequestBodyData> uIOrderRequestBodyDatas)
        {
            string customerID = uIOrderRequestBodyDatas[0].spC_CST_ID_TE;//_shipmentService.GetShipmentCustomCodesInformation().CST_ID;

            _workflowID = uIOrderRequestBodyDatas[0].wfL_ID;
            CreateOrderShipmentResponse createOrderShipmentResponse = new CreateOrderShipmentResponse();

            createOrderShipmentResponse.FailedToProcessShipments = new List <string>();
            createOrderShipmentResponse.ProcessedShipments       = new List <string>();
            //ShipmentService shipmentService = new ShipmentService();

            //List<UIOrderRequestBodyData> uIOrderRequestBodyDatas = new List<UIOrderRequestBodyData>();

            foreach (var orderRequest in uIOrderRequestBodyDatas)
            {
                string XMLMessage = string.Empty;

                XMLMessage  = "<Request lang=\"zh-CN\" service=\"OrderService\">";
                XMLMessage += "<Head>" + configuration["SFExpress:Access Number"] + "</Head>";
                XMLMessage += "<Body>";
                XMLMessage += "<Order orderid=\"" + orderRequest.pkG_NR_TE + "\" custid=\"" + orderRequest.spC_CST_ID_TE + "\"";
                XMLMessage += " parcel_quantity=\"" + orderRequest.pcS_QTY_NR + "\"";
                XMLMessage += " total_net_weight=\"" + orderRequest.pkG_WGT_DE + "\"";
                XMLMessage += " j_company=\"" + orderRequest.shP_CPY_NA.ampReplacment() + "\"";
                XMLMessage += " j_address=\"" + orderRequest.shP_ADR_TE.ampReplacment() + "\"";
                XMLMessage += " j_city=\"" + orderRequest.orG_CTY_TE.ampReplacment() + "\"";
                XMLMessage += " j_post_code=\"" + orderRequest.orG_PSL_CD + "\"";
                XMLMessage += " j_contact=\"" + orderRequest.shP_CTC_TE.ampReplacment() + "\"";
                XMLMessage += " j_tel=\"" + orderRequest.shP_PH_TE + "\"";
                XMLMessage += " d_company=\"" + orderRequest.rcV_CPY_TE.ampReplacment() + "\"";
                XMLMessage += " d_city=\"" + orderRequest.dsT_CTY_TE.ampReplacment() + "\"";
                XMLMessage += " d_post_code=\"" + orderRequest.dsT_PSL_TE + "\"";
                XMLMessage += " d_contact=\"" + orderRequest.csG_CTC_TE.ampReplacment() + "\"";
                XMLMessage += " d_tel=\"" + orderRequest.pH_NR + "\"";
                XMLMessage += " specifications=\"" + orderRequest.fsT_INV_LN_DES_TE + "\"";
                XMLMessage += " routelabelService=\"1\"";
                XMLMessage += " d_address=\"" + orderRequest.shP_ADR_TR_TE + "\" cargo_total_weight=\"" + orderRequest.pkG_WGT_DE + "\"";
                XMLMessage += " pay_method=\"1\" is_docall=\"" + 0 + "\" need_return_tracking_no=\"" + orderRequest.poD_RTN_SVC + "\" express_type=\"6\"";
                XMLMessage += " >";
                XMLMessage += " </Order>";
                if (!string.IsNullOrEmpty(orderRequest.coD_TE))
                {
                    XMLMessage += "<AddedService name='COD' value=\"" + orderRequest.coD_TE + "\"></AddedService>";
                }
                XMLMessage += "</Body></Request>";


                SFCreateOrderServiceRequest sFCreateOrderServiceRequest = new SFCreateOrderServiceRequest()
                {
                    AccessNumber           = configuration["SFExpress:Access Number"],
                    BaseURI                = configuration["SFExpress:Base URI"],
                    Checkword              = configuration["SFExpress:Checkword"],
                    RequestURI             = configuration["SFExpress:Place Order URI"],
                    Checkcode              = configuration["SFExpress:CheckCode"],
                    RequestOrderXMLMessage = XMLMessage,
                };

                GetSFCreateOrderServiceResponse getSFCreateOrderServiceResponse = QuincusService.SFExpressCreateOrder(sFCreateOrderServiceRequest);

                //shipmentDataResponse = shipmentService.UpdateShipmentStatusById(shipmentDataRequest);
                //if (!shipmentDataResponse.Success)
                //{
                //    AuditEventEntry.WriteEntry(new Exception(shipmentDataResponse.OperationExceptionMsg));
                //}

                if (getSFCreateOrderServiceResponse.Response)
                {
                    XmlDocument xmlDocumentShipmentResponse = new XmlDocument();
                    xmlDocumentShipmentResponse.LoadXml(getSFCreateOrderServiceResponse.OrderResponse);

                    string xmlDocumentShipmentResponseParser = xmlDocumentShipmentResponse.InnerXml;

                    if (xmlDocumentShipmentResponseParser.Contains("<ERROR"))
                    {
                        XmlDocument xmlDocument = new XmlDocument();

                        xmlDocument.LoadXml(getSFCreateOrderServiceResponse.OrderResponse);

                        //if (xmlDocumentShipmentResponseParser.Contains("8019"))
                        //{
                        //    createOrderShipmentResponse.FailedToProcessShipments.Add("Customer order number(" + orderRequest.pkG_NR_TE + ") is already confirmed");
                        //}
                        //else if (xmlDocumentShipmentResponseParser.Contains("8016"))
                        //{
                        //    createOrderShipmentResponse.FailedToProcessShipments.Add("Repeat order numbers ( " + orderRequest.pkG_NR_TE + " )");
                        //}
                        //else
                        //{
                        createOrderShipmentResponse.FailedToProcessShipments.Add(
                            string.Format("{0}:{1}:{2}",
                                          orderRequest.pkG_NR_TE,
                                          xmlDocument.GetElementsByTagName("ERROR")[0].Attributes[0].InnerText,
                                          xmlDocument.GetElementsByTagName("ERROR")[0].InnerXml));
                        //}
                    }
                    else
                    {
                        createOrderShipmentResponse.ProcessedShipments.Add(orderRequest.pkG_NR_TE);

                        ShipmentDataRequest shipmentDataRequest = new ShipmentDataRequest();
                        shipmentDataRequest.ID         = orderRequest.id;
                        shipmentDataRequest.WFL_ID     = orderRequest.wfL_ID;
                        shipmentDataRequest.SMT_STA_NR = ((int)Enums.ATStatus.Completed);
                        shipmentDataRequest.SMT_STA_TE = "Completed";
                        _workflowID = orderRequest.wfL_ID;

                        _shipmentService.UpdateShipmentStatusById(shipmentDataRequest);
                    }

                    createOrderShipmentResponse.Response = true;
                }
                else
                {
                    createOrderShipmentResponse.Response = false;
                }
            }
            //we need to update the workflow status
            int?                workflowstatus      = _shipmentService.SelectShipmentTotalStatusByWorkflowId(_workflowID);
            WorkflowService     workflowService     = new WorkflowService(_context, _addressBookService, _entityValidationService);
            WorkflowDataRequest workflowDataRequest = new WorkflowDataRequest();

            workflowDataRequest.ID         = _workflowID;
            workflowDataRequest.WFL_STA_TE = workflowstatus;
            workflowService.UpdateWorkflowStatusById(workflowDataRequest);



            await iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
            {
                apiTypes       = UPS.DataObjects.LogData.APITypes.SFExpress,
                apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 1),
                dateTime       = System.DateTime.Now,
                LogInformation = new UPS.DataObjects.LogData.LogInformation()
                {
                    LogException = null,
                    LogRequest   = JsonConvert.SerializeObject(uIOrderRequestBodyDatas),
                    LogResponse  = JsonConvert.SerializeObject(createOrderShipmentResponse)
                }
            });

            return(Ok(createOrderShipmentResponse));
        }