ComponentType[] ComponentTypesFromUnit(XmlUnit unit) { ComponentType[] componentTypes = new ComponentType[unit.Components.Length]; List <int> invalidPositions = new List <int>(); for (int i = 0; i < unit.Components.Length; i++) { if (componentTypeDictionary.ContainsKey(unit.Components[i].Name) == false) { Debug.LogError($"TestingScript -- ComponentTypesFromUnit: {unit.Components[i].Name} was not in the dictionary"); invalidPositions.Add(i); continue; } componentTypes[i] = componentTypeDictionary[unit.Components[i].Name]; } return(componentTypes.Where(c => c != null).ToArray()); }
private void txtCardNo_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { var xml = @"<ApplyBillInfo> <PatientInfos> <PatientInfo> <RegCode>970312</RegCode> <BedNo/> <DoctorName null=""yes""/> <PatientType>10</PatientType> <PatientTypeName>普通病人</PatientTypeName> <OutPatientNo>8658580</OutPatientNo> <WardCode>0</WardCode> <DateOfBirth>19980808</DateOfBirth> <RelationshipType/> <EncounterType>O</EncounterType> <EncounterTypeName>门诊</EncounterTypeName> <Age>22岁</Age> <LocationName>内科</LocationName> <RelationshipAdd/> <RelationshipTel/> <MIcardNumber>88888888</MIcardNumber> <HomeTel/> <DoctorCode/> <MedicalCardNumber null=""yes""/> <LocationCode>265</LocationCode> <RelationshipName>测试123321</RelationshipName> <HomeAddress/> <GenderCode>M</GenderCode> <GenderName>男</GenderName> <WorkAddress/> <WardName null=""yes"" /> <PatientName>测试123321</PatientName> <WorkTel/> <Wbbh>8658580</Wbbh> <InPatientNo/> <SSNumber/> <ApplyBills> <ApplyBill> <Result/> <RequestStatus>0 </RequestStatus> <Memo/> <MedicalHistory>主诉:1 现病史:1
 既往史:1 体格检查:1</MedicalHistory> <LocationCode>265</LocationCode> <ReqDoctorName>0000</ReqDoctorName> <RequestDate>20210413111021</RequestDate> <UrgentStatus>0</UrgentStatus> <ReqLocationCode>265</ReqLocationCode> <LocationName>内科</LocationName> <RequestId>385168</RequestId> <ReqLocationName null=""yes"" /> <ReqDoctorCode>0000</ReqDoctorCode> <RequestType/> <ClinicDiagnosis>健康查体</ClinicDiagnosis> <AllergyHistory/> <ApplyItems> <ApplyItem> <UnitPrice>350.0000</UnitPrice> <CheckPointName/> <CheckPointCode/> <Memo/> <MethodName>0</MethodName> <ItemName>电子胃镜检查</ItemName> <MethodCode/> <Quantity>1</Quantity> <ItemCode>NKJJC1344</ItemCode> </ApplyItem> </ApplyItems> </ApplyBill> <ApplyBill> <Result/> <RequestStatus>0 </RequestStatus> <Memo/> <MedicalHistory>主诉:1 现病史:1既往史:1 体格检查:1</MedicalHistory> <LocationCode>265</LocationCode> <ReqDoctorName>0000</ReqDoctorName> <RequestDate>20210413111038</RequestDate> <UrgentStatus>0</UrgentStatus> <ReqLocationCode>265</ReqLocationCode> <LocationName>内科</LocationName> <RequestId>385169</RequestId> <ReqLocationName null=""yes"" /> <ReqDoctorCode>0000</ReqDoctorCode> <RequestType/> <ClinicDiagnosis>健康查体</ClinicDiagnosis> <AllergyHistory/> <ApplyItems> <ApplyItem> <UnitPrice>400.0000</UnitPrice> <CheckPointName/> <CheckPointCode/> <Memo/> <MethodName>0</MethodName> <ItemName>电子肠镜检查</ItemName> <MethodCode/> <Quantity>1</Quantity> <ItemCode>NKJJC1345</ItemCode> </ApplyItem> </ApplyItems> </ApplyBill> <ApplyBill> <Result/> <RequestStatus>0 </RequestStatus> <Memo/> <MedicalHistory>主诉:1 现病史:1既往史:1 体格检查:1</MedicalHistory> <LocationCode>265</LocationCode> <ReqDoctorName>0000</ReqDoctorName> <RequestDate>20210413110330</RequestDate> <UrgentStatus/> <ReqLocationCode>265</ReqLocationCode> <LocationName>内科</LocationName> <RequestId>385162</RequestId> <ReqLocationName null=""yes"" /> <ReqDoctorCode>0000</ReqDoctorCode> <RequestType/> <ClinicDiagnosis>健康查体</ClinicDiagnosis> <AllergyHistory/> <ApplyItems> <ApplyItem> <UnitPrice>350.0000</UnitPrice> <CheckPointName>部位2</CheckPointName> <CheckPointCode>222</CheckPointCode> <Memo/> <MethodName/> <ItemName>电子胃镜检查</ItemName> <MethodCode/> <Quantity>1</Quantity> <ItemCode>NKJJC1344</ItemCode> </ApplyItem> <ApplyItem> <UnitPrice>400.0000</UnitPrice> <CheckPointName>部位</CheckPointName> <CheckPointCode>111</CheckPointCode> <Memo/> <ItemName>电子肠镜检查</ItemName> <MethodName>方法</MethodName> <MethodCode>222</MethodCode> <Quantity>1</Quantity> <ItemCode>NKJJC1345</ItemCode> </ApplyItem> </ApplyItems> </ApplyBill> </ApplyBills> </PatientInfo> </PatientInfos> </ApplyBillInfo> "; if (!string.IsNullOrEmpty(txtCardNo.Text)) { var applyBill = XmlUnit.XmlDeserialize <ApplyBillInfo>(xml); if (applyBill != null && applyBill.PatientInfos.Count > 0 && applyBill.PatientInfos[0].ApplyBills.Count > 0) { patient = applyBill.PatientInfos[0]; patient.ApplyBills[0].ApplyItems.Select(x => x.CheckPointCode); //his接口数据,异步添加配置 var configTask = _typeConfigBll.AddTypeConfigByHisAsync(patient); var deptTask = _deptmentBll.AddDeptmentByHisAsync(patient); dgvApplyBills.DataSource = patient.ApplyBills; tabPage2.Parent = tabControl1; tabControl1.SelectedTab = tabPage2; //同步数据,最后加载,怕线程没有执行完. //configTask.Wait(); //deptTask.Wait(); } else { this.ShowInfo("没有患者信息."); } } } }
// Start is called before the first frame update void Start() { var componentDataQuery = from domainAssembly in AppDomain.CurrentDomain.GetAssemblies() from type in domainAssembly.GetLoadableTypes() where type != null && typeof(IComponentData).IsAssignableFrom(type) && !type.IsAbstract && type.IsPublic orderby type.Name select type; StringBuilder sb = new StringBuilder(); foreach (var value in componentDataQuery) { sb.Append($"{value.Name}, "); componentTypeDictionary.Add(value.Name, value); } Debug.Log(sb); XmlLoader xmlLoader = new XmlLoader(Application.streamingAssetsPath + @"\ExampleMod\Units\TestUnit.xml"); XmlUnit unit = (XmlUnit)xmlLoader.XmlObject; EntityManager EntityManager = World.Active.EntityManager; EntityArchetype playerArchtype = EntityManager.CreateArchetype( ComponentTypesFromUnit(unit) ); Entity entity = EntityManager.CreateEntity(playerArchtype); GameObject gameObject = Instantiate(spritePrefab); int spriteSheetIndex = CheckSpriteSheetsForMatch(spriteSheets, unit.SpritePath); if (spriteSheetIndex == -1) { FileInfo spriteFile = new FileInfo(Application.streamingAssetsPath + "/" + unit.SpritePath); spriteSheets.Add(new SpriteSheet() { Name = unit.SpritePath, Sprites = GetSpriteSheetFromFile(spriteFile) }); spriteSheetIndex = spriteSheets.Count - 1; } Sprite[] spritesArray = spriteSheets[spriteSheetIndex].Sprites; gameObject.GetComponent <SpriteRenderer>().sprite = spritesArray[unit.SpritePosition]; //Sprite sprite = spriteSheets[spriteSheetIndex].Sprites[unit.SpritePosition]; //gameObject.GetComponent<SpriteRenderer>().sprite = sprite; //List<SpriteSheet> sheets = spriteSheets; //gameObject.GetComponent<SpriteRenderer>().sprite = sheets[spriteSheetIndex].Sprites[unit.SpritePosition]; //gameObject.GetComponent<SpriteRenderer>().sprite = spriteSheets[spriteSheetIndex].Sprites[unit.SpritePosition]; int visualID = SpriteManager.RegisterVisualGameObjectAndReturnKey(gameObject); EntityManager.SetComponentData(entity, new SpriteToGameObject { VisualID = visualID }); var staminaIndex = unit.Components.Select((value, index) => new { value, index = index + 1 }) .Where(pair => pair.value.Name == "Stamina") .Select(pair => pair.index) .FirstOrDefault() - 1; Debug.Log($"The stamina to start is {unit.Components[staminaIndex].Values[0]}"); EntityManager.SetComponentData(entity, new Stamina { Value = 5, StaminaCap = 20, StaminaPerTurn = 2 }); }