Generate - Intergraph Smart Reference Data - 2020 (10.0) - Help - Hexagon

Intergraph Smart Reference Data Plus Help (2020)

Language
English
Product
Intergraph Smart Reference Data
Search by Category
Help
Smart Materials/Smart Reference Data Version
2020 (10.0)

You can set up a custom procedure that runs when you click the Generate button on the Components page of the Spec Editor.

Project default

You must set a project default, ZS_SE_CGL, if you want to have the CIP run. If the entry is None for this project default, then the software does not run a CIP during generation of spec items.

The format of the entry for the project default is:

\custom\CustomerName.dll CustomerName.GenerationCustomize

The first part provides the location of the DLL based on the root directory, and the second part provides the class name of the custom class, including the root namespace.

Custom procedure

Interface

The spec generation customization depends on the following interface and transfer classes.

Public Interface ISpecResultGenerationCustomProcedures

Sub ModifyGenerationConditionForOneResultLine(

ByVal information As SpecResultGenerationInformationForCustomProcedure, _

ByVal data As SpecResultGenerationDataForCustomProcedure, _

ByVal context As WorkingContextForCustomProcedure)

End Interface

This interface function is called before the software starts searching for commodity codes for every result line.

Customers get an interface assembly with all the used interfaces and transfer classes. He does the programming part, and the software calls this custom package by interface.

Parameters of the interface

  • The first parameter is a class of type SpecResultGenerationInformationForCustomProcedure. All members of this class are read-only. You can use these members to retrieve information from the database. The members are:

    The BuildCodesOnTheFly is True if automatic code building on the fly is allowed.

  • The third parameter is a working context class with the following members:

    If Cancel is set to True, then no changes are used from the calling module.

    Connection is the Oracle connection to the correct login context. You can use this property to read or modify data in the database.

    For Messages, you can fill in message strings for the log.

  • The second parameter is a class with two other classes: SpecDefault and FilterLines.

    Here you can modify the search process.

    The SpecDefaultForCustomProcedure class has the following entries:

    All the read-only parameters are used for information retrieval.

    If you set the Ignore property to True, then the default filter has no effect on the search process for commodity codes.

    Filterlines is a list of SpecFilterLineForCustomProcedure classes. The class has the following entries:

    All the read-only parameters are used for information retrieval.

    The From and To nominal size properties can be changed for customizing.

    In the ListOfTableDetails parameter, you can find all table detail filter conditions from the filter line. You can make changes such as removing entries, adding entries, and so forth.

    This class has a special function called Clone. It makes a clone of itself, and this clone can be modified. For more information, see the examples.

Example 1

\bin\SPRDServerBusiness.dll Intergraph.Sprd.ServerBusiness.BusSpecGenerationCipSample1

''' <summary>

''' Do Nothing special

''' </summary>

''' <remarks></remarks>

Public Class BusSpecGenerationCipSample1

Implements ISpecResultGenerationCustomProcedures

''' <summary>

''' Gives only an information string back to the caller. You see this string in server log and spec

''' result log.

''' </summary>

''' <param name="information"></param>

''' <param name="data"></param>

''' <param name="context"></param>

''' <remarks></remarks>

Public Sub ModifyGenerationConditionForOneResultLine(ByVal information As SpecResultGenerationInformationForCustomProcedure, ByVal data As SpecResultGenerationDataForCustomProcedure, ByVal context As WorkingContextForCustomProcedure) Implements ISpecResultGenerationCustomProcedures.ModifyGenerationConditionForOneResultLine

context.Messages.Add("Custom Procedure Cip Sample 1")

context.Cancel = False

End Sub

End Class

Example 2

\bin\SPRDServerBusiness.dll Intergraph.Sprd.ServerBusiness.BusSpecGenerationCipSample2

This example removes the default filter before searching for commodity codes.

''' <summary>

''' Remove default filter.

''' </summary>

''' <remarks></remarks>

Public Class BusSpecGenerationCipSample2

Implements ISpecResultGenerationCustomProcedures

''' <summary>

''' Remove the default filter.

''' </summary>

''' <param name="information"></param>

''' <param name="data"></param>

''' <param name="context"></param>

''' <remarks></remarks>

Public Sub ModifyGenerationConditionForOneResultLine(ByVal information As SpecResultGenerationInformationForCustomProcedure, ByVal data As SpecResultGenerationDataForCustomProcedure, ByVal context As WorkingContextForCustomProcedure) Implements ISpecResultGenerationCustomProcedures.ModifyGenerationConditionForOneResultLine

context.Messages.Add("Custom Procedure Cip Sample 2")

data.SpecDefault.Ignore = True

context.Cancel = False

End Sub

End Class

Example 3

\bin\SPRDServerBusiness.dll Intergraph.Sprd.ServerBusiness.BusSpecGenerationCipSample3

This example duplicates all filter lines; it just shows some programming techniques.

''' <summary>

''' Duplicates all filter lines.

''' </summary>

