陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Quintiq file version 2.0
#parent: #root
Method NewKBBranch (
  internal[KBFullID] kbfullid,
  Scenario scenario
) id:Method_ApplicationLibMacroPlanner_NewKBBranch
{
  #keys: '[11122.0.58944168]'
  Body:
  [*
    // Save as ... for a KnowledgeBase
    saveid := kbfullid;
    
    dlg := construct( dlgEditKBID );
    dlg.Data( saveid );
    
    if (saveid.Branch() = '' )
    {
      edit := select (Domain.KnowledgeBaseDefinitions(),Elements,el,el.Name() = saveid.Name() and el.Domain().Domain() = saveid.Domain());
      dlg.EditorBranch().Text( edit.DefaultBranchName() );
      dlg.EditorVersion().Text( '1.0.0.0' );
    }
    
    if ( dlg.DoModal( this ) > 0 )
    {
      editor := CKBEditor::Create();
      componentmds := ComponentMDS::CreateForLoadedMDSsOnly( Application );
      mdsinstance := selectobject( componentmds, ComponentMDSKinds.ComponentMDSInstances, m, m.MDSID().Equals( scenario.DatasetMDSID() ) );
      mdshandle := mdsinstance.GetMDSHandle();
    
      if ( kbfullid.ChangeNr() = 0 )
      {
        ckbhandle := editor.LoadMDSKB( mdshandle, kbfullid.KBID() );
        modelkb := editor.GetModelKB( kbfullid.KBID() );
        ckbhandle.CKB().Upgrade( modelkb.CKB() );
    
        editor.ApplyMDSKB( mdshandle,ckbhandle, true );
      }
    
      editor.SaveMDSKBAs( mdshandle, saveid, 'New branch' );
      ScenarioManager.UpdateScenarioKBInfo( scenario, saveid.Name(), saveid.Branch(), saveid.ChangeNr(), scenario.State(), '' )
    }
  *]
}