private bool DeleteFacClassReg(FacClassReg reg) { try { IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass"); if (oc == null) { return(false); } IQueryFilter filter = new QueryFilter(); filter.WhereClause = string.Format("FacClassCode = '{0}'", reg.FacClassCode); oc.Delete(filter); return(true); } catch (Exception ex) { return(false); } }
public bool TryOpenObjectClass(IDataSource ds, string datasetName, string ocName, out IObjectClass oc) { oc = null; List <DataObject> list = null; if (((ds == null) || string.IsNullOrEmpty(datasetName)) || string.IsNullOrEmpty(ocName)) { return(false); } try { this._finder.SetByName(ds.Guid, datasetName, ocName); list = this._lst.FindAll(new Predicate <DataObject>(this._finder.FinderByName)); if ((list == null) || (list.Count == 0)) { IFeatureDataSet o = ds.OpenFeatureDataset(datasetName); oc = o.OpenObjectClass(ocName); if (oc != null) { this._lst.Add(new DataObject(oc)); } Marshal.ReleaseComObject(o); } else { oc = list[0].GetData(); } return(true); } catch (Exception exception) { return(false); } }
public static TopoClass GetTopoClassByFacClassCode(string facClassCode) { if (DF3DPipeCreateApp.App.TemplateLib == null) { return(null); } IFdeCursor o = null; IRowBuffer buffer = null; IQueryFilter filter = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_Catalog"); if (oc == null) { return(null); } filter = new QueryFilterClass { WhereClause = string.Format("Code = '{0}'", facClassCode), SubFields = "TopoLayerId" }; o = oc.Search(filter, true); buffer = o.NextRow(); if (buffer != null) { if (buffer.IsNull(0)) { return(null); } return(FacilityInfoService.GetTopoClassByObjectId(buffer.GetValue(0).ToString())); } return(null); } catch (Exception ex) { return(null); } finally { if (o != null) { Marshal.ReleaseComObject(o); o = null; } if (buffer != null) { Marshal.ReleaseComObject(buffer); buffer = null; } } }
private bool UpdateFacClassReg(FacClassReg reg) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass"); if (oc == null) { return(false); } IQueryFilter filter = new QueryFilter() { WhereClause = string.Format("FacClassCode = '{0}'", reg.FacClassCode), SubFields = "oid,LocationType,TurnerStyle,FacilityType,Comment" }; cursor = oc.Update(filter); row = cursor.NextRow(); if (row != null) { row.SetValue(1, reg.LocationType.ToString()); row.SetValue(2, reg.TurnerStyle.ToString()); row.SetValue(3, reg.FacilityType.Name); row.SetValue(4, reg.Comment); cursor.UpdateRow(row); return(true); } else { return(false); } } catch (Exception ex) { return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
public int TryCeateObjectClass(IFeatureDataSet dataset, string Name, IFieldInfoCollection fields, string[] indexField, out IObjectClass oc) { oc = null; if (((dataset == null) || string.IsNullOrEmpty(Name)) || (fields == null)) { return(-1); } try { string[] namesByType = dataset.GetNamesByType(gviDataSetType.gviDataSetObjectClassTable); if ((namesByType != null) && (Array.IndexOf <string>(namesByType, Name) != -1)) { oc = dataset.OpenObjectClass(Name); return(0); } oc = dataset.CreateObjectClass(Name, fields); if (dataset == null) { return(-1); } IDbIndexInfo index = null; if (indexField != null) { foreach (string str in indexField) { try { index = new DbIndexInfoClass { Name = string.Format("Index_{0}_{1}", oc.Id, str) }; index.AppendFieldDefine(str, true); oc.AddDbIndex(index); } catch (Exception exception) { } } } return(1); } catch (Exception exception2) { return(-1); } }
public static List <FacStyleClass> GetFacStyleByFacClassCode(string fcCode) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = string.Format("FacClassCode = '{0}'", fcCode) }; cursor = oc.Search(filter, true); List <FacStyleClass> list = new List <FacStyleClass>(); while ((row = cursor.NextRow()) != null) { StyleType type; FacStyleClass fs = null; if (row.FieldIndex("StyleType") >= 0 && Enum.TryParse <StyleType>(row.GetValue(row.FieldIndex("StyleType")).ToString(), out type)) { Dictionary <string, string> dictionary = null; if (row.FieldIndex("StyleInfo") >= 0) { object obj = row.GetValue(row.FieldIndex("StyleInfo")); if (obj != null) { IBinaryBuffer buffer2 = row.GetValue(row.FieldIndex("StyleInfo")) as IBinaryBuffer; if (buffer2 != null) { dictionary = JsonTool.JsonToObject <Dictionary <string, string> >(Encoding.UTF8.GetString(buffer2.AsByteArray())); } } } switch (type) { case StyleType.PipeNodeStyle: fs = new PipeNodeStyleClass(dictionary); break; case StyleType.PipeLineStyle: fs = new PipeLineStyleClass(dictionary); break; case StyleType.PipeBuildStyle: fs = new PipeBuildStyleClass(dictionary); break; } } if (fs == null) { continue; } if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fs.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("ObjectId") >= 0) { object obj = row.GetValue(row.FieldIndex("ObjectId")); if (obj != null) { fs.ObjectId = obj.ToString(); } } if (row.FieldIndex("FacClassCode") >= 0) { object obj = row.GetValue(row.FieldIndex("FacClassCode")); if (obj != null) { fs.FacClassCode = obj.ToString(); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fs.Name = obj.ToString(); } } int index = row.FieldIndex("Thumbnail"); if (index != -1 && !row.IsNull(index)) { IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer; if (row != null) { MemoryStream stream = new MemoryStream(b.AsByteArray()); fs.Thumbnail = Image.FromStream(stream); } } list.Add(fs); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
public static TopoClass GetTopoClassByObjectId(string objectId) { if (dictTopo.ContainsKey(objectId) && dictTopo[objectId] != null) { return(dictTopo[objectId]); } if (DF3DPipeCreateApp.App.TemplateLib == null) { return(null); } IFdeCursor o = null; IRowBuffer row = null; IQueryFilter filter = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TopoManage"); if (oc == null) { return(null); } filter = new QueryFilterClass { WhereClause = string.Format("ObjectId = '{0}'", objectId) }; o = oc.Search(filter, true); row = o.NextRow(); if (row != null) { TopoClass tc = new TopoClass(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { tc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("ObjectId") >= 0) { object obj = row.GetValue(row.FieldIndex("ObjectId")); if (obj != null) { tc.ObjectId = obj.ToString(); } } if (row.FieldIndex("TopoLayerName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoLayerName")); if (obj != null) { tc.Name = obj.ToString(); } } if (row.FieldIndex("Tolerance") >= 0) { object obj = row.GetValue(row.FieldIndex("Tolerance")); if (obj != null) { tc.Tolerance = double.Parse(obj.ToString()); } } if (row.FieldIndex("ToleranceZ") >= 0) { object obj = row.GetValue(row.FieldIndex("ToleranceZ")); if (obj != null) { tc.ToleranceZ = double.Parse(obj.ToString()); } } if (row.FieldIndex("IgnoreZ") >= 0) { object obj = row.GetValue(row.FieldIndex("IgnoreZ")); if (obj != null) { tc.IgnoreZ = obj.ToString() == "1" ? true : false; } } if (row.FieldIndex("TopoTableName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoTableName")); if (obj != null) { tc.TopoTable = obj.ToString(); } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { tc.Comment = obj.ToString(); } } dictTopo[tc.ObjectId] = tc; return(tc); } return(null); } catch (Exception ex) { return(null); } finally { if (o != null) { Marshal.ReleaseComObject(o); o = null; } if (row != null) { Marshal.ReleaseComObject(row); row = null; } } }
public static Dictionary <string, IRowBuffer> GetPipeInfos(IConnectionInfo ci, string datasetName, string ocName) { Dictionary <string, IRowBuffer> infos = new Dictionary <string, IRowBuffer>(); IFdeCursor o = null; IQueryFilter filter = null; IRowBuffer r = null; try { IDataSourceFactory dsFactory = new DataSourceFactory(); if (!dsFactory.HasDataSource(ci)) { return(null); } IDataSource ds = dsFactory.OpenDataSource(ci); if (ds == null) { return(null); } string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return(null); } for (int i = 0; i < setnames.Length; i++) { if (setnames[i] != datasetName) { continue; } IFeatureDataSet fds = ds.OpenFeatureDataset(setnames[i]); IObjectClass oc = fds.OpenObjectClass(ocName); if (oc == null) { return(null); } filter = new QueryFilterClass { WhereClause = "" }; o = oc.Search(filter, false); while ((r = o.NextRow()) != null) { string code = r.GetValue(r.FieldIndex("Code")).ToString(); infos[code] = r; } } } catch (Exception ex) { return(null); } finally { if (filter != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(filter); filter = null; } if (o != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(o); o = null; } if (r != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(r); r = null; } } return(infos); }
private bool CreateFacClassReg(FacClass fc) { if (fc == null || fc.FacilityType == null) { return(false); } IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IFeatureDataSet fdsActuality = this._dsPipe.OpenFeatureDataset("DataSet_GEO_Actuality"); if (fdsActuality == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass"); if (oc == null) { return(false); } row = oc.CreateRowBuffer(); cursor = oc.Insert(); if (row != null) { row.SetValue(row.FieldIndex("FacClassCode"), fc.Code); row.SetValue(row.FieldIndex("Name"), fc.Name); row.SetValue(row.FieldIndex("FacilityType"), fc.FacilityType.Name); row.SetValue(row.FieldIndex("LocationType"), fc.LocationType.ToString()); row.SetValue(row.FieldIndex("TurnerStyle"), fc.TurnerStyle.ToString()); row.SetValue(row.FieldIndex("Comment"), fc.Comment); string fcName = string.Format("FC_{0}_{1}", (int)DataLifeCyle.Actuality, fc.Code); List <CMFieldConfig> fieldConfig = GetFieldsConfig(fc.Code); IFieldInfoCollection fielInfoCol = CreateFieldInfoCollection(fieldConfig, fc.FacilityType.Name); IFeatureClass featureClass = fdsActuality.CreateFeatureClass(fcName, fielInfoCol); if (featureClass == null) { return(false); } featureClass.AliasName = fc.Name; featureClass.LockType = gviLockType.gviLockExclusiveSchema; IGridIndexInfo indexInfo = new GridIndexInfoClass { L1 = 500.0, L2 = 2000.0, L3 = 10000.0, GeoColumnName = "Geometry" }; featureClass.AddSpatialIndex(indexInfo); indexInfo.GeoColumnName = "Shape"; featureClass.AddSpatialIndex(indexInfo); indexInfo.GeoColumnName = "FootPrint"; featureClass.AddSpatialIndex(indexInfo); IRenderIndexInfo info2 = new RenderIndexInfoClass { L1 = 500.0, GeoColumnName = "Geometry" }; featureClass.AddRenderIndex(info2); info2.GeoColumnName = "Shape"; featureClass.AddRenderIndex(info2); info2.GeoColumnName = "FootPrint"; featureClass.AddRenderIndex(info2); featureClass.LockType = gviLockType.gviLockSharedSchema; row.SetValue(row.FieldIndex("FeatureClassId"), featureClass.Guid.ToString()); row.SetValue(row.FieldIndex("DataSetName"), "DataSet_GEO_Actuality"); row.SetValue(row.FieldIndex("FcName"), featureClass.Name); row.SetValue(row.FieldIndex("DataType"), DataLifeCyle.Actuality.ToString()); cursor.InsertRow(row); return(true); } else { return(false); } } catch (Exception ex) { WaitForm.SetCaption("创建管线库中的设施要素类【" + fc.Name + "】失败!"); return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private DataTable GetTextureInfo() { DataTable table = null; IFdeCursor cursor = null; IRowBuffer row = null; try { table = new DataTable("TextureInfo"); table.Columns.Add("Name", typeof(string)); table.Columns.Add("ObjectId", typeof(string)); table.Columns.Add("Thumbnail", typeof(object)); IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = "GroupId != '-1'", SubFields = "Name,ObjectId,Thumbnail", PostfixClause = "order by Name asc" }; cursor = oc.Search(filter, true); while ((row = cursor.NextRow()) != null) { DataRow dtRow = table.NewRow(); dtRow["Name"] = row.GetValue(0).ToString(); dtRow["ObjectId"] = row.GetValue(1).ToString(); if (!row.IsNull(2)) { try { IBinaryBuffer buffer2 = row.GetValue(2) as IBinaryBuffer; if (buffer2 != null) { MemoryStream stream = new MemoryStream(buffer2.AsByteArray()); dtRow["Thumbnail"] = Image.FromStream(stream); } } catch (Exception exception) { } } table.Rows.Add(dtRow); } return(table); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private List <TopoClass> GetAllTopoClasses() { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsTemplate.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TopoManage"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = "1=1" }; cursor = oc.Search(filter, true); List <TopoClass> list = new List <TopoClass>(); while ((row = cursor.NextRow()) != null) { TopoClass tc = new TopoClass(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { tc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("ObjectId") >= 0) { object obj = row.GetValue(row.FieldIndex("ObjectId")); if (obj != null) { tc.ObjectId = obj.ToString(); } } if (row.FieldIndex("TopoLayerName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoLayerName")); if (obj != null) { tc.Name = obj.ToString(); } } if (row.FieldIndex("Tolerance") >= 0) { object obj = row.GetValue(row.FieldIndex("Tolerance")); if (obj != null) { tc.Tolerance = double.Parse(obj.ToString()); } } if (row.FieldIndex("ToleranceZ") >= 0) { object obj = row.GetValue(row.FieldIndex("ToleranceZ")); if (obj != null) { tc.ToleranceZ = double.Parse(obj.ToString()); } } if (row.FieldIndex("IgnoreZ") >= 0) { object obj = row.GetValue(row.FieldIndex("IgnoreZ")); if (obj != null) { tc.IgnoreZ = obj.ToString() == "1" ? true : false; } } if (row.FieldIndex("TopoTableName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoTableName")); if (obj != null) { tc.TopoTable = obj.ToString(); } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { tc.Comment = obj.ToString(); } } list.Add(tc); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private List <FacClass> GetAllFacClasses() { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsTemplate.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_Catalog"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = string.Format("FacilityType <> '{0}'", "UnKnown"), PostfixClause = "order by OrderBy asc" }; cursor = oc.Search(filter, true); List <FacClass> list = new List <FacClass>(); while ((row = cursor.NextRow()) != null) { FacClass fc = new FacClass(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("Code") >= 0) { object obj = row.GetValue(row.FieldIndex("Code")); if (obj != null) { fc.Code = obj.ToString(); } } if (row.FieldIndex("PCode") >= 0) { object obj = row.GetValue(row.FieldIndex("PCode")); if (obj != null) { fc.PCode = obj.ToString(); } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { fc.Comment = obj.ToString(); } } if (row.FieldIndex("FacilityType") >= 0) { object obj = row.GetValue(row.FieldIndex("FacilityType")); if (obj != null) { fc.FacilityType = FacilityClassManager.Instance.GetFacilityClassByName(obj.ToString()); } } if (row.FieldIndex("LocationType") >= 0) { object obj = row.GetValue(row.FieldIndex("LocationType")); if (obj != null) { fc.LocationType = (LocationType)Enum.Parse(typeof(LocationType), obj.ToString()); } } if (row.FieldIndex("TurnerStyle") >= 0) { object obj = row.GetValue(row.FieldIndex("TurnerStyle")); if (obj != null) { fc.TurnerStyle = (TurnerStyle)Enum.Parse(typeof(TurnerStyle), obj.ToString()); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fc.Name = obj.ToString(); } } if (row.FieldIndex("TopoLayerId") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoLayerId")); if (obj != null) { fc.TopoLayerId = obj.ToString(); } } list.Add(fc); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private bool InsertColor() { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_ColorInfo"); if (oc == null) { return(false); } row = oc.CreateRowBuffer(); cursor = oc.Insert(); row.SetValue(row.FieldIndex("Name"), this._color.Name); row.SetValue(row.FieldIndex("ObjectId"), this._color.ObjectId); row.SetValue(row.FieldIndex("GroupId"), this._color.Group); row.SetValue(row.FieldIndex("Code"), this._color.Code); row.SetValue(row.FieldIndex("Type"), this._color.Type); if (this._color.Thumbnail != null) { try { IBinaryBuffer bb = new BinaryBufferClass(); MemoryStream stream = new MemoryStream(); this._color.Thumbnail.Save(stream, ImageFormat.Png); bb.FromByteArray(stream.ToArray()); row.SetValue(row.FieldIndex("Thumbnail"), bb); } catch (Exception exception) { } } row.SetValue(row.FieldIndex("Comment"), this._color.Comment); cursor.InsertRow(row); this._color.Id = cursor.LastInsertId; return(true); } catch (Exception ex) { return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private bool UpdateColor() { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_ColorInfo"); if (oc == null) { return(false); } IQueryFilter filter = new QueryFilter() { WhereClause = string.Format("ObjectId = '{0}'", this._color.ObjectId) }; cursor = oc.Update(filter); row = cursor.NextRow(); if (row != null) { row.SetValue(row.FieldIndex("Name"), this._color.Name); row.SetValue(row.FieldIndex("GroupId"), this._color.Group); row.SetValue(row.FieldIndex("Code"), this._color.Code); row.SetValue(row.FieldIndex("Type"), this._color.Type); row.SetValue(row.FieldIndex("Comment"), this._color.Comment); if (this._color.Thumbnail != null) { try { IBinaryBuffer newVal = new BinaryBufferClass(); MemoryStream stream = new MemoryStream(); this._color.Thumbnail.Save(stream, ImageFormat.Png); newVal.FromByteArray(stream.ToArray()); row.SetValue(2, newVal); } catch (Exception ex) { } } cursor.UpdateRow(row); return(true); } else { return(false); } } catch (Exception ex) { return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
public static List <FacClassReg> GetFacClassRegsByFacilityType(string str) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilter(); filter.WhereClause = "FacilityType='" + str + "'"; cursor = oc.Search(filter, false); List <FacClassReg> list = new List <FacClassReg>(); while ((row = cursor.NextRow()) != null) { FacClassReg fc = new FacClassReg(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fc.Name = obj.ToString(); } } if (row.FieldIndex("FacClassCode") >= 0) { object obj = row.GetValue(row.FieldIndex("FacClassCode")); if (obj != null) { fc.FacClassCode = obj.ToString(); } } if (row.FieldIndex("DataSetName") >= 0) { object obj = row.GetValue(row.FieldIndex("DataSetName")); if (obj != null) { fc.DataSetName = obj.ToString(); } } if (row.FieldIndex("FeatureClassId") >= 0) { object obj = row.GetValue(row.FieldIndex("FeatureClassId")); if (obj != null) { fc.FeatureClassId = obj.ToString(); } } if (row.FieldIndex("FcName") >= 0) { object obj = row.GetValue(row.FieldIndex("FcName")); if (obj != null) { fc.FcName = obj.ToString(); } } if (row.FieldIndex("DataType") >= 0) { object obj = row.GetValue(row.FieldIndex("DataType")); if (obj != null) { DataLifeCyle ts = 0; if (Enum.TryParse <DataLifeCyle>(obj.ToString(), out ts)) { fc.DataType = ts; } else { fc.DataType = 0; } } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { fc.Comment = obj.ToString(); } } if (row.FieldIndex("TurnerStyle") >= 0) { object obj = row.GetValue(row.FieldIndex("TurnerStyle")); if (obj != null) { TurnerStyle ts = 0; if (Enum.TryParse <TurnerStyle>(obj.ToString(), out ts)) { fc.TurnerStyle = ts; } else { fc.TurnerStyle = 0; } } } if (row.FieldIndex("FacilityType") >= 0) { object obj = row.GetValue(row.FieldIndex("FacilityType")); if (obj != null) { fc.FacilityType = FacilityClassManager.Instance.GetFacilityClassByName(obj.ToString()); } } if (row.FieldIndex("LocationType") >= 0) { object obj = row.GetValue(row.FieldIndex("LocationType")); if (obj != null) { LocationType lt = 0; if (Enum.TryParse <LocationType>(obj.ToString(), out lt)) { fc.LocationType = lt; } else { fc.LocationType = 0; } } } list.Add(fc); } return(list); } catch (Exception ex) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private TextureClass GetTextureClass(string objectId) { IFdeCursor cursor = null; IRowBuffer row = null; try { IDataSource ds = DF3DPipeCreateApp.App.TemplateLib; if (ds == null) { return(null); } IFeatureDataSet fds = ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = "ObjectId = '" + objectId + "'" }; cursor = oc.Search(filter, true); if ((row = cursor.NextRow()) != null) { int id = -1; string name = "", objectid = "", groupid = "", code = "", comment = ""; Image thumbnail = null; int index = row.FieldIndex("oid"); if (index != -1 && !row.IsNull(index)) { id = Convert.ToInt32(row.GetValue(index).ToString()); } index = row.FieldIndex("Name"); if (index != -1 && !row.IsNull(index)) { name = row.GetValue(index).ToString(); } index = row.FieldIndex("ObjectId"); if (index != -1 && !row.IsNull(index)) { objectid = row.GetValue(index).ToString(); } index = row.FieldIndex("GroupId"); if (index != -1 && !row.IsNull(index)) { groupid = row.GetValue(index).ToString(); } index = row.FieldIndex("Code"); if (index != -1 && !row.IsNull(index)) { code = row.GetValue(index).ToString(); } index = row.FieldIndex("Comment"); if (index != -1 && !row.IsNull(index)) { comment = row.GetValue(index).ToString(); } index = row.FieldIndex("Thumbnail"); if (index != -1 && !row.IsNull(index)) { IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer; if (row != null) { MemoryStream stream = new MemoryStream(b.AsByteArray()); thumbnail = Image.FromStream(stream); } } if (id != -1 && thumbnail != null) { TextureClass cc = new TextureClass(); cc.Id = id; cc.Name = name; cc.Group = groupid; cc.ObjectId = objectid; cc.Code = code; cc.Comment = comment; cc.Thumbnail = thumbnail; return(cc); } } return(null); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private List <CMFieldConfig> GetFieldsConfig(string code) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsTemplate.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_FieldConfig"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = string.Format("FacClassCode = '{0}'", code), PostfixClause = "order by OrderBy asc" }; cursor = oc.Search(filter, true); List <CMFieldConfig> list = new List <CMFieldConfig>(); while ((row = cursor.NextRow()) != null) { CMFieldConfig fc = new CMFieldConfig(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("FacClassCode") >= 0) { object obj = row.GetValue(row.FieldIndex("FacClassCode")); if (obj != null) { fc.FacClassCode = obj.ToString(); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fc.Name = obj.ToString(); } } if (row.FieldIndex("Alias") >= 0) { object obj = row.GetValue(row.FieldIndex("Alias")); if (obj != null) { fc.Alias = obj.ToString(); } } if (row.FieldIndex("FieldType") >= 0) { object obj = row.GetValue(row.FieldIndex("FieldType")); if (obj != null) { gviFieldType ts = 0; if (Enum.TryParse <gviFieldType>(obj.ToString(), out ts)) { fc.FieldType = ts; } else { fc.FieldType = gviFieldType.gviFieldUnknown; } } } if (row.FieldIndex("Length") >= 0) { object obj = row.GetValue(row.FieldIndex("Length")); if (obj != null) { fc.Length = Convert.ToInt32(obj.ToString()); } } if (row.FieldIndex("Nullable") >= 0) { object obj = row.GetValue(row.FieldIndex("Nullable")); if (obj != null) { fc.Nullable = obj.ToString() == "0" ? false : true; } } list.Add(fc); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private bool UpdateFacStyleClass(FacStyleClass style) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle"); if (oc == null) { return(false); } IQueryFilter filter = new QueryFilter() { WhereClause = string.Format("ObjectId = '{0}'", style.ObjectId) }; cursor = oc.Update(filter); row = cursor.NextRow(); if (row != null) { row.SetValue(row.FieldIndex("Name"), style.Name); row.SetValue(row.FieldIndex("FacClassCode"), style.FacClassCode); row.SetValue(row.FieldIndex("ObjectId"), style.ObjectId); row.SetValue(row.FieldIndex("StyleType"), style.Type.ToString()); row.SetValue(row.FieldIndex("StyleInfo"), style.ObjectToJson()); if (style.Thumbnail != null) { try { IBinaryBuffer bb = new BinaryBufferClass(); MemoryStream stream = new MemoryStream(); style.Thumbnail.Save(stream, ImageFormat.Png); bb.FromByteArray(stream.ToArray()); row.SetValue(row.FieldIndex("Thumbnail"), bb); } catch (Exception exception) { } } cursor.UpdateRow(row); return(true); } else { return(false); } } catch (Exception ex) { return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private static List <Plan> SelectPlans(IDataSource ds, string WhereClause) { List <Plan> list = new List <Plan>(); IFdeCursor cursor = null; IRowBuffer row = null; try { if (ds == null) { return(list); } IFeatureDataSet fds = ds.OpenFeatureDataset("UP_PlanLibDs_Indication"); if (fds == null) { return(list); } IObjectClass class2 = fds.OpenObjectClass("UP_Plan"); if (class2 != null) { IQueryFilter filter = new QueryFilter { WhereClause = WhereClause }; IFieldInfoCollection fiCol = class2.GetFields(); cursor = class2.Search(filter, true); while ((row = cursor.NextRow()) != null) { Plan plan = new Plan { PlanID = (row.IsNull(fiCol.IndexOf("oid"))) ? -1 : Convert.ToInt32(row.GetValue(fiCol.IndexOf("oid"))), PlanGuid = (row.IsNull(fiCol.IndexOf("planGuid"))) ? "" : row.GetValue(fiCol.IndexOf("planGuid")).ToString(), PlanName = (row.IsNull(fiCol.IndexOf("planName"))) ? "" : row.GetValue(fiCol.IndexOf("planName")).ToString(), PlanCode = (row.IsNull(fiCol.IndexOf("planCode"))) ? "" : row.GetValue(fiCol.IndexOf("planCode")).ToString(), PlanDesigner = (row.IsNull(fiCol.IndexOf("planDesigner"))) ? "" : row.GetValue(fiCol.IndexOf("planDesigner")).ToString(), PlanState = (row.IsNull(fiCol.IndexOf("planState"))) ? PlanState.None : (PlanState)row.GetValue(fiCol.IndexOf("planState")), ProjectID = (row.IsNull(fiCol.IndexOf("projectID"))) ? -1 : Convert.ToInt32(row.GetValue(fiCol.IndexOf("projectID"))), XOffset = (row.IsNull(fiCol.IndexOf("xOffset"))) ? double.NaN : Convert.ToDouble(row.GetValue(fiCol.IndexOf("xOffset"))), YOffset = (row.IsNull(fiCol.IndexOf("yOffset"))) ? double.NaN : Convert.ToDouble(row.GetValue(fiCol.IndexOf("yOffset"))), Creator = (row.IsNull(fiCol.IndexOf("creator"))) ? "" : row.GetValue(fiCol.IndexOf("creator")).ToString(), CreateTime = (row.IsNull(fiCol.IndexOf("createTime"))) ? DateTime.MinValue : (DateTime)row.GetValue(fiCol.IndexOf("createTime")), AbandonReason = (row.IsNull(fiCol.IndexOf("abandonReason"))) ? "" : row.GetValue(fiCol.IndexOf("abandonReason")).ToString(), Description = (row.IsNull(fiCol.IndexOf("description"))) ? "" : row.GetValue(fiCol.IndexOf("description")).ToString(), Bound = (row.IsNull(fiCol.IndexOf("Bound"))) ? "" : row.GetValue(fiCol.IndexOf("Bound")).ToString(), ConnType = (row.IsNull(fiCol.IndexOf("ConnType"))) ? PlanType.None : (PlanType)row.GetValue(fiCol.IndexOf("ConnType")) }; if (plan.ConnType == PlanType.Network) { list.Add(new NetWorkPlan(plan)); } else { list.Add(new LocalPlan(plan)); } } } return(list); } catch (Exception exception) { } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } return(list); }