public HttpResponseMessage ImportData(ImportDataBody idb) { List <ExcelImportDataDTO> impdtolst = null; ResultDTO <object> resultdto = new ResultDTO <object>(); IImportDataServices idservices = null; switch (idb.Type) { case 1: // impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelBatch> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new UserApplyServices()); break; } try { //判断是否返回的是真假,如果为假,则跳转chtch resultdto.SubmitResult = idservices.ImportData(impdtolst); } catch (Exception ex) { resultdto.Message = ex.Message; resultdto.SubmitResult = false; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(resultdto), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }
public ImportDataController(IImportDataServices service) { _service = service; }
public HttpResponseMessage ImportData(ImportDataBody idb) { List <ExcelImportDataDTO> impdtolst = null; ResultDTO <object> resultdto = new ResultDTO <object>(); IImportDataServices idservices = null; switch (idb.Type) { case 1: // 试剂产品清单 impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelReagentProductDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 2: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelRepairProductDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 3: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelReagentPriceDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 4: //试剂产品特价 impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelProductSpecialDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 5: //维修产品价格 impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelRepairPriceDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 6: //经销商信息 impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelDistributorDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new DistributorServices()); break; case 7: //经销商授权 impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelDistributorAuthorityDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new DistributorServices()); break; case 8: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelDistributorADAuthorityDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new DistributorServices()); break; case 9: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExclCloseDataDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new BaseInfoServices()); break; case 10: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelCustomerInfoDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new CustomerServices()); break; case 11: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelProductSmallClassDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 12: impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelInstrumentModelDTO> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new ProductServices()); break; case 13: //用户信息 impdtolst = TransformHelper.ConvertBase64JsonStringToDTO <List <ExcelUser> >(idb.Data).ConvertAll <ExcelImportDataDTO>(g => { return(g as ExcelImportDataDTO); }); idservices = (IImportDataServices)(new UserAuthorityServices()); break; } try { //判断是否返回的是真假,如果为假,则跳转chtch resultdto.SubmitResult = idservices.ImportData(impdtolst); } catch (Exception ex) { resultdto.Message = ex.Message; resultdto.SubmitResult = false; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(resultdto), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }