Ejemplo n.º 1
0
        public List <TrailModel> GetTrailsByParkId(int id)
        {
            List <TrailModel> trails = new List <TrailModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT * FROM trails WHERE trails.park_id = @parkId", conn);
                    cmd.Parameters.AddWithValue("@parkId", id);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        TrailModel trail = MapRowToTrail(reader);

                        trails.Add(trail);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(trails);
        }
        public override void SyncFrom(BasePieceModel otherModel)
        {
            base.SyncFrom(otherModel);
            var otherCs = (CustomSaberModel)otherModel;

            TrailModel = otherCs.TrailModel;
        }
Ejemplo n.º 3
0
        public TrailModel GetTrailByTrailName(string name)
        {
            TrailModel trail = new TrailModel();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT * FROM trails WHERE trails.trail_name = @name;", conn);
                    cmd.Parameters.AddWithValue("@name", name);
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        trail = MapRowToTrail(reader);
                    }
                    else
                    {
                        trail = null;
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(trail);
        }
Ejemplo n.º 4
0
        public List <TrailModel> GetTrailsByParkName(string name)
        {
            List <TrailModel> trails = new List <TrailModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT trails.* FROM trails INNER JOIN parks ON trails.park_id = parks.park_id WHERE parks.park_name = @parkName", conn);
                    cmd.Parameters.AddWithValue("@parkName", name);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        TrailModel trail = MapRowToTrail(reader);

                        trails.Add(trail);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(trails);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Creates an <see cref="InstanceTrailData" /> object
        ///     with the correct trail transforms
        /// </summary>
        /// <param name="saberObject">The saber gameobject that the <see cref="CustomTrail" /> component is on</param>
        /// <param name="trailModel">The <see cref="TrailModel" /> to use</param>
        public void InitializeTrailData(GameObject saberObject, TrailModel trailModel)
        {
            if (saberObject is null || trailModel is null)
            {
                return;
            }

            var trails = SaberHelpers.GetTrails(saberObject).ToArray();

            // Add new CustomTrail component with given data (creating position transforms for given position)
            CustomTrail SetupTrail(int length, float startPos, float endPos, Material material)
            {
                var newTrail = saberObject.AddComponent <CustomTrail>();

                newTrail.Length                   = length;
                newTrail.PointStart               = saberObject.CreateGameObject("PointStart").transform;
                newTrail.PointEnd                 = saberObject.CreateGameObject("PointEnd").transform;
                newTrail.PointEnd.localPosition   = new Vector3(0, 0, endPos);
                newTrail.PointStart.localPosition = new Vector3(0, 0, startPos);
                newTrail.TrailMaterial            = material;
                return(newTrail);
            }

            // if saber has no trial set up a generic one
            if (trails is null || trails.Length < 1)
            {
                trails = new[] { SetupTrail(12, 0, 1, null) };
            }

            var saberTrail = trails[0];

            List <CustomTrail> secondaryTrails = null;

            // set up secondary trails from other saber
            if (trailModel.TrailOriginTrails is { } && trailModel.TrailOriginTrails.Count > 1)
Ejemplo n.º 6
0
        public static int InsertFakeTrail(TrailModel trail, int parkId)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("INSERT INTO trails " +
                                                " (park_id, trail_name, trail_description) " +
                                                "VALUES " +
                                                " (@parkId, @name, @description)", conn);
                cmd.Parameters.AddWithValue("@parkId", parkId);
                cmd.Parameters.AddWithValue("@name", trail.Name);
                cmd.Parameters.AddWithValue("@description", trail.Description);

                cmd.ExecuteNonQuery();

                cmd = new SqlCommand("SELECT trail_id FROM trails " +
                                     "WHERE trails.trail_name = @name " +
                                     "AND trails.trail_description = @description", conn);
                cmd.Parameters.AddWithValue("@name", trail.Name);
                cmd.Parameters.AddWithValue("@description", trail.Description);

                int result = Convert.ToInt32(cmd.ExecuteScalar());
                return(result);
            }
        }
