void getresult() { MPLB.ItemsSource = null; //clear the ItemsSource _mpsResult.Clear(); //clear the previous results of analysis //Get result _prj = Globals.project; _monitoringDomain = _prj.getDomain(DomainType.Monitoring); _allMPs = _monitoringDomain.getObjects("MonPoint"); _mps = _allMPs.merge(); int count = 0; string _message = ""; foreach (DGObject mp in _mps) { MonPoint _mp = mp as MonPoint; foreach (string key in _mp.readingsDict.Keys) { List <MonReading> a = _mp.readingsDict[key]; foreach (MonReading b in a) { if (System.Math.Abs(b.value) > mptb) { count++; } } _message = string.Format("{0} of the {1} value exceed the limit value {2}", count, _mp.Name, mptb); } _mpsResult.Add(_message); } MPLB.ItemsSource = _mpsResult; }
public async Task <IHttpActionResult> AddMonPoint([FromBody] MonPoint model) { var result = context.MonPoint.Add(model); context.SaveChanges(); return(Ok(result)); }
static void Main(string[] args) { //StreamReader sr = new StreamReader("D:/1.txt", Encoding.Default); //String line = sr.ReadToEnd(); //JObject jo = JObject.Parse(line); //JArray ja = JArray.Parse(jo["monComponentList"].ToString()); //foreach (JToken jt in ja) //{ // string name = jt["componentName"].ToString(); //} //MonPoint mp = JsonConvert.DeserializeObject<MonPoint>(line); //Console.ReadLine(); MonPoint mp = new MonPoint(); mp.monComponentList = new List <MonComponent>() { new MonComponent() { componentName = "1" }, new MonComponent() { componentName = "2" } }; string st = JsonConvert.SerializeObject(mp); MonPoint mp1 = JsonConvert.DeserializeObject <MonPoint>(st); Console.ReadLine(); }
public async Task <IHttpActionResult> RemoveMonPoint(int id) { MonPoint obj = context.Set <MonPoint>().Find(id); context.Entry(obj).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); return(Ok(obj)); }
public async Task <IHttpActionResult> ModifyMonPoint([FromBody] MonPoint model) { MonPoint obj = context.Set <MonPoint>().Find((model.ID)); UpdateModelHelp.Update(model, obj); context.Entry(obj).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(Ok(obj)); }
private void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { if (view == null) { view = Globals.mainframe.getViewByID("DemoLineChart"); holder.Children.Add(view as UserControl); } MonPoint mp = e.addedObjs.Values.FirstOrDefault().FirstOrDefault() as MonPoint; view.SetData(string.Format("测点{0}监测曲线", mp.Name), mp.readingsDict.Values.FirstOrDefault().ToList(), "time", "value", "", mp.Name); }
//在view中加载图形,和同步图形 void SyncToView() { IView view = InputCB.SelectedItem as IView; //为图形赋值“Name”属性,以便图形和数据关联 foreach (int monID in _MonGraphics.Keys) { MonPoint mp = _allMons[monID] as MonPoint; IGraphicCollection gc = _MonGraphics[monID]; foreach (IGraphic g in gc) { g.Attributes["Name"] = mp.name; } } //将图形添加到view中 string layerID = "DemoLayer"; //图层ID IGraphicsLayer gLayer = getDemoLayer(view, layerID); //获取图层函数 foreach (int id in _MonGraphics.Keys) { IGraphicCollection gc = _MonGraphics[id]; gLayer.addGraphics(gc); } //使数据与图形关联 List <DGObject> sls = _allMons.merge(); gLayer.syncObjects(sls); //计算新建图形范围,并在地图中显示该范围 IEnvelope ext = null; foreach (IGraphicCollection gc in _MonGraphics.Values) { IEnvelope itemExt = GraphicsUtil.GetGraphicsEnvelope(gc); if (ext == null) { ext = itemExt; } else { ext = ext.Union(itemExt); } } _mainFrame.activeView = view; view.zoomTo(ext); }
void _AddReading(MonPoint monPnt, MonReading reading) { Dictionary <string, List <MonReading> > readingsDict = monPnt.readingsDict; List <MonReading> readings; if (readingsDict.ContainsKey(reading.component)) { readings = readingsDict[reading.component]; } else { readings = new List <MonReading>(); readingsDict[reading.component] = readings; } readings.Add(reading); }
void _ReadMonPoints(DGObjects objs, string tableNameSQL, string conditionSQL, string orderSQL) { DataTable table = objs.rawDataSet.Tables[0]; foreach (DataRow row in table.Rows) { if (IsDbNull(row, "ID") || IsDbNull(row, "Name")) { continue; } MonPoint obj = new MonPoint(row); obj.id = ReadInt(row, "ID").Value; obj.name = ReadString(row, "Name"); obj.fullName = ReadString(row, "FullName"); obj.description = ReadString(row, "Description"); obj.shape = ReadShape(row); obj.refPointName = ReadString(row, "refPointName"); obj.distanceX = ReadDouble(row, "distanceX"); obj.distanceY = ReadDouble(row, "distanceY"); obj.distanceZ = ReadDouble(row, "distanceZ"); obj.time = ReadDateTime(row, "time"); obj.instrumentDetail = ReadString(row, "instrumentDetail"); obj.bearingA = ReadDouble(row, "bearingA"); obj.bearingB = ReadDouble(row, "bearingB"); obj.bearingC = ReadDouble(row, "bearingC"); obj.inclinationA = ReadDouble(row, "inclinationA"); obj.inclinationB = ReadDouble(row, "inclinationB"); obj.inclinationC = ReadDouble(row, "inclinationC"); obj.readingSignA = ReadString(row, "readingSignA"); obj.readingSignB = ReadString(row, "readingSignB"); obj.readingSignC = ReadString(row, "readingSignC"); obj.componentCount = ReadInt(row, "componentCount").Value; obj.componentNames = ReadString(row, "componentNames"); obj.remarks = ReadString(row, "remarks"); obj.contractor = ReadString(row, "contractor"); obj.fileName = ReadString(row, "fileName"); objs[obj.key] = obj; } }
public MonPoint getMonPointByID(string project, int id) { var repo = new RepositoryForServer <MonPoint>(project); MonitoringContext monContext = repo.context as MonitoringContext; MonPoint mp = monContext.MonPoint.Where(x => x.ID == id).FirstOrDefault(); if (mp == null) { return(null); } mp.monComponentList = new List <MonComponent>(); List <string> componentNameList = mp.componentNames.Split(',').ToList(); foreach (string key in componentNameList) { mp.monComponentList.Add(new MonComponent() { componentName = key, readings = monContext.MonReading.Where(x => ((x.monPointName == mp.Name) && (x.component == key))).ToList() }); } return(mp); }
public Task SetObjContent(DGObject model) { this.monPoint = model as MonPoint; return(null); }
public EngineeringMap SetIt(DGObject model) { this.monPoint = model as MonPoint; return(null); }
void StartAnalysis() { double max = double.Parse(TB_Max.Text); //获取输入的view和复制坐标系 IView view = InputCB.SelectedItem as IView; _spatialRef = view.spatialReference; //开始分析 foreach (string MonLayerID in _selectedMonsDict.Keys) { //获取衬砌选中列表 IEnumerable <DGObject> mons = _selectedMonsDict[MonLayerID]; List <DGObject> monList = mons.ToList(); IGraphicsLayer gLayer = _inputView.getLayer(MonLayerID); foreach (DGObject dg in monList) { //获取单个监测点对象,计算监测状况 MonPoint mp = dg as MonPoint; int grade = 0; foreach (string key in mp.readingsDict.Keys) { List <MonReading> mrList = mp.readingsDict[key]; foreach (MonReading mr in mrList) { if (Math.Abs(mr.value) > max) { grade = 1; break; } } if (grade == 1) { break; } } //根据评估等级获取图形样式 ISymbol symbol = GetSymbol(grade); //为了演示,采用了较复杂的方法 //<简便方法 可替换下面代码> //IGraphicCollection gcollection = gLayer.getGraphics(sl); //IGraphic g = gcollection[0]; //g.Symbol = symbol; //IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); //gc.Add(g); //_slsGraphics[sl.id] = gc; //</简便方法> //获取衬砌图形 IGraphicCollection gcollection = gLayer.getGraphics(dg); IGraphic g = gcollection[0]; IPolygon ip = g.Geometry as IPolygon; //获取端点 IPointCollection ipc = ip.GetPoints(); //导入的监测点不是点类型,是个圆所以要转换,如果是点,自己可以转换为IMapPoint double centerX = 0; double centerY = 0; foreach (IMapPoint point in ipc) { centerX += point.X; centerY += point.Y; } if (ipc.Count > 0) { centerX = centerX / ipc.Count; centerY = centerY / ipc.Count; } double offset = 2; //新建新的点,注意复制坐标系 IMapPoint p1 = Runtime.geometryEngine.newMapPoint(centerX - offset, centerY - offset, _spatialRef); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(centerX - offset, centerY + offset, _spatialRef); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(centerX + offset, centerY + offset, _spatialRef); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(centerX + offset, centerY - offset, _spatialRef); ////生成新的图形 g = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4); g.Symbol = symbol; IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); gc.Add(g); _MonGraphics[dg.id] = gc; //保存结果 } } }
void _ReadMonPoints(DGObjects objs, string tableNameSQL, string conditionSQL, string orderSQL) { DataTable table = objs.rawDataSet.Tables[0]; foreach (DataRow row in table.Rows) { if (IsDbNull(row, "ID") || IsDbNull(row, "Name")) continue; MonPoint obj = new MonPoint(row); obj.id = ReadInt(row, "ID").Value; obj.name = ReadString(row, "Name"); obj.fullName = ReadString(row, "FullName"); obj.description = ReadString(row, "Description"); obj.shape = ReadShape(row); obj.refPointName = ReadString(row, "refPointName"); obj.distanceX = ReadDouble(row, "distanceX"); obj.distanceY = ReadDouble(row, "distanceY"); obj.distanceZ = ReadDouble(row, "distanceZ"); obj.time = ReadDateTime(row, "time"); obj.instrumentDetail = ReadString(row, "instrumentDetail"); obj.bearingA = ReadDouble(row, "bearingA"); obj.bearingB = ReadDouble(row, "bearingB"); obj.bearingC = ReadDouble(row, "bearingC"); obj.inclinationA = ReadDouble(row, "inclinationA"); obj.inclinationB = ReadDouble(row, "inclinationB"); obj.inclinationC = ReadDouble(row, "inclinationC"); obj.readingSignA = ReadString(row, "readingSignA"); obj.readingSignB = ReadString(row, "readingSignB"); obj.readingSignC = ReadString(row, "readingSignC"); obj.componentCount = ReadInt(row, "componentCount").Value; obj.componentNames = ReadString(row, "componentNames"); obj.remarks = ReadString(row, "remarks"); obj.contractor = ReadString(row, "contractor"); obj.fileName = ReadString(row, "fileName"); objs[obj.key] = obj; } }
void _AddReading(MonPoint monPnt, MonReading reading) { Dictionary<string, List<MonReading>> readingsDict = monPnt.readingsDict; List<MonReading> readings; if (readingsDict.ContainsKey(reading.component)) readings = readingsDict[reading.component]; else { readings = new List<MonReading>(); readingsDict[reading.component] = readings; } readings.Add(reading); }
void StartAnalyzing() { //Get input view IView view = InputCB.SelectedItem as IView; _spatialRef = view.spatialReference; //create new layer view.removeLayer("Rectanglelayer"); //clear the previous layer string layerID = "Rectanglelayer"; IGraphicsLayer mlayer = Runtime.graphicEngine.newGraphicsLayer(layerID, layerID); var sym_fill = GraphicsUtil.GetDefaultFillSymbol(); var renderer = Runtime.graphicEngine.newSimpleRenderer(sym_fill); mlayer.setRenderer(renderer); mlayer.Opacity = 1.0; view.addLayer(mlayer); //Define local variables IGraphic m; int count = 0; int result = 5; double monpointX; double monpointY; _monpoints = _prj.getSelectedObjs(_monitoringDomain, "MonPoint"); foreach (DGObject mp in _mps) { MonPoint _mp = mp as MonPoint; foreach (string key in _mp.readingsDict.Keys) { List <MonReading> a = _mp.readingsDict[key]; foreach (MonReading b in a) { if (System.Math.Abs(b.value) > mptb) { count++; } } if (count <= 50) { result = 5; } else if (count <= 150) { result = 4; } else if (count <= 250) { result = 3; } else if (count <= 350) { result = 2; } else { result = 1; } ISymbol symbol = GetSymbol(result); //Obtain borehole coordinates IGraphicsLayer mplayer = view.getLayer("MonPoint"); IGraphicCollection mpcollection = mplayer.getGraphics(_mp); m = mpcollection[0]; IGeometry mpgeometry = m.Geometry; IMapPoint mpmappoint = mpgeometry as IMapPoint; monpointX = mpmappoint.X; monpointY = mpmappoint.Y; //Draw rectangle IMapPoint p1 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY + 2200, _spatialRef); IMapPoint p2 = Runtime.geometryEngine.newMapPoint(monpointX + 2200, monpointY - 2200, _spatialRef); IMapPoint p3 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY - 2200, _spatialRef); IMapPoint p4 = Runtime.geometryEngine.newMapPoint(monpointX - 2200, monpointY + 2200, _spatialRef); m = Runtime.graphicEngine.newQuadrilateral(p1, p2, p3, p4); m.Symbol = symbol; IGraphicCollection gc = Runtime.graphicEngine.newGraphicCollection(); gc.Add(m); mlayer.addGraphics(gc); } } }