Beispiel #1
0
        private void InitSiteLocation(Document doc)
        {
            var site = ExporterHelper.GetSiteInfo(doc) ?? SiteInfo.CreateDefault();

            txtLongitude.Text = Math.Round(site.Longitude, 6).ToString(CultureInfo.InvariantCulture);
            txtLatitude.Text  = Math.Round(site.Latitude, 6).ToString(CultureInfo.InvariantCulture);
            txtHeight.Text    = Math.Round(site.Height, 6).ToString(CultureInfo.InvariantCulture);
            txtRotation.Text  = Math.Round(site.Rotation, 6).ToString(CultureInfo.InvariantCulture);
        }
Beispiel #2
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.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.GenerateThumbnail, cbGenerateThumbnail.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.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.Site = ExporterHelper.GetSiteInfo(_View.Document) ?? SiteInfo.CreateDefault();
                    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(string.Format(Strings.MessageFileSaveFailure, 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);
        }
Beispiel #3
0
        public void InitializeExport(IList <DocumentSeriesItemWSO> itemWsos, IList <ArchiveAttributeWSO> archiveAttributeWsos)
        {
            CsvFields.Clear();
            ArchiveAttribute.Clear();

            ArchiveAttribute = archiveAttributeWsos;
            if (this._parameters.ExportDocuments)
            {
                ArchiveAttribute.Add(new ArchiveAttributeWSO()
                {
                    Description = "DocumentName"
                });
                ArchiveAttribute.Add(new ArchiveAttributeWSO()
                {
                    Description = "DocumentType"
                });
            }

            if (!itemWsos.Any())
            {
                return;
            }

            foreach (var itemWso in itemWsos)
            {
                var seriesToCsv = new SeriesToCsvFields();
                seriesToCsv.Object          = itemWso.Subject;
                seriesToCsv.PublicationDate = itemWso.PublishingDate;
                seriesToCsv.IdSeries        = itemWso.IdDocumentSeries;
                seriesToCsv.IdSubsection    = itemWso.IdDocumentSeriesSubsection;

                foreach (var data in ArchiveAttribute)
                {
                    var value    = string.Empty;
                    var keyExist = itemWso.DynamicData.Any(x => x.Key.Eq(data.Name));
                    if (keyExist)
                    {
                        value =
                            itemWso.DynamicData.Where(x => x.Key.Eq(data.Name)).Select(s => s.Value).SingleOrDefault();
                    }

                    if (ExporterHelper.EnumTipoProcedimento.Eq(data.Name))
                    {
                        value = ExporterHelper.GetTipoProcedimento(value);
                    }

                    var dict = new KeyValuePair <string, object>(data.Description, value);

                    seriesToCsv.DynamicData.Add(dict);
                }

                if (this._parameters.ExportDocuments)
                {
                    DocumentSeriesItemWSO fullItem = this.WsSeriesConnector.GetFullItemWso(itemWso.Id);

                    fullItem.MainDocs.ForEach((x) =>
                    {
                        SeriesToCsvFields clone           = seriesToCsv.DeepClone();
                        clone.DynamicData["DocumentName"] = x.Name;
                        clone.DynamicData["DocumentType"] = "Documento Principale";
                        CsvFields.Add(clone);
                    });

                    fullItem.AnnexedDocs.ForEach((x) =>
                    {
                        SeriesToCsvFields clone           = seriesToCsv.DeepClone();
                        clone.DynamicData["DocumentName"] = x.Name;
                        clone.DynamicData["DocumentType"] = "Annesso";
                        CsvFields.Add(clone);
                    });

                    if (fullItem.MainDocs.Count == 0 && fullItem.AnnexedDocs.Count == 0)
                    {
                        CsvFields.Add(seriesToCsv);
                    }
                }
                else
                {
                    CsvFields.Add(seriesToCsv);
                }
            }
        }
        private void InitUI()
        {
            var config = _LocalConfig;

            if (config.Features != null && config.Features.Count > 0)
            {
                foreach (var featureType in config.Features)
                {
                    _Features.FirstOrDefault(x => x.Type == featureType)?.ChangeSelected(_Features, true);
                }
            }

            txtTargetPath.Text = config.LastTargetPath;

            bool IsAllowFeature(FeatureType feature)
            {
                return(_Features.Any(x => x.Type == feature && x.Selected));
            }

            #region 基本
            {
                //视觉样式
                var visualStyle = _VisualStyles.FirstOrDefault(x => x.Key == config.VisualStyle) ??
                                  _VisualStyleDefault;
                foreach (var p in visualStyle.Features)
                {
                    _Features.FirstOrDefault(x => x.Type == p.Key)?.ChangeSelected(_Features, p.Value);
                }
                cbVisualStyle.SelectedItem = visualStyle;

                //详细程度
                var levelOfDetail = _LevelOfDetails.FirstOrDefault(x => x.Value == config.LevelOfDetail) ??
                                    _LevelOfDetailDefault;
                cbLevelOfDetail.SelectedItem = levelOfDetail;
            }
            #endregion

            #region 排除
            {
                toolTip1.SetToolTip(cbExcludeLines, Strings.FeatureDescriptionExcludeLines);
                toolTip1.SetToolTip(cbExcludeModelPoints, Strings.FeatureDescriptionExcludePoints);
                toolTip1.SetToolTip(cbExcludeUnselectedElements, Strings.FeatureDescriptionOnlySelected);

                if (IsAllowFeature(FeatureType.ExcludeLines))
                {
                    cbExcludeLines.Checked = true;
                }

                if (IsAllowFeature(FeatureType.ExcludePoints))
                {
                    cbExcludeModelPoints.Checked = true;
                }

                if (IsAllowFeature(FeatureType.OnlySelected))
                {
                    cbExcludeUnselectedElements.Checked = true;
                }

                cbExcludeUnselectedElements.Enabled = _HasElementSelected;
            }
            #endregion

            #region 高级
            {
                toolTip1.SetToolTip(cbUseDraco, Strings.FeatureDescriptionUseGoogleDraco);
                //toolTip1.SetToolTip(cbUseExtractShell, Strings.FeatureDescriptionExtractShell);
                toolTip1.SetToolTip(cbGeneratePropDbSqlite, Strings.FeatureDescriptionGenerateModelsDb);
                toolTip1.SetToolTip(cbExportSvfzip, Strings.FeatureDescriptionExportSvfzip);
                toolTip1.SetToolTip(cbEnableQuantizedAttributes, Strings.FeatureDescriptionEnableQuantizedAttributes);
                toolTip1.SetToolTip(cbEnableTextureWebP, Strings.FeatureDescriptionEnableTextureWebP);
                toolTip1.SetToolTip(cbGenerateThumbnail, Strings.FeatureDescriptionGenerateThumbnail);
                toolTip1.SetToolTip(cbEnableUnlitMaterials, Strings.FeatureDescriptionEnableUnlitMaterials);

                if (IsAllowFeature(FeatureType.UseGoogleDraco))
                {
                    cbUseDraco.Checked = true;
                }

                //if (IsAllowFeature(FeatureType.ExtractShell))
                //{
                //    cbUseExtractShell.Checked = true;
                //}

                if (IsAllowFeature(FeatureType.GenerateModelsDb))
                {
                    cbGeneratePropDbSqlite.Checked = true;
                }

                if (IsAllowFeature(FeatureType.ExportSvfzip))
                {
                    cbExportSvfzip.Checked = true;
                }

                if (IsAllowFeature(FeatureType.EnableQuantizedAttributes))
                {
                    cbEnableQuantizedAttributes.Checked = true;
                }

                if (IsAllowFeature(FeatureType.EnableTextureWebP))
                {
                    cbEnableTextureWebP.Checked = true;
                }

                if (IsAllowFeature(FeatureType.GenerateThumbnail))
                {
                    cbGenerateThumbnail.Checked = true;
                }

                if (IsAllowFeature(FeatureType.EnableUnlitMaterials))
                {
                    cbEnableUnlitMaterials.Checked = true;
                }
            }
            #endregion

            #region 3D Tiles

            switch (config.Mode)
            {
            case 2:
                rbModeShellMesh.Checked = true;
                break;

            case 3:
                rbModeShellElement.Checked = true;
                break;

            default:
                rbModeBasic.Checked = true;
                break;
            }


            //toolTip1.SetToolTip(cbEmbedGeoreferencing, Strings.FeatureDescriptionEnableEmbedGeoreferencing);

            //cbEmbedGeoreferencing.Checked = IsAllowFeature(FeatureType.EnableEmbedGeoreferencing);

            #endregion

            #region 初始化场地配准信息
            {
                _ProjectSiteInfo = ExporterHelper.GetSiteInfo(_View.Document);
                if (_ProjectSiteInfo == null)
                {
                    //如果无法自动获取到项目站点信息,就禁用这个自动获取的选项
                    rbGeoreferencingSiteLocation.Enabled = false;
                }

                switch (config.GeoreferencingData)
                {
                case 0:     //不配准
                    rbGeoreferencingNone.Checked = true;
                    InitSiteLocation(config.GeoreferencingDetails ?? _ProjectSiteInfo ?? SiteInfo.CreateDefault());
                    break;

                case 1:     //自定义
                    rbGeoreferencingCustom.Checked = true;
                    InitSiteLocation(config.GeoreferencingDetails ?? _ProjectSiteInfo ?? SiteInfo.CreateDefault());
                    break;

                case 2:     //自动获取
                    if (_ProjectSiteInfo == null)
                    {
                        //如果无法获取到项目站点信息,改为按自定义处理
                        rbGeoreferencingCustom.Checked = true;
                        InitSiteLocation(config.GeoreferencingDetails ?? SiteInfo.CreateDefault());
                    }
                    else
                    {
                        rbGeoreferencingSiteLocation.Checked = true;
                        InitSiteLocation(_ProjectSiteInfo);
                    }
                    break;
                }
                OnRefreshGeoreferencingDataChanged(null, null);
            }
            #endregion

#if EXPRESS
            cbExportSvfzip.Enabled = false;
            cbExportSvfzip.Checked = false;
#else
            cbExportSvfzip.Enabled = true;
#endif
        }
