Exemplo n.º 1
0
        public static void CheckOutLicense()
        {
            if (!RuntimeManager.Bind(ProductCode.EngineOrDesktop))
            {
                MessageBox.Show("不能绑定ArcGIS runtime,应用程序即将关闭.");
                return;
            }
            IAoInitialize aoInit = new AoInitialize();

            try
            {
                aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
            }
            catch (Exception ex) {
                Logger.log("CheckOutLicense", ex);
            }
            //esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
            //censeStatus = aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
            //aoInit.CheckOutExtension(esriLicenseExtensionCode.);
            //esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB;
            //if (aoInit.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable)
            //{
            //    aoInit.Initialize(productCode);
            //}
        }
Exemplo n.º 2
0
        static void Main()
        {
            //指定arcgis 版本
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                MessageBox.Show("未找到Arcgis Engine。");
                return;
            }
            //初始化Arcgis授权
            AoInitialize      init   = new AoInitialize();
            esriLicenseStatus status = init.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);

            //程序初始化
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Application.Run(new FormBdcMain());

            FormLogin loginForm = new FormLogin();

            if (loginForm.ShowDialog() == DialogResult.OK)
            {
                Application.Run(new FormMain());
            }
            else
            {
                Application.Exit();
            }
        }
Exemplo n.º 3
0
 protected override void OnStartup(StartupEventArgs e)
 {
     StartupUri = new Uri("MainWindow.xaml", UriKind.RelativeOrAbsolute);
     base.OnStartup(e);
     RuntimeManager.Bind(ProductCode.EngineOrDesktop);
     InitializeEngineLicense();
 }
Exemplo n.º 4
0
        void BindingArcGISRuntime(object sender, EventArgs e)
        {
            //
            // Modify ArcGIS runtime binding code as needed; for example,
            // the list of products and their binding preference order.
            //
            ProductCode[] supportedRuntimes = UsedRunTime;

            foreach (ProductCode c in supportedRuntimes)
            {
                sbLog.Append($"Binding to ArcGIS Runtime: {c} ");
                if (RuntimeManager.Bind(c))
                {
                    sbLog.AppendLine("Success.");
                    return;
                }
                sbLog.AppendLine("Fail.");
            }

            //
            // Modify the code below on how to handle bind failure
            //

            // Failed to bind, announce and force exit
            Console.WriteLine("ArcGIS runtimes binding failed.");
            OnBindingArcGISRuntimeFail?.Invoke(this, EventArgs.Empty);
            //System.Environment.Exit(0);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    System.Console.WriteLine("ArcGIS runtime:unable to bind to arcgis runtime.application will be shut down.");
                    return;
                }
            }
            if (args == null || args.Length == 0)
            {
                System.Console.WriteLine("未获取文件夹路径,请联系相关人员!");
                return;
            }
            var folder = args[0];

            if (!System.IO.Directory.Exists(folder))
            {
                System.Console.WriteLine("当前检查文件及路径不存在,请核对文件夹路径!");
                return;
            }
            var ids = args.Skip(1).ToArray();

            System.Console.WriteLine(string.Format("开始质检路径:{0}", folder));
            var workbench = new WorkBench.WorkBench()
            {
                Folder = folder, IDS = ids
            };

            workbench.Program();
            QuestionManager.Save(workbench.ReportPath, workbench.District, workbench.Code);

            System.Console.WriteLine("结束");
        }
Exemplo n.º 6
0
        private static void TryBindProduct(ProductCode productCode)
        {
            try
            {
                // NOTE: InstalledRuntimes can be accessed before binding.
                foreach (RuntimeInfo runtimeInfo in RuntimeManager.InstalledRuntimes)
                {
                    _msg.DebugFormat("Installed product: {0} {1} in {2}",
                                     runtimeInfo.Product,
                                     runtimeInfo.Version,
                                     runtimeInfo.Path);
                }

                if (!RuntimeManager.Bind(productCode))
                {
                    throw new InvalidOperationException("Unable to bind ArcGIS Product.");
                }

                _msg.DebugFormat("Bound product '{0}'", productCode);
            }
            catch (Exception e)
            {
                _msg.Debug("Binding to ArcGIS 10 product failed.", e);
            }
        }
