public void Rock() { CurrDestNoInf = null; var deskNo = DeskNoList.Where(x => x.IsUsed == false).ToArray(); if (deskNo.Length == 0) { return; } Random _r = new Random(); CurrDestNoInf = deskNo[_r.Next(0, deskNo.Length)]; }
public void InitData() { if (!File.Exists(_filePath)) { return; } string[] lines = File.ReadAllLines(_filePath); foreach (var line in lines) { if (string.IsNullOrWhiteSpace(line)) { continue; } var arrData = line.Split(','); var isUse = false; isUse = arrData.Length >1 && arrData[1] == "1"; var deskNoInfo = new DestNoInf() {No = arrData[0],IsUsed = isUse}; DeskNoList.Add(deskNoInfo); } }