Exemple #1
0
        public void SaveUserExportSettings(Guid userId, ExportType type, ListType listType, List <ExportModelConfiguration> configuration, string exportFormat)
        {
            ExportSetting existingSetting = null;

            if (type == ExportType.List)
            {
                existingSetting = _exportSettingRepository.Read(u => u.UserId == userId && u.Type == type && u.ListType == listType).FirstOrDefault();
            }
            else
            {
                existingSetting = _exportSettingRepository.Read(u => u.UserId == userId && u.Type == type).FirstOrDefault();
            }

            if (existingSetting != null)
            {
                existingSetting.Settings     = SerializeSettings(configuration);
                existingSetting.ExportFormat = exportFormat;
                _exportSettingRepository.Update(existingSetting);
            }
            else
            {
                var newSetting = new ExportSetting()
                {
                    Type         = type,
                    ListType     = listType,
                    UserId       = userId,
                    Settings     = SerializeSettings(configuration),
                    ExportFormat = exportFormat
                };
                _exportSettingRepository.Create(newSetting);
            }

            _unitOfWork.SaveChanges();
        }
Exemple #2
0
        public void TestExportError()
        {
            var filename       = "testError.unitypackage";
            var baseFolderPath = "Assets/VitDeck/Exporter/Tests/TestBaseFolder";
            var setting        = new ExportSetting();

            setting.SettingName      = "";
            setting.Description      = "";
            setting.ExportFolderPath = testExportFolder;
            setting.fileNameFormat   = filename;
            setting.ruleSetName      = "";
            Exporter.Export(baseFolderPath, setting, false);
            //ファイル重複していた場合
            ExportResult willFailResult = new ExportResult();

            willFailResult.exportResult = true;
            LogAssert.Expect(LogType.Error, new Regex(@"^System\.IO\.IOException.*"));
            Assert.DoesNotThrow(() => willFailResult = Exporter.Export(baseFolderPath, setting, false));
            Assert.That(willFailResult.exportResult, Is.False);
            Assert.That(willFailResult.exportFilePath, Is.Null);
            Assert.That(willFailResult.log, Is.Not.Empty);
            var willPassResult = Exporter.Export(baseFolderPath, setting, true);

            Assert.That(willPassResult.exportResult, Is.True);
        }
        /// <summary>
        /// 设置导出设置
        /// Make the ExportSettings
        /// </summary>
        private void SetExportSettings(SuperMap.Data.Conversion.FileType type, String targetFilePath)
        {
            try
            {
                ExportSetting setting = new ExportSetting();
                setting.TargetFilePath = targetFilePath;
                setting.TargetFileType = type;
                setting.IsOverwrite    = true;

                if (type == FileType.SIT)
                {
                    setting.SourceData = m_sourceImg;
                    m_dataExport.ExportSettings.Add(setting);
                }
                else
                {
                    setting.SourceData = m_sourceRegion;
                    m_dataExport.ExportSettings.Add(setting);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Exemple #4
0
        public HiProtobuf()
        {
            InitializeComponent();
            if (!string.IsNullOrEmpty(Settings.Export_Folder))
            {
                textBox1.Text = Settings.Export_Folder;
            }
            if (!string.IsNullOrEmpty(Settings.Excel_Folder))
            {
                textBox2.Text = Settings.Excel_Folder;
            }
            if (!string.IsNullOrEmpty(Settings.Compiler_Path))
            {
                textBox5.Text = Settings.Compiler_Path;
            }
            Log.OnInfo += (x) =>
            {
                textBox6.Text = Logger.Log;
            };
            Log.OnWarning += (x) =>
            {
                textBox6.Text = Logger.Log;
            };
            Log.OnError += (x) =>
            {
                textBox6.Text = Logger.Log;
            };

            _exportSetting = ExportSetting.Instance;
        }
Exemple #5
0
        public static ValidatedExportResult ValidatedExport(string baseFolderPath, ExportSetting setting, bool forceExport = false, bool forceOpenScene = false)
        {
            if (setting == null)
            {
                throw new ArgumentNullException("Argument `setting` is null.");
            }
            if (baseFolderPath == null)
            {
                throw new ArgumentNullException("Argument `baseFolderPath` is null.");
            }
            var exportFolderPath = setting.ExportFolderPath;

            if (string.IsNullOrEmpty(exportFolderPath) || !exportFolderPath.StartsWith("Assets"))
            {
                throw new ArgumentNullException("Invalid export folder path:" + exportFolderPath);
            }
            ExportSettingStock settingStock = new ExportSettingStock(setting);
            var result = new ValidatedExportResult(forceExport);

            //validate
            if (!forceExport)
            {
                if (!string.IsNullOrEmpty(setting.ruleSetName))
                {
                    var ruleSet = GetRuleSet(setting.ruleSetName);
                    if (ruleSet == null)
                    {
                        result.log += string.Format("ルールチェック中に問題が発生しました。" + "ルール{0}が見つかりませんでした。", setting.ruleSetName);
                        return(result);
                    }
                    try
                    {
                        result.validationResults = Validator.Validator.Validate(ruleSet, baseFolderPath, forceOpenScene);
                    }
                    catch (FatalValidationErrorException e)
                    {
                        result.log += "ルールチェック中に問題が発生しました。" + System.Environment.NewLine + e.Message;
                        return(result);
                    }
                    if (!result.HasValidationIssues(setting.ignoreValidationWarning ? IssueLevel.Error : IssueLevel.Warning))
                    {
                        result.log += "ルールチェックで問題が発見されました。" + System.Environment.NewLine;
                        return(result);
                    }
                }
                else
                {
                    result.log += "ルールセット指定がないため事前チェックを省略します。" + System.Environment.NewLine;
                }
            }

            //export
            result.exportResult = Exporter.Exporter.Export(baseFolderPath, settingStock.GetSetting(), forceExport);
            if (!result.IsExportSuccess)
            {
                result.log += "エクスポートに失敗しました。" + System.Environment.NewLine;
            }
            return(result);
        }
Exemple #6
0
 /// <summary>
 /// 开始导出
 /// </summary>
 /// <param name="uidoc"></param>
 /// <param name="view"></param>
 /// <param name="setting"></param>
 /// <param name="progressCallback"></param>
 /// <param name="cancellationToken"></param>
 private void StartExport(UIDocument uidoc, View3D view, ExportSetting setting, Action <int> progressCallback, CancellationToken cancellationToken)
 {
     using (var log = new RuntimeLog())
     {
         var exporter = new ExporterX(InnerApp.GetHomePath());
         exporter.Export(view, uidoc, setting, log, progressCallback, cancellationToken);
     }
 }
 private void StartExport(Viewport view, ExportSetting setting, Action <int> progressCallback, CancellationToken cancellationToken)
 {
     using (var log = new RuntimeLog())
     {
         var exporter = new Bimangle.ForgeEngine.Dgn.Pro.Svf.Exporter(InnerApp.GetHomePath());
         exporter.Export(view, setting, log, progressCallback, cancellationToken);
     }
 }
Exemple #8
0
 /// <summary>
 /// 开始导出
 /// </summary>
 /// <param name="setting"></param>
 /// <param name="progressCallback"></param>
 /// <param name="cancellationToken"></param>
 private void StartExport(ExportSetting setting, Action <int> progressCallback, CancellationToken cancellationToken)
 {
     using (var log = new RuntimeLog())
     {
         var exporter = new ExporterX(App.GetHomePath());
         exporter.Export(setting, log, progressCallback, cancellationToken);
     }
 }
        private void OnGUI()
        {
            EditorGUIUtility.labelWidth = 80;
            EditorGUILayout.LabelField("Exporter");
            //Rule set dropdown
            EditorGUI.BeginChangeCheck();
            var index = EditorGUILayout.Popup("Setting:", GetPopupIndex(selectedSetting), SettingNames);

            selectedSetting = Settings.Count() > 0 ? Settings[index] : null;
            if (EditorGUI.EndChangeCheck())
            {
                ruleSetName = "";
            }
            //Base folder field
            DefaultAsset newFolder = (DefaultAsset)EditorGUILayout.ObjectField("Base Folder:", baseFolder, typeof(DefaultAsset), true);
            var          path      = AssetDatabase.GetAssetPath(newFolder);

            baseFolder = AssetDatabase.IsValidFolder(path) ? newFolder : null;
            if (selectedSetting != null)
            {
                if (!string.IsNullOrEmpty(RuleSetName))
                {
                    EditorGUILayout.LabelField("Rule set:", RuleSetName);
                }
                //Setting fields
                GUILayout.TextArea(selectedSetting.Description);
            }
            //ForceExportCheck
            if (result != null && !result.IsExportSuccess)
            {
                forceExport = GUILayout.Toggle(forceExport, LocalizedMessage.Get("ValidatedExporterWindow.ForceExport"));
            }
            //Export button
            EditorGUI.BeginDisabledGroup(selectedSetting == null || baseFolder == null);

            if (GUILayout.Button("Export"))
            {
                OnExport();
            }

            EditorGUI.EndDisabledGroup();
            //Help message
            if (messages != null)
            {
                msaageAreaScroll = EditorGUILayout.BeginScrollView(msaageAreaScroll);
                foreach (var msg in messages)
                {
                    GetMessageBox(msg);
                }
                EditorGUILayout.EndScrollView();
            }
            //Copy Button
            if (GUILayout.Button("Copy result log"))
            {
                OnCopyResultLog();
            }
        }
        private int GetPopupIndex(ExportSetting setting)
        {
            var index = 0;

            if (setting != null && Array.IndexOf(Settings, setting) > 0)
            {
                index = Array.IndexOf(Settings, setting);
            }
            return(index);
        }
Exemple #11
0
        /// <summary>
        /// 設定値をUIに反映させる。
        /// </summary>
        public void LoadFromSetting()
        {
            AppData data = AppData.Instance;
            ExportSetting exportSetting = data.GeneratorSetting.ExportSetting;
            sizeInputCharaChipSize.Value = exportSetting.CharaChipSize;
            labelMaterialDirectory.Text = data.MaterialDirectory;
            labelImageBackground.BackColor = Settings.Default.ImageBackground;

            textBoxExportFilePath.Text = exportSetting.ExportFilePath;
        }
Exemple #12
0
 public ExportSettingStock(ExportSetting setting)
 {
     this.setting                 = setting;
     this.SettingName             = setting.SettingName;
     this.Description             = setting.Description;
     this.ExportFolderPath        = setting.ExportFolderPath;
     this.fileNameFormat          = setting.fileNameFormat;
     this.ruleSetName             = setting.ruleSetName;
     this.ignoreValidationWarning = setting.ignoreValidationWarning;
 }
Exemple #13
0
        /// <summary>
        /// UIの値を設定値に格納する
        /// </summary>
        public void StoreToSetting()
        {
            AppData data = AppData.Instance;
            ExportSetting exportSetting = data.GeneratorSetting.ExportSetting;
            exportSetting.CharaChipSize = sizeInputCharaChipSize.Value;
            exportSetting.ExportFilePath = textBoxExportFilePath.Text;

            Settings.Default.MaterialDirectory = labelMaterialDirectory.Text;
            Settings.Default.CharaChipSize = sizeInputDefaultCharaChipSize.Value;
            Settings.Default.ImageBackground = labelImageBackground.BackColor;
        }
        /// <summary>
        /// 开始导出
        /// </summary>
        /// <param name="view"></param>
        /// <param name="setting"></param>
        /// <param name="progressCallback"></param>
        /// <param name="cancellationToken"></param>
        private void StartExport(Viewport view, ExportSetting setting, Action <int> progressCallback, CancellationToken cancellationToken)
        {
            using (var log = new RuntimeLog())
            {
#if EXPRESS
                var exporter = new Bimangle.ForgeEngine.Dgn.Express.Cesium3DTiles.Exporter(InnerApp.GetHomePath());
#else
                var exporter = new Bimangle.ForgeEngine.Dgn.Pro.Cesium3DTiles.Exporter(InnerApp.GetHomePath());
#endif
                exporter.Export(view, setting, log, progressCallback, cancellationToken);
            }
        }
        private void LoadSettings()
        {
            var userSettings = UserSettingUtility.GetUserSettings();

            baseFolder = AssetDatabase.LoadAssetAtPath <DefaultAsset>(userSettings.validatorFolderPath);
            var settings = Settings.Where(a => a.name == userSettings.exporterSettingFileName);

            if (settings.Count() > 0)
            {
                selectedSetting = settings.First <ExportSetting>();
            }
        }
Exemple #16
0
        /// <summary>
        /// 开始导出
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="progressCallback"></param>
        /// <param name="cancellationToken"></param>
        private void StartExport(ExportSetting setting, Action <int> progressCallback, CancellationToken cancellationToken)
        {
#if EXPRESS
            throw new NotImplementedException();
#else
            using (var log = new RuntimeLog())
            {
                var exporter = new Bimangle.ForgeEngine.Navisworks.Pro.Svf.Exporter(App.GetHomePath());
                exporter.Export(setting, log, progressCallback, cancellationToken);
            }
#endif
        }
Exemple #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (exportWorker.IsBusy)
            {
                return;
            }
            var setting = new ExportSetting();

            if (string.IsNullOrEmpty(targetConnStringBox.Text))
            {
                MessageBox.Show("目标数据库" + Resources.ConnStringEmptyMsg);
                return;
            }
            var db = GetDbName(targetConnStringBox.Text);

            if (string.IsNullOrEmpty(db))
            {
                MessageBox.Show("目标数据库" + Resources.DbNameEmptyMsg);
                return;
            }
            setting.TargetConnString = targetConnStringBox.Text;
            setting.TargetDbName     = db;
            var jsonFile = "";

            if (saveJsonFileDialog.ShowDialog() == DialogResult.OK)
            {
                jsonFile = saveJsonFileDialog.FileName;
                if (File.Exists(jsonFile))
                {
                    if (MessageBox.Show("文件已经存在,是否覆盖?", "文件覆盖提示", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        MessageBox.Show("导出信息已经被取消。");
                        return;
                    }
                }
            }
            else
            {
                return;
            }
            setting.JsonFile = jsonFile;
            try
            {
                exportWorker.RunWorkerAsync(setting);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #18
0
        private static void ExportGroups(IEnumerable <Entry> data, IEnumerable <string> exportFields,
                                         ExportSetting exportSetting, string ExportFolderPath)
        {
            List <string> gFieldList    = new List <string>();
            List <string> gFieldListIns = new List <string>();

            foreach (PartitionsEntryViewmodel p in exportSetting.Partitions)
            {
                if (p.Partition == PARTITION_TYPE.SAME_DIRECTORY)
                {
                    gFieldList.Add(p.Field);
                }
                else if (p.Partition == PARTITION_TYPE.SAME_PAGE)
                {
                    gFieldListIns.Add(p.Field);
                }
            }

            // Putting into different files
            if (gFieldList.Count > 0)
            {
                if (gFieldListIns.Count > 0)
                {
                    string gFieldQuery = string.Join(", ", gFieldList.Select(x => "it[\"" + x + "\"] as " + x));
                    var    grouped     = data.GroupBy("new(" + gFieldQuery + ")", "it")
                                         .Select("new (it.Key as Key, it as Item)");
                    foreach (dynamic g in grouped)
                    {
                        string filename = GroupingToFilename(g.Key, gFieldList);
                        ExportGroupsSameFile(g.Item, exportFields, gFieldListIns, ExportFolderPath + "\\" + filename + ".csv");
                    }
                }
                else
                {
                    string gFieldQuery = string.Join(", ", gFieldList.Select(x => "it[\"" + x + "\"] as " + x));
                    var    grouped     = data.GroupBy("new(" + gFieldQuery + ")", "it")
                                         .Select("new (it.Key as Key, it as Item)");
                    foreach (dynamic g in grouped)
                    {
                        string filename = GroupingToFilename(g.Key, gFieldList);
                        ExportCVS(g.Item, exportFields, ExportFolderPath + "\\" + filename + ".csv");
                    }
                }
            }
            else
            {
                ExportGroupsSameFile(data, exportFields, gFieldListIns, ExportFolderPath + "\\output.csv");
            }
        }
Exemple #19
0
        public void TestExportSettingValue()
        {
            var baseFolderPath = "Assets/VitDeck/Exporter/Tests/TestBaseFolder";
            var setting        = new ExportSetting();

            setting.SettingName      = "";
            setting.Description      = "";
            setting.ExportFolderPath = testExportFolder;
            setting.fileNameFormat   = null;
            setting.ruleSetName      = "";
            var result = Exporter.Export(baseFolderPath, setting, true);

            Assert.That(result.exportResult, Is.True);
            Assert.That(result.exportFilePath, Is.EqualTo(testExportFolder + Path.AltDirectorySeparatorChar + "export.unitypackage"));
            Assert.That(File.Exists(result.exportFilePath));
        }
Exemple #20
0
 private void SetExportSettings(SuperMap.Data.Conversion.FileType type, String targetFilePath)
 {
     try
     {
         ExportSetting setting = new ExportSetting();
         setting.TargetFilePath = targetFilePath;
         setting.TargetFileType = type;
         setting.IsOverwrite    = true;
         setting.SourceData     = sourceImg1;
         dataExport1.ExportSettings.Add(setting);
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Exemple #21
0
        /// <summary>
        /// 开始导出
        /// </summary>
        /// <param name="uidoc"></param>
        /// <param name="view"></param>
        /// <param name="setting"></param>
        /// <param name="progressCallback"></param>
        /// <param name="cancellationToken"></param>
        private void StartExport(UIDocument uidoc, View3D view, ExportSetting setting, Action <int> progressCallback, CancellationToken cancellationToken)
        {
#if EXPRESS
            throw new NotImplementedException();
#else
            using (var log = new RuntimeLog())
            {
                var exporter = new Bimangle.ForgeEngine.Revit.Pro.Svf.Exporter(InnerApp.GetHomePath());
                exporter.Handler = new ExportHandler();

                if (uidoc != null && uidoc.ActiveView.Id == view.Id)
                {
                    exporter.Export(view, uidoc, setting, log, progressCallback, cancellationToken);
                }
                else
                {
                    exporter.Export(view, setting, log, progressCallback, cancellationToken);
                }
            }
#endif
        }
Exemple #22
0
        public void TestExportException()
        {
            var filename       = "testException.unitypackage";
            var baseFolderPath = "Assets/VitDeck/Exporter/Tests/TestBaseFolder";
            var setting        = new ExportSetting();

            setting.SettingName      = "";
            setting.Description      = "";
            setting.ExportFolderPath = testExportFolder;
            setting.fileNameFormat   = filename;
            setting.ruleSetName      = "";
            //setting null
            Assert.That(() => Exporter.Export(baseFolderPath, null, false), Throws.ArgumentNullException);
            //basefolder null
            Assert.That(() => Exporter.Export(null, setting, false), Throws.ArgumentNullException);
            //exportFolderPath empty
            setting.ExportFolderPath = "";
            Assert.That(() => Exporter.Export(null, setting, false), Throws.ArgumentNullException);
            //exportFolderPath does not start with `Assets`
            setting.ExportFolderPath = "InvalidPath/Export";
            Assert.That(() => Exporter.Export(null, setting, false), Throws.ArgumentNullException);
        }
Exemple #23
0
        private int ExecuteExport(ExportSetting setting)
        {
            using (var session = LicenseConfig.Create())
            {
                if (session.IsValid == false)
                {
                    _Log.WriteLine("\tLicense Invalid!");

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

                    return(110);
                }

                try
                {
                    var exporter = new Exporter(App.GetHomePath());
                    exporter.Export(setting, OnProgressCallback, Cancellation.Token);
                    OnProgressCallback(100);
                    return(0);
                }
                catch (Exception ex)
                {
                    _Log.WriteLine(ex.ToString());
                    Trace.WriteLine($@"EngineDWG: {ex}");
                    return(102);
                }
            }
        }
Exemple #24
0
 void OnFocus()
 {
     // Debug.Log("当窗口获得焦点时调用一次");
     foreach (GameObject obj in Object.FindObjectsOfType(typeof(GameObject)))
     {
         ExportSetting seting = obj.GetComponent <ExportSetting>();
         if (seting != null && seting.isActiveAndEnabled)  //需要导出
         {
             Terrain terrain = obj.GetComponent <Terrain>();
             if (terrain != null)
             {
                 editCore.terrainObj = obj;
                 TerrainGrid terrainGrid = obj.GetComponent <TerrainGrid>();
                 if (terrainGrid != null)
                 {
                     editCore.grids        = (int)terrainGrid.Grid_NxN;
                     editCore.grids        = (int)System.Math.Pow(2, editCore.grids);
                     editCore.groupEnabled = true;
                     break;
                 }
             }
         }
     }
 }
Exemple #25
0
        public ExportOptionsModel ReadCustomExportOptions(Guid userId, ExportType type, ListType listType)
        {
            ExportSetting previousSettings = null;

            if (type == ExportType.List)
            {
                previousSettings = _exportSettingRepository.Read(u => u.UserId == userId && u.Type == type && u.ListType == listType).FirstOrDefault();
            }
            else
            {
                previousSettings = _exportSettingRepository.Read(u => u.UserId == userId && u.Type == type).FirstOrDefault();
            }

            List <ExportModelConfiguration> previousOptions = new List <ExportModelConfiguration>();
            var exportOptions = GetTypeSpecificExportOptions(type, listType);

            if (previousSettings != null)
            {
                previousOptions            = DeserializeSettings(previousSettings.Settings);
                exportOptions.SelectedType = previousSettings.ExportFormat;
            }


            //Update the Selected and Order for any used in previous export
            foreach (var setting in previousOptions)
            {
                var options = exportOptions.Fields.Where(f => f.Field.Equals(setting.Field)).FirstOrDefault();
                if (options != null)
                {
                    options.Selected = setting.Selected;
                    options.Order    = setting.Order;
                }
            }

            return(exportOptions);
        }
Exemple #26
0
        //public static void ExportMain(IEnumerable<Content> data, IEnumerable<IFilter> ExportFilters,
        //            IEnumerable<string> ExportField, string ExportFilePath)
        //{
        //    if (File.Exists(ExportFilePath))
        //    {
        //        File.Delete(ExportFilePath);
        //    }


        //}

        public static void ExportMain(IEnumerable <Entry> data, FilterCollection ExportFilters,
                                      ExportSetting exportSetting, string ExportFolderPath)
        {
            List <string> exportFields = new List <string>();

            foreach (FieldsEntryViewmodel f in exportSetting.Columns)
            {
                exportFields.Add(f.Field);
            }

            List <Entry> filtered = data.Where(x => ExportFilters.Filter(x)).ToList(); //FilterContent(data, ExportFilters);

            //filtered = SortEntries(filtered, exportSetting.SortBy); /// Check if it works properly

            // Grouping
            if (exportSetting.Partitions.Count == 0)
            {
                ExportCVS(filtered, exportFields, ExportFolderPath + "\\output.csv");
            }
            else
            {
                ExportGroups(filtered, exportFields, exportSetting, ExportFolderPath);
            }
        }
Exemple #27
0
        bool IExportControl.Run()
        {
            var filePath = txtTargetPath.Text;

            if (string.IsNullOrEmpty(filePath))
            {
                ShowMessageBox(Strings.MessageSelectOutputPathFirst);
                return(false);
            }

#if !R2014
            if (CustomExporter.IsRenderingSupported() == false &&
                ShowConfirmBox(Strings.ExportWillFailBecauseMaterialLib) == false)
            {
                return(false);
            }
#endif

            if (File.Exists(filePath) &&
                ShowConfirmBox(Strings.OutputFileExistedWarning) == false)
            {
                return(false);
            }

            var homePath = InnerApp.GetHomePath();
            if (InnerApp.CheckHomeFolder(homePath) == false &&
                ShowConfirmBox(Strings.HomeFolderIsInvalid) == false)
            {
                return(false);
            }

            var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo;
            if (visualStyle != null)
            {
                foreach (var p in visualStyle.Features)
                {
                    _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value);
                }
            }

            var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault;


            #region 更新界面选项到 _Features

            void SetFeature(FeatureType featureType, bool selected)
            {
                _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected);
            }

            SetFeature(FeatureType.Export2DViewAll, rb2DViewsAll.Checked);
            SetFeature(FeatureType.Export2DViewOnlySheet, rb2DViewsOnlySheet.Checked);

            SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked);
            //SetFeature(FeatureType.GenerateElementData, cbGeneratePropDbJson.Checked);
            SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked);
            SetFeature(FeatureType.GenerateLeaflet, cbGenerateLeaflet.Checked);
            SetFeature(FeatureType.GenerateDwgDrawing, cbGenerateDwg.Checked);

            SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked);
            SetFeature(FeatureType.ExportRooms, cbIncludeRooms.Checked);

            SetFeature(FeatureType.ExcludeProperties, cbExcludeElementProperties.Checked);
            SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked);
            SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked);
            SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked);

            SetFeature(FeatureType.ConsolidateGroup, cbConsolidateArrayGroup.Checked);
            SetFeature(FeatureType.ConsolidateAssembly, cbConsolidateAssembly.Checked);

            SetFeature(FeatureType.UseLevelCategory, rbGroupByLevelDefault.Checked);
            SetFeature(FeatureType.UseNwLevelCategory, rbGroupByLevelNavisworks.Checked);
            SetFeature(FeatureType.UseBoundLevelCategory, rbGroupByLevelBoundingBox.Checked);

            SetFeature(FeatureType.UseCurrentViewport, cbUseCurrentViewport.Checked);

            #endregion

            var isCanncelled = false;
            using (var session = LicenseConfig.Create())
            {
                if (session.IsValid == false)
                {
                    LicenseConfig.ShowDialog(session, ParentForm);
                    return(false);
                }

                #region 保存设置

                var config = _LocalConfig;
                config.Features       = _Features.Where(x => x.Selected).Select(x => x.Type).ToList();
                config.LastTargetPath = txtTargetPath.Text;
                config.VisualStyle    = visualStyle?.Key;
                config.LevelOfDetail  = levelOfDetail?.Value ?? -1;
                _Config.Save();

                #endregion

                var sw = Stopwatch.StartNew();
                try
                {
                    var setting = new ExportSetting();
                    setting.LevelOfDetail      = config.LevelOfDetail;
                    setting.ExportType         = ExportType.Zip;
                    setting.OutputPath         = config.LastTargetPath;
                    setting.Features           = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList();
                    setting.SelectedElementIds = _ElementIds?.Where(x => x.Value).Select(x => x.Key).ToList();
                    setting.Selected2DViewIds  = rb2DViewCustom.Checked ? _ViewIds : null;
                    setting.Oem = LicenseConfig.GetOemInfo(homePath);

                    var hasSuccess = false;
                    using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting))
                    {
                        var cancellationToken = progress.GetCancellationToken();

#if !DEBUG
                        //在有些 Revit 会遇到时不时无法转换的问题,循环多次重试, 应该可以成功
                        for (var i = 0; i < 5; i++)
                        {
                            try
                            {
                                StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken);
                                hasSuccess = true;
                                break;
                            }
                            catch (Autodesk.Revit.Exceptions.ExternalApplicationException)
                            {
                                Application.DoEvents();
                            }
                            catch (IOException ex)
                            {
                                ShowMessageBox("文件保存失败: " + ex.Message);
                                hasSuccess = true;
                                break;
                            }
                        }
