public static void BuildPackageData(ItemPackageData entity, string itemString) { if (entity.Items.Count <= 0) { return; } int start = 0; int end = 0; foreach (var item in entity.Items) { start = itemString.IndexOf("ItemProperty") + 14; end = itemString.IndexOf("GridIndex") - 2; var ss = itemString.Substring(start, end - start); switch (item.ItemType) { case (int)EnumItemType.PlayerCard: item.ItemProperty = JsonConvert.DeserializeObject <PlayerCardProperty>(ss); break; case (int)EnumItemType.Equipment: item.ItemProperty = JsonConvert.DeserializeObject <EquipmentProperty>(ss); break; case (int)EnumItemType.MallItem: item.ItemProperty = JsonConvert.DeserializeObject <MallItemProperty>(ss); break; } itemString = itemString.Substring(end + 9); } }
/// <summary> /// BuildPackageData /// </summary> /// <param name="package"></param> /// <param name="itemType"></param> /// <returns></returns> public ItemPackageData BuildPackageData(ItemPackageFrame package, int itemType = 0) { var data = new ItemPackageData(); data.Items = package.GetItemsByType(itemType); var teammember = MatchDataHelper.GetSolutionTeammembers(package.ManagerId); ItemPackageFrame.CaluPackageCardKpi(data.Items, teammember); data.PackageSize = package.PackageSize; return(data); }