Beispiel #1
0
        private async Task <Adapters.Oal.dbo_ips_import> CreateDeliIpsImport(Adapters.Oal.dbo_delivery_event_new deli, string consignmentNo)
        {
            var ips = new Adapters.Oal.dbo_ips_import
            {
                id             = GenerateId(13),
                version        = 0,
                data_code_name = "deli",
                item_id        = consignmentNo,
                class_cd       = GetClassCode(consignmentNo),
                status         = "1",
                user_fid       = deli.courier_id,
                event_date_local_date_field = deli.date_field,
                event_date_g_m_t_date_field = (deli.date_field ?? DateTime.Now).AddHours(-8),
                postal_status_fcd           = "MINL",
                dest_country_cd             = "MY",
                condition_cd = "30",
                dt_created_oal_date_field = DateTime.Now,
                office_cd            = "MY" + deli.office_no,
                non_delivery_reason  = GetNonDeliveryReason(deli.delivery_code, ""),
                non_delivery_measure = GetNonDeliveryMeasure(deli.delivery_code, ""),
                tn_cd = GetDeliveryTransactionCode(deli.delivery_code, "")
            };
            var signatories = new[] { "01", "10", "11" };

            if (signatories.Contains(deli.delivery_code))
            {
                ips.signatory_nm = deli.receipent_name;
            }

            var consignmentInitialPolly = await Policy.Handle <SqlException>()
                                          .WaitAndRetryAsync(RetryCount, WaitInterval)
                                          .ExecuteAndCaptureAsync(async() => await SearchConsignmentInitialAsync(consignmentNo));

            if (null != consignmentInitialPolly.FinalException)
            {
                throw new Exception("Process pending deli import Polly failed", consignmentInitialPolly.FinalException);
            }

            var consignment = consignmentInitialPolly.Result;

            if (null != consignment)
            {
                ips.item_weight_double = consignment.weight_double;
                if (!string.IsNullOrEmpty(consignment.shipper_address_country))
                {
                    ips.orig_country_cd = consignment.shipper_address_country;
                }
                if (!string.IsNullOrEmpty(consignment.item_category))
                {
                    ips.content = consignment.item_category.Equals("01") ? "M" : "D";
                }
                else
                {
                    ips.content = "D";
                }
            }

            return(ips);
        }
Beispiel #2
0
        private void ProcessChild(Adapters.Oal.dbo_delivery_event_new parent, string consignmentNo)
        {
            var console = IsConsole(consignmentNo);
            var child   = parent.Clone();

            child.id             = GenerateId(34);
            child.consignment_no = consignmentNo;
            child.data_flag      = "1";
            child.item_type_code = console ? "02" : "01";
            child.date_created_o_a_l_date_field = DateTime.Now;
            m_deliEventRows.Add(child);
        }