Beispiel #1
0
        private async Task InsertEventPendingConsoleAsync(Entt_Console parent, params string[] connoteNotes)
        {
            var pendingAdapter = new Entt_EventPendingConsoleAdapter();
            var rows           = new List <Entt_EventPendingConsole>();

            foreach (var connoteNo in connoteNotes)
            {
                rows.Add(GetPendingConsoleRow(parent.Id, connoteNo, parent.EventType));
                foreach (var item in rows)
                {
                    // verify the id, is not duplicate
                    var onePr = await Policy.Handle <SqlException>(e => e.IsTimeout())
                                .WaitAndRetryAsync(RetryCount, x => TimeSpan.FromMilliseconds(500 * Math.Pow(2, x)))
                                .ExecuteAndCaptureAsync(() => pendingAdapter.LoadOneAsync(item.Id));

                    var one = onePr.Result;
                    if (null != one)
                    {
                        continue;
                    }
                    await Policy.Handle <SqlException>(e => e.IsDeadlockOrTimeout())
                    .WaitAndRetryAsync(RetryCount, x => TimeSpan.FromMilliseconds(500 * Math.Pow(2, x)))
                    .ExecuteAndCaptureAsync(() => pendingAdapter.InsertAsync(item));
                }
            }
        }
Beispiel #2
0
        private async Task <Entt_Console> CloneChildAsync(Entt_Console parent, string consignmentNo)
        {
            var console = IsConsole(consignmentNo);
            var child   = parent.Clone();

            child.Id            = GenerateId(34);
            child.ConsignmentNo = consignmentNo;
            child.DataFlag      = "1";
            child.ItemTypeCode  = console ? "02" : "01";
            if (console)
            {
                child.ItemConsignments = await this.GetItemConsigmentsFromConsoleDetailsAsync(consignmentNo);
            }

            return(child);
        }
Beispiel #3
0
        private async Task <IEnumerable <Entt_Console> > GetEventRowsAsync(
            Entt_Console eventRow,
            IList <string> pendingConsoles,
            string consignmentNotes,
            int level = 0)
        {
            Console.Write("." + level);

            var list = new ConcurrentBag <Entt_Console>();

            if (level > 4)
            {
                return(list);
            }
            var items = consignmentNotes.Split(new[] { ',', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

            foreach (var c in items)
            {
                var itemConNote = c;
                var row         = await CloneChildAsync(eventRow, itemConNote);

                list.Add(row);
                if (!IsConsole(itemConNote))
                {
                    continue;
                }

                var childConsignments = await GetItemConsigmentsFromConsoleDetailsAsync(itemConNote);

                if (null == childConsignments)
                {
                    pendingConsoles.Add(itemConNote);
                    continue;
                }
                var children = await GetEventRowsAsync(eventRow,
                                                       pendingConsoles,
                                                       childConsignments.ToEmptyString().Trim(),
                                                       level + 1);

                list.AddRange(children);
            }

            return(list);
        }