static public DepartmentCellInfo GetDepartmentCellInfoByName(string name, HospitalCellInfo hci = null) { if (selectedHospital == null && hci == null) { return(null); } if (selectedHospital != null) { if (!selectedHospital.departments.ContainsKey(name)) { return(null); //rlready exist } else { return(selectedHospital.departments[name]); } } if (hci != null) { if (!hci.departments.ContainsKey(name)) { return(null); //rlready exist } else { return(hci.departments[name]); } } return(null); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns>0="succeeded"</returns> static public int AddHospitals(string name, int id) { if (Hospitals.ContainsKey(name)) { return(-1); //rlready exist } try { HospitalCellInfo hc = new HospitalCellInfo { name = name, projectID = Guid.NewGuid(), createTime = DateTime.Now, hospitalID = id }; if (/*AddDepartment("通用科室", hc) == 0*/ true) { Hospitals.Add(name, hc); return(0); } else { hc = null; return(-2); } } catch (Exception e) { Debug.Log(e.Message); return(-2); } }
static public int GetDepartmentCellInfoCount(HospitalCellInfo hci) { if (hci != null && hci.departments != null) { return(hci.departments.Count); } return(0); }
/// <summary> /// /// </summary> /// <param name="name"></param> static public void DelHospital(string name) { if (selectedHospital != null) { return; } if (Hospitals.ContainsKey(name)) { Hospitals.Remove(name); } selectedHospital = 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")); } }
/// <summary> /// /// </summary> static public void DelAllHospital() { Hospitals.Clear(); selectedHospital = null; }