#endif

                        //如果之前多次重试仍然没有成功, 这里再试一次,如果再失败就会给出稍后重试的提示
                        if (hasSuccess == false)
                        {
                            StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken);
                        }

                        isCanncelled = cancellationToken.IsCancellationRequested;
                    }

                    sw.Stop();
                    var ts = sw.Elapsed;
                    ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分

                    Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration);

                    if (isCanncelled == false)
                    {
                        {
                            ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration));
                        }
                    }
                }
                catch (IOException ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message));
                }
                catch (Autodesk.Revit.Exceptions.ExternalApplicationException)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(Strings.MessageOperationFailureAndTryLater);
                }
                catch (Exception ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(ex.ToString());
                }
            }

            return(isCanncelled == false);
        }
Exemple #28
0
        bool IExportControl.Run()
        {
            var siteInfo = GetSiteInfo();

            if (siteInfo == null)
            {
                ShowMessageBox(Strings.SiteLocationInvalid);
                return(false);
            }

            var filePath = txtTargetPath.Text;

            if (string.IsNullOrEmpty(filePath))
            {
                ShowMessageBox(Strings.MessageSelectOutputPathFirst);
                return(false);
            }

#if !R2014
            if (CustomExporter.IsRenderingSupported() == false &&
                ShowConfirmBox(Strings.ExportWillFailBecauseMaterialLib) == false)
            {
                return(false);
            }
#endif

            if (File.Exists(filePath) &&
                ShowConfirmBox(Strings.OutputFileExistedWarning) == false)
            {
                return(false);
            }

            var homePath = InnerApp.GetHomePath();
            if (InnerApp.CheckHomeFolder(homePath) == false &&
                ShowConfirmBox(Strings.HomeFolderIsInvalid) == false)
            {
                return(false);
            }

            var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo;
            if (visualStyle != null)
            {
                foreach (var p in visualStyle.Features)
                {
                    _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value);
                }
            }

            var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault;

            #region 更新界面选项到 _Features

            void SetFeature(FeatureType featureType, bool selected)
            {
                _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected);
            }

            //SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked);

            SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked);
            SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked);
            SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked);

            SetFeature(FeatureType.UseGoogleDraco, cbUseDraco.Checked);
            //SetFeature(FeatureType.ExtractShell, cbUseExtractShell.Checked);
            SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked);
            SetFeature(FeatureType.ExportSvfzip, cbExportSvfzip.Checked);
            SetFeature(FeatureType.EnableQuantizedAttributes, cbEnableQuantizedAttributes.Checked);
            SetFeature(FeatureType.EnableTextureWebP, cbEnableTextureWebP.Checked);
            SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked);
            SetFeature(FeatureType.EnableUnlitMaterials, cbEnableUnlitMaterials.Checked);

            SetFeature(FeatureType.EnableEmbedGeoreferencing, cbEmbedGeoreferencing.Checked);

            #endregion

            var isCancelled = false;
            using (var session = LicenseConfig.Create())
            {
                if (session.IsValid == false)
                {
                    LicenseConfig.ShowDialog(session, ParentForm);
                    return(false);
                }

                #region 保存设置

                var config = _LocalConfig;
                config.Features       = _Features.Where(x => x.Selected).Select(x => x.Type).ToList();
                config.LastTargetPath = txtTargetPath.Text;
                config.VisualStyle    = visualStyle?.Key;
                config.LevelOfDetail  = levelOfDetail?.Value ?? -1;

                if (rbModeShellMesh.Checked)
                {
                    config.Mode = 2;
                }
                else if (rbModeShellElement.Checked)
                {
                    config.Mode = 3;
                }
                else
                {
                    config.Mode = 0;
                }

                _Config.Save();

                #endregion

                var sw = Stopwatch.StartNew();
                try
                {
                    var setting = new ExportSetting();
                    setting.LevelOfDetail      = config.LevelOfDetail;
                    setting.OutputPath         = config.LastTargetPath;
                    setting.Mode               = config.Mode;
                    setting.Features           = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList();
                    setting.SelectedElementIds = _ElementIds?.Where(x => x.Value).Select(x => x.Key).ToList();
                    setting.Site               = siteInfo;
                    setting.Oem = LicenseConfig.GetOemInfo(homePath);
                    setting.PreExportSeedFeatures = InnerApp.GetPreExportSeedFeatures(@"3DTiles");

                    var hasSuccess = false;
                    using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting))
                    {
                        var cancellationToken = progress.GetCancellationToken();

#if !DEBUG
                        //在有些 Revit 会遇到时不时无法转换的问题,循环多次重试, 应该可以成功
                        for (var i = 0; i < 5; i++)
                        {
                            try
                            {
                                StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken);
                                hasSuccess = true;
                                break;
                            }
                            catch (Autodesk.Revit.Exceptions.ExternalApplicationException)
                            {
                                Application.DoEvents();
                            }
                            catch (IOException ex)
                            {
                                ShowMessageBox("文件保存失败: " + ex.Message);
                                hasSuccess = true;
                                break;
                            }
                        }
