コード例 #1
0
        private void RunBatFilesForm_Load(object sender, EventArgs e)
        {
            if (Directory.Exists(RepoPath))
            {
                var batFiles = Directory.GetFiles(RepoPath,
                                                  "*.bat", SearchOption.AllDirectories);

                var iniFile = new IniFile(FormMain.RunBatchIni);
                foreach (var batFile in batFiles)
                {
                    var batchFileModel = new BatchFileModel
                    {
                        FullPath     = batFile,
                        RunBatchFile = iniFile.ReadBool(RepoPath,
                                                        batFile, false)
                    };

                    batchFileModelList.Add(batchFileModel);
                }
            }

            gridControl1.DataSource = batchFileModelList;
            gridView1.BestFitColumns();

            if (File.Exists(FormMain.GridRunBatchFilesXml))
            {
                gridView1.RestoreLayoutFromXml(FormMain.GridRunBatchFilesXml);
            }
        }
コード例 #2
0
        public void BatchesWorkflow()
        {
            // Raw batch CSV string.
            const string transactionImport = @"ProcessCode,DocCode,DocType,DocDate,CompanyCode,CustomerCode,EntityUseCode,LineNo,TaxCode,TaxDate,ItemCode,Description,Qty,Amount,Discount,Ref1,Ref2,ExemptionNo,RevAcct,DestAddress,DestCity,DestRegion,DestPostalCode,DestCountry,OrigAddress,OrigCity,OrigRegion,OrigPostalCode,OrigCountry,LocationCode,SalesPersonCode,PurchaseOrderNo,CurrencyCode,ExchangeRate,ExchangeRateEffDate,PaymentDate,TaxIncluded,DestTaxRegion,OrigTaxRegion,Taxable,TaxType,TotalTax,CountryName,CountryCode,CountryRate,CountryTax,StateName,StateCode,StateRate,StateTax,CountyName,CountyCode,CountyRate,CountyTax,CityName,CityCode,CityRate,CityTax,Other1Name,Other1Code,Other1Rate,Other1Tax,Other2Name,Other2Code,Other2Rate,Other2Tax,Other3Name,Other3Code,Other3Rate,Other3Tax,Other4Name,Other4Code,Other4Rate,Other4Tax,ReferenceCode,BuyersVATNo
3,BS1323154187029MG10,2,16-Apr-14,,029MG10,,0000000001,SR060100,06-May-14,6500,REPAIRS & MAINTENANCE,,1980,,,0,,6500,119 N. 72nd St.,Omaha,NE,68114,,6923 MAPLE ST,OMAHA,NE,68104,,029,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS1323158772194036MAC1,2,04-Apr-14,,036MAC1,,0000000001,SC150158,06-May-14,6505,R&M HEAT / VENT / AIR COND,,322.26,,,0,,6505,1200 E. Mall Drive,Holland,OH,43528,,2875 CRANE WAY,NORTHWOOD,OH,43619,,036,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS1323159W206409036MLK,2,25-Mar-14,,036MLK,,0000000001,SR060100,06-May-14,6507,R&M OTHER,,449,,,31.43,,6507,1200 E. Mall Drive,Holland,OH,43528,,1214 JEFFERSON AVE,TOLEDO,OH,43604,,036,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS13231601596048MRP2,2,02-May-14,,048MRP2,,0000000001,SR060100,06-May-14,6520,FURNITURE REPAIRS,,60,,,0,,6520,2201 Hwy 75 North,Sherman,TX,75090,,P.O. BOX 125,POTTSBORO,TX,75076,,048,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS13231631591048MRP2,2,02-May-14,,048MRP2,,0000000001,SR060100,06-May-14,6520,FURNITURE REPAIRS,,58,,,0,,6520,2201 Hwy 75 North,Sherman,TX,75090,,P.O. BOX 125,POTTSBORO,TX,75076,,048,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS13231611594048MRP2,2,01-May-14,,048MRP2,,0000000001,SR060100,06-May-14,6520,FURNITURE REPAIRS,,65,,,0,,6520,2201 Hwy 75 North,Sherman,TX,75090,,P.O. BOX 125,POTTSBORO,TX,75076,,048,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS13231621593048MRP2,2,01-May-14,,048MRP2,,0000000001,SR060100,06-May-14,6520,FURNITURE REPAIRS,,75,,,0,,6520,2201 Hwy 75 North,Sherman,TX,75090,,P.O. BOX 125,POTTSBORO,TX,75076,,048,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS13231641587048MRP2,2,01-May-14,,048MRP2,,0000000001,SR060100,06-May-14,6520,FURNITURE REPAIRS,,60,,,0,,6520,2201 Hwy 75 North,Sherman,TX,75090,,P.O. BOX 125,POTTSBORO,TX,75076,,048,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,BS13231651582048MRP2,2,15-Mar-14,,048MRP2,,0000000001,SR060100,06-May-14,6520,FURNITURE REPAIRS,,47,,,0,,6520,2201 Hwy 75 North,Sherman,TX,75090,,P.O. BOX 125,POTTSBORO,TX,75076,,048,,,USD,,,,0,,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";

            // Let's Create the file portion of the batch request.
            var batchFileModel = new BatchFileModel
            {
                name          = "TransactionImport.csv",
                content       = Encoding.UTF8.GetBytes(transactionImport),
                contentType   = "text/csv",
                fileExtension = "csv"
            };

            // Create the bare-minimum batch header info.
            var batchRequest = new BatchModel
            {
                name  = "AutomationTestBatch",
                type  = BatchType.TransactionImport,
                files = new List <BatchFileModel> {
                    batchFileModel
                }
            };

            // Send the batch!
            try
            {
                var batchResult = Client.CreateBatches(TestCompany.id, new List <BatchModel> {
                    batchRequest
                });
                Assert.NotNull(batchResult, "Batch not sent.");
                Assert.True(batchResult.Count > 0, "No batches created.");

                // Check that the batch comes out of Waiting state using a linear backoff strategy.
                var        waiting          = true;
                BatchModel batchFetchResult = null;
                for (var i = 1; i < 6; ++i)
                {
                    System.Threading.Thread.Sleep(i * 1000);

                    batchFetchResult = Client.GetBatch(TestCompany.id, batchResult[0].id.Value);
                    Assert.NotNull(batchFetchResult, "Batch fetch unsuccessful.");
                    if (batchFetchResult.status.Value == BatchStatus.Waiting)
                    {
                        continue;
                    }
                    waiting = false;
                    break;
                }
                Assert.True(waiting == false, $"Batch waiting too long. Check BatchId: {batchResult[0].id}");

                // This batch is no longer in the Waiting state. Let's see it process.
                var processing = true;
                for (var i = 1; i < 11; ++i)
                {
                    System.Threading.Thread.Sleep(i * 1000);

                    batchFetchResult = Client.GetBatch(TestCompany.id, batchResult[0].id.Value);
                    Assert.NotNull(batchFetchResult, "Batch fetch unsuccessful.");
                    if (batchFetchResult.status.Value == BatchStatus.Processing)
                    {
                        continue;
                    }
                    processing = false;
                    break;
                }
                Assert.True(processing == false, $"Batch processing too long. Check BatchId: {batchResult[0].id}");

                // This batch is done processing.
                Assert.True((batchFetchResult.status.Value == BatchStatus.Errors || batchFetchResult.status.Value == BatchStatus.Completed),
                            $"BatchId: {batchResult[0].id} should either complete or error out.");

                // Ensure that the number of records matches what we sent in.
                Assert.AreEqual(9, batchFetchResult.currentRecord.Value);

                // We should be able to get back the batch file we sent
                var fileResult = Client.DownloadBatch(TestCompany.id, batchFetchResult.id.Value, batchFetchResult.files[0].id.Value);
                Assert.NotNull(fileResult);

                // Compare what we got back with what we sent.
                Assert.AreEqual(batchFetchResult.name + ".Input.CSV; filename*=UTF-8''" + batchFetchResult.name + ".Input.CSV", fileResult.Filename);
                Assert.AreEqual(batchFileModel.content, fileResult.Data);
                Assert.AreEqual(batchFileModel.contentType, fileResult.ContentType);
            } catch (AvaTaxError e)
            {
                Assert.True(false, $"AvaTaxError: {e.error.error.details?[0].message}");
            } catch (Exception e)
            {
                Assert.True(false, $"Unknown Exception! {e.Message}");
            }
        }