コード例 #1
0
ファイル: GxGDBSConnection.cs プロジェクト: secondii/Yutai
        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);
            }
        }
コード例 #2
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 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();
                }
            }
        }
コード例 #3
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();
                }
            }
        }
コード例 #4
0
        /// <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();
                }
            }
        }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: ClassExtensions.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Returns a list of the model names that are assigned to the <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{T}" /> representing the class model names assigned to the object class.
        /// </returns>
        public static IEnumerable <string> GetClassModelNames(this IObjectClass source)
        {
            if (source == null)
            {
                return(null);
            }

            if (ModelNameManager.Instance.CanReadModelNames(source))
            {
                IEnumBSTR names = ModelNameManager.Instance.ClassModelNames(source);
                return(names.AsEnumerable());
            }

            return(null);
        }
コード例 #7
0
 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
     {
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: LineCreateroutes.cs プロジェクト: secondii/Yutai
 public void CreateRoutes(IFeatureClass pLineFC, string InputRouteIDFieldName, string fromMeasureField,
                          string toMeasureField)
 {
     try
     {
         IWorkspace        selectionContainer = (pLineFC as IDataset).Workspace;
         IFeatureClassName outputFClassName   = new FeatureClassNameClass();
         IDataset          dataset            = (IDataset)selectionContainer;
         IWorkspaceName    fullName           = (IWorkspaceName)dataset.FullName;
         IDatasetName      name3 = (IDatasetName)outputFClassName;
         name3.WorkspaceName = fullName;
         name3.Name          = "CreateRoutes";
         IFields      fields            = pLineFC.Fields;
         int          index             = fields.FindField(pLineFC.ShapeFieldName);
         IClone       geometryDef       = (IClone)fields.get_Field(index).GeometryDef;
         IGeometryDef outputGeometryDef = (IGeometryDef)geometryDef.Clone();
         ((ISpatialReference2)outputGeometryDef.SpatialReference).SetMFalseOriginAndUnits(-1000.0, 1000.0);
         IQueryFilter queryFilter = new QueryFilterClass
         {
             WhereClause = "[ROUTE1] <> 0"
         };
         ISelectionSet2 set =
             (ISelectionSet2)
             pLineFC.Select(queryFilter, esriSelectionType.esriSelectionTypeIDSet,
                            esriSelectionOption.esriSelectionOptionNormal, selectionContainer);
         IRouteMeasureCreator creator = new RouteMeasureCreatorClass
         {
             InputFeatureSelection = set,
             InputRouteIDFieldName = InputRouteIDFieldName
         };
         IEnumBSTR mbstr = creator.CreateUsing2Fields(fromMeasureField, toMeasureField, outputFClassName,
                                                      outputGeometryDef, "", null);
         for (string str = mbstr.Next(); str != null; str = mbstr.Next())
         {
         }
     }
     catch (COMException exception)
     {
         MessageBox.Show(exception.Message, "COM Error: " + exception.ErrorCode.ToString(), MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
     catch (Exception exception2)
     {
         MessageBox.Show(exception2.Message, ".NET Error: ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
コード例 #10
0
ファイル: ClassExtensions.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Returns a list of the name of the fields that are assigned the specified <paramref name="modelNames" /> on the
        ///     particiular <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class.</param>
        /// <param name="modelNames">The model names.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{T}" /> representing the name of the fields that are assigned the field model name.
        /// </returns>
        /// <exception cref="ArgumentNullException">modelNames</exception>
        public static IEnumerable <string> GetFieldNames(this IObjectClass source, params string[] modelNames)
        {
            if (modelNames == null)
            {
                throw new ArgumentNullException("modelNames");
            }

            if (ModelNameManager.Instance.CanReadModelNames(source))
            {
                foreach (var modelName in modelNames)
                {
                    IEnumBSTR names = ModelNameManager.Instance.FieldNamesFromModelName(source, modelName);
                    foreach (var name in names.AsEnumerable())
                    {
                        yield return(name);
                    }
                }
            }
        }
コード例 #11
0
ファイル: ClassExtensions.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Returns a list of the name of the fields that are assigned the specified <paramref name="modelName" /> on the
        ///     particiular <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class.</param>
        /// <param name="modelName">The field model name.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{T}" /> representing the name of the fields that are assigned the field model name.
        /// </returns>
        /// <exception cref="ArgumentNullException">modelName</exception>
        public static IEnumerable <string> GetFieldNames(this IObjectClass source, string modelName)
        {
            if (source == null)
            {
                return(null);
            }
            if (modelName == null)
            {
                throw new ArgumentNullException("modelName");
            }

            if (ModelNameManager.Instance.CanReadModelNames(source))
            {
                IEnumBSTR names = ModelNameManager.Instance.FieldNamesFromModelName(source, modelName);
                return(names.AsEnumerable());
            }

            return(null);
        }
コード例 #12
0
ファイル: ClassExtensions.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Returns a list of the model names that are assigned to the <paramref name="field" /> for the specified
        ///     <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class.</param>
        /// <param name="field">The field.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{T}" /> representing the model names assigned to the field.
        /// </returns>
        /// <exception cref="ArgumentNullException">field</exception>
        public static IEnumerable <string> GetFieldModelNames(this IObjectClass source, IField field)
        {
            if (source == null)
            {
                return(null);
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (ModelNameManager.Instance.CanReadModelNames(source))
            {
                IEnumBSTR names = ModelNameManager.Instance.FieldModelNames(source, field);
                return(names.AsEnumerable());
            }

            return(null);
        }
        /// <summary>
        /// Get allowed roles for the user making a request.
        /// </summary>
        /// <returns>set of roles</returns>
        private HashSet <String> GetRoleInformation()
        {
            // Roles set
            HashSet <String> roles = new HashSet <String>();

            try
            {
                /*
                 *  Get the user information.
                 */
                IServerUserInfo userInfo = _restSOIHelper.ServerEnvironment.UserInfo;

                /*
                 *  Get information on the user making the call.
                 */
                String userName = userInfo.Name;

                /*
                 *  Get all roles user belongs to.
                 */
                IEnumBSTR rolesEnum = userInfo.Roles;
                if (rolesEnum != null)
                {
                    String role = rolesEnum.Next();
                    while (!string.IsNullOrEmpty(role))
                    {
                        roles.Add(role);
                        role = rolesEnum.Next();
                    }
                }
                return(roles);
            }
            catch (Exception ignore)
            {
                //TODO error handling
            }
            return(roles);
        }
コード例 #14
0
ファイル: GxAGSConnection.cs プロジェクト: secondii/Yutai
 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, "");
     }
 }
コード例 #15
0
 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();
     }
 }
コード例 #16
0
ファイル: StyleUtils.cs プロジェクト: arcpad/epsgis
        /// <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);
        }
コード例 #17
0
ファイル: frmStyleConvertEx.cs プロジェクト: secondii/Yutai
 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();
     }
 }