Beispiel #5
0
        /// <summary>
        /// Generates the JDEdwards File sttopping when it finds a supervisor-assigned dispatch.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (!ReadyToExport())
            {
                if (user.Lineas.Count > 0)
                {
                    return;
                }
                lblError.ForeColor = Color.Red;
                lblError.Text      = "No posee permisos para reasignar despachos. Contacte con su supervisor.";
                lblError.Refresh();
                return;
            }
            var exporter = new ExporterHelper();

            try
            {
                progressBar.Visible = true;
                progressBar.Step    = 25;
                lblError.ForeColor  = Color.Green;
                lblError.Text       = String.Empty;
                lblError.Refresh();
                progressBar.Refresh();

                exporter.ExportDispatchsToLogictracker((int)ddlCentroCarga.SelectedValue);
                lblError.Text = "Despachos exportados correctamente";
                progressBar.PerformStep();
                progressBar.Refresh();
                lblError.Refresh();

                exporter.ExportToJDEdwards((int)ddlCentroCarga.SelectedValue);
                lblError.Text = "Archivos JDEdwards generados correctamente";
                progressBar.PerformStep();
                progressBar.Refresh();
                lblError.Refresh();

                exporter.ExportNivelesToLogictracker((int)ddlCentroCarga.SelectedValue);
                lblError.Text = "Niveles del Tanque exportados correctamente";
                progressBar.PerformStep();
                progressBar.Refresh();
                lblError.Refresh();

                exporter.ExportRemitosToLogictracker((int)ddlCentroCarga.SelectedValue);
                lblError.Text = "Remitos y Ajustes exportados correctamente";
                progressBar.PerformStep();
                progressBar.Refresh();
                lblError.Refresh();


                lblError.Text = "Exportación Realizada con éxito";
                lblError.Refresh();
                grdDespachos.DataSource = null;
                grdDespachos.Refresh();
            }
            catch (Exception ex)
            {
                progressBar.Visible = false;
                progressBar.Value   = 0;
                lblError.ForeColor  = Color.Red;
                lblError.Text       = ex.Message;
            }
        }
