public ErrorCodes InsertDecorSql(DecorDescription decorDescription, out int newDecorId) { var ec = ErrorCodes.NoError; newDecorId = -1; try { newDecorId = Db.Query().CommandText(@"insert decor (definition, quaternionx,quaterniony,quaternionz,quaternionw,zoneid,x,y,z,scale,fadedistance,category) values (@definition,@quaternionX,@quaternionY,@quaternionZ,@quaternionW,@ZoneID,@x,@y,@z,@scale,@fadeDistance,@category); select cast(scope_identity() as int)").SetParameter("@definition", decorDescription.definition).SetParameter("@quaternionX", decorDescription.quaternionX).SetParameter("@quaternionY", decorDescription.quaternionY).SetParameter("@quaternionZ", decorDescription.quaternionZ).SetParameter("@quaternionW", decorDescription.quaternionW).SetParameter("@ZoneID", decorDescription.zoneId).SetParameter("@x", decorDescription.position.intX).SetParameter("@y", decorDescription.position.intY).SetParameter("@z", decorDescription.position.intZ).SetParameter("@scale", decorDescription.scale).SetParameter("@fadeDistance", decorDescription.fadeDistance).SetParameter("@category", decorDescription.category) .ExecuteScalar <int>(); } catch (Exception ex) { Logger.Error("error occured inserting a decor object: " + ex.Message); ec = ErrorCodes.SQLInsertError; } return(ec); }
public ErrorCodes UpdateDecorSql(DecorDescription decorDescription) { var res = Db.Query().CommandText(@"update decor set definition=@definition, quaternionx=@quaternionX, quaterniony=@quaternionY, quaternionz=@quaternionZ, quaternionw=@quaternionW, zoneid=@ZoneID, x=@x, y=@y, z=@z, scale=@scale, fadedistance=@fadeDistance, category=@category where id=@ID").SetParameter("@definition", decorDescription.definition).SetParameter("@quaternionX", decorDescription.quaternionX).SetParameter("@quaternionY", decorDescription.quaternionY).SetParameter("@quaternionZ", decorDescription.quaternionZ).SetParameter("@quaternionW", decorDescription.quaternionW).SetParameter("@ZoneID", decorDescription.zoneId).SetParameter("@x", decorDescription.position.intX).SetParameter("@y", decorDescription.position.intY).SetParameter("@z", decorDescription.position.intZ).SetParameter("@scale", decorDescription.scale).SetParameter("@fadeDistance", decorDescription.fadeDistance).SetParameter("@ID", decorDescription.id).SetParameter("@category", decorDescription.category) .ExecuteNonQuery(); return((res != 1) ? ErrorCodes.SQLInsertError : ErrorCodes.NoError); }
public void Initialize() { try { var records = Db.Query().CommandText("select * from decor where zoneid=@zoneId") .SetParameter("@zoneId", _zone.Id) .Execute(); foreach (var record in records) { var x = record.GetValue <int>("x"); var y = record.GetValue <int>("y"); var z = record.GetValue <int>("z"); var decorDescription = new DecorDescription { id = record.GetValue <int>("id"), definition = record.GetValue <int>("definition"), quaternionX = record.GetValue <double>("quaternionx"), quaternionY = record.GetValue <double>("quaterniony"), quaternionZ = record.GetValue <double>("quaternionz"), quaternionW = record.GetValue <double>("quaternionw"), position = new Position(x, y, z), scale = record.GetValue <double>("scale"), changed = record.GetValue <bool>("changed"), zoneId = _zone.Id, fadeDistance = record.GetValue <double>("fadedistance"), category = record.GetValue <int>("category"), locked = record.GetValue <bool>("locked") }; SetDecor(decorDescription); } Logger.Info("decor loaded for zone " + _zone.Id); } catch (Exception ex) { Logger.Exception(ex); } }
public void SetDecor(DecorDescription decorDescription) { _decors[decorDescription.id] = decorDescription; }
public void SpreadDecorChanges(DecorDescription decorDescription) { Message.Builder.SetCommand(Commands.DecorUpdate).WithData(new Dictionary <string, object> { { k.description, decorDescription.ToDictionary() } }).ToCharacters(_zone.GetCharacters()).Send(); }