コード例 #1
0
        /// <summary>
        /// Save a geometry to the database given a list of coordinates and a name
        /// </summary>
        /// <param name="pointList"></param>
        /// <param name="name"></param>
        public static void SaveGeometry(List <Mapsui.Geometries.Point> pointList, string name)
        {
            var geom = new ReferenceGeometry();

            geom.geometryId   = Guid.NewGuid().ToString();
            geom.geometryName = name;
            geom.geometry     = DataDAO.CoordinatesToGeoJSON(pointList);
            geom.userName     = App.CurrentUser.userId;
            geom.fullUserName = App.CurrentUser.firstName + " " + App.CurrentUser.name;
            geom.timestamp    = DateTime.Now;
            geom.creationTime = DateTime.Now;
            geom.status       = -1;
            geom.readOnly     = false;
            var proj = Project.FetchCurrentProject();

            geom.project_fk = proj.Id;

            using (SQLiteConnection conn = new SQLiteConnection(Preferences.Get("databaseLocation", "")))
            {
                conn.Insert(geom);

                var project = conn.GetWithChildren <Project>(proj.Id);
                project.geometries = conn.Table <ReferenceGeometry>().Where(g => g.project_fk == proj.Id).ToList();
                conn.UpdateWithChildren(project);
            }
        }