public void SyncTest() { ImportInvoiceDTO model = new ImportInvoiceDTO { InvoiceCode = "4444444444", InvoiceNumber = "44444444", CreateDate = "2016-05-16", SalesTaxNumber = "110101000000000", Amount = 1000, Tax = 30, From = "底帐", Status = "正常", SelectTag = "未勾选", ChosenTime = "未操作" }; ImportInvoiceListDTO soap = new ImportInvoiceListDTO(); soap.List = new List <ImportInvoiceDTO> { model }; var service = new SyncImportInvoiceService(); soap = service.InjectList(soap); Assert.AreNotEqual(0, soap.Result.Status); }
public void FetchListTest() { ImportInvoiceDTO condition = new ImportInvoiceDTO { InvoiceCode = "3600153130", InvoiceNumber = "04444798", //CreateDate = "2016-05-16", //SalesTaxNumber = "110101000000000", //Amount = 1000, //Tax = 30, //From = "底帐", //Status = "正常", //SelectTag = "未勾选", //OperationTime = "未操作" }; var service = new SyncImportInvoiceService(); ImportInvoiceListDTO rs = service.FetchList(condition); Assert.IsNotNull(rs.List); }
/* public List<VIMS_BIZ_INVOICE> FetchList(Condition condition) * { * * using (TaxEntities db = new TaxEntities()) * { * * var datas = condition.Filter(db.VIMS_BIZ_INVOICE); * * //if (!string.IsNullOrEmpty(condition.Location)) * //{ * // datas = datas.Where(o => o.Address.Contains(condition.Location)); * * //} * //var data = datas.OrderByDescending(o => o.KPRQ).DoPage(condition.Pager).ToList(); * var data = datas.OrderByDescending(o => o.KPRQ).ToList(); * return data; * * } * * }*/ public ImportInvoiceListDTO FetchList(ImportInvoiceDTO condition) { ImportInvoiceListDTO rs = new ImportInvoiceListDTO { List = null, Result = new ImportInvoiceResultDTO { Message = "", Status = 0 } }; using (TaxEntities db = new TaxEntities()) { var datas = db.VIMS_BIZ_INVOICE.Where(o => !string.IsNullOrEmpty(condition.InvoiceCode) ? o.FPDM == condition.InvoiceCode : true && !string.IsNullOrEmpty(condition.InvoiceCode) ? o.FPDM == condition.InvoiceCode : true ); if (!string.IsNullOrEmpty(condition.InvoiceCode)) { datas = datas.Where(o => o.FPDM == condition.InvoiceCode); } // var data = datas.OrderByDescending(o => o.KPRQ).DoPage(condition.Pager).ToList(); var data = datas.Select(o => new ImportInvoiceDTO { InvoiceCode = o.FPDM, InvoiceNumber = o.FPHM, // CreateDate = o.KPRQ.ToString(), Amount = o.FPJE, Tax = o.FPSE, SalesTaxNumber = o.XFSH, }).OrderByDescending(o => o.InvoiceCode).ToList(); rs.List = data; } return(rs); }
private void parserValidTR(List <hParser.Tags.TableRow> validRowList, ref List <ImportInvoiceDTO> list) { for (int j = 0; j < validRowList.Count; j++) { ImportInvoiceDTO dto = new ImportInvoiceDTO(); hParser.Tags.TableRow tagTR = validRowList[j]; //抓取td for (int i = 0; i < tagTR.Columns.Count(); i++) { var colum = tagTR.Columns[i] as hParser.Tags.TableColumn; //td switch (i) { case 0: dto.InvoiceCode = colum.StringText; break; case 1: dto.InvoiceNumber = colum.StringText; break; case 2: dto.CreateDate = colum.StringText; break; case 3: dto.SalesTaxNumber = colum.StringText; break; case 4: dto.Amount = ConvertToDecimal(colum.StringText); break; case 5: dto.Tax = ConvertToDecimal(colum.StringText); break; case 6: dto.From = colum.StringText; break; case 7: dto.Status = colum.StringText; break; case 8: dto.SelectTag = colum.StringText; break; case 9: dto.OperationTime = colum.StringText; break; } parseResult += colum.TagName + ":\r\nStringText:" + colum.StringText + " ChildrenHTML:" + colum.ChildrenHTML + " StartPosition:" + colum.StartPosition.ToString() + " EndPosition:" + colum.EndPosition.ToString() + "\r\n"; } list.Add(dto); } }
/* public List<VIMS_BIZ_INVOICE> FetchList(Condition condition) * { * * using (TaxEntities db = new TaxEntities()) * { * * var datas = condition.Filter(db.VIMS_BIZ_INVOICE); * * //if (!string.IsNullOrEmpty(condition.Location)) * //{ * // datas = datas.Where(o => o.Address.Contains(condition.Location)); * * //} * //var data = datas.OrderByDescending(o => o.KPRQ).DoPage(condition.Pager).ToList(); * var data = datas.OrderByDescending(o => o.KPRQ).ToList(); * return data; * * } * * }*/ public ImportInvoiceListDTO FetchList(ImportInvoiceDTO condition) { ImportInvoiceListDTO rs = new ImportInvoiceListDTO { List = null, Result = new ImportInvoiceResultDTO { Message = "", Status = 0 } }; try { using (TaxEntities db = new TaxEntities()) { var datas = db.VIMS_BIZ_INVOICE.Where(o => !string.IsNullOrEmpty(condition.InvoiceCode) ? o.FPDM == condition.InvoiceCode : true && !string.IsNullOrEmpty(condition.InvoiceNumber) ? o.FPDM == condition.InvoiceNumber : true ); //if (!string.IsNullOrEmpty(condition.IsChosen)) //{ // datas = datas.Where(o => o.GSBZ == condition.IsChosen); //} //if (!string.IsNullOrEmpty(condition.IsConfirmed)) //{ // datas = datas.Where(o => o.QRBZ == condition.IsConfirmed); //} if (condition.BeginDateTime.HasValue) { datas = datas.Where(o => o.KPRQ >= condition.BeginDateTime.Value); } if (condition.EndDateTime.HasValue) { datas = datas.Where(o => o.KPRQ <= condition.EndDateTime.Value); } if (!string.IsNullOrEmpty(condition.TaxCode)) { datas = datas.Where(o => o.GFSH == condition.TaxCode); } // var data = datas.OrderByDescending(o => o.KPRQ).DoPage(condition.Pager).ToList(); var data = datas.Select(o => new ImportInvoiceDTO { InvoiceCode = o.FPDM, InvoiceNumber = o.FPHM, Amount = o.FPJE, Tax = o.FPSE, SalesTaxNumber = o.XFSH, //IsChosen = o.GSBZ, //IsConfirmed == o.QRBZ, CreateDateTime = o.KPRQ, //CreateDate = o.KPRQ.ToString("yyyy-MM-dd"),//"LINQ to Entities 不识别方法“System.String ToString(System.String)”,因此该方法无法转换为存储表达式。" IsChosen = "1", IsConfirmed = "0" }).OrderByDescending(o => o.InvoiceCode).ToList(); rs.List = data; rs.Result.Status = data.Count; } } catch (Exception ex) { rs.Result.Status = -1; rs.Result.Message = ex.Message; } return(rs); }