Example #1
0
 internal async void OnCurrentAsycudaDocumentSetExIDChanged(object sender, NotificationEventArgs <string> e)
 {
     using (AsycudaDocumentSetExRepository ctx = new AsycudaDocumentSetExRepository())
     {
         CurrentAsycudaDocumentSetEx = await ctx.GetAsycudaDocumentSetEx(e.Data).ConfigureAwait(continueOnCapturedContext: false);
     }
     NotifyPropertyChanged(m => CurrentAsycudaDocumentSetEx);
 }
        public async Task SelectAll()
        {
            IEnumerable <AsycudaDocumentSetEx> lst = null;

            using (var ctx = new AsycudaDocumentSetExRepository())
            {
                lst = await ctx.GetAsycudaDocumentSetExsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            SelectedAsycudaDocumentSetExs = new ObservableCollection <AsycudaDocumentSetEx>(lst);
        }
        public IList <AsycudaDocumentSetEx> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            try
            {
                if (FilterExpression == null)
                {
                    FilterExpression = "All";
                }
                using (var ctx = new AsycudaDocumentSetExRepository())
                {
                    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 <AsycudaDocumentSetEx>());
            }
        }
// Send to Excel Implementation


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

            using (var ctx = new AsycudaDocumentSetExRepository())
            {
                lst = await ctx.GetAsycudaDocumentSetExsByExpressionNav(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 <AsycudaDocumentSetExExcelLine, List <AsycudaDocumentSetExExcelLine> >
            {
                dataToPrint = lst.Select(x => new AsycudaDocumentSetExExcelLine
                {
                    Declarant_Reference_Number = x.Declarant_Reference_Number,


                    Exchange_Rate = x.Exchange_Rate,


                    Country_of_origin_code = x.Country_of_origin_code,


                    Currency_Code = x.Currency_Code,


                    Description = x.Description,


                    Manifest_Number = x.Manifest_Number,


                    BLNumber = x.BLNumber,


                    EntryTimeStamp = x.EntryTimeStamp,


                    StartingFileCount = x.StartingFileCount,


                    DocumentsCount = x.DocumentsCount,


                    ApportionMethod = x.ApportionMethod,


                    TotalCIF = x.TotalCIF,


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

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