Beispiel #6
0
        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.ExportGrids, cbIncludeGrids.Checked);

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

            SetFeature(FeatureType.UseGoogleDraco, cbUseDraco.Checked);
            SetFeature(FeatureType.ExtractShell, cbUseExtractShell.Checked);
            SetFeature(FeatureType.GenerateModelsDb, cbGeneratePropDbSqlite.Checked);
            SetFeature(FeatureType.ExportSvfzip, cbExportSvfzip.Checked);
            SetFeature(FeatureType.GenerateThumbnail, cbGenerateThumbnail.Checked);
            SetFeature(FeatureType.EnableAutomaticSplit, cbEnableAutomaticSplit.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.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.OutputPath            = config.LastTargetPath;
                    setting.Features              = _Features.Where(x => x.Selected && x.Enabled).Select(x => x.Type).ToList();
                    setting.Site                  = ExporterHelper.GetSiteInfo(_View.GetRootModel()) ?? SiteInfo.CreateDefault();
                    setting.Oem                   = LicenseConfig.GetOemInfo(InnerApp.GetHomePath());
                    setting.PreExportSeedFeatures = InnerApp.GetPreExportSeedFeatures(@"glTF");

                    using (var progress = new ProgressExHelper(this.ParentForm, Strings.MessageExporting))
                    {
                        var cancellationToken = progress.GetCancellationToken();
                        try
                        {
                            StartExport(_View, setting, progress.GetProgressCallback(), cancellationToken);
                        }
                        catch (IOException ex)
                        {
                            ShowMessageBox(string.Format(Strings.MessageFileSaveFailure, 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.Message));
                }
                //catch (Autodesk.Dgn.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);
        }