''' <remarks></remarks>

Public Class BusSpecGenerationCipSample3

Implements ISpecResultGenerationCustomProcedures

''' <summary>

''' Duplicates all filter lines.

''' </summary>

''' <param name="information"></param>

''' <param name="data"></param>

''' <param name="context"></param>

''' <remarks></remarks>

Public Sub ModifyGenerationConditionForOneResultLine(ByVal information As SpecResultGenerationInformationForCustomProcedure, ByVal data As SpecResultGenerationDataForCustomProcedure, ByVal context As WorkingContextForCustomProcedure) Implements ISpecResultGenerationCustomProcedures.ModifyGenerationConditionForOneResultLine

context.Messages.Add("Custom Procedure Cip Sample 3")

Dim duplicateFilterlines As New List(Of SpecFilterLineForCustomProcedure)

For Each filterline As SpecFilterLineForCustomProcedure In data.FilterLines

Dim newLineBottom As SpecFilterLineForCustomProcedure = filterline.Clone

newLineBottom.FromNominalSize = newLineBottom.ToNominalSize

Dim newLineTop As SpecFilterLineForCustomProcedure = filterline.Clone

newLineTop.ToNominalSize = newLineTop.FromNominalSize

duplicateFilterlines.Add(newLineBottom)

duplicateFilterlines.Add(newLineTop)

Next

data.FilterLines.Clear()

data.FilterLines.AddRange(duplicateFilterlines.ToArray)

context.Cancel = False

End Sub

End Class

Example 4

\bin\SPRDServerBusiness.dll Intergraph.Sprd.ServerBusiness.BusSpecGenerationCipSample4

This example adds an additional filter line if the To size is larger than 20.00. In that case, the original line is cut to 20, and the additional line starts from 20 up to the original filter To value. In the additional filter line, we set an additional filter condition.

Case 1: From/To is 0.5 – 16, nothing special happens.

Case 2: From/To is 0.5 – 24, we get additional result lines. Lines are split at 20. The additional line has a subset of codes, because the line has an additional table detail filter.

''' <summary>

''' Do some complex operation.

''' </summary>

''' <remarks></remarks>

Public Class BusSpecGenerationCipSample4

Implements Intergraph.Sprd.ServerInterface.ISpecResultGenerationCustomProcedures

Private mChanged As Boolean

''' <summary>

''' Search for a special component group UT89GR01

''' If the to size is greater 20, than

''' we add an additional filterline

''' which includes an filter table detail for

''' for table ='SP_DIC_FAC',group = 'ALL' and detail = '0'

''' </summary>

''' <param name="information"></param>

''' <param name="data"></param>

''' <param name="context"></param>

''' <remarks></remarks>

Public Sub ModifyGenerationConditionForOneResultLine(ByVal information As SpecResultGenerationInformationForCustomProcedure, ByVal data As SpecResultGenerationDataForCustomProcedure, ByVal context As WorkingContextForCustomProcedure) Implements ISpecResultGenerationCustomProcedures.ModifyGenerationConditionForOneResultLine

context.Messages.Add("Custom Procedure Cip Sample 4")

Dim newLines As New List(Of SpecFilterLineForCustomProcedure)

Dim dt As New DataTable()

Dim sql As String = "SELECT * FROM M_COMPONENT_GROUPS CG WHERE CG.CPG_ID = " & information.ComponentGroupId

Dim mySqlDataAdapter As New OracleDataAdapter(sql, context.Connection)

mySqlDataAdapter.Fill(dt)

If dt.Rows.Count = 1 Then

Dim componentGroupCode As String = dt.Rows(0)("CPG_CODE").ToString

If componentGroupCode = "UT89GR01" Then

For Each line As SpecFilterLineForCustomProcedure In data.FilterLines

If CSng(line.ToNominalSize) > 20.0 Then

Dim newline As SpecFilterLineForCustomProcedure = line.Clone

newline.FromNominalSize = "20.00"

newline.ListOfTableDetails.Add("14646") ' Table/Group/Detail 'SP_DIC_FAC','ALL','0'

line.ToNominalSize = "20.00"

newLines.Add(newline)

End If

Next

End If

End If

data.FilterLines.AddRange(newLines.ToArray)

context.Cancel = False

End Sub

End Class

Visual Studio workflow

  1. Open Visual Studio.

  2. Choose New Project Class Library.

  3. Choose a project name and click OK.

  4. Rename the given Class 1 to a better name.

  5. Add a folder called InterfaceDll to the solution.

  6. Add the SPRDServerInterface.dll to the folder. (DLL is part of the delivery)

  7. Add two references to the solution: SPRDServerInterface and Oracle.DataAccess

    The class must implement the ISpecResultGenerationCustomProcedures interface.

  8. Do your programming in the function ModifyGenerationConditionForOneResultLine.

  9. Save and build the solution.

  10. Copy your custom.dll to the server.

Error logging

You can use the log files to see any errors generated while using the custom dll. Click Administration > Logs to see the log files.