public void Connect() { this.idataServerManager_0.Connect(); IEnumBSTR geodatabaseNames = (this.idataServerManager_0 as IDataServerManagerAdmin).GetGeodatabaseNames(); geodatabaseNames.Reset(); for (string str = geodatabaseNames.Next(); str != null; str = geodatabaseNames.Next()) { IGxObject obj2 = new GxGDSGeodatabase(str, this.idataServerManager_0); obj2.Attach(this, this.igxCatalog_0); } }
/// <summary> /// Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumBSTR" /> /// </summary> /// <param name="source">An <see cref="IEnumBSTR" /> to create an <see cref="IEnumerable{T}" /> from.</param> /// <returns>An <see cref="IEnumerable{T}" /> that contains the values from the input source.</returns> public static IEnumerable <string> AsEnumerable(this IEnumBSTR source) { if (source != null) { source.Reset(); string name = source.Next(); while (name != null) { yield return(name); name = source.Next(); } } }
/// <summary> /// Converts an Esri enumerable interface to a DotNet IEnumerable. /// </summary> /// <param name="esriEnum">An enumerable Esri interface.</param> /// <returns>The adapted dotnet enumeration.</returns> public static IEnumerable <string> Enumerate(this IEnumBSTR esriEnum) { if (esriEnum != null) { esriEnum.Reset(); string esriEnumItem = esriEnum.Next(); while (esriEnumItem != null) { yield return(esriEnumItem); esriEnumItem = esriEnum.Next(); } } }
/// <summary> /// Creates an <see cref="IEnumerable{T}"/> from an <see cref="IEnumBSTR"/> /// </summary> /// <param name="source">An <see cref="IEnumBSTR"/> to create an <see cref="IEnumerable{T}"/> from.</param> /// <returns>An <see cref="IEnumerable{T}"/> that contains the strings from the input source.</returns> public static IEnumerable <string> ToEnumerable(this IEnumBSTR source) { if (source != null) { source.Reset(); string str = source.Next(); while (str != null) { yield return(str); str = source.Next(); } } }
private static void TestWorkspaceKeywords(IFeatureWorkspace ws) { var wsSyntax = (ISQLSyntax)ws; IEnumBSTR keys = wsSyntax.GetKeywords(); keys.Reset(); for (string key = keys.Next(); key != null; key = keys.Next()) { Console.Write(key); Console.Write(@";"); } Console.WriteLine(); }
private void ReadCategories(string className) { try { IEnumBSTR mbstr = this.m_pSG.get_Categories(className); mbstr.Reset(); for (string str = mbstr.Next(); str != null; str = mbstr.Next()) { this.comboBoxEdit.Properties.Items.Add(str); } } catch { } }
private void demo2(string CurrentStyleFile, string CurrentStyleGalleryClass) { IStyleGallery pStyleGallery = new ServerStyleGalleryClass(); IStyleGalleryStorage pStyleGalleryStorage; pStyleGalleryStorage = pStyleGallery as IStyleGalleryStorage; //增加符号文件 pStyleGalleryStorage.AddFile(CurrentStyleFile); //根据当前符号的类别和文件得到符号的枚举循环 //符号类别包括Fill Symbol,Line Symbol等 IEnumStyleGalleryItem mEnumStyleItem; mEnumStyleItem = pStyleGallery.get_Items(CurrentStyleGalleryClass, CurrentStyleFile, ""); //得到符号文件类别的各个条目,增加到一个Combox中 IEnumBSTR pEnumBSTR = pStyleGallery.get_Categories(CurrentStyleGalleryClass); pEnumBSTR.Reset(); string Category = ""; Category = pEnumBSTR.Next(); while (Category != null) { //cbxCategory.Items.Add(Category); Category = pEnumBSTR.Next(); } //得到各个符号并转化为图片 mEnumStyleItem.Reset(); IStyleGalleryItem mStyleItem = mEnumStyleItem.Next(); int ImageIndex = 0; IStyleGalleryClass mStyleClass = new FillSymbolStyleGalleryClassClass(); while (mStyleItem != null) { //调用另一个类的方法将符号转化为图片 Bitmap bmpB = StyleGalleryItemToBmp(32, 32, mStyleClass, mStyleItem); Bitmap bmpS = StyleGalleryItemToBmp(16, 16, mStyleClass, mStyleItem); Largeimage.Images.Add(bmpB); Smallimage.Images.Add(bmpS); ListViewItem lvItem = new ListViewItem(new string[] { mStyleItem.Name, mStyleItem.ID.ToString(), mStyleItem.Category }, ImageIndex); this.lvRendererFields.Items.Add(lvItem); mStyleItem = mEnumStyleItem.Next(); ImageIndex++; } //必须采用此方式进行释放,第二次才能正常读取 System.Runtime.InteropServices.Marshal.ReleaseComObject(mEnumStyleItem); }
private void btnConvert_Click(object sender, EventArgs e) { if (this.listBox1.Items.Count == 0) { MessageBox.Show("请选择要转换的源符号库"); } else if (this.txtDest.Text.Length == 0) { MessageBox.Show("请输入转出目录"); } else { IStyleGallery gallery; int num3; string str; SaveFileDialog dialog = new SaveFileDialog { FileName = this.txtDest.Text }; Stream stream = dialog.OpenFile(); if (stream != null) { Stream manifestResourceStream; int num; if (!this.m_IsStyleFile) { manifestResourceStream = base.GetType() .Assembly.GetManifestResourceStream( "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.style"); } else { manifestResourceStream = base.GetType() .Assembly.GetManifestResourceStream( "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.ServerStyle"); } byte[] buffer = new byte[4096]; while ((num = manifestResourceStream.Read(buffer, 0, 4096)) > 0) { stream.Write(buffer, 0, num); } stream.Close(); } if (this.m_IsStyleFile) { gallery = new ServerStyleGalleryClass(); num3 = (gallery as IStyleGalleryStorage).FileCount - 1; while (num3 >= 0) { str = (gallery as IStyleGalleryStorage).get_File(num3); (gallery as IStyleGalleryStorage).RemoveFile(str); num3--; } } else { gallery = new MyStyleGallery(); } gallery.Clear(); (gallery as IStyleGalleryStorage).TargetFile = this.txtDest.Text; foreach (object obj2 in this.listBox1.Items) { try { IStyleGallery gallery2; if (this.m_IsStyleFile) { gallery2 = new MyStyleGallery(); } else { gallery2 = new ServerStyleGalleryClass(); num3 = (gallery2 as IStyleGalleryStorage).FileCount - 1; while (num3 >= 0) { str = (gallery2 as IStyleGalleryStorage).get_File(num3); (gallery2 as IStyleGalleryStorage).RemoveFile(str); num3--; } } gallery2.Clear(); (gallery2 as IStyleGalleryStorage).AddFile(obj2.ToString()); for (num3 = 0; num3 < gallery2.ClassCount; num3++) { string name = gallery2.get_Class(num3).Name; IEnumBSTR mbstr = gallery2.get_Categories(name); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(obj2.ToString()); mbstr.Reset(); for (string str4 = mbstr.Next(); str4 != null; str4 = mbstr.Next()) { IEnumStyleGalleryItem item = gallery2.get_Items(name, obj2.ToString(), str4); item.Reset(); IStyleGalleryItem item2 = null; try { item2 = item.Next(); } catch { } while (item2 != null) { string str6; if (this.m_IsStyleFile) { IStyleGalleryItem item3 = new ServerStyleGalleryItemClass(); object obj3 = item2.Item; item3.Item = obj3; string str5 = item2.Name; item3.Name = str5; if (item2.Category.Length > 0) { str6 = fileNameWithoutExtension + "_" + item2.Category; item3.Category = str6; } else { item3.Category = fileNameWithoutExtension; } try { string defaultStylePath = (gallery as IStyleGalleryStorage).DefaultStylePath; int fileCount = (gallery as IStyleGalleryStorage).FileCount; gallery.AddItem(item3); } catch (Exception) { } } else { if (item2.Category.Length > 0) { str6 = fileNameWithoutExtension + "_" + item2.Category; item2.Category = str6; } else { item2.Category = fileNameWithoutExtension; } gallery.AddItem(item2); } try { item2 = item.Next(); } catch { } } } } (gallery2 as IStyleGalleryStorage).RemoveFile(obj2.ToString()); } catch (Exception) { } } try { (gallery as IStyleGalleryStorage).RemoveFile(this.txtDest.Text); } catch { } base.Close(); } }
/// <summary> /// 读取ServerStyle中的文件并显示 /// </summary> /// <param name="StyleGalleryClass">符号文件的种类</param> /// <param name="CategoryClass">符号的种类</param> /// <param name="cbxCategory">符号文件的种类的容器</param> /// <param name="lvSymbol">符号位图的容器</param> public static void ReadServerStyle(string StyleGalleryClass, string CategoryClass, ComboBox cbxCategory, ListView lvSymbol) { lvSymbol.Items.Clear(); lvSymbol.LargeImageList.Images.Clear(); IStyleGallery pStyleGallery = new ServerStyleGalleryClass(); IStyleGalleryStorage pStyleGalleryStorage = pStyleGallery as IStyleGalleryStorage; // 增加符号文件 //pStyleGalleryStorage.TargetFile = _STYLEFILE; for (int i = pStyleGalleryStorage.FileCount - 1; i >= 0; i--) { pStyleGalleryStorage.RemoveFile(pStyleGalleryStorage.get_File(i)); } pStyleGalleryStorage.AddFile(_STYLEFILE); // 根据当前符号的类别和文件得到符号的枚举循环子,符号类别包括Fill Symbol,Line Symbol等 IEnumStyleGalleryItem pEnumStyleItem = pStyleGallery.get_Items(StyleGalleryClass, _STYLEFILE, ""); // 得到符号文件类别的各个条目,增加到一个Combox中 if (cbxCategory != null) { cbxCategory.Items.Clear(); cbxCategory.Items.Add(_ALLSYMBOLS); IEnumBSTR pEnumBSTR = pStyleGallery.get_Categories(StyleGalleryClass); pEnumBSTR.Reset(); string Category = ""; Category = pEnumBSTR.Next(); while (Category != null) { cbxCategory.Items.Add(Category); Category = pEnumBSTR.Next(); } } pEnumStyleItem.Reset(); IStyleGalleryItem mStyleItem = pEnumStyleItem.Next(); IStyleGalleryClass mStyleClass = null; for (int i = 0; i < pStyleGallery.ClassCount; i++) { mStyleClass = pStyleGallery.get_Class(i); string str = mStyleClass.Name; if (str == StyleGalleryClass) { break; } } // 得到各个符号并转化为图片 int ImageIndex = 0; ImageList Largeimage = lvSymbol.LargeImageList; if (CategoryClass == "" || CategoryClass == _ALLSYMBOLS) { while (mStyleItem != null) { // 调用另一个类的方法将符号转化为图片 Bitmap bmpB = StyleGalleryItemToBmp(32, 32, mStyleClass, mStyleItem); Largeimage.Images.Add(bmpB); ListViewItem lvItem = new ListViewItem(new string[] { mStyleItem.Name, mStyleItem.ID.ToString(), mStyleItem.Category }, ImageIndex); lvSymbol.Items.Add(lvItem); ImageIndex++; mStyleItem = pEnumStyleItem.Next(); } } else { while (mStyleItem != null) { if (CategoryClass == mStyleItem.Category) { // 调用另一个类的方法将符号转化为图片 Bitmap bmpB = StyleGalleryItemToBmp(32, 32, mStyleClass, mStyleItem); Largeimage.Images.Add(bmpB); ListViewItem lvItem = new ListViewItem(new string[] { mStyleItem.Name, mStyleItem.ID.ToString(), mStyleItem.Category }, ImageIndex); lvSymbol.Items.Add(lvItem); ImageIndex++; } mStyleItem = pEnumStyleItem.Next(); } } // 必须采用此方式进行释放,第二次才能正常读取 System.Runtime.InteropServices.Marshal.ReleaseComObject(pEnumStyleItem); }
private void btnConvert_Click(object sender, EventArgs e) { if (this.listBox1.Items.Count == 0) { MessageBox.Show("请选择要转换的源符号库"); } else if (this.txtDest.Text.Length == 0) { MessageBox.Show("请输入转出目录"); } else { this.Cursor = Cursors.WaitCursor; foreach (object obj2 in this.listBox1.Items) { try { string path = obj2.ToString(); SaveFileDialog dialog = new SaveFileDialog(); string str2 = ".style"; if (this.m_IsStyleFile) { str2 = ".ServerStyle"; } string str3 = Path.Combine(this.txtDest.Text, Path.GetFileNameWithoutExtension(path) + str2); if (File.Exists(str3)) { File.Delete(str3); } dialog.FileName = str3; Stream stream = dialog.OpenFile(); if (stream != null) { Stream manifestResourceStream; int num; IStyleGallery gallery; IStyleGallery gallery2; int num3; string str4; if (!this.m_IsStyleFile) { manifestResourceStream = base.GetType() .Assembly.GetManifestResourceStream( "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.style"); } else { manifestResourceStream = base.GetType() .Assembly.GetManifestResourceStream( "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.ServerStyle"); } byte[] buffer = new byte[4096]; while ((num = manifestResourceStream.Read(buffer, 0, 4096)) > 0) { stream.Write(buffer, 0, num); } stream.Close(); if (this.m_IsStyleFile) { gallery = new MyStyleGallery(); gallery2 = new ServerStyleGalleryClass(); num3 = (gallery2 as IStyleGalleryStorage).FileCount - 1; while (num3 >= 0) { str4 = (gallery2 as IStyleGalleryStorage).get_File(num3); (gallery2 as IStyleGalleryStorage).RemoveFile(str4); num3--; } } else { gallery = new ServerStyleGalleryClass(); gallery2 = new MyStyleGallery(); num3 = (gallery as IStyleGalleryStorage).FileCount - 1; while (num3 >= 0) { str4 = (gallery as IStyleGalleryStorage).get_File(num3); (gallery as IStyleGalleryStorage).RemoveFile(str4); num3--; } } gallery.Clear(); gallery2.Clear(); (gallery as IStyleGalleryStorage).AddFile(path); (gallery2 as IStyleGalleryStorage).TargetFile = str3; for (num3 = 0; num3 < gallery.ClassCount; num3++) { string name = gallery.get_Class(num3).Name; IEnumBSTR mbstr = gallery.get_Categories(name); mbstr.Reset(); for (string str6 = mbstr.Next(); str6 != null; str6 = mbstr.Next()) { IEnumStyleGalleryItem item = gallery.get_Items(name, path, str6); item.Reset(); IStyleGalleryItem item2 = null; try { item2 = item.Next(); } catch { } while (item2 != null) { if (this.m_IsStyleFile) { IStyleGalleryItem item3 = new ServerStyleGalleryItemClass(); object obj3 = item2.Item; item3.Item = obj3; string str7 = item2.Name; item3.Name = str7; string category = item2.Category; item3.Category = category; gallery2.AddItem(item3); } else { gallery2.AddItem(item2); } try { item2 = item.Next(); } catch { } } } } (gallery as IStyleGalleryStorage).RemoveFile(path); (gallery2 as IStyleGalleryStorage).RemoveFile(str3); } } catch (Exception) { } } this.Cursor = Cursors.Default; base.Close(); } }
/// <summary> /// 保存发生更新变化的所有的要素信息 /// </summary> /// <param name="eError"></param> /// <returns></returns> public Dictionary <string, Dictionary <int, List <IRow> > > GetModifyClsInfo(out Exception eError) { eError = null; Dictionary <string, Dictionary <int, List <IRow> > > feaChangeDic = null; //获得命名空间下发生变化的信息 IWorkspaceEdit2 pWSEdit2 = v_WSEdit as IWorkspaceEdit2; if (pWSEdit2 == null) { eError = new Exception("编辑工作空间为空!"); return(null); } //获取在一个编辑会话中发生更新变化数据 IDataChangesEx pDataChangeEx = pWSEdit2.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinSession); if (pDataChangeEx == null) { eError = new Exception("未发现更新变化数据!"); return(null); } feaChangeDic = new Dictionary <string, Dictionary <int, List <IRow> > >(); //获取发生更新变化的要素类集合 IEnumBSTR pEnumString = pDataChangeEx.ModifiedClasses; //发生变化的要素类 pEnumString.Reset(); string pModifyClsName = "";//发生更新变化的要素类名称 pModifyClsName = pEnumString.Next(); //遍历发生更新变化的要素类,并将相关信息保存下来 while (pModifyClsName != null) { IDifferenceCursorEx pDifCusorEx = null; //游标 int pFeaOid = -1; //要素OID IRow pSourceRow = null; //正在编辑的冲突要素行 IRow pDifRow = null; //上一编辑版本的冲突要素行 ILongArray pDifIndices = null; //字段索引 if (pModifyClsName.Contains(".")) { pModifyClsName = pModifyClsName.Substring(pModifyClsName.IndexOf('.') + 1); } Dictionary <int, List <IRow> > stateRowDic = new Dictionary <int, List <IRow> >(); List <IRow> rowLst = null; #region 保存新增加的要素信息 rowLst = new List <IRow>(); //新增数据游标 pDifCusorEx = pDataChangeEx.ExtractEx(pModifyClsName, esriDifferenceType.esriDifferenceTypeInsert); if (pDifCusorEx == null) { eError = new Exception("获取新增数据的游标发生错误!"); return(null); } pDifCusorEx.Next(out pFeaOid, out pSourceRow, out pDifRow, out pDifIndices);//pDifRow=null //遍历新增加的要素oid,并将其保存起来 while (pFeaOid != -1) { //将新增数据保存起来 if (!rowLst.Contains(pSourceRow)) { rowLst.Add(pSourceRow); } pDifCusorEx.Next(out pFeaOid, out pSourceRow, out pDifRow, out pDifIndices); } if (rowLst != null) { if (rowLst.Count > 0) { stateRowDic.Add(1, rowLst); } } #endregion #region 保存修改后的要素信息 rowLst = new List <IRow>(); //修改数据游标 pDifCusorEx = pDataChangeEx.ExtractEx(pModifyClsName, esriDifferenceType.esriDifferenceTypeUpdateNoChange); if (pDifCusorEx == null) { eError = new Exception("获取修改数据的游标发生错误!"); return(null); } pDifCusorEx.Next(out pFeaOid, out pSourceRow, out pDifRow, out pDifIndices); //遍历修改后的要素OID,并将其保存起来 while (pFeaOid != -1) { //将修改后的数据保存起来 if (!rowLst.Contains(pSourceRow)) { rowLst.Add(pSourceRow); } pDifCusorEx.Next(out pFeaOid, out pSourceRow, out pDifRow, out pDifIndices); } if (rowLst != null) { if (rowLst.Count > 0) { stateRowDic.Add(2, rowLst); } } #endregion #region 保存删除的要素信息 rowLst = new List <IRow>(); //删除数据游标 pDifCusorEx = pDataChangeEx.ExtractEx(pModifyClsName, esriDifferenceType.esriDifferenceTypeDeleteNoChange); if (pDifCusorEx == null) { eError = new Exception("获取删除数据的游标发生错误!"); return(null); } pDifCusorEx.Next(out pFeaOid, out pSourceRow, out pDifRow, out pDifIndices);//pSourceRow //遍历删除的要素OID,并将其保存起来 while (pFeaOid != -1) { //将删除的数据保存起来(数据库版本数据) if (!rowLst.Contains(pDifRow)) { rowLst.Add(pDifRow); } pDifCusorEx.Next(out pFeaOid, out pSourceRow, out pDifRow, out pDifIndices); } if (rowLst != null) { if (rowLst.Count > 0) { stateRowDic.Add(3, rowLst); } } #endregion if (!feaChangeDic.ContainsKey(pModifyClsName)) { feaChangeDic.Add(pModifyClsName, stateRowDic); } pModifyClsName = pEnumString.Next(); } return(feaChangeDic); }
private void method_1() { try { object obj2; object obj3; IGxObject obj4; this.ipropertySet_0.GetAllProperties(out obj2, out obj3); string[] strArray = (string[])obj2; if ((strArray.Length == 6) && (strArray[1] == "MANAGERURL")) { obj4 = new GxAddAGSObject(); obj4.Attach(this, this.igxCatalog_0); } if (this.iagsserverConnection2_0 != null) { IEnumBSTR folders = this.iagsserverConnection2_0.GetFolders(""); folders.Reset(); for (string str = folders.Next(); str != null; str = folders.Next()) { IGxServersFolder folder = new GxServersFolder { AGSServerConnection = this.iagsserverConnection2_0, FolderName = str }; (folder as IGxObject).Attach(this, this.igxCatalog_0); } IAGSEnumServerObjectName name = this.iagsserverConnection2_0.get_ServerObjectNamesEx(""); name.Reset(); for (IAGSServerObjectName name2 = name.Next(); name2 != null; name2 = name.Next()) { bool flag; if (name2.Type.ToLower() == "mapserver") { if (this.method_0(name2.Name)) { obj4 = new GxAGSMap(); (obj4 as IGxAGSObject).AGSServerObjectName = name2; flag = true; if ((this.ConnectionMode == 0) && ((obj4 as IGxAGSObject).Status != "Started")) { flag = false; } if (flag) { obj4.Attach(this, this.igxCatalog_0); } } } else if (name2.Type.ToLower() == "gpserver") { if (this.method_0(name2.Name)) { obj4 = new GxGPServer(); (obj4 as IGxAGSObject).AGSServerObjectName = name2; flag = true; if ((this.ConnectionMode == 0) && ((obj4 as IGxAGSObject).Status != "Started")) { flag = false; } if (flag) { obj4.Attach(this, this.igxCatalog_0); } } } else if (name2.Type.ToLower() == "featureserver") { if (this.ConnectionMode == 0) { obj4 = new GxFeatureService(); (obj4 as IGxAGSObject).AGSServerObjectName = name2; if ((obj4 as IGxAGSObject).Status == "Started") { obj4.Attach(this, this.igxCatalog_0); } } } else if ((name2.Type.ToLower() == "geometryserver") && (this.ConnectionMode > 0)) { obj4 = new GxGeometryServer(); (obj4 as IGxAGSObject).AGSServerObjectName = name2; obj4.Attach(this, this.igxCatalog_0); } } } } catch (Exception exception) { MessageBox.Show(exception.Message); Logger.Current.Error("", exception, ""); } }