修改Api返回的Message 改善pdf多一頁空白頁面問題

This commit is contained in:
張家睿 2024-01-31 17:07:43 +08:00
parent 7d3292ad24
commit 58e7ec1be9
2 changed files with 21 additions and 15 deletions

View File

@ -75,7 +75,7 @@ namespace FrontendWebApi.ApiControllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "讀取不到用戶資料。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -106,7 +106,7 @@ namespace FrontendWebApi.ApiControllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "新增用戶失敗。";
if (exception.Message.Contains($" for key 'PRIMARY'")) if (exception.Message.Contains($" for key 'PRIMARY'"))
{ {
apiResult.Msg = "已有相同使用者。"; apiResult.Msg = "已有相同使用者。";
@ -135,12 +135,12 @@ namespace FrontendWebApi.ApiControllers
await backendRepository.ExecuteSql(sqlString); await backendRepository.ExecuteSql(sqlString);
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = "修改成功"; apiResult.Data = "修改用戶成功";
} }
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "修改失敗。";
if (exception.Message.Contains($"a foreign key constraint")) if (exception.Message.Contains($"a foreign key constraint"))
{ {
apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。"; apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。";
@ -167,7 +167,7 @@ namespace FrontendWebApi.ApiControllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "刪除用戶失敗。";
if (exception.Message.Contains($"a foreign key constraint")) if (exception.Message.Contains($"a foreign key constraint"))
{ {
apiResult.Msg = "水電報表仍有該用戶,無法刪除。"; apiResult.Msg = "水電報表仍有該用戶,無法刪除。";
@ -222,7 +222,7 @@ namespace FrontendWebApi.ApiControllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "讀取水電參考報表失敗。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -248,10 +248,16 @@ namespace FrontendWebApi.ApiControllers
startMonth = tb.start_timestamp.Split("-")[0] + tb.start_timestamp.Split("-")[1]; startMonth = tb.start_timestamp.Split("-")[0] + tb.start_timestamp.Split("-")[1];
endMonth = tb.end_timestamp.Split("-")[0] + tb.end_timestamp.Split("-")[1]; endMonth = tb.end_timestamp.Split("-")[0] + tb.end_timestamp.Split("-")[1];
} }
else if (start_timestamp == "")
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "請選擇日期。"; apiResult.Msg = "請選擇起始日期。";
return apiResult;
}
if (end_timestamp == "")
{
apiResult.Code = "9999";
apiResult.Msg = "請選擇結束日期。";
return apiResult; return apiResult;
} }
@ -296,7 +302,7 @@ namespace FrontendWebApi.ApiControllers
// $"WHERE device_number = '{tb.device_number}'"; // $"WHERE device_number = '{tb.device_number}'";
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "請選擇同一個月份"; apiResult.Msg = "請選擇同一個月份";
return apiResult;
} }
@ -309,7 +315,7 @@ namespace FrontendWebApi.ApiControllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "修改水電參考報表失敗。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }

View File

@ -9,13 +9,14 @@
<style> <style>
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
zoom:2; zoom:1.5;
} }
.container { .container {
width: 80%; width: 100%;
margin: auto; height: 100%;
padding: 20px; max-width: 21cm;
max-height: 29.7cm;
} }
.header { .header {
@ -90,7 +91,6 @@
.a4-page { .a4-page {
page-break-before: always; page-break-before: always;
page-break-after: always;
} }
.br { .br {
border-spacing: 0px 20px; border-spacing: 0px 20px;