Ниже приведен пример использования операции GetMs для создания модели. В запросе передается экземпляр открытого контейнера моделирования и шаблон метаданных для создания модели. В ответе приходит созданная модель.
{
"GetMs" :
{
"tMs" :
{
"id" : "GEGBFKLHGPMOFOAEIMFEBNKILLAKNJBEIKKFGPFLECLAJIMA!M!S!CEDFMNBMHGPMOFOAEEOKCHDKLPKPFFKNEILBKMMPKNGGGFEEE"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"scenarios" : "Get",
"period" : "true",
"item" :
{
"problem" :
{
"metamodel" :
{
"calculationChain" : "Get",
"mmParams" : "Get",
"tag" : "true",
"calcChainPattern" :
{
"modelPattern" :
{
"transform" :
{
"inputs" : "Get",
"outputs" : "Get",
"formulaCount" : "true",
"formulas" :
{
"method" : ""
},
"displayId" : "true",
"equationsFormula" :
{
"method" : ""
},
"series" : "Get",
"kind" : "true",
"displaySettings" : "true",
"additionalAttributes" : "true",
"calculationType" : "true",
"calculationDirection" : "true",
"transformVariable" :
{
"slices" : "Get",
"transformSlice" :
{
"selection" : "Get"
}
}
},
"stochastic" : "true",
"calculationPeriod" : "true",
"useModelPeriod" : "true",
"useExistingData" : "true",
"treatNullsAsZeros" : "true",
"autoName" : "true",
"generatedName" : "true",
"period" : "true",
"isExclusive" : "true",
"useAutoPeriod" : "true"
}
},
"visualControllerPattern" :
{
"variableRubricatorKey" : "true",
"useSourceName" : "true",
"levelFormat" : "Short"
}
},
"scenarios" : "Get",
"details" : "true",
"useSavedCoefficients" : "true"
}
}
},
"execParams" :
{
"execCreateProblem" :
{
"parent" : "1581",
"id" : "",
"name" : "Модель"
}
}
}
}
}
{
"GetMsResult" :
{
"id" :
{
"id" : "GEGBFKLHGPMOFOAEIMFEBNKILLAKNJBEIKKFGPFLECLAJIMA!M!S!CEDFMNBMHGPMOFOAEEOKCHDKLPKPFFKNEILBKMMPKNGGGFEEE"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "ключ 306480",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "6",
"@hf" : "0",
"i" : "MODELSPACE",
"n" : "Контейнер моделирования",
"k" : "306480",
"c" : "5121",
"p" : "1580",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "0",
"period" :
{
"start" : "1968-12-08",
"end" : "2022-12-31"
},
"scenarios" :
{
"nodes" :
{
"it" :
{
"@isFolder" : "0",
"k" : "306497",
"id" : "OBJ306497",
"n" : "Базовый",
"vis" : "1",
"scenDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "2",
"@hf" : "0",
"i" : "OBJ306497",
"n" : "Базовый",
"k" : "306497",
"c" : "5124",
"p" : "306485",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0"
},
"internalKey" : "306497"
}
}
},
"item" :
{
"k" : "306669",
"id" : "OBJ306669",
"n" : "Модель",
"vis" : "1",
"type" : "Problem",
"problemMd" :
{
"metamodel" :
{
"k" : "306670",
"calculationChain" :
{
"its" : ""
},
"mmParams" :
{
"its" : ""
},
"visualController" :
{
"userRPath" : "",
"isRExist" : "0"
},
"suppressEmptyFilter" :
{
"suppressEmpty" : "0",
"suppressEmptyArea" : "SerieBounds"
},
"readOnly" : "0",
"variableTestUseR" : "0",
"calculateIdentOnFact" : "0"
},
"scenarios" :
{
"its" : ""
},
"details" :
{
"period" :
{
"identificationStartDate" : "1968-01-01",
"identificationEndDate" : "2020-12-31",
"forecastStartDate" : "2020-12-31",
"forecastEndDate" : "2020-12-31",
"identificationStartDateParamID" : "",
"identificationEndDateParamID" : "",
"forecastStartDateParamID" : "",
"forecastEndDateParamID" : "",
"autoPeriod" : "0",
"identificationStartOffset" : "0",
"identificationEndOffset" : "0",
"forecastEndOffset" : "0",
"isIdentStartCorrect" : "1",
"isIdentEndCorrect" : "1",
"isForecastEndCorrect" : "1"
},
"currentPoint" : "2020-12-31"
},
"useSavedCoefficients" : "0",
"useScenarios" : "0",
"readOnly" : "0"
}
}
}
}
}
public static string GetMsNewModel(MsId ms, uint msKey, string id, string modelName)
{
// Создаем прокси-объект для выполнения операции
var somClient = new SomPortTypeClient();
// Параметры выполнения операции
var getMsOp = new GetMs()
{
tArg = new GetMsArg()
{
// Шаблон извлечения метаданных
pattern = new MsMdPattern()
{
scenarios = ListOperation.Get,
period = true,
item = new MsItemPattern()
{ // Шаблон метаданных модели
problem = new MsProblemPattern()
{
details = true,
scenarios = ListOperation.Get,
useSavedCoefficients = true,
// Шаблон метаданных метамодели
metamodel = new MsMetaModelPattern()
{
calculationChain = ListOperation.Get,
mmParams = ListOperation.Get,
tag = true,
// Шаблон метаданных для цепочки расчёта
calcChainPattern = new MsCalculationChainPattern()
{
modelPattern = new MsModelPattern()
{
transform = new MsFormulaTransformPattern()
{
inputs = ListOperation.Get,
outputs = ListOperation.Get,
kind = true,
formulaCount = true,
formulas = new TsFormulaPattern()
{
method = new TsMethodPattern()
},
displayId = true,
equationsFormula = new TsFormulaPattern()
{
method = new TsMethodPattern()
},
series = ListOperation.Get,
displaySettings = true,
additionalAttributes = true,
calculationType = true,
calculationDirection = true,
transformVariable = new MsFormulaTransformVariablePattern()
{
slices = ListOperation.Get,
transformSlice = new MsFormulaTransformSlicePattern()
{
selection = ListOperation.Get
}
}
},
stochastic = true,
calculationPeriod = true,
useModelPeriod = true,
useExistingData = true,
treatNullsAsZeros = true,
autoName = true,
period = true,
isExclusive = true,
useAutoPeriod = true,
generatedName = true
}
},
visualControllerPattern = new MsMetaModelVisualControllerPattern()
{
variableRubricatorKey = true,
levelFormat = MsLevelFormat.Short,
useSourceName = true
}
}
}
}
},
execParams = new MsMdExecParams()
{
execCreateProblem = new MsMdExecCreateProblem()
{
id = id,
name = modelName,
key = null,
parent = msKey
}
}
},
tMs = ms
};
// Создание модели
var result = somClient.GetMs(getMsOp);
return result.meta.item.id;
}
См. также: