public static string PointsOfInterest() { if (Storage.GossipPOIs.IsEmpty()) { return(string.Empty); } if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.points_of_interest)) { return(string.Empty); } if (Settings.DBEnabled) { return(SQLUtil.Compare(Storage.GossipPOIs, SQLDatabase.Get(Storage.GossipPOIs), StoreNameType.None)); } else { uint count = 0; var rows = new RowList <PointsOfInterest>(); foreach (var pointOfInterest in Storage.GossipPOIs) { Row <PointsOfInterest> row = new Row <PointsOfInterest>(); Type t = pointOfInterest.Item1.ID.GetType(); if (t.Equals(typeof(int))) { row.Data.ID = pointOfInterest.Item1.ID; } else { row.Data.ID = "@PID+" + count; } row.Data.PositionX = pointOfInterest.Item1.PositionX; row.Data.PositionY = pointOfInterest.Item1.PositionY; row.Data.PositionZ = pointOfInterest.Item1.PositionZ; row.Data.Icon = pointOfInterest.Item1.Icon; row.Data.Flags = pointOfInterest.Item1.Flags; row.Data.Importance = pointOfInterest.Item1.Importance; row.Data.Name = pointOfInterest.Item1.Name; row.Data.VerifiedBuild = pointOfInterest.Item1.VerifiedBuild; ++count; rows.Add(row); } StringBuilder result = new StringBuilder(); // delete query for GUIDs var delete = new SQLDelete <PointsOfInterest>(Tuple.Create("@PID+0", "@PID+" + --count)); result.Append(delete.Build()); var sql = new SQLInsert <PointsOfInterest>(rows, false); result.Append(sql.Build()); return(result.ToString()); } }
public static SQLInsert alteraPedido(int _numped, String _cpf, String _medico, int _tip_proc, int _cof_proc, String _proc, int _codexm, DateTime _dt) { SQLInsert sqli = new SQLInsert(); using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConn"].ToString())) { SqlCommand cmm = cnn.CreateCommand(); cmm.CommandText = "UPDATE Pedidos SET Procedencia = @proc, Cod_Procedencia = @cod_proc," + "Cod_Tipo_Procedencia = @tip_proc, Nome_Solicitante = @medico, " + "CPF_Solcitante = @cpf, Cod_Grupo_Exame = @codexm WHERE " + "(Num_Pedido = @numped)"; cnn.Open(); SqlTransaction st = cnn.BeginTransaction(); try { cmm.Transaction = st; cmm.Parameters.Add("@proc", SqlDbType.NVarChar).Value = _proc; cmm.Parameters.Add("@cod_proc", SqlDbType.Int).Value = _cof_proc; cmm.Parameters.Add("@tip_proc", SqlDbType.Int).Value = _tip_proc; cmm.Parameters.Add("@medico", SqlDbType.NVarChar).Value = _medico; cmm.Parameters.Add("@cpf", SqlDbType.NVarChar).Value = _cpf; cmm.Parameters.Add("@codexm", SqlDbType.Int).Value = _codexm; cmm.Parameters.Add("@numped", SqlDbType.Int).Value = _numped; cmm.ExecuteNonQuery(); cmm.CommandText = "UPDATE Pedido_Extra SET DataHora = @dt WHERE (Num_Pedido = @numped)"; cmm.Parameters.Add("@dt", SqlDbType.DateTime).Value = _dt; cmm.ExecuteNonQuery(); cmm.CommandText = "UPDATE Checkin_Pedido SET DataHora = @dt WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); cmm.CommandText = "INSERT INTO Log_Pedido ([Num_Pedido],[TimeStamp],[Usuario],[Cod_Ent_Log]) " + "VALUES (@numped,getdate(),@usu,@entlog)"; cmm.Parameters.Add("@entlog", SqlDbType.Int).Value = 2; cmm.Parameters.Add("@usu", SqlDbType.UniqueIdentifier).Value = (Guid)Membership.GetUser().ProviderUserKey; cmm.ExecuteNonQuery(); st.Commit(); sqli.Success = true; } catch (Exception ex) { try { sqli.Success = false; sqli.Erro = ex.Message; st.Rollback(); } catch (Exception ex1) { sqli.Erro += ex1.Message; } } } return(sqli); }
public string GetCommand(int questId, int idx, int objIndex, int pointX, int pointY) { var builder = new SQLInsert(); builder.Table = "quest_poi_points"; builder.AddValue("questId", questId); builder.AddValue("id", idx); builder.AddValue("x", pointX); builder.AddValue("y", pointY); builder.AddWhere("questId", questId); return(builder.Build()); }
public GuiController() { mainMenu = new MainMenu(); administrationMenu = new AdministrationMenu(); vehicleMenuToAddData = new VehicleMenuToAddData(); dataEditingMenu = new DataEditingMenu(); dataDeleteMenu = new DataDeleteMenu(); rentMenu = new RentMenu(); getInfoMenu = new GetInfoMenu(); searchInfoMenu = new SearchInfoMenu(); functionsForSQL = new FunctionsCheckEnteredAndSQLData(); functionsForBike = new BikeManagement(); functionsForCar = new CarManagement(); functionsForMoto = new MotoManagement(); functionsForClient = new ClientManagement(); sqlInsert = new SQLInsert(); sqlEdit = new SQLEdit(); sqlDelete = new SQLDelete(); }
public string GetCommand(uint entry, uint map, int phaseMask, Vector3 position, float orient) { var builder = new SQLInsert(); builder.Table = "creature"; // If map is Eastern Kingdoms, Kalimdor, Outland, Northrend or Ebon Hold use a lower respawn time // TODO: Rank and if npc is needed for quest kill should change spawntime aswell var spawnTimeSecs = (map == 0 || map == 1 || map == 530 || map == 571 || map == 609) ? 120 : 7200; var movementType = 0; var spawnDist = (movementType == 1) ? 5 : 0; builder.AddValue("guid", "@GUID+X"); builder.AddValue("id", entry); builder.AddValue("map", map); builder.AddValue("spawnMask", 1); builder.AddValue("phaseMask", "0x" + phaseMask.ToString("X8")); builder.AddValue("modelid", 0); builder.AddValue("equipment_id", 0); builder.AddValue("position_x", position.X); builder.AddValue("position_y", position.Y); builder.AddValue("position_z", position.Z); builder.AddValue("orientation", orient); builder.AddValue("spawntimesecs", spawnTimeSecs); builder.AddValue("spawndist", spawnDist); builder.AddValue("currentwaypoint", 0); builder.AddValue("curhealth", 1); builder.AddValue("curmana", 0); builder.AddValue("MovementType", movementType); builder.AddValue("npcflag", 0); // TODO: Check if they match updated creature_template value ? builder.AddValue("unit_flags", 0); builder.AddValue("dynamicflags", 0); builder.AddWhere("guid", "@GUID+X"); builder.AddWhere("id", entry); return(builder.Build()); }
public static string Creature(Dictionary <WowGuid, Unit> units) { if (units.Count == 0) { return(string.Empty); } if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature)) { return(string.Empty); } uint count = 0; var rows = new RowList <Creature>(); var addonRows = new RowList <CreatureAddon>(); foreach (var unit in units) { Row <Creature> row = new Row <Creature>(); bool badTransport = false; Unit creature = unit.Value; if (Settings.AreaFilters.Length > 0) { if (!(creature.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters))) { continue; } } if (Settings.MapFilters.Length > 0) { if (!(creature.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters))) { continue; } } uint entry = (uint)creature.ObjectData.EntryID; if (entry == 0) { continue; // broken entry, nothing to spawn } uint movementType = 0; int spawnDist = 0; row.Data.AreaID = 0; row.Data.ZoneID = 0; if (creature.Movement.HasWpsOrRandMov) { movementType = 1; spawnDist = 10; } row.Data.GUID = "@CGUID+" + count; row.Data.ID = entry; if (!creature.IsOnTransport()) { row.Data.Map = creature.Map; } else { int mapId; badTransport = !GetTransportMap(creature, out mapId); if (mapId != -1) { row.Data.Map = (uint)mapId; } } if (creature.Area != -1) { row.Data.AreaID = (uint)creature.Area; } if (creature.Zone != -1) { row.Data.ZoneID = (uint)creature.Zone; } row.Data.SpawnMask = (uint)creature.GetDefaultSpawnMask(); if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_0_3_22248)) { string data = string.Join(",", creature.GetDefaultSpawnDifficulties()); if (string.IsNullOrEmpty(data)) { data = "0"; } row.Data.spawnDifficulties = data; } row.Data.PhaseMask = creature.PhaseMask; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && creature.Phases != null) { string data = string.Join(" - ", creature.Phases); if (string.IsNullOrEmpty(data)) { data = "0"; } row.Data.PhaseID = data; } if (!creature.IsOnTransport()) { row.Data.PositionX = creature.Movement.Position.X; row.Data.PositionY = creature.Movement.Position.Y; row.Data.PositionZ = creature.Movement.Position.Z; row.Data.Orientation = creature.Movement.Orientation; } else { row.Data.PositionX = creature.Movement.TransportOffset.X; row.Data.PositionY = creature.Movement.TransportOffset.Y; row.Data.PositionZ = creature.Movement.TransportOffset.Z; row.Data.Orientation = creature.Movement.TransportOffset.O; } row.Data.SpawnTimeSecs = creature.GetDefaultSpawnTime(creature.DifficultyID); row.Data.SpawnDist = spawnDist; row.Data.MovementType = movementType; // set some defaults row.Data.PhaseGroup = 0; row.Data.ModelID = 0; row.Data.CurrentWaypoint = 0; row.Data.CurHealth = (uint)creature.UnitData.MaxHealth; row.Data.CurMana = (uint)creature.UnitData.MaxPower[0]; row.Data.NpcFlag = 0; row.Data.UnitFlag = 0; row.Data.DynamicFlag = 0; row.Comment = StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false); row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, creature.Area, false) + " - "; row.Comment += "Difficulty: " + StoreGetters.GetName(StoreNameType.Difficulty, (int)creature.DifficultyID, false) + ")"; string auras = string.Empty; string commentAuras = string.Empty; if (creature.Auras != null && creature.Auras.Count != 0) { foreach (Aura aura in creature.Auras) { if (aura == null) { continue; } // usually "template auras" do not have caster if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ? !aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) : !aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster)) { continue; } auras += aura.SpellId + " "; commentAuras += aura.SpellId + " - " + StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", "; } auras = auras.TrimEnd(' '); commentAuras = commentAuras.TrimEnd(',', ' '); row.Comment += " (Auras: " + commentAuras + ")"; } var addonRow = new Row <CreatureAddon>(); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon)) { addonRow.Data.GUID = "@CGUID+" + count; addonRow.Data.PathID = 0; addonRow.Data.Mount = (uint)creature.UnitData.MountDisplayID; addonRow.Data.Bytes1 = creature.Bytes1; addonRow.Data.Bytes2 = creature.Bytes2; addonRow.Data.Emote = 0; addonRow.Data.Auras = auras; addonRow.Data.AIAnimKit = creature.AIAnimKit.GetValueOrDefault(0); addonRow.Data.MovementAnimKit = creature.MovementAnimKit.GetValueOrDefault(0); addonRow.Data.MeleeAnimKit = creature.MeleeAnimKit.GetValueOrDefault(0); addonRow.Comment += StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false); if (!string.IsNullOrWhiteSpace(auras)) { addonRow.Comment += " - " + commentAuras; } addonRows.Add(addonRow); } if (creature.IsTemporarySpawn() && !Settings.SaveTempSpawns) { row.CommentOut = true; row.Comment += " - !!! might be temporary spawn !!!"; if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon)) { addonRow.CommentOut = true; addonRow.Comment += " - !!! might be temporary spawn !!!"; } } else if (creature.IsOnTransport() && badTransport) { row.CommentOut = true; row.Comment += " - !!! on transport - transport template not found !!!"; if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon)) { addonRow.CommentOut = true; addonRow.Comment += " - !!! on transport - transport template not found !!!"; } } else { ++count; } if (creature.Movement.HasWpsOrRandMov) { row.Comment += " (possible waypoints or random movement)"; } rows.Add(row); } if (count == 0) { return(string.Empty); } StringBuilder result = new StringBuilder(); // delete query for GUIDs var delete = new SQLDelete <Creature>(Tuple.Create("@CGUID+0", "@CGUID+" + --count)); result.Append(delete.Build()); var sql = new SQLInsert <Creature>(rows, false); result.Append(sql.Build()); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon)) { var addonDelete = new SQLDelete <CreatureAddon>(Tuple.Create("@CGUID+0", "@CGUID+" + count)); result.Append(addonDelete.Build()); var addonSql = new SQLInsert <CreatureAddon>(addonRows, false); result.Append(addonSql.Build()); } return(result.ToString()); }
public static string GameObject(Dictionary <WowGuid, GameObject> gameObjects) { if (gameObjects.Count == 0) { return(string.Empty); } if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject)) { return(string.Empty); } uint count = 0; var rows = new RowList <GameObjectModel>(); var addonRows = new RowList <GameObjectAddon>(); foreach (var gameobject in gameObjects) { Row <GameObjectModel> row = new Row <GameObjectModel>(); GameObject go = gameobject.Value; if (Settings.AreaFilters.Length > 0) { if (!(go.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters))) { continue; } } if (Settings.MapFilters.Length > 0) { if (!(go.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters))) { continue; } } uint entry = (uint)go.ObjectData.EntryID; if (entry == 0) { continue; // broken entry, nothing to spawn } bool badTransport = false; row.Data.GUID = "@OGUID+" + count; row.Data.ID = entry; if (!go.IsOnTransport()) { row.Data.Map = go.Map; } else { int mapId; badTransport = !GetTransportMap(go, out mapId); if (mapId != -1) { row.Data.Map = (uint)mapId; } } row.Data.ZoneID = 0; row.Data.AreaID = 0; if (go.Area != -1) { row.Data.AreaID = (uint)go.Area; } if (go.Zone != -1) { row.Data.ZoneID = (uint)go.Zone; } row.Data.SpawnMask = (uint)go.GetDefaultSpawnMask(); if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_0_3_22248)) { string data = string.Join(",", go.GetDefaultSpawnDifficulties()); if (string.IsNullOrEmpty(data)) { data = "0"; } row.Data.spawnDifficulties = data; } row.Data.PhaseMask = go.PhaseMask; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && go.Phases != null) { row.Data.PhaseID = string.Join(" - ", go.Phases); } if (!go.IsOnTransport()) { row.Data.PositionX = go.Movement.Position.X; row.Data.PositionY = go.Movement.Position.Y; row.Data.PositionZ = go.Movement.Position.Z; row.Data.Orientation = go.Movement.Orientation; } else { row.Data.PositionX = go.Movement.TransportOffset.X; row.Data.PositionY = go.Movement.TransportOffset.Y; row.Data.PositionZ = go.Movement.TransportOffset.Z; row.Data.Orientation = go.Movement.TransportOffset.O; } var rotation = go.GetStaticRotation(); row.Data.Rotation = new float?[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; bool add = true; var addonRow = new Row <GameObjectAddon>(); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { addonRow.Data.GUID = "@OGUID+" + count; var parentRotation = go.GetParentRotation(); if (parentRotation != null) { addonRow.Data.parentRot0 = parentRotation.Value.X; addonRow.Data.parentRot1 = parentRotation.Value.Y; addonRow.Data.parentRot2 = parentRotation.Value.Z; addonRow.Data.parentRot3 = parentRotation.Value.W; if (addonRow.Data.parentRot0 == 0.0f && addonRow.Data.parentRot1 == 0.0f && addonRow.Data.parentRot2 == 0.0f && addonRow.Data.parentRot3 == 1.0f) { add = false; } } else { add = false; } addonRow.Comment += StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false); if (add) { addonRows.Add(addonRow); } } row.Data.SpawnTimeSecs = go.GetDefaultSpawnTime(go.DifficultyID); row.Data.AnimProgress = go.GameObjectData.PercentHealth; row.Data.State = (uint)go.GameObjectData.State; // set some defaults row.Data.PhaseGroup = 0; row.Comment = StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false); row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, go.Area, false) + " - "; row.Comment += "Difficulty: " + StoreGetters.GetName(StoreNameType.Difficulty, (int)go.DifficultyID, false) + ")"; if (go.IsTemporarySpawn() && !Settings.SaveTempSpawns) { row.CommentOut = true; row.Comment += " - !!! might be temporary spawn !!!"; if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { addonRow.CommentOut = true; addonRow.Comment += " - !!! might be temporary spawn !!!"; } } else if (go.IsTransport()) { row.CommentOut = true; row.Comment += " - !!! transport !!!"; if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { addonRow.CommentOut = true; addonRow.Comment += " - !!! transport !!!"; } } else if (go.IsOnTransport() && badTransport) { row.CommentOut = true; row.Comment += " - !!! on transport - transport template not found !!!"; if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { addonRow.CommentOut = true; addonRow.Comment += " - !!! on transport - transport template not found !!!"; } } else { ++count; } rows.Add(row); } if (count == 0) { return(String.Empty); } StringBuilder result = new StringBuilder(); // delete query for GUIDs var delete = new SQLDelete <GameObjectModel>(Tuple.Create("@OGUID+0", "@OGUID+" + --count)); result.Append(delete.Build()); var sql = new SQLInsert <GameObjectModel>(rows, false); result.Append(sql.Build()); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { var addonDelete = new SQLDelete <GameObjectAddon>(Tuple.Create("@OGUID+0", "@OGUID+" + count)); result.Append(addonDelete.Build()); var addonSql = new SQLInsert <GameObjectAddon>(addonRows, false); result.Append(addonSql.Build()); } return(result.ToString()); }
public string SerializeInsert(SQLInsert insert) { if (String.IsNullOrEmpty(insert.TableName)) throw new Exceptions.DatabaseObjectsException("TableName property has not been set."); else if (insert.Fields.Count == 0) throw new Exceptions.DatabaseObjectsException("Field values have not been set."); string fieldNames = String.Join(", ", insert.Fields.Select(field => SerializeIdentifier(field.Name)).ToArray()); string fieldValues = String.Join(", ", insert.Fields.Select(field => SerializeValue(field.Value)).ToArray()); var tokens = new TokenSerializer(); tokens.Add("INSERT INTO"); tokens.Add(SerializeIdentifier(insert.TableName)); tokens.Add("(" + fieldNames + ")"); tokens.Add("VALUES"); tokens.Add("(" + fieldValues + ")"); return tokens.ToString(); }
public static SQLInsert gravaFechamentoPedido(int _numped, ExamesRealzs _exms, Profs _profs, MateriaisUtils _mats, int _status) { SQLInsert sqi = new SQLInsert(); using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConn"].ToString())) { SqlCommand cmm = cnn.CreateCommand(); cnn.Open(); SqlTransaction st = cnn.BeginTransaction(); cmm.Transaction = st; try { cmm.CommandText = "select cod_status from pedidos where num_pedido = @numped"; cmm.Parameters.Add("@numped", SqlDbType.Int).Value = _numped; int status = (int)cmm.ExecuteScalar(); int ent_log = 4; if (status != 3) { cmm.CommandText = "update pedidos set cod_status = 3 where num_pedido = @numped"; cmm.ExecuteNonQuery(); ent_log = 3; } cmm.CommandText = "DELETE FROM Exames_Pedido WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); if (_exms.Items.Count > 0) { cmm.CommandText = "INSERT INTO Exames_Pedido (Cod_Exame,Num_Pedido) VALUES (@exm,@numped)"; cmm.Parameters.Add("@exm", SqlDbType.Int); foreach (ExameRealz exm in _exms.Items.Values) { cmm.Parameters["@exm"].Value = exm.Cod_exame; cmm.ExecuteNonQuery(); } } cmm.CommandText = "DELETE FROM Profissionais_Pedido WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); if (_profs.Items.Count > 0) { cmm.CommandText = "INSERT INTO Profissionais_Pedido (Cod_Profissional, Num_Pedido) VALUES (@prof,@numped)"; cmm.Parameters.Add("@prof", SqlDbType.Int); foreach (Prof pf in _profs.Items.Values) { cmm.Parameters["@prof"].Value = pf.Cod; cmm.ExecuteNonQuery(); } } cmm.CommandText = "DELETE FROM Materiais_Pedido WHERE (Num_Pedido = @numped)"; cmm.ExecuteNonQuery(); if (_mats.Items.Count > 0) { cmm.CommandText = "INSERT INTO Materiais_Pedido (Cod_Material, Num_Pedido,Qtd) VALUES (@mat,@numped,@qtd)"; cmm.Parameters.Add("@mat", SqlDbType.Int); cmm.Parameters.Add("@qtd", SqlDbType.Int); foreach (MaterialUtil mt in _mats.Items.Values) { cmm.Parameters["@mat"].Value = mt.Cod; cmm.Parameters["@qtd"].Value = mt.Qtd; cmm.ExecuteNonQuery(); } } cmm.CommandText = "INSERT INTO Log_Pedido ([Num_Pedido],[TimeStamp],[Usuario],[Cod_Ent_Log]) " + "VALUES (@numped,getdate(),@usu,@entlog)"; cmm.Parameters.Add("@entlog", SqlDbType.Int).Value = ent_log; cmm.Parameters.Add("@usu", SqlDbType.UniqueIdentifier).Value = (Guid)Membership.GetUser().ProviderUserKey; cmm.ExecuteNonQuery(); st.Commit(); sqi.Success = true; } catch (Exception ex) { sqi.Success = false; sqi.Erro = ex.Message; try { st.Rollback(); } catch (Exception ex1) { sqi.Erro += ex1.Message; } } } return(sqi); }
public static SQLInsert gravaPedidoExtra(int _id, int _tipId, String _nome, DateTime _dt, long _cpfMed, String _nomeMed, int _tipSet, int _codSet, String _nomeSet, int _tipexm) { SQLInsert sqi = new SQLInsert(); using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConn"].ToString())) { cnn.Open(); SqlTransaction st = cnn.BeginTransaction(); SqlCommand cmm = cnn.CreateCommand(); cmm.Transaction = st; cmm.CommandText = "INSERT INTO Pedidos ([ID_Paciente] ,[Nome_Paciente] ,[Cod_Tipo_Paciente] " + ",[Procedencia],[Cod_Procedencia],[Cod_Tipo_Procedencia],[Nome_Solicitante],[CPF_Solcitante]" + ",[Cod_Status],[Cod_Tipo_Pedido],[Cod_Grupo_Exame]) VALUES " + "(@idpac,@nomep,@tippac,@nomeset,@codset,@tipset,@nomemed,@cpfmed,@status,@tipped,@tipexm);SELECT SCOPE_IDENTITY()"; cmm.Parameters.Add("@idpac", SqlDbType.Int).Value = _id; cmm.Parameters.Add("@nomep", SqlDbType.NVarChar).Value = _nome; cmm.Parameters.Add("@tippac", SqlDbType.Int).Value = _tipId; cmm.Parameters.Add("@nomeset", SqlDbType.NVarChar).Value = _nomeSet; cmm.Parameters.Add("@codset", SqlDbType.Int).Value = _codSet; cmm.Parameters.Add("@tipset", SqlDbType.Int).Value = _tipSet; cmm.Parameters.Add("@nomemed", SqlDbType.NVarChar).Value = _nomeMed; cmm.Parameters.Add("@cpfmed", SqlDbType.BigInt).Value = _cpfMed; cmm.Parameters.Add("@status", SqlDbType.Int).Value = Tipos.Status.Checkin; cmm.Parameters.Add("@tipped", SqlDbType.Int).Value = Tipos.Pedido.Extra; cmm.Parameters.Add("@tipexm", SqlDbType.Int).Value = _tipexm; try { int id = Convert.ToInt32(cmm.ExecuteScalar()); sqi.Id = id; cmm.CommandText = "Insert into pedido_extra (num_pedido,datahora) values (@numped,@dth)"; cmm.Parameters.Add("@numped", SqlDbType.Int).Value = id; cmm.Parameters.Add("@dth", SqlDbType.DateTime).Value = _dt.Date; cmm.ExecuteNonQuery(); cmm.CommandText = "Insert into checkin_Pedido (num_pedido,datahora) values (@numped,@dth)"; cmm.ExecuteNonQuery(); cmm.CommandText = "INSERT INTO Log_Pedido ([Num_Pedido],[TimeStamp],[Usuario],[Cod_Ent_Log]) " + "VALUES (@numped,getdate(),@usu,@entlog)"; cmm.Parameters.Add("@entlog", SqlDbType.Int).Value = 1; cmm.Parameters.Add("@usu", SqlDbType.UniqueIdentifier).Value = (Guid)Membership.GetUser().ProviderUserKey; cmm.ExecuteNonQuery(); st.Commit(); sqi.Success = true; } catch (Exception ex) { sqi.Success = false; sqi.Erro = ex.Message; try { st.Rollback(); } catch (Exception ex1) { sqi.Erro += " - " + ex1.Message; } } } return(sqi); }
public static string GameObject(Dictionary <WowGuid, GameObject> gameObjects) { if (gameObjects.Count == 0) { return(string.Empty); } if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject)) { return(string.Empty); } uint count = 0; var rows = new RowList <GameObjectModel>(); foreach (var gameobject in gameObjects) { Row <GameObjectModel> row = new Row <GameObjectModel>(); GameObject go = gameobject.Value; if (Settings.AreaFilters.Length > 0) { if (!(go.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters))) { continue; } } if (Settings.MapFilters.Length > 0) { if (!(go.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters))) { continue; } } uint animprogress = 0; uint state = 0; UpdateField uf; if (!go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out uf)) { continue; // broken entry, nothing to spawn } uint entry = uf.UInt32Value; bool badTransport = false; if (go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(GameObjectField.GAMEOBJECT_BYTES_1), out uf)) { uint bytes = uf.UInt32Value; state = (bytes & 0x000000FF); animprogress = Convert.ToUInt32((bytes & 0xFF000000) >> 24); } row.Data.GUID = "@OGUID+" + count; row.Data.ID = entry; if (!go.IsOnTransport()) { row.Data.Map = go.Map; } else { int mapId; badTransport = !GetTransportMap(go, out mapId); if (mapId != -1) { row.Data.Map = (uint)mapId; } } row.Data.SpawnMask = (uint)go.GetDefaultSpawnMask(); row.Data.PhaseMask = go.PhaseMask; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && go.Phases != null) { row.Data.PhaseID = string.Join(" - ", go.Phases); } if (!go.IsOnTransport()) { row.Data.PositionX = go.Movement.Position.X; row.Data.PositionY = go.Movement.Position.Y; row.Data.PositionZ = go.Movement.Position.Z; row.Data.Orientation = go.Movement.Orientation; } else { row.Data.PositionX = go.Movement.TransportOffset.X; row.Data.PositionY = go.Movement.TransportOffset.Y; row.Data.PositionZ = go.Movement.TransportOffset.Z; row.Data.Orientation = go.Movement.TransportOffset.O; } var rotation = go.GetRotation(); if (rotation != null && rotation.Length == 4) { row.Data.Rotation = rotation.Cast <float?>().ToArray(); } else { row.Data.Rotation = new float?[] { 0, 0, 0, 0 } }; row.Data.SpawnTimeSecs = (int)go.GetDefaultSpawnTime(); row.Data.AnimProgress = animprogress; row.Data.State = state; // set some defaults row.Data.ZoneID = 0; row.Data.AreaID = 0; row.Data.PhaseGroup = 0; row.Comment = StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false); row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, go.Area, false) + ")"; if (go.IsTemporarySpawn()) { row.CommentOut = true; row.Comment += " - !!! might be temporary spawn !!!"; } else if (go.IsTransport()) { row.CommentOut = true; row.Comment += " - !!! transport !!!"; } else if (go.IsOnTransport() && badTransport) { row.CommentOut = true; row.Comment += " - !!! on transport - transport template not found !!!"; } else { ++count; } rows.Add(row); } StringBuilder result = new StringBuilder(); if (count > 0) { // delete query for GUIDs var delete = new SQLDelete <GameObjectModel>(Tuple.Create("@OGUID+0", "@OGUID+" + --count)); result.Append(delete.Build()); } var sql = new SQLInsert <GameObjectModel>(rows, false); result.Append(sql.Build()); return(result.ToString()); } }
public Result Insert(SQLInsert sql) { return(Insert(sql.TbName, sql.KVpairs)); }
public static string GameObject(Dictionary<WowGuid, GameObject> gameObjects) { if (gameObjects.Count == 0) return string.Empty; if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject)) return string.Empty; uint count = 0; var rows = new RowList<GameObjectModel>(); var addonRows = new RowList<GameObjectAddon>(); foreach (var gameobject in gameObjects) { Row<GameObjectModel> row = new Row<GameObjectModel>(); GameObject go = gameobject.Value; if (Settings.AreaFilters.Length > 0) if (!(go.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters))) continue; if (Settings.MapFilters.Length > 0) if (!(go.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters))) continue; uint animprogress = 0; uint state = 0; UpdateField uf; if (!go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out uf)) continue; // broken entry, nothing to spawn uint entry = uf.UInt32Value; bool badTransport = false; if (go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(GameObjectField.GAMEOBJECT_BYTES_1), out uf)) { uint bytes = uf.UInt32Value; state = (bytes & 0x000000FF); animprogress = Convert.ToUInt32((bytes & 0xFF000000) >> 24); } row.Data.GUID = "@OGUID+" + count; row.Data.ID = entry; if (!go.IsOnTransport()) row.Data.Map = go.Map; else { int mapId; badTransport = !GetTransportMap(go, out mapId); if (mapId != -1) row.Data.Map = (uint)mapId; } row.Data.SpawnMask = (uint)go.GetDefaultSpawnMask(); row.Data.PhaseMask = go.PhaseMask; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && go.Phases != null) row.Data.PhaseID = string.Join(" - ", go.Phases); if (!go.IsOnTransport()) { row.Data.PositionX = go.Movement.Position.X; row.Data.PositionY = go.Movement.Position.Y; row.Data.PositionZ = go.Movement.Position.Z; row.Data.Orientation = go.Movement.Orientation; } else { row.Data.PositionX = go.Movement.TransportOffset.X; row.Data.PositionY = go.Movement.TransportOffset.Y; row.Data.PositionZ = go.Movement.TransportOffset.Z; row.Data.Orientation = go.Movement.TransportOffset.O; } var rotation = go.GetStaticRotation(); row.Data.Rotation = new float?[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; bool add = true; var addonRow = new Row<GameObjectAddon>(); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { addonRow.Data.GUID = "@OGUID+" + count; var parentRotation = go.GetParentRotation(); if (parentRotation != null) { addonRow.Data.parentRot0 = parentRotation[0].GetValueOrDefault(0.0f); addonRow.Data.parentRot1 = parentRotation[1].GetValueOrDefault(0.0f); addonRow.Data.parentRot2 = parentRotation[2].GetValueOrDefault(0.0f); addonRow.Data.parentRot3 = parentRotation[3].GetValueOrDefault(1.0f); if (addonRow.Data.parentRot0 == 0.0f && addonRow.Data.parentRot1 == 0.0f && addonRow.Data.parentRot2 == 0.0f && addonRow.Data.parentRot3 == 1.0f) add = false; } else add = false; addonRow.Comment += StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false); if (add) addonRows.Add(addonRow); } row.Data.SpawnTimeSecs = (int)go.GetDefaultSpawnTime(); row.Data.AnimProgress = animprogress; row.Data.State = state; // set some defaults row.Data.ZoneID = 0; row.Data.AreaID = 0; row.Data.PhaseGroup = 0; row.Comment = StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false); row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, go.Area, false) + ")"; if (go.IsTemporarySpawn()) { row.CommentOut = true; row.Comment += " - !!! might be temporary spawn !!!"; } else if (go.IsTransport()) { row.CommentOut = true; row.Comment += " - !!! transport !!!"; } else if (go.IsOnTransport() && badTransport) { row.CommentOut = true; row.Comment += " - !!! on transport - transport template not found !!!"; } else ++count; rows.Add(row); } if (count == 0) return String.Empty; StringBuilder result = new StringBuilder(); // delete query for GUIDs var delete = new SQLDelete<GameObjectModel>(Tuple.Create("@OGUID+0", "@OGUID+" + --count)); result.Append(delete.Build()); var sql = new SQLInsert<GameObjectModel>(rows, false); result.Append(sql.Build()); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon)) { var addonDelete = new SQLDelete<GameObjectAddon>(Tuple.Create("@OGUID+0", "@OGUID+" + count)); result.Append(addonDelete.Build()); var addonSql = new SQLInsert<GameObjectAddon>(addonRows, false); result.Append(addonSql.Build()); } return result.ToString(); }
public static string Creature(Dictionary<WowGuid, Unit> units) { if (units.Count == 0) return string.Empty; if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature)) return string.Empty; uint count = 0; var rows = new RowList<Creature>(); var addonRows = new RowList<CreatureAddon>(); foreach (var unit in units) { Row<Creature> row = new Row<Creature>(); bool badTransport = false; Unit creature = unit.Value; if (Settings.AreaFilters.Length > 0) if (!(creature.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters))) continue; if (Settings.MapFilters.Length > 0) if (!(creature.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters))) continue; UpdateField uf; if (!creature.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out uf)) continue; // broken entry, nothing to spawn uint entry = uf.UInt32Value; uint movementType = 0; int spawnDist = 0; if (creature.Movement.HasWpsOrRandMov) { movementType = 1; spawnDist = 10; } row.Data.GUID = "@CGUID+" + count; row.Data.ID = entry; if (!creature.IsOnTransport()) row.Data.Map = creature.Map; else { int mapId; badTransport = !GetTransportMap(creature, out mapId); if (mapId != -1) row.Data.Map = (uint)mapId; } row.Data.SpawnMask = (uint)creature.GetDefaultSpawnMask(); row.Data.PhaseMask = creature.PhaseMask; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && creature.Phases != null) { string data = string.Join(" - ", creature.Phases); if (string.IsNullOrEmpty(data)) data = "0"; row.Data.PhaseID = data; } if (!creature.IsOnTransport()) { row.Data.PositionX = creature.Movement.Position.X; row.Data.PositionY = creature.Movement.Position.Y; row.Data.PositionZ = creature.Movement.Position.Z; row.Data.Orientation = creature.Movement.Orientation; } else { row.Data.PositionX = creature.Movement.TransportOffset.X; row.Data.PositionY = creature.Movement.TransportOffset.Y; row.Data.PositionZ = creature.Movement.TransportOffset.Z; row.Data.Orientation = creature.Movement.TransportOffset.O; } row.Data.SpawnTimeSecs = creature.GetDefaultSpawnTime(); row.Data.SpawnDist = spawnDist; row.Data.MovementType = movementType; // set some defaults row.Data.ZoneID = 0; row.Data.AreaID = 0; row.Data.PhaseGroup = 0; row.Data.ModelID = 0; row.Data.CurrentWaypoint = 0; row.Data.CurHealth = 0; row.Data.CurMana = 0; row.Data.NpcFlag = 0; row.Data.UnitFlag = 0; row.Data.DynamicFlag = 0; row.Comment = StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false); row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, creature.Area, false) + ")"; string auras = string.Empty; string commentAuras = string.Empty; if (creature.Auras != null && creature.Auras.Count != 0) { foreach (Aura aura in creature.Auras) { if (aura == null) continue; // usually "template auras" do not have caster if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ? !aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) : !aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster)) continue; auras += aura.SpellId + " "; commentAuras += aura.SpellId + " - " + StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", "; } auras = auras.TrimEnd(' '); commentAuras = commentAuras.TrimEnd(',', ' '); row.Comment += " (Auras: " + commentAuras + ")"; } var addonRow = new Row<CreatureAddon>(); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon)) { addonRow.Data.GUID = "@CGUID+" + count; addonRow.Data.PathID = 0; addonRow.Data.Mount = creature.Mount.GetValueOrDefault(0); addonRow.Data.Bytes1 = creature.Bytes1.GetValueOrDefault(0); addonRow.Data.Bytes2 = creature.Bytes2.GetValueOrDefault(0); addonRow.Data.Emote = 0; addonRow.Data.Auras = auras; addonRow.Data.AIAnimKit = creature.AIAnimKit.GetValueOrDefault(0); addonRow.Data.MovementAnimKit = creature.MovementAnimKit.GetValueOrDefault(0); addonRow.Data.MeleeAnimKit = creature.MeleeAnimKit.GetValueOrDefault(0); addonRow.Comment += StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false); if (!string.IsNullOrWhiteSpace(auras)) addonRow.Comment += " - " + commentAuras; addonRows.Add(addonRow); } if (creature.IsTemporarySpawn()) { row.CommentOut = true; row.Comment += " - !!! might be temporary spawn !!!"; } else if (creature.IsOnTransport() && badTransport) { row.CommentOut = true; row.Comment += " - !!! on transport - transport template not found !!!"; } else ++count; if (creature.Movement.HasWpsOrRandMov) row.Comment += " (possible waypoints or random movement)"; rows.Add(row); } if (count == 0) return string.Empty; StringBuilder result = new StringBuilder(); // delete query for GUIDs var delete = new SQLDelete<Creature>(Tuple.Create("@CGUID+0", "@CGUID+" + --count)); result.Append(delete.Build()); var sql = new SQLInsert<Creature>(rows, false); result.Append(sql.Build()); if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon)) { var addonDelete = new SQLDelete<CreatureAddon>(Tuple.Create("@CGUID+0", "@CGUID+" + count)); result.Append(addonDelete.Build()); var addonSql = new SQLInsert<CreatureAddon>(addonRows, false); result.Append(addonSql.Build()); } return result.ToString(); }
private void FormSQLInsert(Sheet sheet, int row, int col) { List <string> fld = new List <string>(); List <string> data = new List <string>(); string nameTable = sheet.Cells[row - 1][col + 1].ToString(); int k = row; int j = col; while (!string.IsNullOrWhiteSpace(sheet.Cells[k][j].ToString())) { string name = sheet.Cells[k][j + 1]; string cont = null; if (name.IndexOf("<") != -1) { cont = name.Substring(name.IndexOf("<") + 1); cont = cont.Trim('>'); name = name.Substring(0, name.IndexOf("<")); } fld.Add(name); data.Add(cont); k++; } k = row; j = 0; while (!string.IsNullOrWhiteSpace(sheet.Cells[k][j].ToString())) { string name = sheet.Cells[k][j + 1]; int index = fld.IndexOf(name); if (index != -1) { data[index] = name; } k++; } string sql = $"INSERT INTO [{nameTable}] ("; for (int i = 0; i < fld.Count; i++) { sql += $"[{fld[i]}],"; } sql = sql.Trim(',') + $") IN '{Settings.Default.PathBaseED2}'"; sql += " SELECT "; for (int i = 0; i < data.Count; i++) { sql += ((data[i] != null) ? $"[{ data[i]}]" : "null") + ","; } if (string.IsNullOrWhiteSpace(sheet.Cells[row - 1][col + 3])) { sql = sql.Trim(',') + $" FROM [{sheet.Cells[row - 1][1]}]"; } else { string name = sheet.Cells[row - 1][col + 3]; sql = sql.Trim(',') + $" FROM {name}"; } SQLInsert.Add(sql); }