/// <summary> /// Insert a DBInstancedItem into table /// </summary> /// <param name="item"> /// Item to write /// </param> public static void Save(DBInstancedItem item) { try { using (IDbConnection conn = Connector.GetConnection()) { conn.Execute( "INSERT INTO instanceditems (containertype,containerinstance,containerplacement,itemtype,iteminstance" + ",lowid,highid,quality,multiplecount,x,y,z,headingx,headingy,headingz,headingw,stats) VALUES (@conttype," + " @continstance, @contplacement, @itype, @iinstance, @low, @high, @ql, @mc, @ix, @iy, @iz, @hx, @hy, @hz, @hw, @st)", new { conttype = item.containertype, continstance = item.containerinstance, contplacement = item.containerplacement, itype = item.itemtype, iinstance = item.iteminstance, low = item.lowid, high = item.highid, ql = item.quality, mc = item.multiplecount, ix = item.x, iy = item.y, iz = item.z, hx = item.headingx, hy = item.headingy, hz = item.headingz, hw = item.headingw, st = item.stats }); } } catch (Exception e) { LogUtil.ErrorException(e); throw; } }
/// <summary> /// </summary> /// <returns> /// </returns> public virtual bool Write() { List<DBInstancedItem> DBinstanced = new List<DBInstancedItem>(); List<DBItem> DBuninstanced = new List<DBItem>(); foreach (KeyValuePair<int, IItem> kv in this.Content) { if (kv.Value.Identity.Type != IdentityType.None) { DBInstancedItem dbi = new DBInstancedItem { containerinstance = this.Identity.Instance, containertype = (int)this.Identity.Type, containerplacement = kv.Key, itemtype = (int)kv.Value.Identity.Type, Id = kv.Value.Identity.Instance, lowid = kv.Value.LowID, highid = kv.Value.HighID, quality = kv.Value.Quality, multiplecount = kv.Value.MultipleCount, stats = new Binary(kv.Value.GetItemAttributes()) }; DBinstanced.Add(dbi); } else { DBItem dbi = new DBItem { containerinstance = this.Identity.Instance, containertype = (int)this.Identity.Type, containerplacement = kv.Key, lowid = kv.Value.LowID, highid = kv.Value.HighID, quality = kv.Value.Quality, multiplecount = kv.Value.MultipleCount }; DBuninstanced.Add(dbi); } } ItemDao.Instance.Save(DBuninstanced, null, null); InstancedItemDao.Instance.Save(DBinstanced, null, null); return true; }