Ejemplo n.º 7
0
        private async Task LoadSaberModel(SaberModel saberModel, SerializableSaber serializableSaber)
        {
            saberModel.SaberWidth = serializableSaber.SaberWidth;

            if (_mainAssetStore.IsLoading)
            {
                await _mainAssetStore.CurrentTask;
            }

            foreach (var piece in serializableSaber.Pieces)
            {
                var comp = await _mainAssetStore[piece.Path];
                saberModel.PieceCollection.AddPiece(comp.AssetTypeDefinition, comp.GetPiece(saberModel.SaberSlot));
            }

            var trail = serializableSaber.Trail;

            if (trail != null)
            {
                var trailModel = new TrailModel(Vector3.zero, trail.Width, trail.Length, null, trail.Whitestep, trail.TrailOrigin);
                if (!string.IsNullOrEmpty(trail.TrailOrigin))
                {
                    await LoadFromTrailOrigin(trailModel, trail.TrailOrigin);
                }

                if (saberModel.GetCustomSaber(out var customsaber))
                {
                    customsaber.TrailModel = trailModel;
                }
                else
                {
                    saberModel.TrailModel = trailModel;
                }
            }
        }
        public InstanceTrailData(TrailModel trailModel, Transform pointStart, Transform pointEnd)
        {
            TrailModel = trailModel;
            PointStart = pointStart;
            PointEnd   = pointEnd;

            Init(trailModel);
        }
Ejemplo n.º 9
0
 private void SetTrailModel(TrailModel trailModel)
 {
     if (_editorInstanceManager.CurrentPiece is CustomSaberInstance customsaber)
     {
         var model = (CustomSaberModel)customsaber.Model;
         model.TrailModel = trailModel;
     }
 }
Ejemplo n.º 10
0
 public void Add(TrailModel item)
 {
     using (IDbConnection dbConnection = Connection) {
         string query = "INSERT INTO trails (name, description, length, elevationChange, longitude, latitude) VALUES (@Name, @Description, @Length, @ElevationChange, @Longitude, @Latitude)";
         dbConnection.Open();
         dbConnection.Execute(query, item);
     }
 }
Ejemplo n.º 11
0
        private async void SaberSelected(ICustomListItem item)
        {
            if (item is PreloadMetaData metaData)
            {
                _selectedTrailModel = await GetTrail(metaData);

                _onSelectionChanged?.Invoke(_selectedTrailModel);
            }
        }
Ejemplo n.º 12
0
        public List <TrailModel> GetFollowTrail(string FileName)
        {
            List <TrailModel> objTrailModelList = new List <TrailModel>();

            string[] GetText = new string[3];

            StreamReader reader = new StreamReader(@"\\192.168.10.5\\Log\\" + FileName + ""); //pick appropriate Encoding

            reader.BaseStream.Seek(0, SeekOrigin.End);
            int count = 0;

            while ((count < 23) && (reader.BaseStream.Position > 0))
            {
                reader.BaseStream.Position--;
                int c = reader.BaseStream.ReadByte();
                if (reader.BaseStream.Position > 0)
                {
                    reader.BaseStream.Position--;
                }
                if (c == Convert.ToInt32('\n'))
                {
                    ++count;
                }
            }
            string str = reader.ReadToEnd();

            string[] arr = str.Replace("\r", "").Split('\n');
            reader.Close();

            List <string> listahb = new List <string>();


            TrailModel objTrailModel;

            for (int i = 0; i < 21; i++)
            {
                if (arr[i].Length > 20)
                {
                    objTrailModel        = new TrailModel();
                    GetText              = TextSplit(arr[i]);
                    objTrailModel.Time   = GetText[0];
                    objTrailModel.MSISDN = GetText[1];
                    objTrailModel.SMS    = GetText[2];
                    if (i <= 5)
                    {
                        objTrailModelList.Add(objTrailModel);
                    }

                    listahb.Add(GetText[0]);
                }
            }

            //GlobalVariables.listahb = listahb;
            TPS(listahb);

            return(objTrailModelList);
        }
