Skip to content

Commit 63d0bee

Browse files
committed
Fix bugs
修复查房翻页过快时UI出错
1 parent cfd2e48 commit 63d0bee

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

HousingCheck/HousingCheck.cs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ void Log(string type, string message)
132132
ActGlobals.oFormActMain.ParseRawLogLine(false, DateTime.Now, $"{text}"); //插入ACT日志
133133
}
134134

135+
void Log(string type, Exception ex, string msg = "")
136+
{
137+
Log(type, msg + ex.ToString());
138+
}
139+
135140
string HousingListToJson()
136141
{
137142
return JsonConvert.SerializeObject(
@@ -166,6 +171,30 @@ void NetworkReceived(string connection, long epoch, byte[] message)
166171
}
167172

168173
HousingItem[] onSaleList = snapshot.GetOnSale();
174+
175+
Monitor.Enter(this);
176+
foreach (var item in HousingList)
177+
{
178+
if (item.Area == snapshot.Area && item.Slot == snapshot.Slot)
179+
{
180+
if(onSaleList.Where(x => x.Slot == item.Slot && x.IsEmpty)
181+
.ToArray().Length == 0)
182+
{
183+
//空房已消失
184+
item.CurrentStatus = false;
185+
HousingListUpdated = true;
186+
try
187+
{
188+
bindingSource1.ResetItem(HousingList.IndexOf(item));
189+
}
190+
catch(Exception ex)
191+
{
192+
Log("Error", ex, "刷新列表出错:");
193+
}
194+
}
195+
}
196+
}
197+
169198
int listIndex;
170199
//更新空房列表
171200
foreach(HousingItem house in onSaleList)
@@ -192,14 +221,15 @@ void NetworkReceived(string connection, long epoch, byte[] message)
192221
HousingListUpdated = true;
193222
}
194223
LastOperateTime = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds(); //更新上次操作的时间
195-
bindingSource1.ResetBindings(false); //刷新列表
224+
196225
Log("Info", string.Format("{0} 第{1}区查询完成",
197226
HousingItem.GetHouseAreaStr(snapshot.Area),
198227
snapshot.Slot + 1)); //输出翻页日志
228+
Monitor.Exit(this);
199229
}
200230
catch (Exception ex)
201231
{
202-
Log("Error", ex.Message);
232+
Log("Error", ex, "查询房屋列表出错:");
203233
return;
204234
}
205235
}
@@ -254,7 +284,7 @@ private void LoadHousingList()
254284
}
255285
catch(Exception ex)
256286
{
257-
Log("Error", "恢复上次保存的房屋列表失败:" + ex.Message);
287+
Log("Error", ex, "恢复上次保存的房屋列表失败:");
258288
}
259289
reader.Close();
260290
}
@@ -436,7 +466,7 @@ public bool UploadData(string type, string postContent, string mime = "applicati
436466
catch(Exception ex)
437467
{
438468
Monitor.Enter(this);
439-
Log("Error", "上传出错:" + ex.Message);
469+
Log("Error", ex, "上传出错:");
440470
Monitor.Exit(this);
441471
}
442472
return false;
@@ -506,7 +536,7 @@ private void UploadSnapshot()
506536
}
507537
catch(Exception ex)
508538
{
509-
Log("Error", ex.Message + Environment.NewLine + ex.StackTrace);
539+
Log("Error", ex, "房区快照上报出错:");
510540
}
511541
//Log("Info", $"上报消息给 {post_url}");
512542
}

HousingCheck/PluginControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void LoadSettings()
100100
//checkBoxML.Checked = bool.Parse(head?.SelectSingleNode("UploadMLOnly")?.InnerText ?? "true");
101101
checkBoxUploadSnapshot.Checked = bool.Parse(head?.SelectSingleNode("UploadSnapshot")?.InnerText ?? "true");
102102
}
103-
catch(Exception ex)
103+
catch (Exception)
104104
{
105105
File.Delete(SettingsFile);
106106
}

HousingCheck/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.3.0")]
36-
[assembly: AssemblyFileVersion("1.3.2.0")]
35+
[assembly: AssemblyVersion("1.3.4.0")]
36+
[assembly: AssemblyFileVersion("1.3.4.0")]

0 commit comments

Comments
 (0)