예제 #1
0
        /// <summary>
        ///     Converts the array of arguments to the strongly type object and executes the program while checking
        ///     out the ArcFM and ESRI licenses
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <param name="esriLicenseProduct">The esri license product.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing 0 for success and failure any other value.
        /// </returns>
        public virtual int Run(string[] args, esriLicenseProductCode esriLicenseProduct)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                Console.Title = Application.ProductName;

                Log.Info("===============================");
                Log.Info(Application.ProductName + " Started.");
                Log.Info("Version: " + Application.ProductVersion);
                Log.Info("User: "******"===============================");
                Log.Info("");

                if (args == null || args.Length == 0)
                {
                    args = this.CreateArguments();
                }

                Log.Info($"Arguments: {string.Join(" ", args)}");
                Log.Info("");

                TProgramArguments o = this.ParseArguments(args);
                if (this.Initialize(o))
                {
                    using (EsriRuntimeAuthorization lic = new EsriRuntimeAuthorization())
                    {
                        if (!lic.Initialize(esriLicenseProduct))
                        {
                            Log.Error(lic.GetInitializationStatus());
                            return(-1);
                        }
                        else
                        {
                            Log.Info(lic.GetInitializationStatus());
                        }

                        return((this.Execute(o)) ? 1 : 0);
                    }
                }

                return(0);
            }
            catch (Exception ex)
            {
                Log.Error(ex);

                return(-1);
            }
            finally
            {
                Log.Info("");
                Log.Info("Elapsed time was: {0}:{1}:{2}.{3}", stopwatch.Elapsed.Hours, stopwatch.Elapsed.Minutes, stopwatch.Elapsed.Seconds, stopwatch.Elapsed.Milliseconds);
            }
        }
예제 #2
0
        public virtual void Setup()
        {
            ComReleaser           = new ComReleaser();
            _RuntimeAuthorization = new EsriRuntimeAuthorization();

            Assert.IsTrue(_RuntimeAuthorization.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard));

            Workspace = WorkspaceFactories.Open(_PathName);
            ComReleaser.ManageLifetime(Workspace);
        }
예제 #3
0
        public void EsriRuntimeAuthorization_GetInitializationStatus()
        {
            using (var lic = new EsriRuntimeAuthorization())
            {
                var status = lic.GetInitializationStatus();
                Assert.AreEqual("Product: No licenses were requested", status);

                var extensionCodes = Enum.GetValues(typeof(esriLicenseExtensionCode));
                lic.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard, extensionCodes.OfType <esriLicenseExtensionCode>().ToArray());

                status = lic.GetInitializationStatus();
                Assert.IsNotNull(status);
            }
        }
예제 #4
0
        public virtual void Cleanup()
        {
            if (_RuntimeAuthorization != null)
            {
                _RuntimeAuthorization.Dispose();
                _RuntimeAuthorization = null;
            }

            if (ComReleaser != null)
            {
                ComReleaser.Dispose();
                ComReleaser = null;
            }

            Workspace = null;
        }
예제 #5
0
파일: Program.cs 프로젝트: wey12138/Wave
        /// <summary>
        ///     Exports or imports the version edits as XML files.
        /// </summary>
        /// <param name="args">The arguments.</param>
        internal void Run(ProgramArguments args)
        {
            using (EsriRuntimeAuthorization lic = new EsriRuntimeAuthorization(ProductCode.EngineOrDesktop))
            {
                if (lic.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard))
                {
                    var workspace          = WorkspaceFactories.Open(Path.GetFullPath(args.ConnectionFile));
                    var versionedWorkspace = (IVersionedWorkspace)workspace;

                    switch (args.Task)
                    {
                    case ProgramTask.Import:

                        var version       = versionedWorkspace.DefaultVersion.CreateVersion(args.VersionName);
                        var workspaceName = (IWorkspaceName)((IDataset)version).FullName;

                        string changesFileName = Path.GetFullPath(args.Path);

                        IDeltaDataChangesInit2 ddci = new DeltaDataChangesClass();
                        ddci.Init2(changesFileName, esriExportDataChangesOption.esriExportToXML, false);

                        IImportDataChanges idc = new DataChangesImporterClass();
                        idc.ImportDataChanges(workspaceName, (IDeltaDataChanges)ddci, true, true);

                        break;

                    case ProgramTask.Export:

                        var source = versionedWorkspace.FindVersion(args.VersionName);
                        var target = source.GetParent();

                        IWorkspaceName wsNameSource = (IWorkspaceName)((IDataset)source).FullName;
                        IWorkspaceName wsNameTarget = (IWorkspaceName)((IDataset)target).FullName;

                        var exportFileName = Path.Combine(Path.GetFullPath(args.Path), args.VersionName + ".xml");

                        IVersionDataChangesInit vdci = new VersionDataChangesClass();
                        vdci.Init(wsNameSource, wsNameTarget);

                        IExportDataChanges2 edc = new DataChangesExporterClass();
                        edc.ExportDataChanges(exportFileName, esriExportDataChangesOption.esriExportToXML, (IDataChanges)vdci, true);
                        break;
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only
        ///     unmanaged resources.
        /// </param>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (ComReleaser != null)
                {
                    ComReleaser.Dispose();
                }

                ComReleaser = null;

                if (_RuntimeAuthorization != null)
                {
                    _RuntimeAuthorization.Dispose();
                }

                _RuntimeAuthorization = null;
            }
        }
예제 #7
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RuntimeAuthorization" /> class.
 /// </summary>
 /// <param name="productCode">The product code.</param>
 public RuntimeAuthorization(ProductCode productCode)
 {
     _EsriRuntime = new EsriRuntimeAuthorization();
     _EsriRuntime.ResolveRuntimeBinding += (sender, args) => args.ProductCode = productCode;
     _MinerRuntime = new MinerRuntimeAuthorization();
 }