Ниже приведен пример использования операции GetMs для создания модели. В запросе передается экземпляр открытого контейнера моделирования и шаблон метаданных для создания модели. В ответе приходит созданная модель.
{
"Envelope" :
{
"Body" :
{
"GetMs" :
{
"tMs" :
{
"id" : "S47!M!S!C1"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"scenarios" : "Get",
"period" : "true",
"item" :
{
"key" : "0",
"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", "chainWorkbookKey" : "true" } }, "scenarios" : "Get", "details" : "true", "useSavedCoefficients" : "true" } } },
"execParams" :
{
"emptyProblemId" : "",
"emptyProblemName" : "Модель",
"execCreateEmptyProblem" : "true"
}
}
}
}
}
}
{
"Envelope" :
{
"Body" :
{
"GetMsResult" :
{
"id" :
{
"id" : "S47!M!S!C1"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@isShortcut" : "0",
"i" : "MODELSPACE", "n" : "Контейнер моделирования", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0" } }, "dirty" : "0", "period" :
{
"start" : "1990-01-01",
"end" : "2020-01-01"
},
"scenarios" :
{
"nodes" :
{
"it" :
[
{
"@isFolder" : "0",
"k" : "1628",
"id" : "OBJ1628",
"n" : "Базовый",
"vis" : "1",
"scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1628",
"n" : "Базовый",
"k" : "1628",
"c" : "5124",
"p" : "1627",
"h" : "0"
}
},
{
"@isFolder" : "0",
"k" : "1630",
"id" : "OBJ1630",
"n" : "Оптимистический",
"vis" : "1",
"scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1630",
"n" : "Оптимистический",
"k" : "1630",
"c" : "5124",
"p" : "1627",
"h" : "0"
}
},
{
"@isFolder" : "0",
"k" : "1632",
"id" : "OBJ1632",
"n" : "Устаревший",
"vis" : "1",
"scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1632",
"n" : "Устаревший",
"k" : "1632",
"c" : "5124",
"p" : "1627",
"h" : "0"
}
}
]
}
},
"item" :
{
"k" : "2564",
"id" : "OBJ2564",
"n" : "Модель",
"vis" : "1",
"type" : "Problem",
"problemMd" :
{
"metamodel" :
{
"k" : "2565",
"calculationChain" :
{
"its" : ""
},
"mmParams" :
{
"its" : ""
},
"visualController" :
{
"variableRubricatorKey" : "2566",
"chainWorkbookKey" : "2598"
}
},
"scenarios" :
{
"its" : ""
},
"details" :
{
"period" :
{
"identificationStartDate" : "1990-01-01",
"identificationEndDate" : "2012-07-31",
"forecastStartDate" : "2012-08-01", "forecastEndDate" : "2020-01-01", "identificationStartDateParamID" : "", "identificationEndDateParamID" : "", "forecastStartDateParamID" : "", "forecastEndDateParamID" : "", "autoPeriod" : "0", "identificationStartOffset" : "0", "identificationEndOffset" : "0", "forecastEndOffset" : "0"
}, "currentPoint" : "2012-08-01" }, "useSavedCoefficients" : "0" } } } } } } }
Функция GetMsNewModel создаёт новую модель. Экземпляр контейнера моделирования, наименование и идентификатор создаваемой модели передаются в качестве входных параметров. В результате выполнения функция возвращает идентификатор созданной модели.
public static string GetMsNewModel(MsId ms, string id, string name)
{
var getMsOp = new GetMs();
// Задаем параметры выполнения операции
getMsOp.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,
chainWorkbookKey = true
}
}
}
}
},
execParams = new MsMdExecParams()
{
emptyProblemId = id,
emptyProblemName = name,
execCreateEmptyProblem = true } }; getMsOp.tMs = ms; // Создаем прокси-объект для выполнения операции var somClient = new SomPortTypeClient(); GetMsResult getMsResult = somClient.GetMs(getMsOp); MsMd meta = getMsResult.meta; MsItem newModel = meta.item; return newModel.id; }
См. также:
SOAP