Hide Table of Contents
SetSerNoNextCounterVal Method (IEdmSerNoGen8)

Sets the next counter value for the specified serial number generator.

Syntax

Visual Basic (Declaration) 
Sub SetSerNoNextCounterVal( _
   ByVal bsSerNoName As System.String, _
   ByVal lNextCounterValue As System.Integer _
) 
C# 
void SetSerNoNextCounterVal( 
   System.string bsSerNoName,
   System.int lNextCounterValue
)
C++/CLI 
void SetSerNoNextCounterVal( 
&   System.String^ bsSerNoName,
&   System.int lNextCounterValue
) 

Parameters

bsSerNoName
Name of serial number generator
lNextCounterValue
Next value

Example

//Preconditions:

//1. Create a C# console application in Visual Studio.

//2. Add references EPDM.Interop.epdm and EPDM.Interop.EPDMResultCode to the project.

//3. Copy the code below to Program.cs.

//4. Change the namespace to match your project name.

//5. Add a serial number generator called “NSN” using the Admin tool.

//6. Ensure that parameters of Login match your vault.

//

//Postconditions:

//1. Open the Admin Tool.

//2. Observe that the next counter value for the NSN serial number generator is 9.

 

//Program.cs:

using System;

using System.Linq;

using System.Text;

using EPDM.Interop.epdm;

using EPDM.Interop.EPDMResultCode;

namespace project_name

{

  class Program

  {

    static string userName = "Admin";

    static string vaultName = "JEB12";

    static string serNoGenName = "NSN";

    static int newCounterValue = 9;

    static void Main(string[] args)

    {

      StringBuilder sb = new StringBuilder();

      try

      {

        sb.AppendFormat("UserName: {0}", userName).AppendLine();

        sb.AppendFormat("VaultName: {0}", vaultName).AppendLine();

        IEdmVault11 vault = (IEdmVault11)(new EdmVault5());

        if (!vault.IsLoggedIn)

          vault.Login(userName, "password", vaultName);

        IEdmSerNoGen7 serNoGen7 = (IEdmSerNoGen7)vault.CreateUtility(EdmUtility.EdmUtil_SerNoGen);

        string[] names = { };

        serNoGen7.GetSerialNumberNames(out names);

        sb.AppendFormat("Serial number generators present in vault: {0}", String.Join(",", names)).AppendLine();

        if (names.Contains(serNoGenName))

        {

          IEdmSerNoGen8 serNoGen8 = (IEdmSerNoGen8)serNoGen7;

          serNoGen8.SetSerNoNextCounterVal(serNoGenName, newCounterValue);

          sb.AppendFormat("Serial number generator's {0} next counter value set to {1}", serNoGenName, newCounterValue).AppendLine();

        }

        else

        {

          sb.AppendFormat("There is no {0} serial number generator present in vault", serNoGenName).AppendLine();

        }

      }

      catch (System.Runtime.InteropServices.COMException ex)

      {

        var errorType = typeof(EdmResultErrorCodes_e);

        if (Enum.IsDefined(errorType, ex.ErrorCode))

          sb.AppendFormat("Edm error occurred: {0}", Enum.GetName(errorType, ex.ErrorCode)).AppendLine();

        else

          sb.AppendLine("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);

      }

      catch (Exception ex)

      {

        sb.AppendFormat("Error occurred: {0}", ex.Message).AppendLine();

      }

      Console.WriteLine(sb.ToString());

      Console.WriteLine("Please press any key to exit");

      Console.ReadKey();

    }

  }

}

Remarks

Return codes:

  • S_OK: The method successfully executed.
  • E_EDM_INVALID_SERIAL_NUMBER_NAME is returned if bsSerNoName is incorrect.
  • E_EDM_PERMISSION_DENIED is returned if user does not have "Can update serial numbers" permission.
 

See Also

Availability

SOLIDWORKS PDM Professional 2022


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   SetSerNoNextCounterVal Method (IEdmSerNoGen8)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2022 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.