/// <summary> /// /// </summary> static public void DelAllDepartment() { if (selectedHospital == null) { return; } selectedHospital.departments.Clear(); selectedDepartment = null; }
/// <summary> /// /// </summary> /// <param name="name"></param> static public void DelDepartment(string name) { if (selectedHospital == null) { return; } if (selectedHospital.departments.ContainsKey(name)) { selectedHospital.departments.Remove(name); } selectedDepartment = null; }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="id"></param> /// <param name="hci"></param> /// <returns></returns> static public int AddDepartment(string name, int id, HospitalCellInfo hci = null) { if (hci == null && selectedHospital == null) { return(-3); //hopstial not selected } if (hci != null && hci.departments.ContainsKey(name)) { return(-1); //rlready exist } else if (selectedHospital != null && selectedHospital.departments.ContainsKey(name)) { return(-1); //rlready exist } try { DepartmentCellInfo dci = new DepartmentCellInfo { name = name, questionID = "", hospital = hci != null ? hci : selectedHospital, departmentID = id }; if (hci != null) { hci.departments.Add(name, dci); } else { selectedHospital.departments.Add(name, dci); } return(0); } catch (Exception e) { Debug.Log(e.Message); return(-2); } }
static public void UnserializeData() { if (System.IO.File.Exists(Application.persistentDataPath + "/hospital.bin")) { FileStream fs = new FileStream(Application.persistentDataPath + "/hospital.bin", FileMode.Open); if (fs != null) { BinaryFormatter bf = new BinaryFormatter(); Hospitals = bf.Deserialize(fs) as Dictionary <string, HospitalCellInfo>; if (!isOfflineMode) { QExcludeMap.Clear(); foreach (KeyValuePair <string, HospitalCellInfo> pair in Hospitals) { foreach (KeyValuePair <string, DepartmentCellInfo> dci in pair.Value.departments) { if (dci.Value.qusetionLoaded) { QuestionMap[dci.Value.questionID] = dci.Value.questions; foreach (Question q in dci.Value.questions) { if (q.rev1 != "") //判断是跳转还是互斥 { if (q.rev2 != "") //跳转模式 { try { string[] _params = q.rev1.Split(new char[1] { ',' }); string[] _params2 = q.rev2.Split(new char[1] { ',' }); for (int i = 0; i < _params.Length; i += 2) { PollsConfig.QExclude qe = new PollsConfig.QExclude(); qe.idxA = _params[i]; qe.idxB = _params2[i]; qe.qidxA = Int32.Parse(_params[i + 1]); qe.qidxB = Int32.Parse(_params2[i + 1]); PollsConfig.QExclude qe2 = new PollsConfig.QExclude(); qe2.idxA = _params2[i]; qe2.idxB = _params[i]; qe2.qidxA = Int32.Parse(_params2[i + 1]); qe2.qidxB = Int32.Parse(_params[i + 1]); if (QExcludeMap.ContainsKey(qe.idxA)) { QExcludeMap[qe.idxA].List.Add(qe); } else { QExclude _qe = new QExclude(); _qe.List.Add(qe); QExcludeMap.Add(qe.idxA, _qe); } if (QExcludeMap.ContainsKey(qe.idxB)) { QExcludeMap[qe.idxB].List.Add(qe2); } else { QExclude _qe = new QExclude(); _qe.List.Add(qe2); QExcludeMap.Add(qe.idxB, _qe); } } } catch { Toast.ShowToast("解析互斥题目失败, 请检查题库"); } } } } } } } } fs.Close(); } } if (PlayerPrefs.GetString("SelectedHospital") != "") { selectedHospital = GetHospitalCellInfoByName(PlayerPrefs.GetString("SelectedHospital")); } if (PlayerPrefs.GetString("SelectedDepartment") != "") { selectedDepartment = GetDepartmentCellInfoByName(PlayerPrefs.GetString("SelectedDepartment")); } }