Exemplo n.º 7
0
        public void InitTest()
        {
            RuntimeManager.Bind(ProductCode.Desktop);
            AoInitialize aoInit = new AoInitializeClass();

            aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
        }
        void BindingArcGISRuntime(object sender, EventArgs e)
        {
            //
            // TODO: Modify ArcGIS runtime binding code as needed; for example,
            // the list of products and their binding preference order.
            //
            ProductCode[] supportedRuntimes = new ProductCode[] {
                ProductCode.Engine, ProductCode.Desktop
            };
            foreach (ProductCode c in supportedRuntimes)
            {
                if (RuntimeManager.Bind(c))
                {
                    return;
                }
            }

            //
            // TODO: Modify the code below on how to handle bind failure
            //

            // Failed to bind, announce and force exit
            Console.WriteLine("ArcGIS runtime binding failed. Application will shut down.");
            System.Environment.Exit(0);
        }
Exemplo n.º 9
0
 static void Main()
 {
     Application.EnableVisualStyles();
     RuntimeManager.Bind(ProductCode.EngineOrDesktop);
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new FormDataDocking());
 }
Exemplo n.º 10
0
        private static void Main()
        {
            Thread.CurrentThread.CurrentUICulture =
                new CultureInfo("zh-Hans");

            // The following line provides localization for data formats.
            Thread.CurrentThread.CurrentCulture =
                new CultureInfo("zh-Hans");


            IConfigurationSource config = new XmlConfigurationSource("ARConfig.xml");

            var asm = Assembly.Load("LibEntity");

            ActiveRecordStarter.Initialize(asm, config);
            Log.Debug("[WM]....Starting...");
            RuntimeManager.Bind(ProductCode.EngineOrDesktop);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var mf = new MainFormWm();

            Log.Debug("[WM]....Main Form Construction Finished...");
            var lf = new LoginForm(mf);

            Application.Run(lf);
        }
Exemplo n.º 11
0
        static void Main()
        {
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }

            IAoInitialize     m_AoInitialize = new AoInitializeClass();
            esriLicenseStatus licenseStatus  = esriLicenseStatus.esriLicenseUnavailable;

            licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
            if (licenseStatus == esriLicenseStatus.esriLicenseNotInitialized)
            {
                MessageBox.Show("没有esriLicenseProductCodeArcInfo许可!");
                Application.Exit();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Exemplo n.º 12
0
 static void Main()
 {
     RuntimeManager.Bind(ProductCode.Engine);
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(FormHolder.GetInstance);
 }
Exemplo n.º 13
0
        public static void Initialize()
        {
            RuntimeManager.Bind(ProductCode.EngineOrDesktop);
            IAoInitialize iao = new AoInitialize();

            iao.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            RuntimeManager.Bind(ProductCode.EngineOrDesktop);
            IMapDocument imd = new MapDocument();

            imd.Open(@"C:\test\pzhmxd\phq.mxd");
            var m0       = imd.Map[0];
            var emLayers = m0.Layers;

            ILayer layer;

            while ((layer = emLayers.Next()) != null)
            {
                Console.WriteLine(String.Format("{0} {1}", layer.Name, layer.Valid));
                //if(   (layer as IFeatureLayer2)  )
                //var ifl = ((IFeatureLayer)layer);
                //var fc = ifl.FeatureClass;
                //var igfl = layer as IGeoFeatureLayer;
                //var igflfc = igfl.FeatureClass;
                var dsn = ((layer as IDataLayer2).DataSourceName);
                //var ifc = (dsn.Open() as IFeatureClass);
                //var tryobj = dsn.Open().GetType();
                //Console.WriteLine(ifl.FeatureClass);
                //Console.WriteLine(fc.FeatureCount(null));
                //var ws = (layer as IGeoFeatureLayer).FeatureClass.FeatureDataset.Workspace;
                //Console.WriteLine(ws.ConnectionProperties.GetProperty("INSTANCE"));
            }
        }
Exemplo n.º 15
0
        private static IPropertySet GetPropertySet()
        {
            RuntimeManager.Bind(ProductCode.EngineOrDesktop);
            (new AoInitializeClass()).Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
            IPropertySet propertySet = new PropertySetClass();

            try
            {
                string ServerName   = ConfigurationManager.AppSettings["ServerName"].ToString();
                string InstanceName = ConfigurationManager.AppSettings["InstanceName"].ToString();
                string DBName       = ConfigurationManager.AppSettings["DatabaseName"].ToString();
                string UserName     = ConfigurationManager.AppSettings["UserName"].ToString();
                string UserPassword = ConfigurationManager.AppSettings["UserPassword"].ToString();
                propertySet.SetProperty("Server", ServerName);
                propertySet.SetProperty("Instance", InstanceName);
                propertySet.SetProperty("Database", DBName);
                propertySet.SetProperty("user", UserName);
                propertySet.SetProperty("password", UserPassword);
                propertySet.SetProperty("version", "MSD.QC");
            }
            catch (Exception exception)
            {
                Exception ee = exception;
                Assets.logger.Debug(string.Concat("Error from GetPropertySet :", ee.Message, " ", ee.StackTrace));
            }
            return(propertySet);
        }
Exemplo n.º 16
0
Arquivo: Program.cs Projeto: jin111/RS
        static void Main()
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB },
                                                         new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst, esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork, esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst, esriLicenseExtensionCode.esriLicenseExtensionCodeSchematics, esriLicenseExtensionCode.esriLicenseExtensionCodeMLE, esriLicenseExtensionCode.esriLicenseExtensionCodeDataInteroperability, esriLicenseExtensionCode.esriLicenseExtensionCodeTracking });
            //ESRI License Initializer generated code.

            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());


            //ESRI License Initializer generated code.
            //Do not make any call to ArcObjects after ShutDownApplication()
            m_AOLicenseInitializer.ShutdownApplication();
        }