#endif

                        //如果之前多次重试仍然没有成功, 这里再试一次,如果再失败就会给出稍后重试的提示
                        if (hasSuccess == false)
                        {
                            StartExport(_UIDocument, _View, setting, progress.GetProgressCallback(), cancellationToken);
                        }

                        isCancelled = cancellationToken.IsCancellationRequested;
                    }

                    sw.Stop();
                    var ts = sw.Elapsed;
                    ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分

                    Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration);

                    if (isCancelled == false)
                    {
                        ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration));
                    }
                }
                catch (IOException ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message));
                }
                catch (Autodesk.Revit.Exceptions.ExternalApplicationException)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(Strings.MessageOperationFailureAndTryLater);
                }
                catch (Exception ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(ex.ToString());
                }
            }

            return(isCancelled == false);
        }
Exemple #29
0
        bool IExportControl.Run()
        {
            var filePath = txtTargetPath.Text;

            if (string.IsNullOrEmpty(filePath))
            {
                ShowMessageBox(Strings.MessageSelectOutputPathFirst);
                return(false);
            }

            if (Autodesk.Navisworks.Api.Application.ActiveDocument.Models.Count == 0)
            {
                ShowMessageBox(Strings.SceneIsEmpty);
                return(false);
            }
            if (File.Exists(filePath) && ShowConfigBox(Strings.OutputFileExistedWarning) == false)
            {
                return(false);
            }

            var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo;

            if (visualStyle != null)
            {
                foreach (var p in visualStyle.Features)
                {
                    _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value);
                }
            }

            // var autoOpenAppItem = cbAppList.SelectedItem as IconComboBoxItem;

            #region 更新界面选项到 _Features

            void SetFeature(FeatureType featureType, bool selected)
            {
                _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected);
            }

            //SetFeature(FeatureType.ExportGrids, cbIncludeGrids.Checked);

            SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked);
            SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked);
            SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked);

            SetFeature(FeatureType.UseGoogleDraco, cbUseDraco.Checked);
            SetFeature(FeatureType.ExtractShell, cbUseExtractShell.Checked);
            SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked);
            SetFeature(FeatureType.ExportSvfzip, cbExportSvfzip.Checked);

            #endregion

            var isCancelled = false;
            using (var session = LicenseConfig.Create())
            {
                if (session.IsValid == false)
                {
                    LicenseConfig.ShowDialog(session, ParentForm);
                    return(false);
                }

                #region 保存设置

                var config = _LocalConfig;
                config.Features       = _Features.Where(x => x.Selected).Select(x => x.Type).ToList();
                config.LastTargetPath = txtTargetPath.Text;
                config.VisualStyle    = visualStyle?.Key;
                _Config.Save();

                #endregion

                var sw = Stopwatch.StartNew();
                try
                {
                    var setting = new ExportSetting();
                    setting.OutputPath = config.LastTargetPath;
                    setting.Features   = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList();
                    setting.Site       = SiteInfo.CreateDefault();
                    setting.Oem        = LicenseConfig.GetOemInfo(App.GetHomePath());

                    using (var progress = new ProgressExHelper(ParentForm, Strings.MessageExporting))
                    {
                        var cancellationToken = progress.GetCancellationToken();
                        StartExport(setting, progress.GetProgressCallback(), cancellationToken);
                        isCancelled = cancellationToken.IsCancellationRequested;
                    }

                    sw.Stop();
                    var ts = sw.Elapsed;
                    ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分

                    Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration);

                    if (isCancelled == false)
                    {
                        if (config.AutoOpenAllow && config.AutoOpenAppName != null)
                        {
                            Process.Start(config.AutoOpenAppName, config.LastTargetPath);
                        }
                        else
                        {
                            ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration));
                        }
                    }
                }
                catch (IOException ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.Message));
                }
                catch (Exception ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(ex.ToString());
                }
            }

            return(isCancelled == false);
        }
        bool IExportControl.Run()
        {
            var filePath = txtTargetPath.Text;

            if (string.IsNullOrEmpty(filePath))
            {
                ShowMessageBox(Strings.MessageSelectOutputPathFirst);
                return(false);
            }

            if (File.Exists(filePath) &&
                ShowConfirmBox(Strings.OutputFileExistedWarning) == false)
            {
                return(false);
            }

            var homePath = InnerApp.GetHomePath();

            if (InnerApp.CheckHomeFolder(homePath) == false &&
                ShowConfirmBox(Strings.HomeFolderIsInvalid) == false)
            {
                return(false);
            }

            var visualStyle = cbVisualStyle.SelectedItem as VisualStyleInfo;

            if (visualStyle != null)
            {
                foreach (var p in visualStyle.Features)
                {
                    _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value);
                }
            }

            var levelOfDetail = (cbLevelOfDetail.SelectedItem as ComboItemInfo) ?? _LevelOfDetailDefault;

            #region 更新界面选项到 _Features

            void SetFeature(FeatureType featureType, bool selected)
            {
                _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, selected);
            }

            SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked);
            //SetFeature(FeatureType.GenerateElementData, cbGeneratePropDbJson.Checked);
            SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked);

            SetFeature(FeatureType.RegroupForLink, cbRegroupForLink.Checked);

            SetFeature(FeatureType.ExcludeProperties, cbExcludeElementProperties.Checked);
            SetFeature(FeatureType.ExcludeLines, cbExcludeLines.Checked);
            SetFeature(FeatureType.ExcludePoints, cbExcludeModelPoints.Checked);
            SetFeature(FeatureType.OnlySelected, cbExcludeUnselectedElements.Checked && _HasSelectElements);

            #endregion

            var isCanncelled = false;
            using (var session = LicenseConfig.Create())
            {
                if (session.IsValid == false)
                {
                    LicenseConfig.ShowDialog(session, ParentForm);
                    return(false);
                }

                #region 保存设置

                var config = _LocalConfig;
                config.Features        = _Features.Where(x => x.Selected).Select(x => x.Type).ToList();
                config.LastTargetPath  = txtTargetPath.Text;
                config.AutoOpenAppName = string.Empty;
                config.VisualStyle     = visualStyle?.Key;
                config.LevelOfDetail   = levelOfDetail?.Value ?? -1;
                _Config.Save();

                #endregion

                var sw = Stopwatch.StartNew();
                try
                {
                    var setting = new ExportSetting();
                    setting.LevelOfDetail = config.LevelOfDetail;
                    setting.ExportType    = ExportType.Zip;
                    setting.OutputPath    = config.LastTargetPath;
                    setting.Features      = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList();
                    //setting.Selected2DViewIds = rb2DViewCustom.Checked ? _ViewIds : null;
                    setting.Oem = LicenseConfig.GetOemInfo(InnerApp.GetHomePath());

                    using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting))
                    {
                        var cancellationToken = progress.GetCancellationToken();
                        try
                        {
                            StartExport(_View, setting, progress.GetProgressCallback(), cancellationToken);
                        }
                        catch (IOException ex)
                        {
                            ShowMessageBox("文件保存失败: " + ex.ToString());
                        }

                        isCanncelled = cancellationToken.IsCancellationRequested;
                    }

                    sw.Stop();
                    var ts = sw.Elapsed;
                    ExportDuration = new TimeSpan(ts.Days, ts.Hours, ts.Minutes, ts.Seconds); //去掉毫秒部分

                    Debug.WriteLine(Strings.MessageOperationSuccessAndElapsedTime, ExportDuration);

                    if (isCanncelled == false)
                    {
                        ShowMessageBox(string.Format(Strings.MessageExportSuccess, ExportDuration));
                    }
                }
                catch (IOException ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, ex.ToString()));
                }
                //catch (Autodesk.Revit.Exceptions.ExternalApplicationException)
                //{
                //    sw.Stop();
                //    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                //    ShowMessageBox(Strings.MessageOperationFailureAndTryLater);
                //}
                catch (Exception ex)
                {
                    sw.Stop();
                    Debug.WriteLine(Strings.MessageOperationFailureAndElapsedTime, sw.Elapsed);

                    ShowMessageBox(ex.ToString());
                }
            }

            return(isCanncelled == false);
        }