Beispiel #1
0
 internal async void OnCurrentPreviousDocumentItemIDChanged(object sender, NotificationEventArgs <string> e)
 {
     using (PreviousDocumentItemRepository ctx = new PreviousDocumentItemRepository())
     {
         CurrentPreviousDocumentItem = await ctx.GetPreviousDocumentItem(e.Data).ConfigureAwait(continueOnCapturedContext: false);
     }
     NotifyPropertyChanged(m => CurrentPreviousDocumentItem);
 }
        public async Task SelectAll()
        {
            IEnumerable <PreviousDocumentItem> lst = null;

            using (var ctx = new PreviousDocumentItemRepository())
            {
                lst = await ctx.GetPreviousDocumentItemsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            SelectedPreviousDocumentItems = new ObservableCollection <PreviousDocumentItem>(lst);
        }
        public IList <PreviousDocumentItem> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            try
            {
                if (FilterExpression == null)
                {
                    FilterExpression = "None";
                }
                using (var ctx = new PreviousDocumentItemRepository())
                {
                    var r = ctx.LoadRange(startIndex, count, FilterExpression, navExp, IncludesLst);
                    overallCount = r.Result.Item2;

                    return(r.Result.Item1.ToList());
                }
            }
            catch (Exception ex)
            {
                StatusModel.Message(ex.Message);
                overallCount = 0;
                return(new List <PreviousDocumentItem>());
            }
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <PreviousDocumentItem> lst = null;

            using (var ctx = new PreviousDocumentItemRepository())
            {
                lst = await ctx.GetPreviousDocumentItemsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <PreviousDocumentItemExcelLine, List <PreviousDocumentItemExcelLine> >
            {
                dataToPrint = lst.Select(x => new PreviousDocumentItemExcelLine
                {
                    Amount_deducted_from_licence = x.Amount_deducted_from_licence,


                    Licence_number = x.Licence_number,


                    Free_text_1 = x.Free_text_1,


                    Free_text_2 = x.Free_text_2,


                    LineNumber = x.LineNumber,


                    IsAssessed = x.IsAssessed,


                    DPQtyAllocated = x.DPQtyAllocated,


                    DFQtyAllocated = x.DFQtyAllocated,


                    EntryTimeStamp = x.EntryTimeStamp,


                    AttributeOnlyAllocation = x.AttributeOnlyAllocation,


                    DoNotAllocate = x.DoNotAllocate,


                    DoNotEX = x.DoNotEX,


                    Item_price = x.Item_price,


                    ItemNumber = x.ItemNumber,


                    TariffCode = x.TariffCode,


                    DutyLiability = x.DutyLiability,


                    Total_CIF_itm = x.Total_CIF_itm,


                    Freight = x.Freight,


                    Statistical_value = x.Statistical_value,


                    PiQuantity = x.PiQuantity,


                    Description_of_goods = x.Description_of_goods,


                    Commercial_Description = x.Commercial_Description,


                    Suppplementary_unit_code = x.Suppplementary_unit_code,


                    ItemQuantity = x.ItemQuantity,


                    Number = x.Number,


                    DocumentType = x.DocumentType
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }