Deleting Variable

Below is the example of using the SetMs operation to delete a variable. The request contains an instance of opened modeling container, parameters of operation execution, data slice that corresponds to the variable to be deleted, and the pattern for getting changed data. After execution the operation returns the changed model.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SetMs xmlns="http://www.prognoz.ru/PP.SOM.Som">
<tMs xmlns="">
  <id>CEOHFIGABHNBFOAEACLDIHAAFIBLHLNEJJHHIHEGOIMCAOGA!M!S!CPOKJBJGABHNBFOAEFABNMBGBLLNHOPAEHKDKCJFDLLMFBFKJ</id>
  </tMs>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
<item>
  <key>92146</key>
<metaModel>
  <calculationChain>Remove</calculationChain>
  </metaModel>
  </item>
  </pattern>
<meta>
<item>
  <k>92146</k>
  <type>MetaModel</type>
<metaModelMd>
<calculationChain>
<its>
<Item>
  <k>1</k>
  <type>Variable</type>
  </Item>
  </its>
  </calculationChain>
  </metaModelMd>
  </item>
  </meta>
  </tArg>
  </SetMs>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SetMsResult xmlns="http://www.prognoz.ru/PP.SOM.Som" xmlns:q1="http://www.prognoz.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns="">
  <id>CEOHFIGABHNBFOAEACLDIHAAFIBLHLNEJJHHIHEGOIMCAOGA!M!S!CPOKJBJGABHNBFOAEFABNMBGBLLNHOPAEHKDKCJFDLLMFBFKJ</id>
  </id>
  </SetMsResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
 "SetMs" : 
  {
   "tMs" : 
    {
     "id" : "CEOHFIGABHNBFOAEACLDIHAAFIBLHLNEJJHHIHEGOIMCAOGA!M!S!CPOKJBJGABHNBFOAEFABNMBGBLLNHOPAEHKDKCJFDLLMFBFKJ"
    },
   "tArg" : 
    {
     "pattern" : 
      {
       "obInst" : "true",
       "item" : 
        {
         "key" : "92146",
         "metaModel" : 
          {
           "calculationChain" : "Remove"
          }
        }
      },
     "meta" : 
      {
       "item" : 
        {
         "k" : "92146",
         "type" : "MetaModel",
         "metaModelMd" : 
          {
           "calculationChain" : 
            {
             "its" : 
              {
               "Item" : 
                {
                 "k" : "1",
                 "type" : "Variable"
                }
              }
            }
          }
        }
      }
    }
  }
}

JSON response:

{
 "SetMsResult" : 
  {
   "id" : 
    {
     "id" : "CEOHFIGABHNBFOAEACLDIHAAFIBLHLNEJJHHIHEGOIMCAOGA!M!S!CPOKJBJGABHNBFOAEFABNMBGBLLNHOPAEHKDKCJFDLLMFBFKJ"
    }
  }
}
public static MsId SetMsDelVar(MsId ms, ulong metaKey, ulong varKeyDel)
{
    var setMsOp = new SetMs();
    setMsOp.tMs = ms;
    setMsOp.tArg = new SetMsArg()
    {  // Set data change pattern
        pattern = new MsMdPattern()
        {
            item = new MsItemPattern()
            {
                key = metaKey,
                metaModel = new MsMetaModelPattern()
                {
                    calculationChain = ListOperation.Remove
                }
            }
        },
        // Set data that must be changed
        meta = new MsMd()
        {
            item = new MsItem()
            {
                k = metaKey,
                type = MsItemType.MetaModel,
                metaModelMd = new MsMetaModel()
                {
                    calculationChain = new MsCalculationChainEntries()
                    {
                        its = new MsCalculationChainEntry[] 
                        {
                            new MsCalculationChainEntry()
                            {
                                k = varKeyDel,
                                type = MsCalculationChainType.Variable
                            }
                        }
                    }
                }
            }
        }        
    }; // Create a proxy object for operation execution
    var somClient = new SomPortTypeClient();
    // Set operation execution parameters
    var result = somClient.SetMs(setMsOp);
    return result.id;
}

See also:

SetMs: Operation