Ejemplo n.º 13
0
        private async Task LoadSaberModel(SaberModel saberModel, SerializableSaber serializableSaber)
        {
            saberModel.SaberWidth = serializableSaber.SaberWidth;

            if (_mainAssetStore.IsLoading)
            {
                await _mainAssetStore.CurrentTask;
            }

            foreach (var piece in serializableSaber.Pieces)
            {
                var comp = await _mainAssetStore[piece.Path];
                if (comp != null)
                {
                    saberModel.PieceCollection.AddPiece(comp.AssetTypeDefinition, comp.GetPiece(saberModel.SaberSlot));
                }
            }

            TrailModel trailModel = null;

            if (saberModel.GetCustomSaber(out var customsaber))
            {
                trailModel = customsaber.TrailModel;
            }
            else
            {
                trailModel = new TrailModel();
            }

            var trail = serializableSaber.Trail;

            if (trail != null)
            {
                trailModel.TrailPosOffset = Vector3.zero;
                trailModel.Width          = trail.Width;
                trailModel.Length         = trail.Length;
                trailModel.Whitestep      = trail.Whitestep;
                trailModel.ClampTexture   = trail.ClampTexture;

                // if trail comes from another saber
                if (!string.IsNullOrEmpty(trail.TrailOrigin))
                {
                    await LoadFromTrailOrigin(trailModel, trail.TrailOrigin);
                }

                // assign trailmodel to custom saber or saber factory saber
                // depending on which trail type is being used
                if (customsaber is null)
                {
                    saberModel.TrailModel = trailModel;
                }

                trail.Material?.ApplyToMaterial(trailModel.Material?.Material, ResolveTexture);
            }
        }