Exemplo n.º 17
0
 public static bool Initialize()
 {
     if (!RuntimeManager.Bind(ProductCode.Engine) && !RuntimeManager.Bind(ProductCode.Desktop))
     {
         return(false);
     }
     return(InitLicense());
 }
Exemplo n.º 18
0
 void BindingArcGISRuntime(object sender, EventArgs e)
 {
     if (!RuntimeManager.Bind(ProductCode.Server))
     {
         // Failed to bind, announce and force exit
         Console.WriteLine("Invalid ArcGIS runtime binding. Application will shut down.");
         System.Environment.Exit(0);
     }
 }
Exemplo n.º 19
0
        static void Main()
        {
            //if (!RuntimeManager.Bind(ProductCode.Engine))
            //{
            //    if (!RuntimeManager.Bind(ProductCode.Desktop))
            //    {
            //        MessageBox.Show("当前机器上无法找到ArcGIS授权");
            //        return;
            //    }
            //}

            if (!RuntimeManager.Bind(ProductCode.Desktop))
            {
                if (!RuntimeManager.Bind(ProductCode.Engine))
                {
                    MessageBox.Show("当前机器上无法找到ArcGIS授权");
                    return;
                }
            }
            try
            {
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB, esriLicenseProductCode.esriLicenseProductCodeAdvanced }, new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst });
                //m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced,esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB }, new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst });
                var load = new LoadForm();
                load.Show();
                Application.DoEvents();
                _form = new MainForm();
                //_form2 = new AdvanceForm();
                Application.Run(_form);
                m_AOLicenseInitializer.ShutdownApplication();
            }
            catch (Exception ex)
            {
                string str         = "";
                string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";

                if (ex != null)
                {
                    str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                                        ex.GetType().Name, ex.Message, ex.StackTrace);
                }
                else
                {
                    str = string.Format("应用程序线程错误:{0}", ex);
                }


                WriteLog(str);
                MessageBox.Show("发生未处理异常,请及时联系软件维护人员!", "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 20
0
 static void BindingArcGisRuntime(object sender, EventArgs e)
 {
     if (RuntimeManager.Bind(ProductCode.Desktop))
     {
         return;
     }
     // Failed to bind, announce and force exit
     Console.WriteLine("Invalid ArcGIS runtime binding. Application will shut down.");
     Environment.Exit(1);
 }
Exemplo n.º 21
0
        static void Main(string[] Args)
        {
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    Environment.Exit(-1);
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Args.Length != 1)
            {
                Args = new string[1];

SelectFile:
                OpenFileDialog OFD = new OpenFileDialog()
                {
                    CheckPathExists = true,
                    Multiselect     = false,
                    Title           = "选择栅格底图...",
                };
                if (OFD.ShowDialog() == DialogResult.OK)
                {
                    IRasterLayer lyr = new RasterLayerClass();
                    try
                    {
                        lyr.CreateFromFilePath(OFD.FileName);
                        if (lyr != null)
                        {
                            Args[0] = OFD.FileName;
                        }
                        else
                        {
                            MessageBox.Show("选中的文件不能作为底图,请重新选择。");
                            goto SelectFile;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("选中的文件不能作为底图,请重新选择。");
                        goto SelectFile;
                    }
                }
                else
                {
                    Environment.Exit(-1);
                }
            }

            Application.Run(new MainForm(Args[0]));
        }
Exemplo n.º 22
0
 /// <summary>
 /// �󶨵�ArcGIS Runtime��
 /// </summary>
 public static bool BindArcGISRuntime(ProductCode[] products)
 {
     foreach (var product in products)
     {
         if (RuntimeManager.Bind(product))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 23
0
        public static bool LoadAdvanceLicense(bool isLoadSpatialAnalyst, bool isLoadCodeNetwork, out string ErrorMessage)
        {
            bool result = true;

            ErrorMessage = "";
            //检测ArcGIS授权
            if (!RuntimeManager.Bind(ProductCode.EngineOrDesktop))
            {
                ErrorMessage = "请确认ArcGIS的许可安装正确有效!";
                return(false);
            }
            IAoInitialize aoInitialize = new AoInitialize();

            try
            {
                esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
                licenseStatus = aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
                if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
                {
                    licenseStatus = aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
                    if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        ErrorMessage = "获取ARCGIS授权失败";
                        return(false);
                    }
                }
                ////盗版使用的授权
                licenseStatus = aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer);
                // 迁出空间分析扩展模块
                if (isLoadSpatialAnalyst)
                {
                    if (aoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst) != esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        ErrorMessage = "获取空间分析扩展模块授权失败!";
                        return(false);
                    }
                }
                // 迁出网络分析扩展模块
                if (isLoadCodeNetwork)
                {
                    if (aoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork) != esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        ErrorMessage = "获取网络分析扩展模块授权失败!";
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                result       = false;
                ErrorMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 24
0
 static void Main()
 {
     if (!(RuntimeManager.Bind(ProductCode.EngineOrDesktop)))
     {
         MessageBox.Show("Could not bind to a Runtime!", "No ArcGIS Runtime available!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new FrmMapControl());
 }
Exemplo n.º 25
0
        public MainForm()
        {
            // 绑定到ArcGIS Runtime
            if (!RuntimeManager.Bind(ProductCode.EngineOrDesktop))
            {
                MessageBox.Show("无法绑定到ArcGIS运行时,程序将退出");
                Close();
            }

            InitializeComponent();
        }
Exemplo n.º 26
0
        static void BindingArcGISRuntime(object sender, EventArgs e)
        {
            if (RuntimeManager.Bind(MiscClass.BindingProductCode))
            {
                return;
            }

            // Failed to bind, announce and force exit
            System.Windows.Forms.MessageBox.Show("Invalid ArcGIS runtime binding. Application will shut down.");
            Environment.Exit(0);
        }
        public void InitTest()
        {
            RuntimeManager.Bind(ProductCode.Desktop);
            AoInitialize aoInit = new AoInitializeClass();

            aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);

            syriaLocalRoadsLargeArray =
                File.ReadAllLines(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + SyriaLocalRoadsLargeFile);
        }
Exemplo n.º 28
0
 void BindingArcGISRuntime(object sender, EventArgs e)
 {
     //
     // TODO: Modify ArcGIS runtime binding code as needed
     //
     if (!RuntimeManager.Bind(ProductCode.Engine))
     {
         // Failed to bind, announce and force exit
         System.Windows.Forms.MessageBox.Show("Invalid ArcGIS runtime binding. Application will shut down.");
         System.Environment.Exit(0);
     }
 }
Exemplo n.º 29
0
        static void Main()
        {
            if (!RuntimeManager.Bind(ProductCode.EngineOrDesktop))
            {
                MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmLogIn());
        }
 static void Main()
 {
     if (!RuntimeManager.Bind(ProductCode.Engine))
     {
         if (!RuntimeManager.Bind(ProductCode.Desktop))
         {
             MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
             return;
         }
     }
     Application.Run(new Form1());
 }