JiangSu/App_Data/js.db | 补丁 | 查看 | 原始文档 | blame | 历史 | |
JiangSu/Controllers/ImgController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
JiangSu/JiangSu.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
JiangSu/Models/Img.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
JiangSu/Models/ImgPg.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
JiangSu/cs/ImgPgDAL.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
JiangSu/cs/Tools.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
JiangSu/App_Data/js.dbBinary files differ
JiangSu/Controllers/ImgController.cs
@@ -125,7 +125,7 @@ Img img = new Img(); img.name = info.Name; img.path = uploadPath + "\\" + newName; img.geom = Tools.GetImgGps(f.LocalFileName); //img.geom = Tools.GetImgGps(f.LocalFileName); if (!File.Exists(newFile)) File.Move(f.LocalFileName, newFile); int rows = ImgDAL.Insert(img); JiangSu/JiangSu.csproj
@@ -152,6 +152,7 @@ <Compile Include="cs\PostgreHelper.cs" /> <Compile Include="cs\SQLiteHelper.cs" /> <Compile Include="cs\Tools.cs" /> <Compile Include="cs\ImgPgDAL.cs" /> <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> @@ -159,6 +160,7 @@ <Compile Include="Models\Grid.cs" /> <Compile Include="Models\Img.cs" /> <Compile Include="Models\Model.cs" /> <Compile Include="Models\ImgPg.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> JiangSu/Models/Img.cs
@@ -17,6 +17,10 @@ public string json { set; get; } public string geom { set; get; } public double x { set; get; } public double y { set; get; } public double z { set; get; } } } JiangSu/Models/ImgPg.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,22 @@ using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace JiangSu.Models { public class ImgPg { public ImgPg() { } public long id { set; get; } public string name { set; get; } public string path { set; get; } public string json { set; get; } public string geom { set; get; } } } JiangSu/cs/ImgPgDAL.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,73 @@ using JiangSu.Models; using Npgsql; using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Web; namespace JiangSu.cs { public class ImgPgDAL { public static List<ImgPg> SelectByPage(string name, int pageSize = 10, int pageIndex = 1) { bool flag = string.IsNullOrWhiteSpace(name); string sql = string.Format("select id, name, path, json, st_astext(geom) geom from sd.img {0} order by id limit {1} offset {2}", flag ? "" : "where upper(name) like @name", pageSize, pageSize * (pageIndex - 1)); DataTable dt = flag ? Tools.PGHelper.GetDataTable(sql) : Tools.PGHelper.GetDataTable(sql, new NpgsqlParameter("@name", "%" + name.Trim().ToUpper() + "%")); if (null == dt || dt.Rows.Count == 0) { return null; } return ModelHandler.FillModel<ImgPg>(dt); } public static ImgPg SelectById(long id) { string sql = "select id, name, path, json, st_astext(geom) geom from sd.img where id = @id"; DbParameter param = new NpgsqlParameter("@id", id); DataTable dt = Tools.PGHelper.GetDataTable(sql, param); if (null == dt || dt.Rows.Count == 0) { return null; } var list = ModelHandler.FillModel<ImgPg>(dt); return null == list || list.Count == 0 ? null : list[0]; } public static int DeleteByIds(List<int> ids) { string str = string.Join(",", ids.ToArray()); string sql = string.Format("delete from sd.img where id in ({0})", str); return Tools.PGHelper.ExecuteNonQuery(sql); } public static int Insert(ImgPg img) { string geom = string.IsNullOrWhiteSpace(img.geom) ? "null" : string.Format("ST_GeomFromText('{0}')", img.geom); string sql = string.Format("insert into sd.img (name, path, json, geom) values (@name, @path, @json, {0}) returning id", geom); DbParameter[] sqlParams = Tools.GetPGParams<ImgPg>(sql, img); object obj = Tools.PGHelper.GetScalar(sql, sqlParams); return null == obj ? 0 : Convert.ToInt32(obj); } public static int UpdateById(ImgPg img) { string geom = string.IsNullOrWhiteSpace(img.geom) ? "" : string.Format(", geom = ST_GeomFromText('{0}')", img.geom); string sql = string.Format("update sd.img set name = @name, path = @path, json = @json{0} where id = @id", geom); DbParameter[] sqlParams = Tools.GetPGParams<ImgPg>(sql, img); return Tools.PGHelper.ExecuteNonQuery(sql, sqlParams); } } } JiangSu/cs/Tools.cs
@@ -131,7 +131,7 @@ /// <summary> /// è·åå¾ççGPSä¿¡æ¯ /// </summary> public static string GetImgGps(string path) public static List<string> GetImgGps(string path) { Image img = null; try @@ -163,7 +163,7 @@ } } return string.Format("POINT Z ({0})", string.Join(" ", list.ToArray())); return list; } catch (Exception ex) { @@ -176,6 +176,13 @@ } } public static string GetImgPointZ(string path) { List<string> list = GetImgGps(path); return null == list ? null : string.Format("POINT Z ({0})", string.Join(" ", list.ToArray())); } /// <summary> /// è·åGPSå¼ /// </summary>