Exemplo n.º 1
0
        public void GenerateSql()
        {
            WriteSql("-- SQL created by " + _config.Version);
            WriteSql("--");
            WriteSql("-- Using Decoder: " + _streamProcessor.GetDecoderVersion());
            WriteSql("--");
            WriteSql("-- Packets captured on " + _streamProcessor.GetCaptureStartTime().ToString());
            WriteSql("--");
            WriteSql("-- Change these variables if required");
            WriteSql("--");
            WriteSql("set @StartingNPCTypeID = " + _config.SpawnDBID + ";");
            WriteSql("set @StartingSpawnGroupID = " + _config.SpawnGroupID + ";");
            WriteSql("set @StartingSpawnEntryID = " + _config.SpawnEntryID + ";");
            WriteSql("set @StartingSpawn2ID = " + _config.Spawn2ID + ";");
            WriteSql("set @StartingGridID = " + _config.GridDBID + ";");
            WriteSql("set @StartingMerchantID = " + _config.MerchantDBID + ";");
            WriteSql("set @BaseDoorID = " + _config.DoorDBID + ";");
            WriteSql("set @StartingGroundSpawnID = " + _config.GroundSpawnDBID + ";");
            WriteSql("set @StartingObjectID = " + _config.ObjectDBID + ";");
            WriteSql("--");
            WriteSql("--");

            if (_config.GenerateZone)
            {
                _streamProcessor.GenerateZoneSQL(WriteSql);
            }

            if (_config.GenerateZonePoint)
            {
                _streamProcessor.GenerateZonePointSQL(_config.ZoneName, WriteSql);
            }


            if (_config.GenerateDoors)
            {
                Log("Starting to generate SQL for Doors.");
                _streamProcessor.GenerateDoorsSQL(_config.ZoneName, _config.DoorDBID, _config.SpawnVersion, WriteSql);
                Log("Finished generating SQL for Doors.");
            }

            Log("Starting to generate SQL for Spawns and/or Grids.");

            _streamProcessor.GenerateSpawnSQL(_config.GenerateSpawns, _config.GenerateGrids, _config.GenerateMerchants, _config.ZoneName, _config.ZoneID, _config.SpawnVersion,
                                              _config.UpdateExistingNPCTypes, _config.UseNPCTypesTint, _config.SpawnNameFilter, _config.CoalesceWaypoints, _config.GenerateInvisibleMen, WriteSql);

            Log("Finished generating SQL for Spawns and/or Grids.");

            if (_config.GenerateGroundSpawns || _config.GenerateObjects)
            {
                Log("Starting to generate SQL for Ground Spawns and/or Objects.");

                _streamProcessor.GenerateObjectSQL(_config.GenerateGroundSpawns, _config.GenerateObjects, _config.SpawnVersion, WriteSql);

                Log("Finished generating SQL for Ground Spawns and/or Objects.");
            }

            SetStatus("SQL written to " + _fileName);
            SqlStream.Close();
        }
Exemplo n.º 2
0
        public void SqlStream_Integration_Test_With_Output_Parameter()
        {
            int actual   = 0;
            int expected = 100;

            using (SqlStream <StreamSchema> target = new SqlStream <StreamSchema>(new SqlStreamConnection("Server=(local);Database=tempdb;Trusted_Connection=Yes;"), SqlStreamBehavior.CloseConnection, 10))
            {
                target.StoredProcedureName = "dbo.TVPTestProc";

                target.Parameters.AddStructured <StreamSchema>("@stream", "dbo.StreamSchema", target)
                .Map(src => src.Id, "Id", SqlDbType.Int)
                .Map(src => src.ProductName, "ProductName", SqlDbType.VarChar, 255)
                .Map(src => Convert.ToDecimal(src.Price), "Price", SqlDbType.Decimal, 9, 3);

                target.Parameters.Add("@userid", SqlDbType.Int).Value = 1;
                var output = target.Parameters.Add("@resultCount", SqlDbType.Int);
                output.Direction = ParameterDirection.InputOutput;
                output.Value     = 0;

                for (int i = 0; i < expected; i++)
                {
                    target.Write(new StreamSchema
                    {
                        Id          = i,
                        ProductName = String.Format("Product {0}", i),
                        Price       = (i + 1.0) - 0.01
                    });
                }

                // need to wait for Close() or Dispose() before checking output parameters
                target.Close();
                actual = Convert.ToInt32(output.Value);
            }

            Assert.AreEqual(expected, actual, "Data wasn't streamed.");
        }