如何修改 web api to return message not matched when compare excel function return false?

How to modify web api to return message not matched when compare excel function return false?

我在做 asp.net core 2.2 我遇到了我不能做的问题

修改web api显示消息"Not Matched Compare" 当比较 excel 函数 return false (areIdentical == false) .

web api 低于 return 物理文件为 zip file

如果比较 excel return true

但我需要比较 excel 函数 return false

显示消息"Not matched compare"

所以请问怎么做?

我的尝试

public IActionResult ExportNormalizedRelation()
{

        var InputfilePath = System.IO.Path.Combine(GetFilesDownload, "DeliveryGenerationNormalTest_Input.xlsx");
        using (var stream = new FileStream(dbPath, FileMode.Create))
        {
            Request.Form.Files[0].CopyTo(stream);
            stream.Flush();
            stream.Close();
        }
        bool areIdentical = ex.CompareExcel(dbPath, InputfilePath, out rowCount, out error);
        if (areIdentical == true)
        {

            pathToCreate = Path.Combine(myValue2,Month,"file" + DateTime.Now.Ticks.ToString());
            
                Directory.CreateDirectory(pathToCreate);

                List<inputexcelnormaltest> inputexcellist = new List<inputexcelnormaltest>();
                inputexcellist = ex.ImportNormalTest(dbPath);
                List<string> tabs = new List<string>();
                var outputTemplatePath = System.IO.Path.Combine(GetFilesDownload, "DeliveryGeneration_Output.xlsx");
                List<inputexcelnormaltest> inputmodulelist = new List<inputexcelnormaltest>();
             
                  

                        foreach (var m in tabs)
                        {
                            inputmodulelist.Clear();
                            inputmodulelist = inputexcellist.Where(x => (x.TabName == m && x.FileName == f)).ToList();
                            var dtimport = DatatableConversion.ToDataTable(inputmodulelist);
                            DataTable dtexport = new DataTable();

                            dtexport = _deliveryService.LoadExcelToDataTableZipData(_connectionString, dtimport);

                            ex.Export(dtexport, m, exportPath);

                        }

                    


        }

        string zipPath = Path.Combine(myValue2,Month,"result" + DateTime.Now.Ticks.ToString() + ".zip");

        ZipFile.CreateFromDirectory(pathToCreate, zipPath);

        return PhysicalFile(zipPath, "application/zip", Path.GetFileName(zipPath));
   
    
   
}
expected result

if (areIdentical == false)
return "Not Matched Compare"

那么该怎么做?

我解决了我的问题

我只加returnreturn new JsonResult("Not Matched Excel");

public IActionResult ExportNormalizedRelation()
{

        var InputfilePath = System.IO.Path.Combine(GetFilesDownload, "DeliveryGenerationNormalTest_Input.xlsx");
        using (var stream = new FileStream(dbPath, FileMode.Create))
        {
            Request.Form.Files[0].CopyTo(stream);
            stream.Flush();
            stream.Close();
        }
        bool areIdentical = ex.CompareExcel(dbPath, InputfilePath, out rowCount, out error);
        if (areIdentical == false)
                {
                    return new JsonResult("Not Matched Excel");
                }
                else
                    
                {

            pathToCreate = Path.Combine(myValue2,Month,"file" + DateTime.Now.Ticks.ToString());
            
                Directory.CreateDirectory(pathToCreate);

                List<inputexcelnormaltest> inputexcellist = new List<inputexcelnormaltest>();
                inputexcellist = ex.ImportNormalTest(dbPath);
                List<string> tabs = new List<string>();
                var outputTemplatePath = System.IO.Path.Combine(GetFilesDownload, "DeliveryGeneration_Output.xlsx");
                List<inputexcelnormaltest> inputmodulelist = new List<inputexcelnormaltest>();
             
                  

                        foreach (var m in tabs)
                        {
                            inputmodulelist.Clear();
                            inputmodulelist = inputexcellist.Where(x => (x.TabName == m && x.FileName == f)).ToList();
                            var dtimport = DatatableConversion.ToDataTable(inputmodulelist);
                            DataTable dtexport = new DataTable();

                            dtexport = _deliveryService.LoadExcelToDataTableZipData(_connectionString, dtimport);

                            ex.Export(dtexport, m, exportPath);

                        }

                    


        }

        string zipPath = Path.Combine(myValue2,Month,"result" + DateTime.Now.Ticks.ToString() + ".zip");

        ZipFile.CreateFromDirectory(pathToCreate, zipPath);

        return PhysicalFile(zipPath, "application/zip", Path.GetFileName(zipPath));
   
    
   
}