/// <summary> /// 更新信息 /// </summary> public void SaveData() { var json = Request["data"]; UtilLog.WriteTextLog("Eqp Model Add", json); var rows = (ArrayList)PluSoft.Utils.JSON.Decode(json); var bllEquipmentModel = new EquipmentModel(); Sys.Model.EquipmentModel model; foreach (Hashtable row in rows) { var id = row["ModelId"] != null ? row["ModelId"].ToString() : ""; //根据记录状态,进行不同的增加、删除、修改操作 var state = row["_state"] != null ? row["_state"].ToString() : ""; if (state == "added" || id == "") //新增:id为空,或_state为added { model = new Sys.Model.EquipmentModel(); model.ModelName = row["ModelName"].ToString(); if (!string.IsNullOrEmpty(row["EqpType"].ToString())) { model.EqpType = Convert.ToInt32(row["EqpType"]); } model.ParentModelId = Utils.StrToInt(row["ParentModelId"], 0); model.Status = "1"; model.CreateDate = DateTime.Now; bllEquipmentModel.Add(model); } else if (state == "modified" || state == "") //更新:_state为空或modified { model = bllEquipmentModel.GetModel(Utils.StrToInt(row["ModelId"], 0)); if (model != null) { model.ModelName = row["ModelName"].ToString(); if (!string.IsNullOrEmpty(row["EqpType"].ToString())) { model.EqpType = Convert.ToInt32(row["EqpType"]); } else { model.EqpType = null; } model.ParentModelId = Utils.StrToInt(row["ParentModelId"], 0); model.ModifyDate = DateTime.Now; bllEquipmentModel.Update(model); } } } }
public void ReciveItem(int id) { if (id == -1) { return; } var itemMaster = GameModel.Instance.Masters.Item.Datas.FirstOrDefault(i => i.id == id); if (itemMaster != null) { itemModel.Add(Item.Create(itemMaster, false)); } var equipmentMaster = GameModel.Instance.Masters.Equipment.Datas.FirstOrDefault(e => e.id == id); if (equipmentMaster != null) { equipmentModel.Add(Equipment.Create(equipmentMaster)); } }