public override void Execute(SldWorksModelProxy model, ReleasedComponent component, GenerationSettings generationSettings)
        {
            // This method gets called during generation, we now have full access to
            // 1). The release data for the component
            // 2). The evaluated result of our rules defined in the Parameters property
            // 3). The entire SOLIDWORKS API

            bool topLevelOnly = false;

            if (!this.Data.TryGetParameterValueAsBoolean(REBUILD_TOP_LEVEL_RULE_INVARIANT_NAME, ref topLevelOnly))
            {
                // The user didn't build a rule for the "Top Level Only" rule, or the rule evaluated
                // to something that couldn't be converted to a Boolean.
                // Report on it, and just use the default value of False
                this.Report.WriteEntry(Reporting.ReportingLevel.Minimal, Reporting.ReportEntryType.Information, "Rebuild Component Task", "Model Generation", "No / Invalid value provided for the 'Top Level Only'-rule. Assuming false.", null);
            }

            var forceRebuildSuccess = model.Model.ForceRebuild3(topLevelOnly);

            if (forceRebuildSuccess)
            {
                this.SetExecutionResult(TaskExecutionResult.Success, "Successfully force rebuilt model.");
            }
            else
            {
                this.SetExecutionResult(TaskExecutionResult.Failed, "Failed to force rebuild model.");
            }
        }
Exemple #2
0
        protected override bool Evaluate(SldWorksModelProxy model, ReleasedComponent component, GenerationSettings generationSettings)
        {
            // Using the provided SldWorksModelProxy object to query information from the current model.
            var nbrOfConfigurations       = model.Model.GetConfigurationCount();
            var hasMultipleConfigurations = nbrOfConfigurations > 1;

            // EvaluationResultDetails will be used by DriveWorks for reporting in the Model Generation Reports or Model Insight.
            if (hasMultipleConfigurations)
            {
                this.EvaluationResultDetails = $"The component has multiple configurations. ({nbrOfConfigurations} found).";
            }
            else
            {
                this.EvaluationResultDetails = "The component has 1 configuration only.";
            }

            return(hasMultipleConfigurations);
        }
        public override void Execute(SldWorksModelProxy model, ReleasedComponent component, GenerationSettings generationSettings)
        {
            var activeEnvironment = EnvironmentManager.GetEnvironment(generationSettings.Group);
            var activeGroupName   = generationSettings.Group.Name;

            using (var recordService = new RecordService(activeEnvironment.GetSQLExtendConnectionString()))
            {
                try
                {
                    int generationId = 0;
                    int stateId      = 0;

                    if (this.Data.TryGetParameterValueAsInteger(GENERATIONID, ref generationId))
                    {
                        this.Report.WriteEntry(ReportingLevel.Minimal, ReportEntryType.Information, "Report generation progress", "Report generation progress", "Generation id est invalide", null);
                    }

                    if (this.Data.TryGetParameterValueAsInteger(STATEID, ref stateId))
                    {
                        this.Report.WriteEntry(ReportingLevel.Minimal, ReportEntryType.Information, "Report generation progress", "Report generation progress", "State id est invalide", null);
                    }

                    //récupération de la génération
                    var theGeneration = recordService.GetGenerationById(generationId);
                    if (theGeneration == null)
                    {
                        throw new Exception("La génération est introuvable");
                    }
                    if (theGeneration.History.IsNotNullAndNotEmpty())
                    {
                        theGeneration.History += Environment.NewLine;
                    }

                    theGeneration.History += "Modification le '{0}', par '{1}', vers l'état {2}".FormatString(DateTime.Now.ToStringDMYHMS(), generationSettings.Group.CurrentUser.DisplayName, ((GenerationStatusEnum)stateId).GetName("FR"));
                    theGeneration.State    = (GenerationStatusEnum)stateId;

                    recordService.UpdageGeneration(theGeneration);
                }
                catch (Exception ex)
                {
                    this.Report.WriteEntry(ReportingLevel.Minimal, ReportEntryType.Information, "Report generation progress", "Report generation progress", "Erreur : " + ex.Message, null);
                }
            }
        }