internal async Task ExportDocSet(AsycudaDocumentSetEx docSet) { var res = MessageBox.Show("Do you want to Export ALL Documents in this Document Set?", "Export Document Set", MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { StatusModel.Timer("Exporting DocumentSet"); var od = new SaveFileDialog(); od.FileName = docSet.Declarant_Reference_Number + ".xml"; var result = od.ShowDialog(); if (result == true) { string first = null; foreach (var name in od.FileNames) { first = name; break; } if (first != null) { var directoryInfo = new DirectoryInfo(first).Parent; if (directoryInfo != null) { var dir = directoryInfo.FullName; await AsycudaDocumentSetExRepository.Instance.ExportDocSet(docSet.AsycudaDocumentSetId, dir).ConfigureAwait(false); await SalesReportModel.Instance.ExportDocSetSalesReport(docSet, dir).ConfigureAwait(false); } } } StatusModel.StopStatusUpdate(); MessageBox.Show("Complete"); } }
public async Task SaveAsycudaDocumentSetEx(AsycudaDocumentSetEx asycudaDocumentSetEx) { var docset = new AsycudaDocumentSet(); asycudaDocumentSetEx.ModifiedProperties = null; docset.InjectFrom(asycudaDocumentSetEx); await WaterNut.DataSpace.DocumentDS.DataModels.BaseDataModel.Instance.SaveAsycudaDocumentSet(docset).ConfigureAwait(false); }
public async Task SaveCSVFile(string fileType, AsycudaDocumentSetEx docSet) { //import asycuda xml id and details var od = new OpenFileDialog(); od.Title = "Import Entry Data"; od.DefaultExt = ".csv"; od.Filter = "CSV Files (.csv)|*.csv|TXT Files (.txt)|*.txt"; od.Multiselect = true; var result = od.ShowDialog(); if (result == true) { bool overwrite = false; var res = MessageBox.Show( "Do you want to Over Write Existing Items?, Click Yes to Replace or No to Skip or Cancel to Stop.", "Existing Item Found", MessageBoxButton.YesNoCancel); switch (res) { case MessageBoxResult.Yes: overwrite = true; break; case MessageBoxResult.No: break; case MessageBoxResult.Cancel: return; } foreach (var f in od.FileNames) { if (f.EndsWith(".csv")) { await EntryDataExRepository.Instance.SaveCSV(f, fileType, docSet.AsycudaDocumentSetId, overwrite) .ConfigureAwait(false); } if (f.EndsWith(".pdf")) { await EntryDataExRepository.Instance.SavePDF(f, fileType, docSet.AsycudaDocumentSetId, overwrite) .ConfigureAwait(false); } if (f.EndsWith(".txt")) { await EntryDataExRepository.Instance.SaveTXT(f, fileType, docSet.AsycudaDocumentSetId, overwrite) .ConfigureAwait(false); } } MessageBox.Show("Complete"); } }
internal async Task ExportDocSetSalesReport(AsycudaDocumentSetEx docSet, string folder) { var doclst = await SalesDataRepository.Instance.GetSalesDocuments( docSet.AsycudaDocumentSetId) .ConfigureAwait(false); if (doclst == null || !doclst.ToList().Any()) { return; } StatusModel.StartStatusUpdate("Exporting Files", doclst.Count()); var exceptions = new ConcurrentQueue <Exception>(); using (var sta = new StaTaskScheduler(numberOfThreads: 1)) { await Task.Factory.StartNew(() => { var s = new ExportToExcel <SaleReportLine, List <SaleReportLine> >(); s.StartUp(); foreach (var doc in doclst) { try { var data = GetDocumentSalesReport(doc.ASYCUDA_Id).Result; if (data != null) { string path = Path.Combine(folder, !string.IsNullOrEmpty(doc.CNumber) ? doc.CNumber : doc.ReferenceNumber + ".xls"); s.dataToPrint = data.ToList(); s.SaveReport(path); } else { File.Create(Path.Combine(folder, doc.CNumber ?? doc.ReferenceNumber + ".xls")); } StatusModel.StatusUpdate(); } catch (Exception ex) { exceptions.Enqueue(ex); } } s.ShutDown(); }, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false); } if (exceptions.Count > 0) { throw new AggregateException(exceptions); } }
public async Task SaveAsycudaDocumentSetEx(AsycudaDocumentSetEx asycudaDocumentSetEx) { await Channel.SaveAsycudaDocumentSetEx(asycudaDocumentSetEx).ConfigureAwait(false); }
public async Task <AsycudaDocumentSetEx> CreateAsycudaDocumentSetEx(AsycudaDocumentSetEx entity) { return(await Channel.CreateAsycudaDocumentSetEx(entity).ConfigureAwait(false)); }
private async Task LoadDataFromAdoc(AsycudaDocumentSetEx docSet, AsycudaDocument doc) { if (docSet == null && ((doc != null) && (docSet != doc.AsycudaDocumentSetEx))) { docSet = doc.AsycudaDocumentSetEx; } if (docSet != null && doc == null) //(docSet != null && (doc == null || (doc != null && doc.AutoUpdate == true))) { Document_TypeId = Convert.ToInt32(docSet.Document_TypeId); Description = docSet.Description; Customs_ProcedureId = Convert.ToInt32(docSet.Customs_ProcedureId); Country_of_origin_code = docSet.Country_of_origin_code; Currency_Code = docSet.Currency_Code; Exchange_Rate = Convert.ToSingle(docSet.Exchange_Rate); Declarant_Reference_Number = docSet.Declarant_Reference_Number; Manifest_Number = docSet.Manifest_Number; BLNumber = docSet.BLNumber; TotalGrossWeight = docSet.TotalGrossWeight.GetValueOrDefault(); TotalFreight = docSet.TotalFreight.GetValueOrDefault(); } else if (doc != null)//else if (doc != null && doc.AutoUpdate == false) { Document_TypeId = Convert.ToInt32(doc.Document_TypeId); Description = doc.Description; Customs_ProcedureId = Convert.ToInt32(doc.Customs_ProcedureId); // if (doc.Country_first_destination != null) Country_of_origin_code = doc.Country_first_destination; Currency_Code = doc.Currency_code; Exchange_Rate = Convert.ToSingle(doc.Currency_rate); Declarant_Reference_Number = doc.ReferenceNumber; //docSet.Declarant_Reference_Number; //if (doc.Manifest_reference_number != null) Manifest_Number = doc.Manifest_reference_number; // docSet.Manifest_Number; BLNumber = doc.BLNumber; // docSet.BLNumber; TotalGrossWeight = doc.TotalGrossWeight.GetValueOrDefault(); TotalFreight = doc.TotalFreight.GetValueOrDefault(); } else { Description = ""; Customs_ProcedureId = 0; Country_of_origin_code = null; Currency_Code = ""; Exchange_Rate = 0; Declarant_Reference_Number = ""; Manifest_Number = ""; BLNumber = ""; TotalGrossWeight = 0; } //if (CurrentAsycudaDocument != null) //{ // IsManuallyAssessed = CurrentAsycudaDocument.IsManuallyAssessed; // NotifyPropertyChanged(x => this.IsManuallyAssessed"); //} NotifyPropertyChanged(x => Document_TypeId); NotifyPropertyChanged(x => Description); NotifyPropertyChanged(x => Customs_ProcedureId); NotifyPropertyChanged(x => Declarant_Reference_Number); NotifyPropertyChanged(x => Currency_Code); NotifyPropertyChanged(x => Country_of_origin_code); NotifyPropertyChanged(x => Manifest_Number); NotifyPropertyChanged(x => BLNumber); NotifyPropertyChanged(x => Exchange_Rate); NotifyPropertyChanged(x => TotalFreight); NotifyPropertyChanged(x => TotalGrossWeight); }