76 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C#
		
	
	
	
namespace BLL
 | 
						|
{
 | 
						|
    using System.Collections.Generic;
 | 
						|
    using System.Linq;
 | 
						|
    using Model;
 | 
						|
 | 
						|
    public static class ProjectSetMapService
 | 
						|
    {
 | 
						|
        public static Model.SGGLDB db = Funs.DB;
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        ///获取项目坐标点
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static List<string> GetProjectGpsPointByProjectId(string projectId)
 | 
						|
        {
 | 
						|
            return Funs.DB.WxProjectGpsPoint.Where(x => x.ProjectId == projectId).OrderBy(x => x.Orders).Select(x => x.Point).ToList();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 保存项目坐标范围
 | 
						|
        /// </summary>
 | 
						|
        public static void SaveProjectGpsPoint(string projectId, string projectPointResult)
 | 
						|
        {
 | 
						|
            SGGLDB db = Funs.DB;
 | 
						|
            string strGpsAreId = SQLHelper.GetNewID();
 | 
						|
            var getGpsAre = db.WxProjectGpsAre.FirstOrDefault(x => x.ProjectId == projectId);
 | 
						|
            if (getGpsAre != null)
 | 
						|
            {
 | 
						|
                strGpsAreId = getGpsAre.GpsAreId;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                WxProjectGpsAre newAre = new WxProjectGpsAre
 | 
						|
                {
 | 
						|
                    GpsAreId = strGpsAreId,
 | 
						|
                    GpsAreName = ProjectService.GetProjectNameByProjectId(projectId),
 | 
						|
                    ProjectId = projectId,
 | 
						|
                    Enabled = "Y",
 | 
						|
                };
 | 
						|
                db.WxProjectGpsAre.InsertOnSubmit(newAre);
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
 | 
						|
            var getPoints = db.WxProjectGpsPoint.Where(x => x.ProjectId == projectId && x.GpsAreId == strGpsAreId);
 | 
						|
            if (getPoints.Count() > 0)
 | 
						|
            {
 | 
						|
                db.WxProjectGpsPoint.DeleteAllOnSubmit(getPoints);
 | 
						|
                db.SubmitChanges();
 | 
						|
            }
 | 
						|
            var listPoints = Funs.GetStrListByStr(projectPointResult, '|');
 | 
						|
            if (listPoints.Count() > 0)
 | 
						|
            {
 | 
						|
                int intOrders = 1;
 | 
						|
                foreach (var item in listPoints)
 | 
						|
                {
 | 
						|
                    if (!string.IsNullOrEmpty(item))
 | 
						|
                    {
 | 
						|
                        WxProjectGpsPoint newPoint = new WxProjectGpsPoint
 | 
						|
                        {
 | 
						|
                            LocationId = SQLHelper.GetNewID(),
 | 
						|
                            Point = item,
 | 
						|
                            ProjectId = projectId,
 | 
						|
                            GpsAreId = strGpsAreId,
 | 
						|
                            Orders = intOrders,
 | 
						|
                        };
 | 
						|
                        db.WxProjectGpsPoint.InsertOnSubmit(newPoint);
 | 
						|
                        db.SubmitChanges();
 | 
						|
                        intOrders++;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |