Example of Fixed Asset Service Operations

using System;
using System.Collections.Generic;
using System.Text;

namespace AssetFixedAssetTest
{
    class Test
    {
        static void Main()
        {
            AssetFixedAssetServiceClient client = new AssetFixedAssetServiceClient();
            QueryCriteria queryCriteria = new QueryCriteria();
            AxdFixedAsset axdFA = new AxdFixedAsset();
            EntityKey[] entityKeyList = new EntityKey[1];

            //Set up query criteria for find.
            queryCriteria.CriteriaElement = new CriteriaElement[1];
            queryCriteria.CriteriaElement[0] = new CriteriaElement();
            queryCriteria.CriteriaElement[0].DataSourceName = "AssetTable";
            queryCriteria.CriteriaElement[0].FieldName = "AssetId";
            queryCriteria.CriteriaElement[0].Operator = Operator.Equal;
            queryCriteria.CriteriaElement[0].Value1 = "CNC-01";

            // Use the 'client' variable to call operations on the service.            
            axdFA = client.find(queryCriteria);
            
            axdFA.AssetTable[0].Name = "Copy of CNC-01";
            axdFA.AssetTable[0].AssetId = null;

            //Create a new asset.
            client.create(axdFA);
            
            //Set up entity key.
            entityKeyList[0] = new EntityKey();
            entityKeyList[0].KeyData = new KeyField[1];
            entityKeyList[0].KeyData[0] = new KeyField();
            entityKeyList[0].KeyData[0].Field = "AssetId";
            entityKeyList[0].KeyData[0].Value = "CNC-01";            

            //Update the Name field.            
            axdFA = client.find(queryCriteria);
            axdFA.AssetTable[0].Name = "Updated Name";
            client.update(entityKeyList, axdFA);                       

            // Always close the client.       
            client.Close();
            
        }
    }
}

 

posted @ 2016-03-25 16:50  止在入门  阅读(203)  评论(0编辑  收藏  举报