public bool Delete(string ids) { var idArray = ids.Split(','); var context = new ZHCC_GAPlanEntities(); foreach (var item in idArray) { var entity = context.RepetitivePlan.Where(u => u.RepetPlanID.ToString().Equals(item)).FirstOrDefault(); if (entity != null) { context.RepetitivePlan.Remove(entity); } var airlist = context.File_Airport.Where(u => u.RepetPlanID.Equals(item)); foreach (var sitem in airlist) { context.File_Airport.Remove(sitem); } var masterlist = context.File_Master.Where(u => u.RepetPlanID.Equals(item)); foreach (var sitem in masterlist) { context.File_Master.Remove(sitem); } var detaillist = context.File_Detail.Where(u => u.RepetPlanID.Equals(item)); foreach (var sitem in detaillist) { context.File_Detail.Remove(sitem); } } return(context.SaveChanges() > 0); }
public void AddFlightPlanOther(string masterIDs, string flightPlanID, string keyValue, ref string airlineworkText) { var context = new ZHCC_GAPlanEntities(); StringBuilder sb = new StringBuilder(""); //using (var dbContextTransaction = context.Database.BeginTransaction()) //{ //try //{ if (!string.IsNullOrEmpty(keyValue)) { var masterlist = context.File_FlightPlanMaster.Where(u => u.FlightPlanID.Equals(keyValue)); foreach (var item in masterlist) { context.File_FlightPlanMaster.Remove(item); } context.SaveChanges(); } var masterArray = masterIDs.Split(','); foreach (var item in masterArray) { File_FlightPlanMaster master = new File_FlightPlanMaster() { MasterID = item, FlightPlanID = flightPlanID }; context.File_FlightPlanMaster.Add(master); context.SaveChanges(); var fileMaster = context.File_Master.Where(u => u.ID.Equals(item)).FirstOrDefault(); if (fileMaster != null) { sb.AppendLine(fileMaster.LineDescript + ";"); } } airlineworkText = sb.ToString(); // dbContextTransaction.Commit(); //} //catch (Exception ex) //{ // dbContextTransaction.Rollback(); // throw ex; //} // } }
public static string GetLZCode() { lock (_lock) { var dt = DateTime.Now.Date; var data = context.Set <LZCodeGenerate>().Where(m => m.CurrentDate >= dt).FirstOrDefault(); var _code = "A"; if (data != null) { if (data.LZCode.Length > 7) { var _tempCode = data.LZCode.Substring(9, 1).ToUpper(); if (array.Contains(_tempCode)) { var index = array.ToList().IndexOf(_tempCode); _code = array[index + 1]; } } data.LZCode = $"{dt.ToString("yyyyMMdd")}_{_code}_KGB"; context.Entry(data).State = EntityState.Modified; context.SaveChanges(); } else { LZCodeGenerate entity = new LZCodeGenerate() { LZCode = $"{dt.ToString("yyyyMMdd")}_{_code}_KGB", CurrentDate = dt }; context.Entry(entity).State = EntityState.Added; context.SaveChanges(); } return($"{dt.ToString("yyyyMMdd")}_{_code}_KGB"); } }
/// <summary> /// 新增单个实体 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual int Add(T entity) { Create(entity); //设置字段默认值 //第一种方式 context.Entry(entity).State = EntityState.Added; //第二种方式 //context.Set<T>().Add(entity); // return context.SaveChanges(); var result = 0; SaveAction(() => { result = context.SaveChanges(); }); return(result); }
public bool Delete(string ids) { var idArray = ids.Split(','); var context = new ZHCC_GAPlanEntities(); foreach (var id in idArray) { var entity = context.FlightPlan.Where(u => u.FlightPlanID.ToString().Equals(id)).FirstOrDefault(); if (entity != null) { context.FlightPlan.Remove(entity); } var masterlist = context.File_FlightPlanMaster.Where(u => u.FlightPlanID.Equals(id)); foreach (var item in masterlist) { context.File_FlightPlanMaster.Remove(item); } } return(context.SaveChanges() > 0); }
/// <summary> /// 添加机场、航线、作业区 /// </summary> /// <param name="airportidList"></param> /// <param name="airlineText"></param> /// <param name="repetPlanID"></param> public void AddCurrentPlanTempOther(string airlineText, string cworkText, string pworkText, string hworkText, string currentPlanID, string keyValue, ref string airlineworkText) { var context = new ZHCC_GAPlanEntities(); StringBuilder sb = new StringBuilder(""); List <string> masterIDs = new List <string>(); using (var dbContextTransaction = context.Database.BeginTransaction()) { try { if (!string.IsNullOrEmpty(keyValue)) { var flightmasterlist = context.File_CurrentPlanMaster.Where(u => u.CurrentPlanID.Equals(currentPlanID)); foreach (var item in flightmasterlist) { var master = context.File_Master.Find(item.MasterID); context.File_Master.Remove(master); var detaillist = context.File_Detail.Where(u => u.MasterID.Equals(item.MasterID)); foreach (var sitem in detaillist) { context.File_Detail.Remove(sitem); } context.SaveChanges(); } } #region 航线 if (!string.IsNullOrEmpty(airlineText)) { var airlineList = (AirlineFillTotal)JsonConvert.DeserializeObject(airlineText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in airlineList.airlineArray) { if (item.airlinePointList.Count() > 0) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), WorkType = "airline", FlyHeight = item.FlyHeight, }; masterIDs.Add(master.ID); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); sblinedesc.Append("-"); index++; } if (sblinedesc.Length > 0) { sblinedesc.Remove(sblinedesc.Length - 1, 1); } if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion #region 作业区(圆) if (!string.IsNullOrEmpty(cworkText)) { var workList = (AirlineFillTotal)JsonConvert.DeserializeObject(cworkText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in workList.airlineArray) { if (item.airlinePointList.Count() > 0 && !string.IsNullOrEmpty(item.Radius)) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), FlyHeight = item.FlyHeight, WorkType = "circle" }; masterIDs.Add(master.ID); var customAreaStr = new StringBuilder(""); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); if (!string.IsNullOrEmpty(point.Latitude) && !string.IsNullOrEmpty(point.Longitude)) { customAreaStr.Append("N"); customAreaStr.Append(point.Latitude); customAreaStr.Append("E"); customAreaStr.Append(point.Longitude); customAreaStr.Append(","); } index++; } DbGeography geoArea = null; try { geoArea = context.f_GetGEOAreaByPointString(customAreaStr.ToString(), 4).First(); } catch { } //计算管制区 var customAreaList = context.CustomControlArea.Where(m => m.ControlAreaBoundary.Intersects(geoArea)).Select(m => m.ControlAreaName); master.CustomArea = string.Join(",", customAreaList.ToArray()); Int16 _radius = 0; if (!string.IsNullOrWhiteSpace(item.Radius) && Int16.TryParse(item.Radius, out _radius)) { master.RaidusMile = _radius; var tempraidus = "为圆心半径" + item.Radius + "公里范围内"; sblinedesc.Append(tempraidus); } if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion #region 作业区(点) if (!string.IsNullOrEmpty(pworkText)) { var workList = (AirlineFillTotal)JsonConvert.DeserializeObject(pworkText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in workList.airlineArray) { if (item.airlinePointList.Count() > 0) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), FlyHeight = item.FlyHeight, WorkType = "area" }; masterIDs.Add(master.ID); var customAreaStr = new StringBuilder(""); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); sblinedesc.Append("-"); if (!string.IsNullOrEmpty(point.Latitude) && !string.IsNullOrEmpty(point.Longitude)) { customAreaStr.Append("N"); customAreaStr.Append(point.Latitude); customAreaStr.Append("E"); customAreaStr.Append(point.Longitude); customAreaStr.Append(","); } index++; } if (customAreaStr.Length > 0) { customAreaStr.Remove(customAreaStr.Length - 1, 1); } if (sblinedesc.Length > 0) { sblinedesc.Remove(sblinedesc.Length - 1, 1); } DbGeography geoArea = null; try { geoArea = context.f_GetGEOAreaByPointString(customAreaStr.ToString(), 3).First(); } catch { } //计算管制区 var customAreaList = context.CustomControlArea.Where(m => m.ControlAreaBoundary.Intersects(geoArea)).Select(m => m.ControlAreaName); master.CustomArea = string.Join(",", customAreaList.ToArray()); var tempraidus = item.airlinePointList.Count() + "点连线范围内"; sblinedesc.Append(tempraidus); if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion #region 作业区(线) if (!string.IsNullOrEmpty(hworkText)) { var workList = (AirlineFillTotal)JsonConvert.DeserializeObject(hworkText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in workList.airlineArray) { if (item.airlinePointList.Count() > 0) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), FlyHeight = item.FlyHeight, WorkType = "airlinelr" }; masterIDs.Add(master.ID); var customAreaStr = new StringBuilder(""); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); sblinedesc.Append("-"); if (!string.IsNullOrEmpty(point.Latitude) && !string.IsNullOrEmpty(point.Longitude)) { customAreaStr.Append("N"); customAreaStr.Append(point.Latitude); customAreaStr.Append("E"); customAreaStr.Append(point.Longitude); customAreaStr.Append(","); } index++; } if (customAreaStr.Length > 0) { customAreaStr.Remove(customAreaStr.Length - 1, 1); } if (sblinedesc.Length > 0) { sblinedesc.Remove(sblinedesc.Length - 1, 1); } Int16 _radius = 0; if (!string.IsNullOrWhiteSpace(item.Radius) && Int16.TryParse(item.Radius, out _radius)) { master.RaidusMile = _radius; var tempraidus = "航线左右" + item.Radius + "公里范围内"; sblinedesc.Append(tempraidus); } if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } DbGeography geoArea = null; try { geoArea = context.f_GetGEOAreaByPointString(customAreaStr.ToString(), 2).First(); } catch { } //计算管制区 var customAreaList = context.CustomControlArea.Where(m => m.ControlAreaBoundary.Intersects(geoArea)).Select(m => m.ControlAreaName); master.CustomArea = string.Join(",", customAreaList.ToArray()); master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion foreach (var item in masterIDs) { File_CurrentPlanMaster master = new File_CurrentPlanMaster() { MasterID = item, CurrentPlanID = currentPlanID }; context.File_CurrentPlanMaster.Add(master); context.SaveChanges(); var fileMaster = context.File_Master.Where(u => u.ID.Equals(item)).FirstOrDefault(); if (fileMaster != null) { sb.AppendLine(fileMaster.LineDescript + ";"); } } airlineworkText = sb.ToString(); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
/// <summary> /// 添加机场、航线、作业区 /// </summary> /// <param name="airportidList"></param> /// <param name="airlineText"></param> /// <param name="repetPlanID"></param> public void AddRepetitivePlanOther(List <string> airportidList, string airlineText, string cworkText, string pworkText, string hworkText, string repetPlanID, string keyValue, ref string airlineworkText) { var context = new ZHCC_GAPlanEntities(); StringBuilder sb = new StringBuilder(""); // using (TransactionScope scope = new TransactionScope()) // using (var scope = context.Database.BeginTransaction()) // { //try //{ if (!string.IsNullOrEmpty(keyValue)) { var airlist = context.File_Airport.Where(u => u.RepetPlanID.Equals(repetPlanID)); foreach (var item in airlist) { context.File_Airport.Remove(item); } var masterlist = context.File_Master.Where(u => u.RepetPlanID.Equals(repetPlanID)); foreach (var item in masterlist) { context.File_Master.Remove(item); } var detaillist = context.File_Detail.Where(u => u.RepetPlanID.Equals(repetPlanID)); foreach (var item in detaillist) { context.File_Detail.Remove(item); } context.SaveChanges(); } #region 机场 var i = 1; foreach (var item in airportidList) { File_Airport airport = new File_Airport() { RepetPlanID = repetPlanID, AirportID = item, Sort = i }; i++; context.File_Airport.Add(airport); } var a = context.SaveChanges(); #endregion #region 航线 if (!string.IsNullOrEmpty(airlineText)) { var airlineList = (AirlineFillTotal)JsonConvert.DeserializeObject(airlineText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in airlineList.airlineArray) { if (item.airlinePointList.Count() > 0) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), RepetPlanID = repetPlanID, WorkType = "airline", FlyHeight = item.FlyHeight, }; var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, RepetPlanID = repetPlanID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); sblinedesc.Append("-"); index++; } if (sblinedesc.Length > 0) { sblinedesc.Remove(sblinedesc.Length - 1, 1); } if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion #region 作业区(圆) if (!string.IsNullOrEmpty(cworkText)) { var workList = (AirlineFillTotal)JsonConvert.DeserializeObject(cworkText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in workList.airlineArray) { if (item.airlinePointList.Count() > 0 && !string.IsNullOrEmpty(item.Radius)) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), RepetPlanID = repetPlanID, FlyHeight = item.FlyHeight, WorkType = "circle" }; var customAreaStr = new StringBuilder(""); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, RepetPlanID = repetPlanID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); var b = context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); if (!string.IsNullOrEmpty(point.Latitude) && !string.IsNullOrEmpty(point.Longitude)) { customAreaStr.Append("N"); customAreaStr.Append(point.Latitude); customAreaStr.Append("E"); customAreaStr.Append(point.Longitude); customAreaStr.Append(","); } index++; } DbGeography geoArea = null; try { geoArea = context.f_GetGEOAreaByPointString(customAreaStr.ToString(), 4).First(); } catch { } //计算管制区 var customAreaList = context.CustomControlArea.Where(m => m.ControlAreaBoundary.Intersects(geoArea)).Select(m => m.ControlAreaName); master.CustomArea = string.Join(",", customAreaList.ToArray()); Int16 _radius = 0; if (!string.IsNullOrWhiteSpace(item.Radius) && Int16.TryParse(item.Radius, out _radius)) { master.RaidusMile = _radius; var tempraidus = "为圆心半径" + item.Radius + "公里范围内"; sblinedesc.Append(tempraidus); } if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); var s = context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion #region 作业区(点) if (!string.IsNullOrEmpty(pworkText)) { var workList = (AirlineFillTotal)JsonConvert.DeserializeObject(pworkText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in workList.airlineArray) { if (item.airlinePointList.Count() > 0) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), RepetPlanID = repetPlanID, FlyHeight = item.FlyHeight, WorkType = "area" }; var customAreaStr = new StringBuilder(""); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, RepetPlanID = repetPlanID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); sblinedesc.Append("-"); if (!string.IsNullOrEmpty(point.Latitude) && !string.IsNullOrEmpty(point.Longitude)) { customAreaStr.Append("N"); customAreaStr.Append(point.Latitude); customAreaStr.Append("E"); customAreaStr.Append(point.Longitude); customAreaStr.Append(","); } index++; } if (customAreaStr.Length > 0) { customAreaStr.Remove(customAreaStr.Length - 1, 1); } if (sblinedesc.Length > 0) { sblinedesc.Remove(sblinedesc.Length - 1, 1); } DbGeography geoArea = null; try { geoArea = context.f_GetGEOAreaByPointString(customAreaStr.ToString(), 3).First(); } catch { } //计算管制区 var customAreaList = context.CustomControlArea.Where(m => m.ControlAreaBoundary.Intersects(geoArea)).Select(m => m.ControlAreaName); master.CustomArea = string.Join(",", customAreaList.ToArray()); var tempraidus = item.airlinePointList.Count() + "点连线范围内"; sblinedesc.Append(tempraidus); if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion #region 作业区(线) if (!string.IsNullOrEmpty(hworkText)) { var workList = (AirlineFillTotal)JsonConvert.DeserializeObject(hworkText, typeof(AirlineFillTotal)); var sblinedesc = new StringBuilder(""); foreach (var item in workList.airlineArray) { if (item.airlinePointList.Count() > 0) { sblinedesc.Clear(); File_Master master = new File_Master() { ID = Guid.NewGuid().ToString(), RepetPlanID = repetPlanID, FlyHeight = item.FlyHeight, WorkType = "airlinelr" }; var customAreaStr = new StringBuilder(""); var index = 1; foreach (var pointItem in item.airlinePointList) { if (string.IsNullOrEmpty(pointItem.PointName)) { continue; } sblinedesc.Append(pointItem.PointName); File_Detail point = new File_Detail() { ID = Guid.NewGuid().ToString(), MasterID = master.ID, RepetPlanID = repetPlanID, PointName = pointItem.PointName, Sort = index }; var splitmodel = SpecialFunctions.latLongSplit(pointItem.LatLong); point.Longitude = splitmodel.Longitude; point.Latitude = splitmodel.Latitude; context.File_Detail.Add(point); context.SaveChanges(); sblinedesc.Append("("); sblinedesc.Append(pointItem.LatLong); sblinedesc.Append(")"); sblinedesc.Append("-"); if (!string.IsNullOrEmpty(point.Latitude) && !string.IsNullOrEmpty(point.Longitude)) { customAreaStr.Append("N"); customAreaStr.Append(point.Latitude); customAreaStr.Append("E"); customAreaStr.Append(point.Longitude); customAreaStr.Append(","); } index++; } if (customAreaStr.Length > 0) { customAreaStr.Remove(customAreaStr.Length - 1, 1); } if (sblinedesc.Length > 0) { sblinedesc.Remove(sblinedesc.Length - 1, 1); } Int16 _radius = 0; if (!string.IsNullOrWhiteSpace(item.Radius) && Int16.TryParse(item.Radius, out _radius)) { master.RaidusMile = _radius; var tempraidus = "航线左右" + item.Radius + "公里范围内"; sblinedesc.Append(tempraidus); } if (!string.IsNullOrEmpty(master.FlyHeight)) { sblinedesc.Append(",高度"); sblinedesc.Append(master.FlyHeight); sblinedesc.Append("米(含)以下"); } DbGeography geoArea = null; try { geoArea = context.f_GetGEOAreaByPointString(customAreaStr.ToString(), 2).First(); } catch { } //计算管制区 var customAreaList = context.CustomControlArea.Where(m => m.ControlAreaBoundary.Intersects(geoArea)).Select(m => m.ControlAreaName); master.CustomArea = string.Join(",", customAreaList.ToArray()); master.LineDescript = sblinedesc.ToString(); context.File_Master.Add(master); context.SaveChanges(); sb.AppendLine(master.LineDescript + ";"); } } } #endregion airlineworkText = sb.ToString(); // scope.Complete(); //} //catch (Exception ex) //{ // //var ss = ex.Message + ex.InnerException + ex.StackTrace; // //dbContextTransaction.(); // throw ex; //} // } }