Ejemplo n.º 14
0
 public void GetTrailByTrailName()
 {
     using (TransactionScope transaction = new TransactionScope())
     {
         int         newParkId  = ParkSqlDALTests.InsertFakePark(park);
         int         newTrailId = TrailSqlDALTests.InsertFakeTrail(trail, newParkId);
         TrailSqlDAL testClass  = new TrailSqlDAL(connectionString);
         TrailModel  newTrail   = testClass.GetTrailByTrailName(trail.Name);
         Assert.AreEqual(newTrail.TrailId, newTrailId);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Load trail from another saber
        /// </summary>
        /// <param name="trailModel">TrailModel to load the other saber's data into</param>
        /// <param name="trailOrigin">Path of the other saber</param>
        /// <returns></returns>
        private async Task LoadFromTrailOrigin(TrailModel trailModel, string trailOrigin)
        {
            var comp             = await _mainAssetStore[trailOrigin];
            var originTrailModel = (comp?.GetLeft() as CustomSaberModel)?.GrabTrail(true);

            if (originTrailModel == null)
            {
                return;
            }
            trailModel.Material.Material = originTrailModel.Material.Material;
        }
 public IActionResult Create(TrailModel submission)
 {
     if (ModelState.IsValid)
     {
         trailFactory.Add(submission);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewTrail"));
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates an <see cref="InstanceTrailData"/> object
        /// with the correct trail transforms
        /// </summary>
        /// <param name="saberObject">The saber gameobject that the <see cref="CustomTrail"/> component is on</param>
        /// <param name="trailModel">The <see cref="TrailModel"/> to use</param>
        public void InitializeTrailData(GameObject saberObject, TrailModel trailModel)
        {
            if (trailModel is null)
            {
                return;
            }

            var trails = saberObject?.GetComponentsInChildren <CustomTrail>();

            if (trails is null || trails.Length < 1)
            {
                return;
            }

            var saberTrail = trails[0];

            if (trails.Length > 1)
            {
                SecondaryTrails = new List <CustomTrail>();
                for (int i = 1; i < trails.Length; i++)
                {
                    SecondaryTrails.Add(trails[i]);
                }
            }

            // if trail comes from the preset save system
            // the model comes without the material assigned
            // so we assign
            if (trailModel.Material is null)
            {
                trailModel.Material = new MaterialDescriptor(saberTrail.TrailMaterial);

                // set texture wrap mode
                if (trailModel.Material.Material.TryGetMainTexture(out var tex))
                {
                    trailModel.OriginalTextureWrapMode = tex.wrapMode;
                }
            }

            Transform pointStart = saberTrail.PointStart;
            Transform pointEnd   = saberTrail.PointEnd;

            // Correction for sabers that have the transforms set up the other way around
            bool isTrailReversed = pointStart.localPosition.z > pointEnd.localPosition.z;

            if (isTrailReversed)
            {
                pointStart = saberTrail.PointEnd;
                pointEnd   = saberTrail.PointStart;
            }

            InstanceTrailData = new InstanceTrailData(trailModel, pointStart, pointEnd, isTrailReversed);
        }
Ejemplo n.º 18
0
        public TrailModel InitializeTrailData(GameObject saberObject, TrailModel trailModel)
        {
            var(data, model) = InstanceTrailData.FromCustomSaber(saberObject, trailModel);
            if (data == null || model == null)
            {
                return(null);
            }

            InstanceTrailData = data;

            return(model);
        }
Ejemplo n.º 19
0
        public IHttpActionResult GetTrailByTrailName(string trailName)
        {
            TrailModel trail = trailDAL.GetTrailByTrailName(trailName);

            trail.PanoramicsInTrail = panoramicDAL.GetPanoramicsByTrailName(trailName);
            trail.PanoramicsInTrail.ForEach(panoramic => panoramic.Connections          = panoramicDAL.GetConnectionsByPanoramicId(panoramic.PanoramicId));
            trail.PanoramicsInTrail.ForEach(panoramic => panoramic.LastSeenImages       = lastSeenImagesDAL.GetLastSeenImagesByPanoramicId(panoramic.PanoramicId));
            trail.PanoramicsInTrail.ForEach(panoramic => panoramic.LastSeenVideos       = lastSeenVideosDAL.GetLastSeenVideosByPanoramicId(panoramic.PanoramicId));
            trail.PanoramicsInTrail.ForEach(panoramic => panoramic.BackgroundSoundClips = panoramicDAL.GetAllBackgroundSoundClips());
            trail.TrailHead = panoramicDAL.GetTrailHeadByTrailId(trail.TrailId);
            trail.TrailHead = trail.PanoramicsInTrail.First(panoramic => panoramic.PanoramicId == trail.TrailHead.PanoramicId);
            return(Ok(trail));
        }
Ejemplo n.º 20
0
 public List <TrailModel> GetAllTrails()
 {
     List <TrailModel> trails = new List <TrailModel>();
     {
         using (SqlConnection conn = new SqlConnection(connectionString))
             try
             {
                 conn.Open();
                 SqlCommand    cmd    = new SqlCommand(@"SELECT * FROM trails;", conn);
                 SqlDataReader reader = cmd.ExecuteReader();
                 while (reader.Read())
                 {
                     TrailModel trail = MapRowToTrail(reader);
                     trails.Add(trail);
                 }
                 return(trails);
             }
             catch (SqlException)
             {
                 throw;
             }
     }
 }
Ejemplo n.º 21
0
        public void Initialize()
        {
            park = new ParkModel()
            {
                Name        = "testPark",
                Description = "testDescription",
                Latitude    = 41,
                Longitude   = 100,
                Zoom        = 200
            };

            trail = new TrailModel()
            {
                Name        = "testTrail",
                Description = "testTrailDescription"
            };

            trailImage = new TrailImagesModel()
            {
                Bit          = true,
                ImageAddress = "address"
            };
        }
Ejemplo n.º 22
0
        public void Initialize()
        {
            park = new ParkModel()
            {
                Name        = "testPark",
                Description = "testDescription",
                Latitude    = 41,
                Longitude   = 100,
                Zoom        = 200
            };

            trail = new TrailModel()
            {
                Name        = "testTrail",
                Description = "testTrailDescription"
            };

            panoramicImage = new PanoramicModel()
            {
                ImageAddress = "address",
                Latitude     = 100,
                Longitude    = 42,
            };
        }
 public void Init(TrailModel trailModel)
 {
     SetWidth(trailModel.Width);
 }
        public static (InstanceTrailData, TrailModel) FromCustomSaber(GameObject saberObject, TrailModel trailModel)
        {
            var saberTrail = saberObject.GetComponent <CustomTrail>();

            if (!saberTrail)
            {
                return(default);