コード例 #18
0
        /// <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);
        }
コード例 #19
0
        private byte[] ExecuteStoredProcedureHandler(NameValueCollection boundVariables,
                                                     JsonObject operationInput,
                                                     string outputFormat,
                                                     string requestProperties,
                                                     out string responseProperties)
        {
            responseProperties = null;
            string retString = "";

            try
            {
                //return Encoding.UTF8.GetBytes(retStrn);
                //return null;

                string pipeDelimetedStringValuePairsForStoredProc = "";
                bool   found = operationInput.TryGetString("ParamValuePairs", out pipeDelimetedStringValuePairsForStoredProc);
                if (!found || string.IsNullOrEmpty(pipeDelimetedStringValuePairsForStoredProc))
                {
                    throw new ArgumentNullException("ParamValuePairs");
                }

                string extra;
                found = operationInput.TryGetString("Extra", out extra);
                if (!found || string.IsNullOrEmpty(extra))
                {
                    throw new ArgumentNullException("extra");
                }

                responseProperties = null;
                IServerEnvironment3 senv    = GetServerEnvironment() as IServerEnvironment3;
                JsonObject          result  = new JsonObject();
                JsonObject          suinfoj = new JsonObject();
                //get user info and serialize into JSON
                IServerUserInfo suinfo = senv.UserInfo;
                if (null != suinfo)
                {
                    suinfoj.AddString("currentUser", suinfo.Name);

                    IEnumBSTR     roles    = suinfo.Roles;
                    List <string> rolelist = new List <string>();
                    if (null != roles)
                    {
                        string role = roles.Next();
                        while (!string.IsNullOrEmpty(role))
                        {
                            rolelist.Add(role);
                            role = roles.Next();
                        }
                    }

                    suinfoj.AddArray("roles", rolelist.ToArray());
                    result.AddJsonObject("serverUserInfo", suinfoj);
                }
                else
                {
                    result.AddJsonObject("serverUserInfo", null);
                }

                IServerObject so = serverObjectHelper.ServerObject;
                retString = "got so>";

                string progString = "";
                retString += "> Stored Proc via oleDB ";// + ex.Message;
                OleDbConnection con = new OleDbConnection();
                string          paramsThatParsed = "";



                con.ConnectionString = @"Provider =SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" + extra.Split(',')[0] + ";Data Source=" + extra.Split(',')[1];// @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TestDB;Data Source=PC684"; //
                string storedProcedureName = "dbo.apLITSaveChanges";
                bool   isStatusOutput      = Convert.ToBoolean(extra.Split(',')[2]);
                //the connection string below uses integrated security which is usually superior to storing credential in visible text
                //con.ConnectionString = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TestDB;Data Source=PC684";
                //con.Open();
                //retString += ">opened connection";
                string       SQLString = "";
                OleDbCommand cmd       = new OleDbCommand(storedProcedureName, con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                string userName = "******";
                if (suinfo.Name != null)
                {
                    userName = suinfo.Name;
                }
                cmd.Parameters.AddWithValue("@WindowsLogin", userName);
                SQLString += "@WindowsLogin='******'";
                //SQLString += "@WindowsLogin="******">created command";
                string[] paramValsForStoredProc = pipeDelimetedStringValuePairsForStoredProc.Split('|');
                foreach (string paramVal in paramValsForStoredProc)
                {
                    string param = paramVal.Split(',')[0];
                    paramsThatParsed += "," + param;
                    string val = paramVal.Split(',')[1];
                    retString += ">param and value : " + param + " = " + val;

                    param = "@" + param;
                    if (param.ToUpper().Contains("GEOLOCID"))
                    {
                        int i = int.Parse(val);
                        cmd.Parameters.AddWithValue(param, i);
                        SQLString += ", " + param + "= " + i;
                    }
                    else if (param.ToUpper() == "@LATITUDE" || param.ToUpper() == "@LONGITUDE")
                    {
                        double d = double.Parse(val);
                        cmd.Parameters.AddWithValue(param, d);
                        SQLString += ", " + param + "=  " + d;
                    }
                    else if (param.ToUpper() == "@STATUS")
                    {
                        if (isStatusOutput)
                        {
                            //cmd.Parameters[param].Direction = ParameterDirection.Output;
                            retString += ">Set direction of status parameter to output";
                            SQLString += ", @STATUS = @localstatus OUTPUT";
                        }
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue(param, val);
                        //SQLString += ", " + param + "=  " + val ;
                        SQLString += ", " + param + "=  '" + val + "'";
                    }
                }//CurGeoLocID,NewGeoLocID,Address,City,ZipCode,Latitude,Longitude,FacilityName,AppID,WindowsLogin,ServerName,ServerName,Status
                SQLString = "exec dbo.apLITSaveChanges " + SQLString;
                if (isStatusOutput)
                {
                    SQLString = "DECLARE @localstatus varchar(256);" + SQLString;
                }
                string retStrn = UseAOToCreateUpdateFeatures(SQLString);
                return(Encoding.UTF8.GetBytes(retStrn));

                return(null);

                cmd.Connection = con;
                cmd.ExecuteNonQuery();

                return(Encoding.UTF8.GetBytes(result.ToJson() + "  -  " + retString.ToString()));
            }
            catch (Exception ex)
            {
                return(Encoding.UTF8.GetBytes("ERROR   " + ex.ToString() + "  :  " + retString.ToString()));
            }
        }