Beispiel #1
0
        private bool StartExport(JobConfig jobConfig, RuntimeLog log, Action <int> progressCallback)
        {
            var targetFormat = jobConfig.Format?.Trim().ToLowerInvariant();

            switch (targetFormat)
            {
            case @"gltf":
                ExportToGltf(jobConfig, log, progressCallback);
                break;

            case @"3dtiles":
                ExportToCesium3DTiles(jobConfig, log, progressCallback);
                break;

#if !EXPRESS
            case @"svf":
                ExportToSvf(jobConfig, log, progressCallback);
                break;
#endif
            default:
                log.Log(@"Fail", @"Startup", $@"Unsupported format - {targetFormat}");
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public override int Execute(params string[] args)
        {
            using (var log = new RuntimeLog())
                using (var session = LicenseConfig.Create())
                {
                    try
                    {
                        if (args == null || args.Length != 1)
                        {
                            log.Log(@"Fail", @"Startup", $@"传入参数数量: {args?.Length ?? -1}");
                            return(101);
                        }

                        var jobConfigFilePath = args[0];
                        var jobConfig         = JobConfig.Load(jobConfigFilePath);
                        if (jobConfig == null)
                        {
                            log.Log(@"Fail", @"Startup", @"任务设置加载失败");
                            return(102);
                        }

                        if (session.IsValid == false)
                        {
                            log.Log(@"Fail", @"Startup", @"授权无效!");

                            #region 保存授权无效信息文件
                            try
                            {
                                var filePath = Path.Combine(jobConfig.OutputPath, @"License Invalid.txt");
                                File.WriteAllText(filePath, @"未检测到有效的授权, 请检查授权期限是否已过期, 如使用 USBKEY 请确认 USBKEY 是否已正确插入 USB 接口!", Encoding.UTF8);
                            }
                            catch
                            {
                                // ignored
                            }
                            #endregion

                            return(110);
                        }

                        const string SOURCE_NAME = @"Nw"; //这个数据源名称不可修改,是和 CLI 里的设置对应的
                        Router.SetProgressPhase(SOURCE_NAME, 1.0);

                        var progress = 0;
                        var ret      = StartExport(jobConfig, log, x =>
                        {
                            var newProgress = x;
                            if (newProgress > progress)
                            {
                                progress = newProgress;
                                Router.SetProgressValue(SOURCE_NAME, newProgress);
                            }
                        });

                        if (!ret)
                        {
                            return(103);
                        }

                        Router.SetProgressValue(SOURCE_NAME, 100);
                    }
                    catch (Exception ex)
                    {
                        log.Log(@"Exception", @"Startup", ex.ToString());
                        return(100);
                    }
                }

            return(0);
        }