Repository.Model.UpdateModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}
{{Template:Repository.UpdateModel.Cmt}} {{Template:BooleanReturn.Cmt}}


== Syntax==
UpdateModel( m {{APIPrefix|As}}[[cModel Class|cModel]] ) {{APIPrefix|As Boolean}}


Parameters
<onlyinclude>Updates the properties of a given model resource in the current project. Returns a '''Boolean''' value; when true, indicates a successful update.</onlyinclude>
:''m'': The [[cModel Class|cModel]] to update.


== Usage Example ==
{{APIComment|Declare a new repository connection class.}}
        Private WithEvents MyRepository As New Repository


{{APIComment|Connect to the Synthesis repository.}}
'''Remarks''': This method does not apply to published models, which are model resources that have been published from and are associated with an existing analysis/data source.
        Dim Success As Boolean = False
        Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")


{{APIComment|Get the list of Models in the connected repository.}}
== Syntax ==
        Dim ListOfModels() As [[NameIdPair Class|NameIdPair]]
'''.Model.UpdateModel'''(''m'')
        ListOfModels = MyRepository.GetAllModelsInfo()
=== Parameters ===
''m''
:Required. The [[CModel Class|cModel]] object that represents the model resource to be updated.


{{APIComment|Select the ID of the model and retrieve it.}}
        Dim AModel as cModel
        AModel = MyRepository.GetModel(ListOfModels(0).ID)


{{APIComment|After modifying AModel, update the repository.}}
== Example ==
        Dim SuccessUpdateModel As Boolean
This example assumes that a model with ID #47 exists in the first available project of a repository.
        SuccessUpdateModel = MyRepository.UpdateModel(AModel)
 
'''VBA'''
{{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
   
{{APIComment|'Get model #47 from project #1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1) 
  {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(47)
{{APIComment|'Change the model's name to "New_Name."}}
  AModel.Name = {{APIString|"New_Name"}}
{{APIComment|'Send the change to the Synthesis repository.}}
  {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)
 
'''VB.NET'''
{{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
  {{APIComment|'Get model #47 from project #1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1) 
  AModel = MyRepository.Model.GetModel(47)
{{APIComment|'Change the model's name to "New_Name."}}
  AModel.Name = {{APIString|"New_Name"}}
{{APIComment|'Send the change to the Synthesis repository.}}
  MyRepository.Model.UpdateModel(AModel)

Latest revision as of 20:34, 18 August 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Updates the properties of a given model resource in the current project. Returns a Boolean value; when true, indicates a successful update.


Remarks: This method does not apply to published models, which are model resources that have been published from and are associated with an existing analysis/data source.

Syntax

.Model.UpdateModel(m)

Parameters

m

Required. The cModel object that represents the model resource to be updated.


Example

This example assumes that a model with ID #47 exists in the first available project of a repository.

VBA

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
   
 'Get model #47 from project #1. 
  Dim AModel As cModel
  MyRepository.Project.SetCurrentProject(1)  
  Set AModel = MyRepository.Model.GetModel(47)

 'Change the model's name to "New_Name." 
  AModel.Name = "New_Name"

 'Send the change to the Synthesis repository. 
  Call MyRepository.Model.UpdateModel(AModel)
VB.NET

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")

  'Get model #47 from project #1. 
  Dim AModel As cModel
  MyRepository.Project.SetCurrentProject(1)  
  AModel = MyRepository.Model.GetModel(47)

 'Change the model's name to "New_Name." 
  AModel.Name = "New_Name"

 'Send the change to the Synthesis repository. 
  MyRepository.Model.UpdateModel(AModel)