public void PushItemData(ItemDataCollection col) { string sp = "up_PushItemData"; foreach (ItemData item in col.data.Values) { using (SqlConnection con = new SqlConnection(CONNECTION_STRING)) { using (SqlCommand cmd = new SqlCommand(sp, con)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@itemid", SqlDbType.Int).Value = item.id; cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = item.name; con.Open(); cmd.ExecuteNonQuery(); } finally { con.Close(); } } } } }
public void SaveItemData() { ItemDataCollection items = JsonConvert.DeserializeObject <ItemDataCollection>(Properties.Resources.ItemData); DataPush push = new DataPush(); push.PushItemData(items); }
public IDCache() { Logger.DBLog.Info("[fBaseXtensions] Loading The External Cache..."); var unitdata = UnitDataCollection.DeserializeFromXML(); //var unitdata = new UnitDataCollection(); UnitDataCollection.SerializeToXML(unitdata); UnitEntries.Clear(); foreach (var entry in unitdata.UnitEntries) { UnitEntries.Add(entry.SnoId, new CacheUnitEntry(entry.SnoId, (UnitFlags)entry.ObjectType, entry.InternalName)); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Unit Entries", UnitEntries.Count); UnitPetEntries.Clear(); foreach (var entry in unitdata.UnitPetEntries) { UnitPetEntries.Add(entry.SnoId, new CacheUnitPetEntry(entry.SnoId, (PetTypes)entry.ObjectType, entry.InternalName)); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Pet Entries", UnitPetEntries.Count); var Items = ItemDataCollection.DeserializeFromXML(); //var Items = new ItemDataCollection(); ItemDataCollection.SerializeToXML(Items); ItemDroppedEntries.Clear(); foreach (var entry in Items.DroppedItemCache) { ItemDroppedEntries.Add(entry.SnoId, new CacheDroppedItemEntry(entry.SnoId, (PluginDroppedItemTypes)entry.ObjectType, entry.InternalName)); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Dropped Item Entries", ItemDroppedEntries.Count); ItemDataEntries.Clear(); foreach (var entry in Items.ItemDataCache) { ItemDataEntries.Add(entry.SnoId, entry); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Item Entries", ItemDataEntries.Count); ItemGemEntries.Clear(); foreach (var entry in Items.GemCache) { ItemGemEntries.Add(entry.SnoId, new CacheItemGemEntry(entry)); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Gem Entries", ItemGemEntries.Count); ItemDroppedInternalNames.Clear(); foreach (var entry in Items.DroppedItemInternalNames) { ItemDroppedInternalNames.Add(entry); } //Logger.DBLog.InfoFormat("[fBaseXtensions] Loaded {0} Item Name Entries", ItemDroppedInternalNames.Count); var Gizmos = GizmoDataCollection.DeserializeFromXML(); //var Gizmos = new GizmoDataCollection(); GizmoDataCollection.SerializeToXML(Gizmos); GizmoEntries.Clear(); foreach (var entry in Gizmos.GizmoCache) { var pluginGizmoType = (PluginGizmoType)entry.ObjectType; GizmoEntries.Add(entry.SnoId, new CacheGizmoEntry(entry.SnoId, (GizmoType)Enum.Parse(typeof(GizmoType), pluginGizmoType.ToString()), entry.InternalName, entry.GizmotargetType)); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Gizmo Entries", GizmoEntries.Count); var Avoidance = AvoidanceDataCollection.DeserializeFromXML(); //var Avoidance = new AvoidanceDataCollection(); AvoidanceDataCollection.SerializeToXML(Avoidance); AvoidanceEntries.Clear(); foreach (var entry in Avoidance.AvoidanceCache) { AvoidanceEntries.Add(entry.SnoId, new CacheAvoidanceEntry(entry.SnoId, (AvoidanceType)entry.ObjectType, entry.InternalName)); } Logger.DBLog.DebugFormat("[fBaseXtensions] Loaded {0} Avoidance Entries", AvoidanceEntries.Count); Logger.DBLog.InfoFormat("[fBaseXtensions] Finished Loading The External Cache!"); }
public static bool ParseAssetBundleData(string configString, out AssetBundleData assetBundleData) { assetBundleData = null; XmlDocument doc = new XmlDocument(); try { doc.LoadXml(configString); } catch (System.Exception exception) { Debug.LogError("Cannot parse config file"); return false; } assetBundleData = new AssetBundleData(); XmlNode buildAssetBundleNode = doc.SelectSingleNode("buildAssetBundle"); if (buildAssetBundleNode == null) { Debug.LogError("Cannot parse node(buildAssetBundle)"); return false; } // ignoreExtention XmlNode ignoreExtentionNode = buildAssetBundleNode.Attributes.GetNamedItem("ignoreExtention"); if (ignoreExtentionNode != null) { string[] blocks = ignoreExtentionNode.Value.Split(';'); if (blocks != null && blocks.Length > 0) { assetBundleData.ignoreExtentionList = new List<string>(); foreach (string block in blocks) { assetBundleData.ignoreExtentionList.Add(block); } } } // platform #if UNITY_EDITOR XmlNode platformNode = buildAssetBundleNode.Attributes.GetNamedItem("platform"); if (platformNode != null) { try { assetBundleData.platform = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformNode.Value); } catch (System.Exception exception) { Debug.LogError("Cannot parse node(platform)" + ":" + platformNode.Value); return false; } } #endif // saveRoot XmlNode saveRootNode = doc.SelectSingleNode("buildAssetBundle/saveRoot"); if (saveRootNode == null) { Debug.LogError("Cannot parse node(saveRoot)"); return false; } assetBundleData.saveRoot = saveRootNode.InnerText; // asset XmlNodeList assetNodeList = doc.SelectNodes("buildAssetBundle/asset"); if (assetNodeList == null || assetNodeList.Count == 0) { Debug.LogError("Nothing asset"); return false; } assetBundleData.assetDataMap = new Dictionary<string, AssetData>(); foreach (XmlNode assetNode in assetNodeList) { AssetData assetData = new AssetData(); assetData.enabled = true; assetData.itemDataCollectionList = new List<ItemDataCollection>(); // id XmlNode idNode = assetNode.Attributes.GetNamedItem("id"); if (idNode == null) { Debug.LogError("Missing asset id"); return false; } if (assetBundleData.assetDataMap.ContainsKey(idNode.Value)) { Debug.LogError("Repeated id:" + idNode.Value); return false; } if (string.IsNullOrEmpty(idNode.Value)) { Debug.LogError("Missing asset id:" + idNode.Value); return false; } assetData.id = idNode.Value; assetBundleData.assetDataMap.Add(assetData.id, assetData); // dependence XmlNode dependenceNode = assetNode.Attributes.GetNamedItem("dependence"); if (dependenceNode != null) { assetData.dependence = dependenceNode.Value; } // item XmlNodeList itemNodeList = assetNode.SelectNodes("item"); if (itemNodeList != null && itemNodeList.Count > 0) { foreach (XmlNode itemNode in itemNodeList) { ItemDataCollection itemDataCollection = new ItemDataCollection(); assetData.itemDataCollectionList.Add(itemDataCollection); itemDataCollection.bind = false; itemDataCollection.itemDataList = new List<ItemData>(); ItemData itemData = null; if (!ParseItemNode(itemNode, assetData.id, out itemData)) { return false; } itemDataCollection.itemDataList.Add(itemData); } } // bind XmlNodeList bindNodeList = assetNode.SelectNodes("bind"); if (bindNodeList != null) { foreach (XmlNode bindNode in bindNodeList) { ItemDataCollection itemDataCollection = new ItemDataCollection(); assetData.itemDataCollectionList.Add(itemDataCollection); itemDataCollection.bind = true; itemDataCollection.itemDataList = new List<ItemData>(); // savePath XmlNode savePathNode = bindNode.Attributes.GetNamedItem("savePath"); if (savePathNode == null) { Debug.LogError("Cannot parse node(bind.savePath)" + ":" + assetData.id); return false; } itemDataCollection.savePath = savePathNode.Value; // item XmlNodeList itemNodeList2 = bindNode.SelectNodes("item"); if (itemNodeList2 != null && itemNodeList2.Count > 0) { foreach (XmlNode itemNode in itemNodeList2) { ItemData itemData = null; if (!ParseItemNode(itemNode, assetData.id, out itemData)) { return false; } itemDataCollection.itemDataList.Add(itemData); } } // empty test if (itemDataCollection.IsEmpty()) { Debug.LogWarning("Empty asset config:" + assetData.id); } } } // empty test if (assetData.IsEmpty()) { Debug.LogWarning("Empty asset config:" + assetData.id); } } return true; }
public static bool ParseAssetBundleData(string configString, out AssetBundleData assetBundleData) { assetBundleData = null; XmlDocument doc = new XmlDocument(); try { doc.LoadXml(configString); } catch (System.Exception exception) { Debug.LogError("Cannot parse config file"); return(false); } assetBundleData = new AssetBundleData(); XmlNode buildAssetBundleNode = doc.SelectSingleNode("buildAssetBundle"); if (buildAssetBundleNode == null) { Debug.LogError("Cannot parse node(buildAssetBundle)"); return(false); } // ignoreExtention XmlNode ignoreExtentionNode = buildAssetBundleNode.Attributes.GetNamedItem("ignoreExtention"); if (ignoreExtentionNode != null) { string[] blocks = ignoreExtentionNode.Value.Split(';'); if (blocks != null && blocks.Length > 0) { assetBundleData.ignoreExtentionList = new List <string>(); foreach (string block in blocks) { assetBundleData.ignoreExtentionList.Add(block); } } } // platform #if UNITY_EDITOR XmlNode platformNode = buildAssetBundleNode.Attributes.GetNamedItem("platform"); if (platformNode != null) { try { assetBundleData.platform = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformNode.Value); } catch (System.Exception exception) { Debug.LogError("Cannot parse node(platform)" + ":" + platformNode.Value); return(false); } } #endif // saveRoot XmlNode saveRootNode = doc.SelectSingleNode("buildAssetBundle/saveRoot"); if (saveRootNode == null) { Debug.LogError("Cannot parse node(saveRoot)"); return(false); } assetBundleData.saveRoot = saveRootNode.InnerText; // asset XmlNodeList assetNodeList = doc.SelectNodes("buildAssetBundle/asset"); if (assetNodeList == null || assetNodeList.Count == 0) { Debug.LogError("Nothing asset"); return(false); } assetBundleData.assetDataMap = new Dictionary <string, AssetData>(); foreach (XmlNode assetNode in assetNodeList) { AssetData assetData = new AssetData(); assetData.enabled = true; assetData.itemDataCollectionList = new List <ItemDataCollection>(); // id XmlNode idNode = assetNode.Attributes.GetNamedItem("id"); if (idNode == null) { Debug.LogError("Missing asset id"); return(false); } if (assetBundleData.assetDataMap.ContainsKey(idNode.Value)) { Debug.LogError("Repeated id:" + idNode.Value); return(false); } if (string.IsNullOrEmpty(idNode.Value)) { Debug.LogError("Missing asset id:" + idNode.Value); return(false); } assetData.id = idNode.Value; assetBundleData.assetDataMap.Add(assetData.id, assetData); // dependence XmlNode dependenceNode = assetNode.Attributes.GetNamedItem("dependence"); if (dependenceNode != null) { assetData.dependence = dependenceNode.Value; } // item XmlNodeList itemNodeList = assetNode.SelectNodes("item"); if (itemNodeList != null && itemNodeList.Count > 0) { foreach (XmlNode itemNode in itemNodeList) { ItemDataCollection itemDataCollection = new ItemDataCollection(); assetData.itemDataCollectionList.Add(itemDataCollection); itemDataCollection.bind = false; itemDataCollection.itemDataList = new List <ItemData>(); ItemData itemData = null; if (!ParseItemNode(itemNode, assetData.id, out itemData)) { return(false); } itemDataCollection.itemDataList.Add(itemData); } } // bind XmlNodeList bindNodeList = assetNode.SelectNodes("bind"); if (bindNodeList != null) { foreach (XmlNode bindNode in bindNodeList) { ItemDataCollection itemDataCollection = new ItemDataCollection(); assetData.itemDataCollectionList.Add(itemDataCollection); itemDataCollection.bind = true; itemDataCollection.itemDataList = new List <ItemData>(); // savePath XmlNode savePathNode = bindNode.Attributes.GetNamedItem("savePath"); if (savePathNode == null) { Debug.LogError("Cannot parse node(bind.savePath)" + ":" + assetData.id); return(false); } itemDataCollection.savePath = savePathNode.Value; // item XmlNodeList itemNodeList2 = bindNode.SelectNodes("item"); if (itemNodeList2 != null && itemNodeList2.Count > 0) { foreach (XmlNode itemNode in itemNodeList2) { ItemData itemData = null; if (!ParseItemNode(itemNode, assetData.id, out itemData)) { return(false); } itemDataCollection.itemDataList.Add(itemData); } } // empty test if (itemDataCollection.IsEmpty()) { Debug.LogWarning("Empty asset config:" + assetData.id); } } } // empty test if (assetData.IsEmpty()) { Debug.LogWarning("Empty asset config:" + assetData.id); } } return(true); }