/// <summary> /// 武器的导入 /// </summary> /// <param name="target"></param> /// <param name="workbook"></param> private void Weapon(TargetType target, dynamic workbook) { if (Directory.Exists(XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\")) { Directory.Delete(XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\", true); } Directory.CreateDirectory(XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\"); //武器的导入 dynamic worksheet = workbook.Sheets(3); int rowCount = 4; while (!String.IsNullOrEmpty(worksheet.Cells(rowCount, 2).Text)) { Card.WeaponCard Weapon = new Card.WeaponCard(); Weapon.SN = worksheet.Cells(rowCount, 2).Text; Weapon.Name = worksheet.Cells(rowCount, 3).Text; Weapon.Description = worksheet.Cells(rowCount, 4).Text; Weapon.Class = CardUtility.GetEnum <Card.CardUtility.ClassEnum>(worksheet.Cells(rowCount, 5).Text, Card.CardUtility.ClassEnum.中立); Weapon.StandardCostPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 7).Text); Weapon.ActualCostPoint = Weapon.StandardCostPoint; Weapon.StandardAttackPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 8).Text); Weapon.标准耐久度 = CardUtility.GetInt(worksheet.Cells(rowCount, 9).Text); Weapon.Rare = CardUtility.GetEnum <Card.CardBasicInfo.稀有程度>(worksheet.Cells(rowCount, 12).Text, CardBasicInfo.稀有程度.白色); Weapon.IsCardReady = !String.IsNullOrEmpty(worksheet.Cells(rowCount, 13).Text); switch (target) { case TargetType.MongoDB: //innerCollection.Insert<Card.WeaponCard>(Weapon); break; case TargetType.Xml: XmlSerializer xml = new XmlSerializer(typeof(Card.WeaponCard)); String XmlFilename = XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\" + Weapon.SN + ".xml"; xml.Serialize(new StreamWriter(XmlFilename), Weapon); break; default: break; } rowCount++; } }
/// <summary> /// 武器的导入 /// </summary> /// <param name="target"></param> /// <param name="workbook"></param> private void Weapon(TargetType target, dynamic workbook) { if (Directory.Exists(XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\")) { Directory.Delete(XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\", true); } Directory.CreateDirectory(XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\"); //武器的导入 dynamic worksheet = workbook.Sheets(3); int rowCount = 4; while (!String.IsNullOrEmpty(worksheet.Cells(rowCount, 2).Text)) { Card.WeaponCard Weapon = new Card.WeaponCard(); Weapon.SN = worksheet.Cells(rowCount, 2).Text; Weapon.Name = worksheet.Cells(rowCount, 3).Text; Weapon.Description = worksheet.Cells(rowCount, 4).Text; Weapon.Class = CardUtility.GetEnum<Card.CardUtility.ClassEnum>(worksheet.Cells(rowCount, 5).Text, Card.CardUtility.ClassEnum.中立); Weapon.StandardCostPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 7).Text); Weapon.ActualCostPoint = Weapon.StandardCostPoint; Weapon.StandardAttackPoint = CardUtility.GetInt(worksheet.Cells(rowCount, 8).Text); Weapon.标准耐久度 = CardUtility.GetInt(worksheet.Cells(rowCount, 9).Text); Weapon.Rare = CardUtility.GetEnum<Card.CardBasicInfo.稀有程度>(worksheet.Cells(rowCount, 12).Text, CardBasicInfo.稀有程度.白色); Weapon.IsCardReady = !String.IsNullOrEmpty(worksheet.Cells(rowCount, 13).Text); switch (target) { case TargetType.MongoDB: //innerCollection.Insert<Card.WeaponCard>(Weapon); break; case TargetType.Xml: XmlSerializer xml = new XmlSerializer(typeof(Card.WeaponCard)); String XmlFilename = XmlFolderPicker.SelectedPathOrFileName + "\\Weapon\\" + Weapon.SN + ".xml"; xml.Serialize(new StreamWriter(XmlFilename), Weapon); break; default: break; } rowCount++; } }