diff --git a/SYS.Common/HttpHelper.cs b/SYS.Common/HttpHelper.cs index d495dae88f50fac9b602841f963ccca6d23e7a41..efdc84cbc26c21e4098f90a5b538cc2d42bdda3d 100644 --- a/SYS.Common/HttpHelper.cs +++ b/SYS.Common/HttpHelper.cs @@ -1,7 +1,5 @@ -using jvncorelib_fr.EncryptorLib; -using jvncorelib_fr.EntityLib; -using jvncorelib_fr.HttpLib; -using Newtonsoft.Json; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.IO; @@ -15,6 +13,8 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; using System.Web.Script.Serialization; +using jvncorelib_fr.EncryptorLib; +using jvncorelib_fr.EntityLib; namespace SYS.Common { @@ -23,7 +23,7 @@ namespace SYS.Common /// public static class HttpHelper { - static EncryptLib encryptLib = new EncryptLib(); + static EncryptLib encrypt = new EncryptLib(); #region 受限于打包插件的限制才放在这,个人开发时建议统一在App.Config进行配置 @@ -41,12 +41,65 @@ namespace SYS.Common /// public const string postUrl = ""; /// - /// WebApi URL + /// WebApi URL(release) /// + //public const string apiUrl = ""; + + + + // Debug public const string apiUrl = ""; #endregion + public class IgnoreNullValuesConverter : JsonConverter + { + private readonly bool _convertEmptyStringToNull; + + // 添加一个构造函数,允许在创建转换器实例时指定是否将空字符串转换为 null + public IgnoreNullValuesConverter(bool convertEmptyStringToNull = false) + { + _convertEmptyStringToNull = convertEmptyStringToNull; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + JObject obj = JObject.FromObject(value, serializer); + + foreach (var prop in obj.Properties().ToList()) + { + if (prop.Value == null || string.IsNullOrEmpty(prop.Value.ToString())) + { + // 根据 _convertEmptyStringToNull 决定是移除属性还是设置为 null + if (_convertEmptyStringToNull && prop.Value?.Type == JTokenType.String) + { + prop.Value = JValue.CreateNull(); + } + else + { + prop.Remove(); + } + } + } + + obj.WriteTo(writer); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + // 实现这个方法是必要的,但是本例中不需要修改 + throw new NotImplementedException(); + } + + public override bool CanConvert(Type objectType) + { + // 仅为示例,根据实际情况调整 + return objectType == typeof(JObject); + } + + public override bool CanRead => false; // 设置为 false,因为我们不需要修改反序列化的行为 + } + /// /// WebClient上传文件至服务器 /// @@ -77,7 +130,7 @@ namespace SYS.Common var sourceStr = url.Replace("​", string.Empty); //解密原始URL - var api = encryptLib.Decryption(apiUrl); + var api = encrypt.Decryption(apiUrl); var requestUrl = api + sourceStr; @@ -404,7 +457,11 @@ namespace SYS.Common { try { - return Newtonsoft.Json.JsonConvert.SerializeObject(input); + return Newtonsoft.Json.JsonConvert.SerializeObject(input, new JsonSerializerSettings + { + Converters = { new IgnoreNullValuesConverter(true) }, + Formatting = Formatting.Indented // 如果需要格式化输出 + }); } catch (Exception ex) { diff --git a/SYS.Common/SYS.Common.csproj b/SYS.Common/SYS.Common.csproj index 6b385fa43e6c4571d4d55e2604afc145d05d298f..b9e64592bfa0ddfd9f87bc6006fa2bf07dc4137d 100644 --- a/SYS.Common/SYS.Common.csproj +++ b/SYS.Common/SYS.Common.csproj @@ -43,7 +43,7 @@ - + ..\packages\jvncorelib.1.0.1.7\lib\net461\jvncorelib-fr.dll diff --git a/SYS.Common/packages.config b/SYS.Common/packages.config index f1e044719b131c12be1d1f4c59d7088b4e6e960a..86b3d1080927d9b98161da0498d8801480f5a89d 100644 --- a/SYS.Common/packages.config +++ b/SYS.Common/packages.config @@ -1,17 +1,7 @@  - - - - \ No newline at end of file diff --git a/SYS.FormUI/AppFunction/FrmDepartment.cs b/SYS.FormUI/AppFunction/FrmDepartment.cs index 7c5ec46641734a403407b91f61b132dafa7c411b..fa04f579a758ad3fbef887cf94ba6bc0c878044d 100644 --- a/SYS.FormUI/AppFunction/FrmDepartment.cs +++ b/SYS.FormUI/AppFunction/FrmDepartment.cs @@ -35,6 +35,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using jvncorelib_fr.EntityLib; namespace SYS.FormUI { @@ -256,9 +257,9 @@ namespace SYS.FormUI { if (dgvDeptList.SelectedRows.Count == 1) { - txtDeptNo.Text = dgvDeptList.SelectedRows[0].Cells["clDeptNo"].Value.ToString(); - txtDeptName.Text = dgvDeptList.SelectedRows[0].Cells["clDeptName"].Value.ToString(); - txtDeptDesc.Text = dgvDeptList.SelectedRows[0].Cells["clDeptDesc"].Value.ToString(); + txtDeptNo.Text = dgvDeptList.SelectedRows[0].Cells["clDeptNo"].Value.IsNullOrEmpty() ? "" : dgvDeptList.SelectedRows[0].Cells["clDeptNo"].Value.ToString(); + txtDeptName.Text = dgvDeptList.SelectedRows[0].Cells["clDeptName"].Value.IsNullOrEmpty() ? "" : dgvDeptList.SelectedRows[0].Cells["clDeptName"].Value.ToString(); + txtDeptDesc.Text = dgvDeptList.SelectedRows[0].Cells["clDeptDesc"].Value.IsNullOrEmpty() ? "" : dgvDeptList.SelectedRows[0].Cells["clDeptDesc"].Value.ToString(); } } } diff --git a/SYS.FormUI/AppFunction/FrmOperation.Designer.cs b/SYS.FormUI/AppFunction/FrmOperation.Designer.cs index db251f78799e4c4c8117ea0cc4a029b29570b9c5..a5815a7624ec8a5a8dffa29aa1f6b9a71d2ef7d9 100644 --- a/SYS.FormUI/AppFunction/FrmOperation.Designer.cs +++ b/SYS.FormUI/AppFunction/FrmOperation.Designer.cs @@ -106,6 +106,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dgvOperationlog.RowHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dgvOperationlog.RowHeadersVisible = false; + this.dgvOperationlog.RowHeadersWidth = 72; this.dgvOperationlog.RowHeight = 29; dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; this.dgvOperationlog.RowsDefaultCellStyle = dataGridViewCellStyle5; @@ -113,13 +114,14 @@ this.dgvOperationlog.SelectedIndex = -1; this.dgvOperationlog.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvOperationlog.ShowGridLine = true; - this.dgvOperationlog.Size = new System.Drawing.Size(998, 582); + this.dgvOperationlog.Size = new System.Drawing.Size(998, 522); this.dgvOperationlog.TabIndex = 1; // // clOperationTime // this.clOperationTime.DataPropertyName = "OperationTime"; this.clOperationTime.HeaderText = "操作时间"; + this.clOperationTime.MinimumWidth = 9; this.clOperationTime.Name = "clOperationTime"; this.clOperationTime.ReadOnly = true; // @@ -127,6 +129,7 @@ // this.clSoftwareVersion.DataPropertyName = "SoftwareVersion"; this.clSoftwareVersion.HeaderText = "软件版本"; + this.clSoftwareVersion.MinimumWidth = 9; this.clSoftwareVersion.Name = "clSoftwareVersion"; this.clSoftwareVersion.ReadOnly = true; // @@ -134,6 +137,7 @@ // this.clOperationlog.DataPropertyName = "LogContent"; this.clOperationlog.HeaderText = "操作日志"; + this.clOperationlog.MinimumWidth = 9; this.clOperationlog.Name = "clOperationlog"; this.clOperationlog.ReadOnly = true; // @@ -141,6 +145,7 @@ // this.clOperationAccount.DataPropertyName = "OperationAccount"; this.clOperationAccount.HeaderText = "操作人"; + this.clOperationAccount.MinimumWidth = 9; this.clOperationAccount.Name = "clOperationAccount"; this.clOperationAccount.ReadOnly = true; // @@ -148,6 +153,7 @@ // this.Column1.DataPropertyName = "delete_mk"; this.Column1.HeaderText = "Column1"; + this.Column1.MinimumWidth = 9; this.Column1.Name = "Column1"; this.Column1.ReadOnly = true; this.Column1.Visible = false; @@ -156,6 +162,7 @@ // this.Column2.DataPropertyName = "datains_usr"; this.Column2.HeaderText = "Column2"; + this.Column2.MinimumWidth = 9; this.Column2.Name = "Column2"; this.Column2.ReadOnly = true; this.Column2.Visible = false; @@ -164,6 +171,7 @@ // this.Column3.DataPropertyName = "datains_date"; this.Column3.HeaderText = "Column3"; + this.Column3.MinimumWidth = 9; this.Column3.Name = "Column3"; this.Column3.ReadOnly = true; this.Column3.Visible = false; @@ -172,6 +180,7 @@ // this.Column4.DataPropertyName = "datachg_usr"; this.Column4.HeaderText = "Column4"; + this.Column4.MinimumWidth = 9; this.Column4.Name = "Column4"; this.Column4.ReadOnly = true; this.Column4.Visible = false; @@ -180,6 +189,7 @@ // this.Column5.DataPropertyName = "datachg_date"; this.Column5.HeaderText = "Column5"; + this.Column5.MinimumWidth = 9; this.Column5.Name = "Column5"; this.Column5.ReadOnly = true; this.Column5.Visible = false; @@ -188,6 +198,7 @@ // this.clOperationLevel.DataPropertyName = "OperationLevelNm"; this.clOperationLevel.HeaderText = "日志级别"; + this.clOperationLevel.MinimumWidth = 9; this.clOperationLevel.Name = "clOperationLevel"; this.clOperationLevel.ReadOnly = true; // @@ -195,13 +206,14 @@ // this.Column6.DataPropertyName = "OperationLevel"; this.Column6.HeaderText = "Column6"; + this.Column6.MinimumWidth = 9; this.Column6.Name = "Column6"; this.Column6.ReadOnly = true; this.Column6.Visible = false; // // FrmOperation // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); + this.AutoScaleDimensions = new System.Drawing.SizeF(17F, 36F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255))))); this.ClientSize = new System.Drawing.Size(1005, 623); diff --git a/topsky-hotel-manager-system-web-api b/topsky-hotel-manager-system-web-api index 0cb470d901a0376335da1c52bc9ac206a6bc8107..362105ec9f3044a9038dd66d6addec6dd0e09384 160000 --- a/topsky-hotel-manager-system-web-api +++ b/topsky-hotel-manager-system-web-api @@ -1 +1 @@ -Subproject commit 0cb470d901a0376335da1c52bc9ac206a6bc8107 +Subproject commit 362105ec9f3044a9038dd66d6addec6dd0e09384