using System;
using System.Collections.Generic;
using System.Threading;
using com.itac.mes.imsapi.domain.container;

namespace com.itac.mes.imsapi.client.dotnet
{
    public class IMSApiDotNet : IMSApiDotNetBase, IIMSApiDotNet
    {
        private Thread _subscriptionThread;
        private volatile bool _subscriptionStop;

        // Legacy 10.0.0-3 returned one process-wide singleton. Keep that behavior so
        // property state and callers compiled against the old DLL behave identically.
        private static IMSApiDotNet instance;
        private static readonly object instanceSync = new object();

        public static IMSApiDotNet loadLibrary()
        {
            if(instance!=null) return instance;
            lock(instanceSync)
            {
                if(instance==null) instance=new IMSApiDotNet();
                return instance;
            }
        }
        public override int imsapiGetLibraryVersion(ref string libraryVersion)
        {
            // FIX7 diagnostic output: show the value physically present in the
            // ihas.properties file next to IMSApiDotNet.dll. Do not use Prop() here,
            // because Prop() may return a setProperty override and would hide whether
            // the expected file was actually found/read.
            string filePath = GetIhasPropertyFilePathForDiagnostics();
            string clusterNodes = GetIhasPropertyForDiagnostics("itac.artes.clusternodes");

            libraryVersion = "10.0.0-59 C# HttpClient port" + Environment.NewLine +
                "ihas.properties=" + (string.IsNullOrWhiteSpace(filePath) ? "<not resolved>" : filePath) + Environment.NewLine +
                "itac.artes.clusternodes=" + (clusterNodes ?? "<not found in ihas.properties>");
            return 0;
        }

        public int adviceGetAdvice(IMSApiSessionContextStruct sessionContext, string stationNumber, bool ignoreStationNumber, bool checkStationGroup, bool checkPartGroup, KeyValue[] adviceFilters, ref Advice[] adviceArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.adviceGetAdvice(sessionContext, stationNumber, ignoreStationNumber, checkStationGroup, checkPartGroup, adviceFilters);
                adviceArray=r.adviceArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int adviceConfirmAdvice(IMSApiSessionContextStruct sessionContext, string stationNumber, string userName, string password, int adviceId, int confirmationStatus, string[] adviceEditTextArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.adviceConfirmAdvice(sessionContext, stationNumber, userName, password, adviceId, confirmationStatus, adviceEditTextArray);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribCreateAttribute(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string attributeCode, string attributeDesc, string uniquenessType)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribCreateAttribute(sessionContext, stationNumber, objectType, attributeCode, attributeDesc, uniquenessType);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribCheckAttributeValues(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, long bookDate, int allowOverWrite, string[] attributeUploadKeys, string[] attributeUploadValues, ref string[] attributeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribCheckAttributeValues(sessionContext, stationNumber, objectType, objectNumber, objectDetail, bookDate, allowOverWrite, attributeUploadKeys, attributeUploadValues);
                attributeResultValues=r.attributeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribAppendAttributeValues(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, long bookDate, int allowOverWrite, string[] attributeUploadKeys, string[] attributeUploadValues, ref string[] attributeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribAppendAttributeValues(sessionContext, stationNumber, objectType, objectNumber, objectDetail, bookDate, allowOverWrite, attributeUploadKeys, attributeUploadValues);
                attributeResultValues=r.attributeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribAppendAttributeValuesWriteDirect(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string[] attributeUploadKeys, string[] attributeUploadValues, ref string[] attributeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribAppendAttributeValuesWriteDirect(sessionContext, stationNumber, objectType, objectNumber, objectDetail, attributeUploadKeys, attributeUploadValues);
                attributeResultValues=r.attributeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribRemoveAttributeValue(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string attributeCode, string attributeValueKey)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribRemoveAttributeValue(sessionContext, stationNumber, objectType, objectNumber, objectDetail, attributeCode, attributeValueKey);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAttributeValues(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string[] attributeCodeArray, int allMergeLevel, string[] attributeResultKeys, ref string[] attributeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAttributeValues(sessionContext, stationNumber, objectType, objectNumber, objectDetail, attributeCodeArray, allMergeLevel, attributeResultKeys);
                attributeResultValues=r.attributeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetObjectsForAttributeValues(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string attributeCode, string attributeValue, int maxRows, KeyValue[] attributeFilters, string[] objectResultKeys, ref string[] objectResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetObjectsForAttributeValues(sessionContext, stationNumber, objectType, attributeCode, attributeValue, maxRows, attributeFilters, objectResultKeys);
                objectResultValues=r.objectResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAttributeClass(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeClassFilter, string[] classResultKeys, ref string[] classResultValues, string[] classTypeResultKeys, ref string[] classTypeResultValues, string[] classItemResultKeys, ref string[] classItemResultValues, string[] classItemConditionResultKeys, ref string[] classItemConditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAttributeClass(sessionContext, stationNumber, attributeClassFilter, classResultKeys, classTypeResultKeys, classItemResultKeys, classItemConditionResultKeys);
                classResultValues=r.classResultValues;
                classTypeResultValues=r.classTypeResultValues;
                classItemResultValues=r.classItemResultValues;
                classItemConditionResultValues=r.classItemConditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAttributeCondition(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeConditionFilter, string[] conditionResultKeys, ref string[] conditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAttributeCondition(sessionContext, stationNumber, attributeConditionFilter, conditionResultKeys);
                conditionResultValues=r.conditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribCreateAttributeCondition(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] conditionKeys, string[] conditionValues, ref string[] conditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribCreateAttributeCondition(sessionContext, stationNumber, conditionKeys, conditionValues);
                conditionResultValues=r.conditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribManageAttributeCondition(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeCodeFilter, string[] conditionKeys, string[] conditionValues, ref string[] conditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribManageAttributeCondition(sessionContext, stationNumber, attributeCodeFilter, conditionKeys, conditionValues);
                conditionResultValues=r.conditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribRemoveAttributeClassValue(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] attributeRemoveKeys, string[] attributeRemoveValues, ref string[] attributeRemoveResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribRemoveAttributeClassValue(sessionContext, stationNumber, attributeRemoveKeys, attributeRemoveValues);
                attributeRemoveResult=r.attributeRemoveResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribEditAttributeClassState(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeClassData)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribEditAttributeClassState(sessionContext, stationNumber, attributeClassData);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribCreateAttributeClass(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeClassCreateFilter, string[] classCreateKeys, string[] classCreateValues, string[] classCreateResultKeys, ref string[] classCreateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribCreateAttributeClass(sessionContext, stationNumber, attributeClassCreateFilter, classCreateKeys, classCreateValues, classCreateResultKeys);
                classCreateResultValues=r.classCreateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribManageAttributeClassAttribute(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeClassManageAttributeFilter, string[] classAttributeKeys, string[] classAttributeValues, ref string[] classAttributeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribManageAttributeClassAttribute(sessionContext, stationNumber, attributeClassManageAttributeFilter, classAttributeKeys, classAttributeValues);
                classAttributeResultValues=r.classAttributeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribManageAttributeClassCondition(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeClassManageAttributeFilter, string[] classConditionKeys, string[] classConditionValues, ref string[] classConditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribManageAttributeClassCondition(sessionContext, stationNumber, attributeClassManageAttributeFilter, classConditionKeys, classConditionValues);
                classConditionResultValues=r.classConditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribCreateAttributeCode(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] codeKeys, string[] codeValues, ref string[] codeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribCreateAttributeCode(sessionContext, stationNumber, codeKeys, codeValues);
                codeResultValues=r.codeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribUpdateAttributeCode(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] codeKeys, string[] codeValues, ref string[] codeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribUpdateAttributeCode(sessionContext, stationNumber, codeKeys, codeValues);
                codeResultValues=r.codeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAttributeCode(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeCodeFilter, string[] codeResultKeys, ref string[] codeResultValues, string[] conditionResultKeys, ref string[] conditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAttributeCode(sessionContext, stationNumber, attributeCodeFilter, codeResultKeys, conditionResultKeys);
                codeResultValues=r.codeResultValues;
                conditionResultValues=r.conditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribCreateAttributeCodeByCatalog(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeCodeFilter)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribCreateAttributeCodeByCatalog(sessionContext, stationNumber, attributeCodeFilter);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAllAttributeValue(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeValueSearchFilter, string[] attributeValueSearchKeys, string[] attributeValueSearchValues, string[] attributeValueResultKeys, ref string[] attributeValueSearchResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAllAttributeValue(sessionContext, stationNumber, attributeValueSearchFilter, attributeValueSearchKeys, attributeValueSearchValues, attributeValueResultKeys);
                attributeValueSearchResultValues=r.attributeValueSearchResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAttributeValuesForObjectType(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeFilterKeys, string[] attributeFilterArrayKeys, string[] attributeFilterArrayValues, string[] attributeResultKeys, ref string[] attributeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAttributeValuesForObjectType(sessionContext, stationNumber, attributeFilterKeys, attributeFilterArrayKeys, attributeFilterArrayValues, attributeResultKeys);
                attributeResultValues=r.attributeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribGetAttributeHistory(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string[] attributeCodeArray, KeyValue[] attributeHistoryFilter, string[] attributeHistoryResultKeys, ref string[] attributeHistoryResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribGetAttributeHistory(sessionContext, stationNumber, objectType, objectNumber, objectDetail, attributeCodeArray, attributeHistoryFilter, attributeHistoryResultKeys);
                attributeHistoryResultValues=r.attributeHistoryResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int attribUploadAttributeCacheData(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string attributeCacheData)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.attribUploadAttributeCacheData(sessionContext, stationNumber, objectType, objectNumber, objectDetail, attributeCacheData);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchAssignBatchNumberToWorkOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string partNumber, string bomVersion, string bomIndex, string bomVersionErp, int processLayer, string batchNumber, double quantity, int activateWorkOrder)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchAssignBatchNumberToWorkOrder(sessionContext, stationNumber, workOrderNumber, partNumber, bomVersion, bomIndex, bomVersionErp, processLayer, batchNumber, quantity, activateWorkOrder);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchRegisterBatch(IMSApiSessionContextStruct sessionContext, string stationNumber, string batchNumber, int processLayer, int ignoreBatchComplete, long registerDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchRegisterBatch(sessionContext, stationNumber, batchNumber, processLayer, ignoreBatchComplete, registerDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchUnregisterBatch(IMSApiSessionContextStruct sessionContext, string stationNumber, string batchNumber, int processLayer, double batchTotalQuantity, int batchComplete, long unregisterDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchUnregisterBatch(sessionContext, stationNumber, batchNumber, processLayer, batchTotalQuantity, batchComplete, unregisterDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchSplitBatchNumberToSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, ref string serialNumberRef, ref string serialNumberPos, string batchNumber, int processLayer, double usedBatchQuantity, int duplicateSerialNumber, int ignoreBatchComplete)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchSplitBatchNumberToSerialNumber(sessionContext, stationNumber, serialNumberRef, serialNumberPos, batchNumber, processLayer, usedBatchQuantity, duplicateSerialNumber, ignoreBatchComplete);
                serialNumberRef=r.serialNumberRef;
                serialNumberPos=r.serialNumberPos;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchMergeBatch(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberPos, string batchNumber, int processLayer, double usedBatchQuantity, int duplicateSerialNumber, int ignoreBatchComplete)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchMergeBatch(sessionContext, stationNumber, serialNumberRef, serialNumberPos, batchNumber, processLayer, usedBatchQuantity, duplicateSerialNumber, ignoreBatchComplete);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchGetRegisteredBatch(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string[] batchResultKeys, ref string[] batchResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchGetRegisteredBatch(sessionContext, stationNumber, processLayer, batchResultKeys);
                batchResultValues=r.batchResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchGetBatchInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] batchInfoFilter, string[] batchInfoResultKeys, ref string[] batchInfoResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchGetBatchInfo(sessionContext, stationNumber, batchInfoFilter, batchInfoResultKeys);
                batchInfoResultValues=r.batchInfoResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchUnregBatch(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] batchUploadKeyValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchUnregBatch(sessionContext, stationNumber, batchUploadKeyValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configCreateParameters(IMSApiSessionContextStruct sessionContext, KeyValue[] options, string[] parameterUploadKeys, string[] parameterUploadValues, string[] parameterResultKeys, ref string[] parameterResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configCreateParameters(sessionContext, options, parameterUploadKeys, parameterUploadValues, parameterResultKeys);
                parameterResultValues=r.parameterResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configUpdateParameters(IMSApiSessionContextStruct sessionContext, KeyValue[] options, string[] parameterUploadKeys, string[] parameterUploadValues, string[] parameterResultKeys, ref string[] parameterResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configUpdateParameters(sessionContext, options, parameterUploadKeys, parameterUploadValues, parameterResultKeys);
                parameterResultValues=r.parameterResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configGetParameters(IMSApiSessionContextStruct sessionContext, KeyValue[] options, KeyValue[] parameterFilter, string[] parameterResultKeys, ref string[] parameterResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configGetParameters(sessionContext, options, parameterFilter, parameterResultKeys);
                parameterResultValues=r.parameterResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configDeleteParameters(IMSApiSessionContextStruct sessionContext, KeyValue[] options, KeyValue[] parameterFilter, string[] parameterResultKeys, ref string[] parameterResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configDeleteParameters(sessionContext, options, parameterFilter, parameterResultKeys);
                parameterResultValues=r.parameterResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configGetValues(IMSApiSessionContextStruct sessionContext, KeyValue[] options, KeyValue[] configContext, KeyValue[] parameterFilter, string[] parameterResultKeys, ref string[] parameterResultValues, string[] resultKeys, ref string[] resultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configGetValues(sessionContext, options, configContext, parameterFilter, parameterResultKeys, resultKeys);
                parameterResultValues=r.parameterResultValues;
                resultValues=r.resultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configUpdateValues(IMSApiSessionContextStruct sessionContext, KeyValue[] options, KeyValue[] configContext, string[] uploadKeys, string[] uploadValues, string[] resultKeys, ref string[] resultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configUpdateValues(sessionContext, options, configContext, uploadKeys, uploadValues, resultKeys);
                resultValues=r.resultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configDeleteValues(IMSApiSessionContextStruct sessionContext, KeyValue[] options, KeyValue[] configContext, string[] uploadKeys, string[] uploadValues, string[] resultKeys, ref string[] resultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configDeleteValues(sessionContext, options, configContext, uploadKeys, uploadValues, resultKeys);
                resultValues=r.resultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int configGetDimensionValues(IMSApiSessionContextStruct sessionContext, KeyValue[] options, KeyValue[] dimensionFilter, ref string[] resultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.configGetDimensionValues(sessionContext, options, dimensionFilter);
                resultValues=r.resultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customFunction(IMSApiSessionContextStruct sessionContext, string methodName, string[] inArgs, ref string[] outArgs, ref string customErrorString)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customFunction(sessionContext, methodName, inArgs);
                outArgs=r.outArgs;
                customErrorString=r.customErrorString;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customGetDbObjectMetaData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] dbObjectFilterKeyValues, string[] dbColumnMetaDataResultKeys, ref string[] dbColumnMetaDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customGetDbObjectMetaData(sessionContext, stationNumber, dbObjectFilterKeyValues, dbColumnMetaDataResultKeys);
                dbColumnMetaDataResultValues=r.dbColumnMetaDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customGetDbObjectData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] dbObjectSearchKeyValues, string[] dbColumnFilterKeys, string[] dbColumnFilterValues, string[] dbColumnOrderKeys, string[] dbColumnOrderValues, string[] dbColumnResultKeys, ref string[] dbColumnResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customGetDbObjectData(sessionContext, stationNumber, dbObjectSearchKeyValues, dbColumnFilterKeys, dbColumnFilterValues, dbColumnOrderKeys, dbColumnOrderValues, dbColumnResultKeys);
                dbColumnResultValues=r.dbColumnResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customModifyDbObjectData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] dbObjectModifyKeyValues, string[] dbColumnInsertKeys, string[] dbColumnInsertValues, string[] dbColumnInsertResultKeys, string[] dbColumnUpdateKeys, string[] dbColumnUpdateValues, string[] dbColumnUpdateResultKeys, string[] dbRowDeleteFilterKeys, string[] dbRowDeleteFilterValues, ref string[] dbColumnInsertResultValues, ref string[] dbColumnUpdateResultValues, ref string[] dbColumnDeleteResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customModifyDbObjectData(sessionContext, stationNumber, dbObjectModifyKeyValues, dbColumnInsertKeys, dbColumnInsertValues, dbColumnInsertResultKeys, dbColumnUpdateKeys, dbColumnUpdateValues, dbColumnUpdateResultKeys, dbRowDeleteFilterKeys, dbRowDeleteFilterValues);
                dbColumnInsertResultValues=r.dbColumnInsertResultValues;
                dbColumnUpdateResultValues=r.dbColumnUpdateResultValues;
                dbColumnDeleteResultValues=r.dbColumnDeleteResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customGetFunctionInfo(IMSApiSessionContextStruct sessionContext, KeyValue[] functionInfoFilterKeyValues, string[] functionInfoResultKeys, ref string[] functionInfoResultValues, string[] parameterInfoResultKeys, ref string[] parameterInfoResultValues, string[] returnInfoResultKeys, ref string[] returnInfoResultValues, string[] errorCodeResultKeys, ref string[] errorCodeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customGetFunctionInfo(sessionContext, functionInfoFilterKeyValues, functionInfoResultKeys, parameterInfoResultKeys, returnInfoResultKeys, errorCodeResultKeys);
                functionInfoResultValues=r.functionInfoResultValues;
                parameterInfoResultValues=r.parameterInfoResultValues;
                returnInfoResultValues=r.returnInfoResultValues;
                errorCodeResultValues=r.errorCodeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customGetFunctions(IMSApiSessionContextStruct sessionContext, KeyValue[] functionFilterKeyValues, string[] functionInfoResultKeys, ref string[] functionInfoResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customGetFunctions(sessionContext, functionFilterKeyValues, functionInfoResultKeys);
                functionInfoResultValues=r.functionInfoResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customGetCustomEntities(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityFilterKeyValues, string[] entityResultKeys, ref string[] entityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customGetCustomEntities(sessionContext, stationNumber, entityFilterKeyValues, entityResultKeys);
                entityResultValues=r.entityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customCreateCustomEntities(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityCreateKeyValues, string[] entityCreateKeys, string[] entityCreateValues, ref string[] entityCreateResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customCreateCustomEntities(sessionContext, stationNumber, entityCreateKeyValues, entityCreateKeys, entityCreateValues);
                entityCreateResult=r.entityCreateResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customUpdateCustomEntities(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityUpdateKeyValues, string[] entityUpdateKeys, string[] entityUpdateValues, ref string[] entityUpdateResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customUpdateCustomEntities(sessionContext, stationNumber, entityUpdateKeyValues, entityUpdateKeys, entityUpdateValues);
                entityUpdateResult=r.entityUpdateResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customDeleteCustomEntities(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityDeleteKeyValues, string[] entityDeleteKeys, string[] entityDeleteValues, ref string[] entityDeleteResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customDeleteCustomEntities(sessionContext, stationNumber, entityDeleteKeyValues, entityDeleteKeys, entityDeleteValues);
                entityDeleteResult=r.entityDeleteResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customGetCustomEntityTypes(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityTypeFilterKeyValues, string[] entityTypeResultKeys, ref string[] entityTypeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customGetCustomEntityTypes(sessionContext, stationNumber, entityTypeFilterKeyValues, entityTypeResultKeys);
                entityTypeResultValues=r.entityTypeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customCreateCustomEntityType(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityTypeCreateKeyValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customCreateCustomEntityType(sessionContext, stationNumber, entityTypeCreateKeyValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customUpdateCustomEntityType(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityTypeUpdateKeyValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customUpdateCustomEntityType(sessionContext, stationNumber, entityTypeUpdateKeyValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int customDeleteCustomEntityType(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] entityTypeDeleteKeyValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.customDeleteCustomEntityType(sessionContext, stationNumber, entityTypeDeleteKeyValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int edaGetNextFreeExternalData(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, int functionMode, string[] nextFreeExternalDataFilterKeys, string[] nextFreeExternalDataFilterValues, string[] nextFreeExternalDataResultKeys, ref string[] nextFreeExternalDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.edaGetNextFreeExternalData(sessionContext, stationNumber, objectType, objectNumber, objectDetail, functionMode, nextFreeExternalDataFilterKeys, nextFreeExternalDataFilterValues, nextFreeExternalDataResultKeys);
                nextFreeExternalDataResultValues=r.nextFreeExternalDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int edaAssignExternalData(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string[] assignExternalDataUploadKeys, string[] assignExternalDataUploadValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.edaAssignExternalData(sessionContext, stationNumber, objectType, objectNumber, objectDetail, assignExternalDataUploadKeys, assignExternalDataUploadValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int edaGetObjectsForExternalData(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] objectExternalDataFilterKeys, string[] objectExternalDataFilterValues, string[] objectExternalDataResultKeys, ref string[] objectExternalDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.edaGetObjectsForExternalData(sessionContext, stationNumber, objectExternalDataFilterKeys, objectExternalDataFilterValues, objectExternalDataResultKeys);
                objectExternalDataResultValues=r.objectExternalDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int edaGetExternalDataForObject(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] externalDataFilterKeys, string[] externalDataFilterValues, string[] externalDataResultKeys, ref string[] externalDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.edaGetExternalDataForObject(sessionContext, stationNumber, externalDataFilterKeys, externalDataFilterValues, externalDataResultKeys);
                externalDataResultValues=r.externalDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int edaManageExternalData(IMSApiSessionContextStruct sessionContext, string stationNumber, int functionMode, string[] partGroupArray, string[] partNumberArray, KeyValue[] manageExternalData, string[] externalDataValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.edaManageExternalData(sessionContext, stationNumber, functionMode, partGroupArray, partNumberArray, manageExternalData, externalDataValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equCheckEquipmentData(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string serialNumber, string partNumber, int processLayer, int returnFailuresOnly, string[] equipmentResultKeys, ref string[] equipmentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equCheckEquipmentData(sessionContext, stationNumber, workOrderNumber, serialNumber, partNumber, processLayer, returnFailuresOnly, equipmentResultKeys);
                equipmentResultValues=r.equipmentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equUpdateEquipmentData(IMSApiSessionContextStruct sessionContext, string stationNumber, int setupFlag, string serialNumber, string workOrderNumber, int processLayer, string[] equipmentUploadKeys, string[] equipmentUploadValues, ref string[] equipmentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equUpdateEquipmentData(sessionContext, stationNumber, setupFlag, serialNumber, workOrderNumber, processLayer, equipmentUploadKeys, equipmentUploadValues);
                equipmentResultValues=r.equipmentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetSetupEquipmentData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] equipmentSetupFilters, string[] equipmentSetupResultKeys, ref string[] equipmentSetupResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetSetupEquipmentData(sessionContext, stationNumber, equipmentSetupFilters, equipmentSetupResultKeys);
                equipmentSetupResultValues=r.equipmentSetupResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetRequiredEquipmentData(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string serialNumber, string partNumber, int processLayer, string pmGroup, string[] equipmentResultKeys, ref string[] equipmentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetRequiredEquipmentData(sessionContext, stationNumber, workOrderNumber, serialNumber, partNumber, processLayer, pmGroup, equipmentResultKeys);
                equipmentResultValues=r.equipmentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetRequiredEquipmentDetail(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] requiredEquipmentFilterKeys, string[] requiredEquipmentResultKeys, ref string[] requiredEquipmentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetRequiredEquipmentDetail(sessionContext, stationNumber, requiredEquipmentFilterKeys, requiredEquipmentResultKeys);
                requiredEquipmentResultValues=r.requiredEquipmentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equRemoveEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string serialNumber, int processLayer)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equRemoveEquipment(sessionContext, stationNumber, workOrderNumber, serialNumber, processLayer);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equSetLocation(IMSApiSessionContextStruct sessionContext, string stationNumber, string equipmentNo, string equipmentIndex, string location)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equSetLocation(sessionContext, stationNumber, equipmentNo, equipmentIndex, location);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] equipmentGetFilters, string[] equipmentGetResultKeys, ref string[] equipmentGetResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetEquipment(sessionContext, stationNumber, equipmentGetFilters, equipmentGetResultKeys);
                equipmentGetResultValues=r.equipmentGetResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equUpdateEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] equipmentUpdateKeys, string[] equipmentUpdateValues, ref string[] equipmentUpdateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equUpdateEquipment(sessionContext, stationNumber, equipmentUpdateKeys, equipmentUpdateValues);
                equipmentUpdateResultValues=r.equipmentUpdateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equReportQuantity(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] equReportQuantityKeys, string[] equReportQuantityValues, ref string[] equReportQuantityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equReportQuantity(sessionContext, stationNumber, equReportQuantityKeys, equReportQuantityValues);
                equReportQuantityResultValues=r.equReportQuantityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equCreateEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] equipmentUploadKeys, string[] equipmentUploadValues, ref string[] equipmentUploadResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equCreateEquipment(sessionContext, stationNumber, equipmentUploadKeys, equipmentUploadValues);
                equipmentUploadResultValues=r.equipmentUploadResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCarrierAssignRule(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] carrierGetFilters, string[] carrierGetMainResultKeys, string[] carrierGetSerialNoAssignRuleResultKeys, string[] carrierGetCarrierAssignRuleResultKeys, ref string[] carrierGetMainResultValues, ref string[] carrierGetSerialNoAssignRuleResultValues, ref string[] carrierGetCarrierAssignRuleResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCarrierAssignRule(sessionContext, stationNumber, carrierGetFilters, carrierGetMainResultKeys, carrierGetSerialNoAssignRuleResultKeys, carrierGetCarrierAssignRuleResultKeys);
                carrierGetMainResultValues=r.carrierGetMainResultValues;
                carrierGetSerialNoAssignRuleResultValues=r.carrierGetSerialNoAssignRuleResultValues;
                carrierGetCarrierAssignRuleResultValues=r.carrierGetCarrierAssignRuleResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCarrierAssigned(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] carrierGetFilters, string[] carrierMainResultKeys, ref string[] carrierMainResultValues, string[] carrierSerialNoAssignedResultKeys, ref string[] carrierSerialNoAssignedResultValues, string[] carrierCarrierAssignedResultKeys, ref string[] carrierCarrierAssignedResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCarrierAssigned(sessionContext, stationNumber, carrierGetFilters, carrierMainResultKeys, carrierSerialNoAssignedResultKeys, carrierCarrierAssignedResultKeys);
                carrierMainResultValues=r.carrierMainResultValues;
                carrierSerialNoAssignedResultValues=r.carrierSerialNoAssignedResultValues;
                carrierCarrierAssignedResultValues=r.carrierCarrierAssignedResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCarrierAssignmentHistoryData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] carrierGetFilters, string[] carrierSerialNumberAssignedHistoryResultKeys, ref string[] carrierSerialNumberAssignedHistoryResultValues, string[] carrierCarrierAssignedHistoryResultKeys, ref string[] carrierCarrierAssignedHistoryResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCarrierAssignmentHistoryData(sessionContext, stationNumber, carrierGetFilters, carrierSerialNumberAssignedHistoryResultKeys, carrierCarrierAssignedHistoryResultKeys);
                carrierSerialNumberAssignedHistoryResultValues=r.carrierSerialNumberAssignedHistoryResultValues;
                carrierCarrierAssignedHistoryResultValues=r.carrierCarrierAssignedHistoryResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCarrierToSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] carrierToSerialNumberFilters, string[] carrierToSerialNumberResultKeys, ref string[] carrierToSerialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCarrierToSerialNumber(sessionContext, stationNumber, carrierToSerialNumberFilters, carrierToSerialNumberResultKeys);
                carrierToSerialNumberResultValues=r.carrierToSerialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCarrierToCarrier(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] carrierToCarrierFilters, string[] carrierToCarrierResultKeys, ref string[] carrierToCarrierResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCarrierToCarrier(sessionContext, stationNumber, carrierToCarrierFilters, carrierToCarrierResultKeys);
                carrierToCarrierResultValues=r.carrierToCarrierResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equAssignSerialNumberToCarrier(IMSApiSessionContextStruct sessionContext, string stationNumber, string equipmentNumber, string equipmentIndex, int setState, string[] assignSerialNumberToCarrierKeys, string[] assignSerialNumberToCarrierValues, ref string[] assignSerialNumberToCarrierResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equAssignSerialNumberToCarrier(sessionContext, stationNumber, equipmentNumber, equipmentIndex, setState, assignSerialNumberToCarrierKeys, assignSerialNumberToCarrierValues);
                assignSerialNumberToCarrierResultValues=r.assignSerialNumberToCarrierResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equRemoveSerialNumberFromCarrier(IMSApiSessionContextStruct sessionContext, string stationNumber, string equipmentNumber, string equipmentIndex, string[] removeSerialNumberFromCarrierKeys, string[] removeSerialNumberFromCarrierValues, ref string[] removeSerialNumberFromCarrierResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equRemoveSerialNumberFromCarrier(sessionContext, stationNumber, equipmentNumber, equipmentIndex, removeSerialNumberFromCarrierKeys, removeSerialNumberFromCarrierValues);
                removeSerialNumberFromCarrierResultValues=r.removeSerialNumberFromCarrierResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equAssignCarrierToCarrier(IMSApiSessionContextStruct sessionContext, string stationNumber, string equipmentNumber, string equipmentIndex, string[] assignCarrierToCarrierKeys, string[] assignCarrierToCarrierValues, ref string[] assignCarrierToCarrierResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equAssignCarrierToCarrier(sessionContext, stationNumber, equipmentNumber, equipmentIndex, assignCarrierToCarrierKeys, assignCarrierToCarrierValues);
                assignCarrierToCarrierResultValues=r.assignCarrierToCarrierResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equRemoveCarrierFromCarrier(IMSApiSessionContextStruct sessionContext, string stationNumber, string equipmentNumber, string equipmentIndex, string[] removeCarrierFromCarrierKeys, string[] removeCarrierFromCarrierValues, ref string[] removeCarrierFromCarrierResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equRemoveCarrierFromCarrier(sessionContext, stationNumber, equipmentNumber, equipmentIndex, removeCarrierFromCarrierKeys, removeCarrierFromCarrierValues);
                removeCarrierFromCarrierResultValues=r.removeCarrierFromCarrierResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equSetEquipmentLocation(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] equipmentLocationKeys, string[] equipmentLocationValues, ref string[] equipmentLocationResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equSetEquipmentLocation(sessionContext, stationNumber, equipmentLocationKeys, equipmentLocationValues);
                equipmentLocationResultValues=r.equipmentLocationResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCarrierLocation(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] carrierLocationFilters, string[] carrierLocationResultKeys, ref string[] carrierLocationResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCarrierLocation(sessionContext, stationNumber, carrierLocationFilters, carrierLocationResultKeys);
                carrierLocationResultValues=r.carrierLocationResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetEquipmentLocationHist(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] equipmentLocationFilters, string[] equipmentLocationResultKeys, ref string[] equipmentLocationResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetEquipmentLocationHist(sessionContext, stationNumber, equipmentLocationFilters, equipmentLocationResultKeys);
                equipmentLocationResultValues=r.equipmentLocationResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equSetupAssetEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] setupAssetEquipmentUploadKeys, string[] setupAssetEquipmentUploadValues, string[] setupAssetEquipmentResultKeys, ref string[] setupAssetEquipmentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equSetupAssetEquipment(sessionContext, stationNumber, setupAssetEquipmentUploadKeys, setupAssetEquipmentUploadValues, setupAssetEquipmentResultKeys);
                setupAssetEquipmentResultValues=r.setupAssetEquipmentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetAssetEquipmentSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] getAssetEquipmentSetupFilters, string[] getAssetEquipmentSetupResultKeys, ref string[] getAssetEquipmentSetupResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetAssetEquipmentSetup(sessionContext, stationNumber, getAssetEquipmentSetupFilters, getAssetEquipmentSetupResultKeys);
                getAssetEquipmentSetupResultValues=r.getAssetEquipmentSetupResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetAssignedCavity(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] cavityGetAssignedCavityFilters, string[] cavityGetAssignedCavityResultKeys, ref string[] cavityGetAssignedCavityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetAssignedCavity(sessionContext, stationNumber, cavityGetAssignedCavityFilters, cavityGetAssignedCavityResultKeys);
                cavityGetAssignedCavityResultValues=r.cavityGetAssignedCavityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equManagePartCavityRule(IMSApiSessionContextStruct sessionContext, string stationNumber, string cavityPartNumber, string[] managePartCavityRuleKeys, string[] managePartCavityRuleValues, ref string[] managePartCavityRuleResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equManagePartCavityRule(sessionContext, stationNumber, cavityPartNumber, managePartCavityRuleKeys, managePartCavityRuleValues);
                managePartCavityRuleResultValues=r.managePartCavityRuleResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equManageCavityEquipmentRule(IMSApiSessionContextStruct sessionContext, string stationNumber, string equipmentPartNumber, string[] manageCavityEquipmentRuleKeys, string[] manageCavityEquipmentRuleValues, ref string[] manageCavityEquipmentRuleResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equManageCavityEquipmentRule(sessionContext, stationNumber, equipmentPartNumber, manageCavityEquipmentRuleKeys, manageCavityEquipmentRuleValues);
                manageCavityEquipmentRuleResultValues=r.manageCavityEquipmentRuleResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equAssignCavityToEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] assignEquipmentKeys, string[] assignCavityKeys, string[] assignCavityValues, ref string[] assignCavityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equAssignCavityToEquipment(sessionContext, stationNumber, assignEquipmentKeys, assignCavityKeys, assignCavityValues);
                assignCavityResultValues=r.assignCavityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equRemoveCavityFromEquipment(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] removeEquipmentKeys, string[] removeCavityKeys, string[] removeCavityValues, ref string[] removeCavityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equRemoveCavityFromEquipment(sessionContext, stationNumber, removeEquipmentKeys, removeCavityKeys, removeCavityValues);
                removeCavityResultValues=r.removeCavityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equUpdateAssignedCavity(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] updateEquipmentKeys, string[] updateAssignedCavityKeys, string[] updateAssignedCavityValues, ref string[] updateAssignedCavityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equUpdateAssignedCavity(sessionContext, stationNumber, updateEquipmentKeys, updateAssignedCavityKeys, updateAssignedCavityValues);
                updateAssignedCavityResultValues=r.updateAssignedCavityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetPartCavityAssignRule(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] partCavityAssignRuleFilters, string[] partCavityAssignRuleResultKeys, ref string[] partCavityAssignRuleResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetPartCavityAssignRule(sessionContext, stationNumber, partCavityAssignRuleFilters, partCavityAssignRuleResultKeys);
                partCavityAssignRuleResultValues=r.partCavityAssignRuleResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equGetCavityEquipmentAssignRule(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] cavityEquipmentAssignRuleFilters, string[] cavityEquipmentAssignRuleResultKeys, ref string[] cavityEquipmentAssignRuleResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equGetCavityEquipmentAssignRule(sessionContext, stationNumber, cavityEquipmentAssignRuleFilters, cavityEquipmentAssignRuleResultKeys);
                cavityEquipmentAssignRuleResultValues=r.cavityEquipmentAssignRuleResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int execRuleSet(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string ruleType, string ruleSet, KeyValue[] ruleProperties, ref RuleResult[] ruleResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.execRuleSet(sessionContext, stationNumber, processLayer, ruleType, ruleSet, ruleProperties);
                ruleResults=r.ruleResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int execFormula(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] formulaReferences, string[] formulaKeys, string[] formulaValues, string[] parameterKeys, string[] parameterValues, string[] resultKeys, ref string[] resultValues, string[] missingParameterKeys, ref string[] missingParameterValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.execFormula(sessionContext, stationNumber, formulaReferences, formulaKeys, formulaValues, parameterKeys, parameterValues, resultKeys, missingParameterKeys);
                resultValues=r.resultValues;
                missingParameterValues=r.missingParameterValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int execFormulaCatalog(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] formulaKeys, string[] formulaValues, string[] parameterKeys, string[] parameterValues, string[] formularResultKeys, ref string[] formularResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.execFormulaCatalog(sessionContext, stationNumber, formulaKeys, formulaValues, parameterKeys, parameterValues, formularResultKeys);
                formularResultValues=r.formularResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int execTimerProcess(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] timerProcessFilter, string[] timerProcessResultKeys, ref string[] timerProcessResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.execTimerProcess(sessionContext, stationNumber, timerProcessFilter, timerProcessResultKeys);
                timerProcessResultValues=r.timerProcessResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetErrorText(IMSApiSessionContextStruct sessionContext, int errorCode, ref string errorString)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetErrorText(sessionContext, errorCode);
                errorString=r.errorString;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetGroups(IMSApiSessionContextStruct sessionContext, ref ImsApiGroupStruct[] groupArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetGroups(sessionContext);
                groupArray=r.groupArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetFunctions(IMSApiSessionContextStruct sessionContext, string groupName, ref ImsApiFunctionStruct[] functionArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetFunctions(sessionContext, groupName);
                functionArray=r.functionArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetFunctionInfo(IMSApiSessionContextStruct sessionContext, string functionName, ref ImsApiFunctionStruct functionInfo, ref ImsApiParameterStruct[] parameterArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetFunctionInfo(sessionContext, functionName);
                functionInfo=r.functionInfo;
                parameterArray=r.parameterArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetParameterConditions(IMSApiSessionContextStruct sessionContext, string functionName, string parameterName, ref string conditionParamName, ref ImsApiParamConditionStruct[] parameterConditionArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetParameterConditions(sessionContext, functionName, parameterName);
                conditionParamName=r.conditionParamName;
                parameterConditionArray=r.parameterConditionArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetParameterInfo(IMSApiSessionContextStruct sessionContext, string functionName, string parameterName, string conditionValue, ref ImsApiParameterStruct parameter, ref ImsApiParamConditionStruct condition, ref ImsApiKeyStruct[] keys)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetParameterInfo(sessionContext, functionName, parameterName, conditionValue);
                parameter=r.parameter;
                condition=r.condition;
                keys=r.keys;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetSystemInfos(IMSApiSessionContextStruct sessionContext, string[] systemInfoResultKeys, ref string[] systemInfoResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetSystemInfos(sessionContext, systemInfoResultKeys);
                systemInfoResultValues=r.systemInfoResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int imsapiGetErrorList(IMSApiSessionContextStruct sessionContext, string[] localeArray, string[] groupNameArray, string[] functionNameArray, int[] errorCodes, string[] errorCodeResultKeys, ref string[] errorCodeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.imsapiGetErrorList(sessionContext, localeArray, groupNameArray, functionNameArray, errorCodes, errorCodeResultKeys);
                errorCodeResultValues=r.errorCodeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int lockGetLockedObjects(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, string lockGroupName, long lockDateFrom, long lockDateTo, int lockState, int maxRows, string[] objectResultKeys, ref string[] objectResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.lockGetLockedObjects(sessionContext, stationNumber, objectType, objectNumber, objectDetail, lockGroupName, lockDateFrom, lockDateTo, lockState, maxRows, objectResultKeys);
                objectResultValues=r.objectResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int lockObjects(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string lockGroupName, string lockInformation, long lockDate, int lockDependencies, string[] objectUploadKeys, string[] objectUploadValues, ref string[] objectResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.lockObjects(sessionContext, stationNumber, objectType, lockGroupName, lockInformation, lockDate, lockDependencies, objectUploadKeys, objectUploadValues);
                objectResultValues=r.objectResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int lockUnlockObjects(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string lockGroupName, string unlockInformation, int unlockCompleteGroup, long unlockDate, int lockDependencies, string[] objectUploadKeys, string[] objectUploadValues, ref string[] objectResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.lockUnlockObjects(sessionContext, stationNumber, objectType, lockGroupName, unlockInformation, unlockCompleteGroup, unlockDate, lockDependencies, objectUploadKeys, objectUploadValues);
                objectResultValues=r.objectResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int lockGetLockGroups(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] lockGroupFilter, string[] lockGroupResultKeys, string[] lockClassResultKeys, string[] lockOutResultKeys, ref string[] lockGroupResultValues, ref string[] lockClassResultValues, ref string[] lockOutResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.lockGetLockGroups(sessionContext, stationNumber, lockGroupFilter, lockGroupResultKeys, lockClassResultKeys, lockOutResultKeys);
                lockGroupResultValues=r.lockGroupResultValues;
                lockClassResultValues=r.lockClassResultValues;
                lockOutResultValues=r.lockOutResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaGetRecipeData(IMSApiSessionContextStruct sessionContext, string stationNumber, int recipeVersionId, string function, string functionStep, string measurementName, double sequentialNumber, string type, string measurementType, int objectType, KeyValue[] recipeFilters, string[] recipeResultKeys, ref string[] recipeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaGetRecipeData(sessionContext, stationNumber, recipeVersionId, function, functionStep, measurementName, sequentialNumber, type, measurementType, objectType, recipeFilters, recipeResultKeys);
                recipeResultValues=r.recipeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaActivateRecipe(IMSApiSessionContextStruct sessionContext, string stationNumber, int functionMode, int recipeId, int recipeVersionId)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaActivateRecipe(sessionContext, stationNumber, functionMode, recipeId, recipeVersionId);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaCreateRecipe(IMSApiSessionContextStruct sessionContext, string stationNumber, string versionName, string versionDesc, int majorVersionChange, bool activate, long creationDate, int objectType, KeyValue[] recipeFilters, string[] recipeUploadKeys, string[] recipeUploadValues, ref string[] recipeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaCreateRecipe(sessionContext, stationNumber, versionName, versionDesc, majorVersionChange, activate, creationDate, objectType, recipeFilters, recipeUploadKeys, recipeUploadValues);
                recipeResultValues=r.recipeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaGetDocuments(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] attributeFilters, KeyValue[] dataTypeFilters, string[] mdaResultKeys, ref string[] mdaResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaGetDocuments(sessionContext, stationNumber, attributeFilters, dataTypeFilters, mdaResultKeys);
                mdaResultValues=r.mdaResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaUploadDocument(IMSApiSessionContextStruct sessionContext, string stationNumber, int targetType, KeyValue[] attributeValues, KeyValue[] mdaValues, byte[] content)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaUploadDocument(sessionContext, stationNumber, targetType, attributeValues, mdaValues, content);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaGetDocumentContent(IMSApiSessionContextStruct sessionContext, string stationNumber, long documentId, ref byte[] content)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaGetDocumentContent(sessionContext, stationNumber, documentId);
                content=r.content;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaGetRecipeHeaderAndVersion(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, KeyValue[] recipeHeaderFilter, string[] recipeHeaderResultKeys, ref string[] recipeHeaderResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaGetRecipeHeaderAndVersion(sessionContext, stationNumber, objectType, recipeHeaderFilter, recipeHeaderResultKeys);
                recipeHeaderResultValues=r.recipeHeaderResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaActivateDocument(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] mdaActivateDocumentKeys, string[] mdaActivateDocumentValues, ref string[] mdaActivateDocumentResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaActivateDocument(sessionContext, stationNumber, mdaActivateDocumentKeys, mdaActivateDocumentValues);
                mdaActivateDocumentResult=r.mdaActivateDocumentResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdaUploadCustomFunction(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdaValues, byte[] content)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdaUploadCustomFunction(sessionContext, stationNumber, mdaValues, content);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetPartData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] partFilter, string[] partDataResultKeys, ref string[] partDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetPartData(sessionContext, stationNumber, partFilter, partDataResultKeys);
                partDataResultValues=r.partDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetProductInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, string partNumber, int bomVersion, string bomIndex, int processVersion, int desolvingFlag, int onlyReleased, int onlyValid, string[] productInfoResultKeys, ref string[] productInfoResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetProductInfo(sessionContext, stationNumber, partNumber, bomVersion, bomIndex, processVersion, desolvingFlag, onlyReleased, onlyValid, productInfoResultKeys);
                productInfoResultValues=r.productInfoResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataBomVerify(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string workOrderNumber, string productNumber, string bareBoardNumber, string bomIndex, string bomInfo, int bomValidFrom, string bomVersionERP, int verifyCompNameBased, int createNewBom, string[] bomUploadKeys, string[] bomUploadValues, ref string[] bomResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataBomVerify(sessionContext, stationNumber, processLayer, workOrderNumber, productNumber, bareBoardNumber, bomIndex, bomInfo, bomValidFrom, bomVersionERP, verifyCompNameBased, createNewBom, bomUploadKeys, bomUploadValues);
                bomResultValues=r.bomResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetBomData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] bomDataFilter, string[] bomDataResultKeys, ref string[] bomDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetBomData(sessionContext, stationNumber, bomDataFilter, bomDataResultKeys);
                bomDataResultValues=r.bomDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetCalendarData(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] calendarDataResultKeys, ref string[] calendarDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetCalendarData(sessionContext, stationNumber, calendarDataResultKeys);
                calendarDataResultValues=r.calendarDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetWorkplanData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] workplanFilter, string[] workplanDataResultKeys, ref string[] workplanDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetWorkplanData(sessionContext, stationNumber, workplanFilter, workplanDataResultKeys);
                workplanDataResultValues=r.workplanDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetFailureDataForStation(IMSApiSessionContextStruct sessionContext, string stationNumber, int functionMode, string[] failureDataResultKeys, ref string[] failureDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetFailureDataForStation(sessionContext, stationNumber, functionMode, failureDataResultKeys);
                failureDataResultValues=r.failureDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetFailureDefinition(IMSApiSessionContextStruct sessionContext, string stationNumber, int stationMode, int functionMode, KeyValue[] failureDataFilter, string[] failureDataResultKeys, ref string[] failureDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetFailureDefinition(sessionContext, stationNumber, stationMode, functionMode, failureDataFilter, failureDataResultKeys);
                failureDataResultValues=r.failureDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataSetProductionCycleTime(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, string workOrderNumber, int processLayer, double setupCycleTime, double prodCycleTime, string processType, int cycleTimeForMultipleBoard)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataSetProductionCycleTime(sessionContext, stationNumber, serialNumber, serialNumberPos, workOrderNumber, processLayer, setupCycleTime, prodCycleTime, processType, cycleTimeForMultipleBoard);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataCreateWorkorder(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] workorderUploadKeyValues, string[] workorderResultKeys, ref string[] workorderResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataCreateWorkorder(sessionContext, stationNumber, workorderUploadKeyValues, workorderResultKeys);
                workorderResultValues=r.workorderResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataCreateProductionLot(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] parentWorkorderValue, string[] productionLotUploadKeys, string[] productionLotUploadValues, string[] productionLotResultKeys, ref string[] productionLotResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataCreateProductionLot(sessionContext, stationNumber, parentWorkorderValue, productionLotUploadKeys, productionLotUploadValues, productionLotResultKeys);
                productionLotResultValues=r.productionLotResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataChangeWorkorderData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] workorderChangeData)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataChangeWorkorderData(sessionContext, stationNumber, workorderChangeData);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetProductsForLineOrStation(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] productForLineOrStationFilter, string[] bomResultKeys, ref string[] bomResultValues, string[] workplanResultKeys, ref string[] workplanResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetProductsForLineOrStation(sessionContext, stationNumber, productForLineOrStationFilter, bomResultKeys, workplanResultKeys);
                bomResultValues=r.bomResultValues;
                workplanResultValues=r.workplanResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetMachineAssetStructure(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] machineAssetStructureFilter, string[] machineAssetStructureResultKeys, ref string[] machineAssetStructureValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetMachineAssetStructure(sessionContext, stationNumber, machineAssetStructureFilter, machineAssetStructureResultKeys);
                machineAssetStructureValues=r.machineAssetStructureValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetWorkplanActivities(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] workplanFilter, string[] workplanDataResultKeys, ref string[] workplanDataResultValues, string[] activitiesDataResultKeys, ref string[] activitiesDataResultValues, string[] activityParamResultKeys, ref string[] activityParamResultValues, string[] deviceDataResultKeys, ref string[] deviceDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetWorkplanActivities(sessionContext, stationNumber, workplanFilter, workplanDataResultKeys, activitiesDataResultKeys, activityParamResultKeys, deviceDataResultKeys);
                workplanDataResultValues=r.workplanDataResultValues;
                activitiesDataResultValues=r.activitiesDataResultValues;
                activityParamResultValues=r.activityParamResultValues;
                deviceDataResultValues=r.deviceDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetContactData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] contactFilter, string[] contactResultKeys, ref string[] contactResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetContactData(sessionContext, stationNumber, contactFilter, contactResultKeys);
                contactResultValues=r.contactResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetStationConfiguration(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] stationConfigFilter, string[] stationConfigCodeResultKeys, ref string[] stationConfigCodeResultValues, string[] stationParamResultKeys, ref string[] stationParamResultValues, string[] stationLicenseResultKeys, ref string[] stationLicenseResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetStationConfiguration(sessionContext, stationNumber, stationConfigFilter, stationConfigCodeResultKeys, stationParamResultKeys, stationLicenseResultKeys);
                stationConfigCodeResultValues=r.stationConfigCodeResultValues;
                stationParamResultValues=r.stationParamResultValues;
                stationLicenseResultValues=r.stationLicenseResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetWorkorders(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdataGetWorkordersFilters, string[] mdataGetWorkordersResultKeys, ref string[] mdataGetWorkordersResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetWorkorders(sessionContext, stationNumber, mdataGetWorkordersFilters, mdataGetWorkordersResultKeys);
                mdataGetWorkordersResultValues=r.mdataGetWorkordersResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetCostCenter(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdataGetCostCenterFilter, string[] mdataGetCostCenterKeys, ref string[] mdataGetCostCenterValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetCostCenter(sessionContext, stationNumber, mdataGetCostCenterFilter, mdataGetCostCenterKeys);
                mdataGetCostCenterValues=r.mdataGetCostCenterValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetWageType(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdataGetWageTypeFilter, string[] mdataGetWageTypeKeys, ref string[] mdataGetWageTypeValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetWageType(sessionContext, stationNumber, mdataGetWageTypeFilter, mdataGetWageTypeKeys);
                mdataGetWageTypeValues=r.mdataGetWageTypeValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetUserData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdataGetUserDataFilter, string[] mdataGetUserDataKeys, ref string[] mdataGetUserDataValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetUserData(sessionContext, stationNumber, mdataGetUserDataFilter, mdataGetUserDataKeys);
                mdataGetUserDataValues=r.mdataGetUserDataValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataChangeWorkorderBomData(IMSApiSessionContextStruct sessionContext, string stationNumber, string workorderNumber, string[] changeWorkorderBomUploadKeys, string[] changeWorkorderBomUploadValues, ref string[] changeWorkorderBomResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataChangeWorkorderBomData(sessionContext, stationNumber, workorderNumber, changeWorkorderBomUploadKeys, changeWorkorderBomUploadValues);
                changeWorkorderBomResultValues=r.changeWorkorderBomResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetOrderCluster(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] orderClusterFilter, string[] orderClusterHeadResultKeys, string[] orderClusterItemResultKeys, ref string[] orderClusterHeadResultValues, ref string[] orderClusterItemResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetOrderCluster(sessionContext, stationNumber, orderClusterFilter, orderClusterHeadResultKeys, orderClusterItemResultKeys);
                orderClusterHeadResultValues=r.orderClusterHeadResultValues;
                orderClusterItemResultValues=r.orderClusterItemResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataDeleteOrderCluster(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] orderClusterDeleteFilter)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataDeleteOrderCluster(sessionContext, stationNumber, orderClusterDeleteFilter);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataCreateOrderCluster(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] createOrderClusterValues, string[] createOrderClusterItemUploadKeys, string[] createOrderClusterItemUploadValues, ref string[] createOrderClusterResultValues, ref string[] createOrderClusterItemResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataCreateOrderCluster(sessionContext, stationNumber, createOrderClusterValues, createOrderClusterItemUploadKeys, createOrderClusterItemUploadValues);
                createOrderClusterResultValues=r.createOrderClusterResultValues;
                createOrderClusterItemResultValues=r.createOrderClusterItemResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataUpdateOrderCluster(IMSApiSessionContextStruct sessionContext, string stationNumber, string clusterName, KeyValue[] updateOrderClusterValues, string[] createOrderClusterItemUploadKeys, string[] createOrderClusterItemUploadValues, string[] updateOrderClusterItemUploadKeys, string[] updateOrderClusterItemUploadValues, string[] deleteOrderClusterItemUploadKeys, string[] deleteOrderClusterItemUploadValues, ref string[] createOrderClusterItemResultValues, ref string[] updateOrderClusterItemResultValues, ref string[] deleteOrderClusterItemResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataUpdateOrderCluster(sessionContext, stationNumber, clusterName, updateOrderClusterValues, createOrderClusterItemUploadKeys, createOrderClusterItemUploadValues, updateOrderClusterItemUploadKeys, updateOrderClusterItemUploadValues, deleteOrderClusterItemUploadKeys, deleteOrderClusterItemUploadValues);
                createOrderClusterItemResultValues=r.createOrderClusterItemResultValues;
                updateOrderClusterItemResultValues=r.updateOrderClusterItemResultValues;
                deleteOrderClusterItemResultValues=r.deleteOrderClusterItemResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetUserGroupData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdataGetUserGroupDataFilter, string[] mdataGetUserGroupDataKeys, ref string[] mdataGetUserGroupDataValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetUserGroupData(sessionContext, stationNumber, mdataGetUserGroupDataFilter, mdataGetUserGroupDataKeys);
                mdataGetUserGroupDataValues=r.mdataGetUserGroupDataValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetFailureDataForPart(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdataGetFailureDataForPartFilter, string[] failureDataKeys, ref string[] failureDataValues, string[] imageDataKeys, ref string[] imageDataValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetFailureDataForPart(sessionContext, stationNumber, mdataGetFailureDataForPartFilter, failureDataKeys, imageDataKeys);
                failureDataValues=r.failureDataValues;
                imageDataValues=r.imageDataValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataCreateDetectionPoint(IMSApiSessionContextStruct sessionContext, string stationNumber, string detectionPointName, int detectionPointType, KeyValue[] detectionPointKeyValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataCreateDetectionPoint(sessionContext, stationNumber, detectionPointName, detectionPointType, detectionPointKeyValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetDetectionPoint(IMSApiSessionContextStruct sessionContext, string stationNumber, int detectionPointType, KeyValue[] detectionPointFilter, string[] detectionPointKeys, ref string[] detectionPointValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetDetectionPoint(sessionContext, stationNumber, detectionPointType, detectionPointFilter, detectionPointKeys);
                detectionPointValues=r.detectionPointValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetShiftData(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] shiftFilterKeys, string[] shiftFilterValues, string[] shiftResultKeys, ref string[] shiftResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetShiftData(sessionContext, stationNumber, shiftFilterKeys, shiftFilterValues, shiftResultKeys);
                shiftResultValues=r.shiftResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetMessageClass(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] messageClassFilter, string[] messageClassKeys, ref string[] messageClassValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetMessageClass(sessionContext, stationNumber, messageClassFilter, messageClassKeys);
                messageClassValues=r.messageClassValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetMessageCause(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] messageCauseFilter, string[] messageCauseKeys, ref string[] messageCauseValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetMessageCause(sessionContext, stationNumber, messageCauseFilter, messageCauseKeys);
                messageCauseValues=r.messageCauseValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetMessageEffect(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] messageEffectFilter, string[] messageEffectKeys, ref string[] messageEffectValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetMessageEffect(sessionContext, stationNumber, messageEffectFilter, messageEffectKeys);
                messageEffectValues=r.messageEffectValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataCreateSpecialTime(IMSApiSessionContextStruct sessionContext, string stationNumber, int entityType, string entityKey, string timeEventName, long dateFrom, long dateTo, ref long specialTimeId)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataCreateSpecialTime(sessionContext, stationNumber, entityType, entityKey, timeEventName, dateFrom, dateTo);
                specialTimeId=r.specialTimeId;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataChangeWorkOrderWorkStepState(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] workstepChangeKeys, string[] workstepChangeValues, string[] workstepResultKeys, ref string[] workstepResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataChangeWorkOrderWorkStepState(sessionContext, stationNumber, workstepChangeKeys, workstepChangeValues, workstepResultKeys);
                workstepResultValues=r.workstepResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetUserSkill(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] userSkillFilter, string[] userSkillResultKeys, ref string[] userSkillResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetUserSkill(sessionContext, stationNumber, userSkillFilter, userSkillResultKeys);
                userSkillResultValues=r.userSkillResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetWorkstepSkill(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] workstepSkillFilter, string[] workstepSkillResultKeys, ref string[] workstepSkillResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetWorkstepSkill(sessionContext, stationNumber, workstepSkillFilter, workstepSkillResultKeys);
                workstepSkillResultValues=r.workstepSkillResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetFormulaCatalog(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] formulaFilter, string[] formulaResultKeys, string[] formulaParamResultKeys, ref string[] formulaResultValues, ref string[] formulaParamResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetFormulaCatalog(sessionContext, stationNumber, formulaFilter, formulaResultKeys, formulaParamResultKeys);
                formulaResultValues=r.formulaResultValues;
                formulaParamResultValues=r.formulaParamResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataUpdateDetectionPoint(IMSApiSessionContextStruct sessionContext, string stationNumber, string detectionPointName, KeyValue[] detectionPointKeyValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataUpdateDetectionPoint(sessionContext, stationNumber, detectionPointName, detectionPointKeyValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataDeleteDetectionPoint(IMSApiSessionContextStruct sessionContext, string stationNumber, string detectionPointName)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataDeleteDetectionPoint(sessionContext, stationNumber, detectionPointName);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetTimeEvent(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] timeEventFilter, string[] timeEventResultKeys, ref string[] timeEventResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetTimeEvent(sessionContext, stationNumber, timeEventFilter, timeEventResultKeys);
                timeEventResultValues=r.timeEventResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetWeekSchedule(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] weekScheduleFilter, string[] weekScheduleHeadKeys, string[] weekScheduleItemKeys, ref string[] weekScheduleHeadValues, ref string[] weekScheduleItemValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetWeekSchedule(sessionContext, stationNumber, weekScheduleFilter, weekScheduleHeadKeys, weekScheduleItemKeys);
                weekScheduleHeadValues=r.weekScheduleHeadValues;
                weekScheduleItemValues=r.weekScheduleItemValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetShiftModel(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] shiftModelFilter, string[] shiftModelHeadKeys, string[] shiftModelItemKeys, ref string[] shiftModelHeadValues, ref string[] shiftModelItemValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetShiftModel(sessionContext, stationNumber, shiftModelFilter, shiftModelHeadKeys, shiftModelItemKeys);
                shiftModelHeadValues=r.shiftModelHeadValues;
                shiftModelItemValues=r.shiftModelItemValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetAssignedShiftModel(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] assignedShiftModelFilter, string[] assignedShiftModelKeys, ref string[] assignedShiftModelValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetAssignedShiftModel(sessionContext, stationNumber, assignedShiftModelFilter, assignedShiftModelKeys);
                assignedShiftModelValues=r.assignedShiftModelValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataGetAssignedSpecialTime(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] assignedSpecialTimeFilter, string[] assignedSpecialTimeKeys, ref string[] assignedSpecialTimeValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataGetAssignedSpecialTime(sessionContext, stationNumber, assignedSpecialTimeFilter, assignedSpecialTimeKeys);
                assignedSpecialTimeValues=r.assignedSpecialTimeValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdataRequestWorkorder(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] requestWorkorderKeys, string[] requestWorkorderValues, string[] requestWorkorderResultKeys, ref string[] requestWorkorderResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdataRequestWorkorder(sessionContext, stationNumber, requestWorkorderKeys, requestWorkorderValues, requestWorkorderResultKeys);
                requestWorkorderResultValues=r.requestWorkorderResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcUploadStationCondition(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] stationConditionUploadKeys, string[] stationConditionUploadValues, ref string[] stationConditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcUploadStationCondition(sessionContext, stationNumber, stationConditionUploadKeys, stationConditionUploadValues);
                stationConditionResultValues=r.stationConditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetStationConditions(IMSApiSessionContextStruct sessionContext, string stationNumber, long fromDate, long toDate, string conditionType, int objectType, string[] conditionResultKeys, ref string[] conditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetStationConditions(sessionContext, stationNumber, fromDate, toDate, conditionType, objectType, conditionResultKeys);
                conditionResultValues=r.conditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetStationConditionsByFilter(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string[] stationArray, string[] conditionCodeArray, string[] conditionTypeArray, string[] messageTypeArray, string[] detectionPointArray, string[] resourceArray, KeyValue[] conditionResultFilter, string[] conditionResultKeys, ref string[] conditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetStationConditionsByFilter(sessionContext, stationNumber, objectType, stationArray, conditionCodeArray, conditionTypeArray, messageTypeArray, detectionPointArray, resourceArray, conditionResultFilter, conditionResultKeys);
                conditionResultValues=r.conditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetMessageType(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] messageTypeFilter, string[] messageTypeResultKeys, ref string[] messageTypeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetMessageType(sessionContext, stationNumber, messageTypeFilter, messageTypeResultKeys);
                messageTypeResultValues=r.messageTypeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcCreateLog(IMSApiSessionContextStruct sessionContext, string stationNumber, long startDate, long endDate, string subject, string text, int forLine)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcCreateLog(sessionContext, stationNumber, startDate, endDate, subject, text, forLine);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetLog(IMSApiSessionContextStruct sessionContext, string stationNumber, long fromDate, long toDate, ref MdcLog[] logArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetLog(sessionContext, stationNumber, fromDate, toDate);
                logArray=r.logArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetConditionCodes(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] conditionCodeFilter, string[] conditionCodeResultKeys, ref string[] conditionCodeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetConditionCodes(sessionContext, stationNumber, conditionCodeFilter, conditionCodeResultKeys);
                conditionCodeResultValues=r.conditionCodeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcCreateConditionCode(IMSApiSessionContextStruct sessionContext, string stationNumber, string conditionClass, string conditionGroup, string conditionCode, string conditionName, string conditionDesc, string conditionCause, string conditionType, string colorRGB, string[] stationNumbers, string[] lineNumbers)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcCreateConditionCode(sessionContext, stationNumber, conditionClass, conditionGroup, conditionCode, conditionName, conditionDesc, conditionCause, conditionType, colorRGB, stationNumbers, lineNumbers);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcRegisterUserAtLine(IMSApiSessionContextStruct sessionContext, string stationNumber, string userId, string password, int registrationType, long bookDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcRegisterUserAtLine(sessionContext, stationNumber, userId, password, registrationType, bookDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetRegisteredUser(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mdcGetRegisteredUserFilter, string[] mdcGetRegisteredUserKeys, ref string[] mdcGetRegisteredUserValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetRegisteredUser(sessionContext, stationNumber, mdcGetRegisteredUserFilter, mdcGetRegisteredUserKeys);
                mdcGetRegisteredUserValues=r.mdcGetRegisteredUserValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcUploadDetectionPoint(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] detectionPointKeys, string[] detectionPointValues, ref string[] detectionPointResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcUploadDetectionPoint(sessionContext, stationNumber, detectionPointKeys, detectionPointValues);
                detectionPointResultValues=r.detectionPointResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcUpdateStationCondition(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, long conditionId, KeyValue[] stationConditionUpdateKeys, ref string[] stationConditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcUpdateStationCondition(sessionContext, stationNumber, objectType, conditionId, stationConditionUpdateKeys);
                stationConditionResultValues=r.stationConditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcCreateLogData(IMSApiSessionContextStruct sessionContext, string stationNumber, string subject, int forLine, string[] stationLogKeys, string[] stationLogValues, ref string[] stationLogResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcCreateLogData(sessionContext, stationNumber, subject, forLine, stationLogKeys, stationLogValues);
                stationLogResultValues=r.stationLogResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetLogData(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] stationNumbers, string[] subjects, string[] detectionPoints, KeyValue[] stationLogFilter, string[] stationLogResultKeys, ref string[] stationLogResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetLogData(sessionContext, stationNumber, stationNumbers, subjects, detectionPoints, stationLogFilter, stationLogResultKeys);
                stationLogResultValues=r.stationLogResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcAcknowledgeStationConditions(IMSApiSessionContextStruct sessionContext, string stationNumber, string userAcknowledge, long dateAcknowledge, string txtAcknowledge, int selectionType, string[] stationConditionAcknowledgeKeys, string[] stationConditionAcknowledgeValues, ref string[] stationConditionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcAcknowledgeStationConditions(sessionContext, stationNumber, userAcknowledge, dateAcknowledge, txtAcknowledge, selectionType, stationConditionAcknowledgeKeys, stationConditionAcknowledgeValues);
                stationConditionResultValues=r.stationConditionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcManageConditionCode(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] manageConditionCodeUploadKeys, string[] manageConditionCodeUploadValues, ref string[] manageConditionCodeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcManageConditionCode(sessionContext, stationNumber, manageConditionCodeUploadKeys, manageConditionCodeUploadValues);
                manageConditionCodeResultValues=r.manageConditionCodeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcGetKeyPerformanceIndicators(IMSApiSessionContextStruct sessionContext, string stationNumber, long fromDate, long toDate, string[] performanceIndicatorResultKeys, ref string[] performanceIndicatorResultValues, string[] mdeAmountResultKeys, ref string[] mdeAmountResultValues, string[] mdePlannedCycleTimeResultKeys, ref string[] mdePlannedCycleTimeResultValues, string[] mdeShiftTimeResultKeys, ref string[] mdeShiftTimeResultValues, string[] mdeConditionTimeResultKeys, ref string[] mdeConditionTimeResultValues, string[] mdePerformanceResultKeys, ref string[] mdePerformanceResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcGetKeyPerformanceIndicators(sessionContext, stationNumber, fromDate, toDate, performanceIndicatorResultKeys, mdeAmountResultKeys, mdePlannedCycleTimeResultKeys, mdeShiftTimeResultKeys, mdeConditionTimeResultKeys, mdePerformanceResultKeys);
                performanceIndicatorResultValues=r.performanceIndicatorResultValues;
                mdeAmountResultValues=r.mdeAmountResultValues;
                mdePlannedCycleTimeResultValues=r.mdePlannedCycleTimeResultValues;
                mdeShiftTimeResultValues=r.mdeShiftTimeResultValues;
                mdeConditionTimeResultValues=r.mdeConditionTimeResultValues;
                mdePerformanceResultValues=r.mdePerformanceResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mdcCloseStationMessage(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] closeStationMessageUploadKeys, KeyValue[] closeStationMessageFilter, string[] dataBlockValues, string[] controlValues, string[] variableValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mdcCloseStationMessage(sessionContext, stationNumber, closeStationMessageUploadKeys, closeStationMessageFilter, dataBlockValues, controlValues, variableValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlCreateNewMaterialBin(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] materialBinUploadKeys, string[] materialBinUploadValues, ref string[] materialBinResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlCreateNewMaterialBin(sessionContext, stationNumber, materialBinUploadKeys, materialBinUploadValues);
                materialBinResultValues=r.materialBinResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlSetMaterialBinLocation(IMSApiSessionContextStruct sessionContext, string stationNumber, string materialBinNumber, long bookDate, string binLocation, string binLocationBarcode, int transactionType)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlSetMaterialBinLocation(sessionContext, stationNumber, materialBinNumber, bookDate, binLocation, binLocationBarcode, transactionType);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlUpdateMaterialBinLocationData(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] materialBinLocationDataUpdateKeys, string[] materialBinLocationDataUpdateValues, ref string[] materialBinLocationDataUpdateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlUpdateMaterialBinLocationData(sessionContext, stationNumber, materialBinLocationDataUpdateKeys, materialBinLocationDataUpdateValues);
                materialBinLocationDataUpdateResultValues=r.materialBinLocationDataUpdateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlChangeMaterialBinData(IMSApiSessionContextStruct sessionContext, string stationNumber, string materialBinNumber, KeyValue[] materialBinDataUploadValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlChangeMaterialBinData(sessionContext, stationNumber, materialBinNumber, materialBinDataUploadValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetNextMaterialBinNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string partNumber, ref string materialBinNumber)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetNextMaterialBinNumber(sessionContext, stationNumber, partNumber);
                materialBinNumber=r.materialBinNumber;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetMaterialBinData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] materialBinFilters, AttributeInfo[] attributes, string[] materialBinResultKeys, ref string[] materialBinResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetMaterialBinData(sessionContext, stationNumber, materialBinFilters, attributes, materialBinResultKeys);
                materialBinResultValues=r.materialBinResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetStorage(IMSApiSessionContextStruct sessionContext, string stationNumber, string storageCellNumber, string storageGroupNumber, string storageNumber, string[] storageResultKeys, ref string[] storageResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetStorage(sessionContext, stationNumber, storageCellNumber, storageGroupNumber, storageNumber, storageResultKeys);
                storageResultValues=r.storageResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlUploadMaterialBinBooking(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] materialBinBookingUploadKeys, string[] materialBinBookingUploadValues, ref string[] materialBinBookingResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlUploadMaterialBinBooking(sessionContext, stationNumber, materialBinBookingUploadKeys, materialBinBookingUploadValues);
                materialBinBookingResultValues=r.materialBinBookingResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlSplitMaterialBin(IMSApiSessionContextStruct sessionContext, string stationNumber, string materialBinNumber, string[] splitMaterialBinKeys, string[] splitMaterialBinUploadValues, string[] splitMaterialBinResultKeys, ref string[] splitMaterialBinResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlSplitMaterialBin(sessionContext, stationNumber, materialBinNumber, splitMaterialBinKeys, splitMaterialBinUploadValues, splitMaterialBinResultKeys);
                splitMaterialBinResultValues=r.splitMaterialBinResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetPurchaseOrderData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] purchaseDataFilters, string[] purchaseDataResultKeys, ref string[] purchaseDataResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetPurchaseOrderData(sessionContext, stationNumber, purchaseDataFilters, purchaseDataResultKeys);
                purchaseDataResultValues=r.purchaseDataResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetIncomingGoods(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] incomingGoodsFilters, string[] incomingGoodsHeadResultKeys, string[] incomingGoodsItemResultKeys, ref string[] incomingGoodsHeadResultValues, ref string[] incomingGoodsItemResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetIncomingGoods(sessionContext, stationNumber, incomingGoodsFilters, incomingGoodsHeadResultKeys, incomingGoodsItemResultKeys);
                incomingGoodsHeadResultValues=r.incomingGoodsHeadResultValues;
                incomingGoodsItemResultValues=r.incomingGoodsItemResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlUpdateStorageCell(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] storageUpdateKeys, string[] storageUpdateValues, ref string[] storageUpdateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlUpdateStorageCell(sessionContext, stationNumber, storageUpdateKeys, storageUpdateValues);
                storageUpdateResultValues=r.storageUpdateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlUpdateStorageGroup(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] storageGroupUpdateKeys, string[] storageGroupUpdateValues, ref string[] storageGroupUpdateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlUpdateStorageGroup(sessionContext, stationNumber, storageGroupUpdateKeys, storageGroupUpdateValues);
                storageGroupUpdateResultValues=r.storageGroupUpdateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlUpdateStorage(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] storageUpdateKeys, string[] storageUpdateValues, string[] storagePartAssignmentUpdateKeys, string[] storagePartAssignmentUpdateValues, ref string[] storageUpdateResultValues, ref string[] storagePartAssignmentUpdateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlUpdateStorage(sessionContext, stationNumber, storageUpdateKeys, storageUpdateValues, storagePartAssignmentUpdateKeys, storagePartAssignmentUpdateValues);
                storageUpdateResultValues=r.storageUpdateResultValues;
                storagePartAssignmentUpdateResultValues=r.storagePartAssignmentUpdateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetStorageData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] storageDataFilter, string[] storageCellResultKeys, string[] storageGroupResultKeys, string[] storageResultKeys, string[] storagePartAssignmentResultKeys, ref string[] storageCellResultValues, ref string[] storageGroupResultValues, ref string[] storageResultValues, ref string[] storagePartAssignmentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetStorageData(sessionContext, stationNumber, storageDataFilter, storageCellResultKeys, storageGroupResultKeys, storageResultKeys, storagePartAssignmentResultKeys);
                storageCellResultValues=r.storageCellResultValues;
                storageGroupResultValues=r.storageGroupResultValues;
                storageResultValues=r.storageResultValues;
                storagePartAssignmentResultValues=r.storagePartAssignmentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetMaterialTransactions(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] materialTransactionsFilters, string[] materialTransactionsResultKeys, ref string[] materialTransactionsResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetMaterialTransactions(sessionContext, stationNumber, materialTransactionsFilters, materialTransactionsResultKeys);
                materialTransactionsResultValues=r.materialTransactionsResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetTestplanData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] materialTestFilters, string[] testResulttKeys, ref string[] testResultValues, string[] varParamResultKeys, ref string[] varParamResultValues, string[] attribParamResultKeys, ref string[] attribParamResultValues, string[] attribParamValueResultKeys, ref string[] attribParamValueResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetTestplanData(sessionContext, stationNumber, materialTestFilters, testResulttKeys, varParamResultKeys, attribParamResultKeys, attribParamValueResultKeys);
                testResultValues=r.testResultValues;
                varParamResultValues=r.varParamResultValues;
                attribParamResultValues=r.attribParamResultValues;
                attribParamValueResultValues=r.attribParamValueResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlUploadTestplanResult(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] materialTestFilters, long bookDate, bool testCanceled, string testState, string[] varUploadKeys, string[] varUploadValues, ref string[] varUploadResults, string[] attribUploadKeys, string[] attribUploadValues, ref string[] attribUploadResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlUploadTestplanResult(sessionContext, stationNumber, materialTestFilters, bookDate, testCanceled, testState, varUploadKeys, varUploadValues, attribUploadKeys, attribUploadValues);
                varUploadResults=r.varUploadResults;
                attribUploadResults=r.attribUploadResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int regLogin(IMSApiSessionValidationStruct sessionValidationStruct, ref IMSApiSessionContextStruct sessionContext)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.regLogin(sessionValidationStruct);
                sessionContext=r.sessionContext;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int regLogout(IMSApiSessionContextStruct sessionContext)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.regLogout(sessionContext);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int regRegisterUser(IMSApiSessionContextStruct sessionContext, string stationNumber, string userName, string password, string client)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.regRegisterUser(sessionContext, stationNumber, userName, password, client);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int regUnregisterUser(IMSApiSessionContextStruct sessionContext, string stationNumber, string userName, string password, string client)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.regUnregisterUser(sessionContext, stationNumber, userName, password, client);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int regGetRegisteredUser(IMSApiSessionContextStruct sessionContext, string stationNumber, ref string userName, ref string name, ref string firstname)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.regGetRegisteredUser(sessionContext, stationNumber);
                userName=r.userName;
                name=r.name;
                firstname=r.firstname;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int regCheckLicense(IMSApiSessionContextStruct sessionContext, string stationNumber, int licenseType, string[] licenseUploadKeys, string[] licenseUploadValues, ref string[] licenseResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.regCheckLicense(sessionContext, stationNumber, licenseType, licenseUploadKeys, licenseUploadValues);
                licenseResultValues=r.licenseResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupReplaceSetupForSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumber, int serialNumberPos, string materialNumber, string compName, string materialBinNumberOld, string materialBinNumberNew, long bookDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupReplaceSetupForSerialNumber(sessionContext, stationNumber, processLayer, serialNumber, serialNumberPos, materialNumber, compName, materialBinNumberOld, materialBinNumberNew, bookDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupCheck(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberRefPos, string workOrderNumber, int processLayer, int checkMode, int resultMode, ref string workorderNumber, ref string productNumber, ref string placementName, ref int setupActive, ref CheckSetupData[] checkSetupDataArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupCheck(sessionContext, stationNumber, serialNumberRef, serialNumberRefPos, workOrderNumber, processLayer, checkMode, resultMode);
                workorderNumber=r.workorderNumber;
                productNumber=r.productNumber;
                placementName=r.placementName;
                setupActive=r.setupActive;
                checkSetupDataArray=r.checkSetupDataArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupStateChange(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string workOrderNumber, string serialNumber, int serialNumberPos, int activateFlag)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupStateChange(sessionContext, stationNumber, processLayer, workOrderNumber, serialNumber, serialNumberPos, activateFlag);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetStationSetupDataForMaterialBin(IMSApiSessionContextStruct sessionContext, string stationNumber, string materialBinNumber, string[] setupResultKeys, ref string[] setupResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetStationSetupDataForMaterialBin(sessionContext, stationNumber, materialBinNumber, setupResultKeys);
                setupResultValues=r.setupResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetSetupDataBySerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string partNumber, string location, int level, string[] setupResultKeys, ref string[] setupResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetSetupDataBySerialNumber(sessionContext, stationNumber, serialNumber, partNumber, location, level, setupResultKeys);
                setupResultValues=r.setupResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetSetupName(IMSApiSessionContextStruct sessionContext, string stationNumber, ref string setupName)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetSetupName(sessionContext, stationNumber);
                setupName=r.setupName;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupUpdateMaterialSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string workOrderNumber, string productNumber, string setupName, string[] materialSetupUploadKeys, string[] materialSetupUploadValues, string[] compPositionsUploadKeys, string[] compPositionsUploadValues, ref string[] materialSetupResultValues, ref string[] compPositionsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupUpdateMaterialSetup(sessionContext, stationNumber, processLayer, workOrderNumber, productNumber, setupName, materialSetupUploadKeys, materialSetupUploadValues, compPositionsUploadKeys, compPositionsUploadValues);
                materialSetupResultValues=r.materialSetupResultValues;
                compPositionsResultValues=r.compPositionsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetMaterialSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, int setupFlag, long setupStartDate, long setupEndDate, string[] setupResultKeys, ref string[] setupResultValues, string[] componentResultKeys, ref string[] componentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetMaterialSetup(sessionContext, stationNumber, processLayer, setupFlag, setupStartDate, setupEndDate, setupResultKeys, componentResultKeys);
                setupResultValues=r.setupResultValues;
                componentResultValues=r.componentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupChangeSetupForSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] setupChangeSerialKeys, string[] setupChangeSerialValues, string[] setupChangePartKeys, string[] setupChangePartValues, string[] setupChangeResultKeys, ref string[] setupChangeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupChangeSetupForSerialNumber(sessionContext, stationNumber, setupChangeSerialKeys, setupChangeSerialValues, setupChangePartKeys, setupChangePartValues, setupChangeResultKeys);
                setupChangeResultValues=r.setupChangeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupCreatePreSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadUploadData, string[] presetupConsumerUploadKeys, string[] presetupConsumerUploadValues, string[] presetupSectionUploadKeys, string[] presetupSectionUploadValues, string[] presetupHeadResultKeys, string[] presetupConsumerResultKeys, string[] presetupSectionResultKeys, ref string[] presetupHeadResultValues, ref string[] presetupConsumerResultValues, ref string[] presetupSectionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupCreatePreSetup(sessionContext, stationNumber, presetupHeadUploadData, presetupConsumerUploadKeys, presetupConsumerUploadValues, presetupSectionUploadKeys, presetupSectionUploadValues, presetupHeadResultKeys, presetupConsumerResultKeys, presetupSectionResultKeys);
                presetupHeadResultValues=r.presetupHeadResultValues;
                presetupConsumerResultValues=r.presetupConsumerResultValues;
                presetupSectionResultValues=r.presetupSectionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupUpdatePreSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, KeyValue[] presetupHeadUploadKeys, string[] presetupConsumerUploadKeys, string[] presetupConsumerUploadValues, string[] presetupSectionUploadKeys, string[] presetupSectionUploadValues, ref string[] presetupConsumerResultValues, ref string[] presetupSectionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupUpdatePreSetup(sessionContext, stationNumber, presetupHeadFilter, presetupHeadUploadKeys, presetupConsumerUploadKeys, presetupConsumerUploadValues, presetupSectionUploadKeys, presetupSectionUploadValues);
                presetupConsumerResultValues=r.presetupConsumerResultValues;
                presetupSectionResultValues=r.presetupSectionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetPreSetupDetails(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, string[] presetupHeadResultKeys, string[] presetupConsumerResultKeys, string[] presetupSectionResultKeys, string[] presetupPositionResultKeys, string[] presetupPositionComponentResultKeys, ref string[] presetupHeadResultValues, ref string[] presetupConsumerResultValues, ref string[] presetupSectionResultValues, ref string[] presetupPositionResultValues, ref string[] presetupPositionComponentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetPreSetupDetails(sessionContext, stationNumber, presetupHeadFilter, presetupHeadResultKeys, presetupConsumerResultKeys, presetupSectionResultKeys, presetupPositionResultKeys, presetupPositionComponentResultKeys);
                presetupHeadResultValues=r.presetupHeadResultValues;
                presetupConsumerResultValues=r.presetupConsumerResultValues;
                presetupSectionResultValues=r.presetupSectionResultValues;
                presetupPositionResultValues=r.presetupPositionResultValues;
                presetupPositionComponentResultValues=r.presetupPositionComponentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupSearchPreSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, string[] presetupHeadResultKeys, string[] presetupConsumerResultKeys, string[] presetupSectionResultKeys, ref string[] presetupHeadResultValues, ref string[] presetupConsumerResultValues, ref string[] presetupSectionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupSearchPreSetup(sessionContext, stationNumber, presetupHeadFilter, presetupHeadResultKeys, presetupConsumerResultKeys, presetupSectionResultKeys);
                presetupHeadResultValues=r.presetupHeadResultValues;
                presetupConsumerResultValues=r.presetupConsumerResultValues;
                presetupSectionResultValues=r.presetupSectionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupUpdatePreSetupPosition(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, string[] presetupPositionUploadKeys, string[] presetupPositionUploadValues, string[] presetupPositionComponentUploadKeys, string[] presetupPositionComponentUploadValues, ref string[] presetupPositionResultValues, ref string[] presetupPositionComponentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupUpdatePreSetupPosition(sessionContext, stationNumber, presetupHeadFilter, presetupPositionUploadKeys, presetupPositionUploadValues, presetupPositionComponentUploadKeys, presetupPositionComponentUploadValues);
                presetupPositionResultValues=r.presetupPositionResultValues;
                presetupPositionComponentResultValues=r.presetupPositionComponentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupAttachPreSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, string[] presetupAttachPositionUploadKeys, string[] presetupAttachPositionUploadValues, string[] presetupAttachPositionResultKeys, ref string[] presetupAttachPositionResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupAttachPreSetup(sessionContext, stationNumber, presetupHeadFilter, presetupAttachPositionUploadKeys, presetupAttachPositionUploadValues, presetupAttachPositionResultKeys);
                presetupAttachPositionResultValues=r.presetupAttachPositionResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetRequiredMaterialForPreSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, string[] presetupMaterialResultKeys, string[] presetupMaterialAlternativeResultKeys, ref string[] presetupMaterialResultValues, ref string[] presetupMaterialAlternativeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetRequiredMaterialForPreSetup(sessionContext, stationNumber, presetupHeadFilter, presetupMaterialResultKeys, presetupMaterialAlternativeResultKeys);
                presetupMaterialResultValues=r.presetupMaterialResultValues;
                presetupMaterialAlternativeResultValues=r.presetupMaterialAlternativeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupCheckPreSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] presetupHeadFilter, string[] presetupHeadResultKeys, string[] presetupPositionResultKeys, string[] presetupPositionComponentResultKeys, ref string[] presetupHeadResultValues, ref string[] presetupPositionResultValues, ref string[] presetupPositionComponentResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupCheckPreSetup(sessionContext, stationNumber, presetupHeadFilter, presetupHeadResultKeys, presetupPositionResultKeys, presetupPositionComponentResultKeys);
                presetupHeadResultValues=r.presetupHeadResultValues;
                presetupPositionResultValues=r.presetupPositionResultValues;
                presetupPositionComponentResultValues=r.presetupPositionComponentResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int setupGetSetupDataBySerialNumberRef(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] serialSetupFilter, string[] setupResultKeys, ref string[] setupResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.setupGetSetupDataBySerialNumberRef(sessionContext, stationNumber, serialSetupFilter, setupResultKeys);
                setupResultValues=r.setupResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipRemoveSerialNumberFromShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, string serialNumber, string serialNumberPos, long bookDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipRemoveSerialNumberFromShippingLot(sessionContext, stationNumber, lotNumber, serialNumber, serialNumberPos, bookDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipRemoveSerialNumbersFromShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] shippingLotFilter, string[] serialNumberKeys, string[] serialNumberValues, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipRemoveSerialNumbersFromShippingLot(sessionContext, stationNumber, shippingLotFilter, serialNumberKeys, serialNumberValues);
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipCheckSerialNumberFromShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, string serialNumber, string serialNumberPos)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipCheckSerialNumberFromShippingLot(sessionContext, stationNumber, lotNumber, serialNumber, serialNumberPos);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipMoveSerialNumberToOtherShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] shippingLotFilter, string[] serialNumberKeys, string[] serialNumberValues, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipMoveSerialNumberToOtherShippingLot(sessionContext, stationNumber, shippingLotFilter, serialNumberKeys, serialNumberValues);
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipAddSerialNumberToShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, string serialNumber, int serialNumberPos, long bookDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipAddSerialNumberToShippingLot(sessionContext, stationNumber, lotNumber, serialNumber, serialNumberPos, bookDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipDeactivateShippingLotAtKap(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipDeactivateShippingLotAtKap(sessionContext, stationNumber, lotNumber);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipActivateShippingLotAtKap(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipActivateShippingLotAtKap(sessionContext, stationNumber, lotNumber);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipGetSerialNumberDataForShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, string[] serialNumberResultKeys, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipGetSerialNumberDataForShippingLot(sessionContext, stationNumber, lotNumber, serialNumberResultKeys);
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipCompleteLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, int allowLessQuantity, long bookDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipCompleteLot(sessionContext, stationNumber, lotNumber, allowLessQuantity, bookDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipSendLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, long bookDate, KeyValue[] shippingLotSendValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipSendLot(sessionContext, stationNumber, lotNumber, bookDate, shippingLotSendValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipReuseCompletedShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, int functionMode, string lotNumber, string[] shippingLotResultKeys, ref string[] shippingLotResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipReuseCompletedShippingLot(sessionContext, stationNumber, functionMode, lotNumber, shippingLotResultKeys);
                shippingLotResultValues=r.shippingLotResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipGetShippingLotInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] shippingLotFilters, string[] shippingLotResultKeys, ref string[] shippingLotResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipGetShippingLotInfo(sessionContext, stationNumber, shippingLotFilters, shippingLotResultKeys);
                shippingLotResultValues=r.shippingLotResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipCheckSerialNumberAddToShippingLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumber, string serialNumber, string serialNumberPos)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipCheckSerialNumberAddToShippingLot(sessionContext, stationNumber, lotNumber, serialNumber, serialNumberPos);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipAddChildLotToParentLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumberChild, string lotNumberParent, long bookDate)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipAddChildLotToParentLot(sessionContext, stationNumber, lotNumberChild, lotNumberParent, bookDate);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipRemoveChildLots(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumberParent, string[] lotNumbersChild, long bookDate, ref ResultData[] resultArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipRemoveChildLots(sessionContext, stationNumber, lotNumberParent, lotNumbersChild, bookDate);
                resultArray=r.resultArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipGetChildLotsForParentLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string lotNumberParent, string[] childLotResultKeys, ref string[] childLotResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipGetChildLotsForParentLot(sessionContext, stationNumber, lotNumberParent, childLotResultKeys);
                childLotResultValues=r.childLotResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipMoveChildLots(IMSApiSessionContextStruct sessionContext, string stationNumber, StringStruct[] childLotArray, string actualParentLot, string newParentLot, long bookDate, ref ResultData[] resultDataArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipMoveChildLots(sessionContext, stationNumber, childLotArray, actualParentLot, newParentLot, bookDate);
                resultDataArray=r.resultDataArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipGetLotFromSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, string[] lotResultKeys, ref string[] lotResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipGetLotFromSerialNumber(sessionContext, stationNumber, serialNumber, serialNumberPos, lotResultKeys);
                lotResultValues=r.lotResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipGetShippingPrefs(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, string objectNumber, string objectDetail, int withPackagingRule, string[] shippingPrefsResultKeys, ref string[] shippingPrefsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipGetShippingPrefs(sessionContext, stationNumber, objectType, objectNumber, objectDetail, withPackagingRule, shippingPrefsResultKeys);
                shippingPrefsResultValues=r.shippingPrefsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int shipAddSnrsToLot(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] snrsLotKeys, string[] snrsLotValues, ref string[] snrsLotResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.shipAddSnrsToLot(sessionContext, stationNumber, snrsLotKeys, snrsLotValues);
                snrsLotResultValues=r.snrsLotResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int smtConsumption(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string lineName, string setupName, string productName, string bomVersion, string placementRecipe, bool assignSerialNumbers, bool bookSerialNumbers, bool activateSetup, ref SmtSerialNo[] serialNumbers, ref SmtEvent[] events, ref SmtPlacement[] placements, bool ignoreContainerProblems, bool createWorkOrder, bool activateWorkOrder, string workOrderNumber, double cycleTime)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.smtConsumption(sessionContext, stationNumber, processLayer, lineName, setupName, productName, bomVersion, placementRecipe, assignSerialNumbers, bookSerialNumbers, activateSetup, serialNumbers, events, placements, ignoreContainerProblems, createWorkOrder, activateWorkOrder, workOrderNumber, cycleTime);
                serialNumbers=r.serialNumbers;
                events=r.events;
                placements=r.placements;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int smtEventSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string lineName, string setupName, string productName, string bomVersion, string placementRecipe, bool assignSerialNumbers, bool bookSerialNumbers, bool activateSetup, ref SmtSerialNo[] serialNumbers, ref SmtEvent[] events, ref SmtPlacement[] placements, bool ignoreContainerProblems, bool createWorkOrder, bool activateWorkOrder, string workOrderNumber, double cycleTime)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.smtEventSetup(sessionContext, stationNumber, processLayer, lineName, setupName, productName, bomVersion, placementRecipe, assignSerialNumbers, bookSerialNumbers, activateSetup, serialNumbers, events, placements, ignoreContainerProblems, createWorkOrder, activateWorkOrder, workOrderNumber, cycleTime);
                serialNumbers=r.serialNumbers;
                events=r.events;
                placements=r.placements;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int smtSerialNumberSetup(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string lineName, string setupName, string productName, string bomVersion, string placementRecipe, bool assignSerialNumbers, bool bookSerialNumbers, bool activateSetup, ref SmtSerialNo[] serialNumbers, ref SmtEvent[] events, ref SmtPlacement[] placements, bool ignoreContainerProblems, bool createWorkOrder, bool activateWorkOrder, string workOrderNumber, double cycleTime)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.smtSerialNumberSetup(sessionContext, stationNumber, processLayer, lineName, setupName, productName, bomVersion, placementRecipe, assignSerialNumbers, bookSerialNumbers, activateSetup, serialNumbers, events, placements, ignoreContainerProblems, createWorkOrder, activateWorkOrder, workOrderNumber, cycleTime);
                serialNumbers=r.serialNumbers;
                events=r.events;
                placements=r.placements;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int smtSetupData(IMSApiSessionContextStruct sessionContext, string stationNumber, int functionMode, string[] smtSetupHeaderKeys, string[] smtSetupHeaderValues, ref string[] smtSetupHeaderResultValues, string[] smtSerialNumberKeys, string[] smtSerialNumberValues, ref string[] smtSerialNumberResultValues, string[] smtEventKeys, string[] smtEventValues, ref string[] smtEventResultValues, string[] smtPlacementKeys, string[] smtPlacementValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.smtSetupData(sessionContext, stationNumber, functionMode, smtSetupHeaderKeys, smtSetupHeaderValues, smtSerialNumberKeys, smtSerialNumberValues, smtEventKeys, smtEventValues, smtPlacementKeys, smtPlacementValues);
                smtSetupHeaderResultValues=r.smtSetupHeaderResultValues;
                smtSerialNumberResultValues=r.smtSerialNumberResultValues;
                smtEventResultValues=r.smtEventResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int smtCheckMaterialBin(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] materialBinUploadKeys, string[] materialBinUploadValues, ref string[] materialBinResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.smtCheckMaterialBin(sessionContext, stationNumber, materialBinUploadKeys, materialBinUploadValues);
                materialBinResultValues=r.materialBinResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int smtSerialNumberCheckIn(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] serialNoCheckUploadKeys, string[] serialNoCheckUploadValues, ref string[] serialNoCheckResultValues, string[] logInfoUploadKeys, string[] logInfoUploadValues, ref string[] logInfoResultValues, string[] serialNumberStateResultKeys, ref string[] serialNumberStateResultValues, string[] recipeResultKeys, ref string[] recipeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.smtSerialNumberCheckIn(sessionContext, stationNumber, serialNoCheckUploadKeys, serialNoCheckUploadValues, logInfoUploadKeys, logInfoUploadValues, serialNumberStateResultKeys, recipeResultKeys);
                serialNoCheckResultValues=r.serialNoCheckResultValues;
                logInfoResultValues=r.logInfoResultValues;
                serialNumberStateResultValues=r.serialNumberStateResultValues;
                recipeResultValues=r.recipeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadTestplanResult(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, long bookDate, string[] workStepKeys, string[] workStepValues, ref string[] workStepResults, string[] varUploadKeys, string[] varUploadValues, ref string[] varUploadResults, string[] varFailUploadKeys, string[] varFailUploadValues, ref string[] varFailUploadResults, string[] attribUploadKeys, string[] attribUploadValues, ref string[] attribUploadResult, string[] attribFailUploadKeys, string[] attribFailUploadValues, ref string[] attribFailUploadResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadTestplanResult(sessionContext, stationNumber, serialNumber, serialNumberPos, bookDate, workStepKeys, workStepValues, varUploadKeys, varUploadValues, varFailUploadKeys, varFailUploadValues, attribUploadKeys, attribUploadValues, attribFailUploadKeys, attribFailUploadValues);
                workStepResults=r.workStepResults;
                varUploadResults=r.varUploadResults;
                varFailUploadResults=r.varFailUploadResults;
                attribUploadResult=r.attribUploadResult;
                attribFailUploadResults=r.attribFailUploadResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trCheckMergedPartsForSerialNumberComplete(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, int serialNumberPos, int allMergedPartsVisible, int checkMultipleBoard, string[] mergePartsResultKeys, ref string[] mergePartsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trCheckMergedPartsForSerialNumberComplete(sessionContext, stationNumber, serialNumber, serialNumberPos, allMergedPartsVisible, checkMultipleBoard, mergePartsResultKeys);
                mergePartsResultValues=r.mergePartsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trCheckMergedPartsForSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mergedPartsFilters, string[] mergePartsResultKeys, ref string[] mergePartsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trCheckMergedPartsForSerialNumber(sessionContext, stationNumber, mergedPartsFilters, mergePartsResultKeys);
                mergePartsResultValues=r.mergePartsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetMergeParts(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, int resolveDirection, int resolveLevel, string[] mergePartsResultKeys, ref string[] mergePartsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetMergeParts(sessionContext, stationNumber, serialNumber, serialNumberPos, resolveDirection, resolveLevel, mergePartsResultKeys);
                mergePartsResultValues=r.mergePartsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trCheckSerialNumberState(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, int checkMultiBoard, string serialNumber, string serialNumberPos, string[] serialNumberStateResultKeys, ref string[] serialNumberStateResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trCheckSerialNumberState(sessionContext, stationNumber, processLayer, checkMultiBoard, serialNumber, serialNumberPos, serialNumberStateResultKeys);
                serialNumberStateResultValues=r.serialNumberStateResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trVerifyMerge(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberSlave, string serialNumberSlavePos, string serialNumberMaster, string serialNumberMasterPos, int checkMultiBoard, ref SerialNumberStateData[] serialNumberStateDataArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trVerifyMerge(sessionContext, stationNumber, serialNumberSlave, serialNumberSlavePos, serialNumberMaster, serialNumberMasterPos, checkMultiBoard);
                serialNumberStateDataArray=r.serialNumberStateDataArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trVerifyMergeProduct(IMSApiSessionContextStruct sessionContext, string stationNumber, string partNumber, int bomVersion, string bomIndex, string serialNumberSlave, int level)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trVerifyMergeProduct(sessionContext, stationNumber, partNumber, bomVersion, bomIndex, serialNumberSlave, level);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trChangeWorkOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, int lineFlag, string[] workorderResultKeys, ref string[] workorderResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trChangeWorkOrder(sessionContext, stationNumber, lineFlag, workorderResultKeys);
                workorderResultValues=r.workorderResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetStationSetting(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] stationSettingResultKeys, ref string[] stationSettingResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetStationSetting(sessionContext, stationNumber, stationSettingResultKeys);
                stationSettingResultValues=r.stationSettingResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, string[] serialNumberResultKeys, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberInfo(sessionContext, stationNumber, serialNumber, serialNumberPos, serialNumberResultKeys);
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberUploadInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumber, string serialNumberPos, int checkProcessStep, string[] uploadInfoResultKeys, ref string[] uploadInfoResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberUploadInfo(sessionContext, stationNumber, processLayer, serialNumber, serialNumberPos, checkProcessStep, uploadInfoResultKeys);
                uploadInfoResultValues=r.uploadInfoResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trMergeParts(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, int duplicateSerialNumber, string serialNumberMaster, string serialNumberMasterPos, string serialNumberSlave, string serialNumberSlavePos)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trMergeParts(sessionContext, stationNumber, processLayer, duplicateSerialNumber, serialNumberMaster, serialNumberMasterPos, serialNumberSlave, serialNumberSlavePos);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trRemoveMergeParts(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumberSlave, string serialNumberSlavePos, string textInfo)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trRemoveMergeParts(sessionContext, stationNumber, processLayer, serialNumberSlave, serialNumberSlavePos, textInfo);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUnmergeParts(IMSApiSessionContextStruct sessionContext, string stationNumber, int duplicateSerialNumber, string[] serialNumberUnmergeKeys, string[] serialNumberUnmergeValues, ref string[] serialNumberUnmergeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUnmergeParts(sessionContext, stationNumber, duplicateSerialNumber, serialNumberUnmergeKeys, serialNumberUnmergeValues);
                serialNumberUnmergeResultValues=r.serialNumberUnmergeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberBySerialNumberRef(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberRefPos, ref SerialNumberData[] serialNumberArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberBySerialNumberRef(sessionContext, stationNumber, serialNumberRef, serialNumberRefPos);
                serialNumberArray=r.serialNumberArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trSwitchSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberRefPos, ref SwitchSerialNumberData[] serialNumberArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trSwitchSerialNumber(sessionContext, stationNumber, serialNumberRef, serialNumberRefPos, serialNumberArray);
                serialNumberArray=r.serialNumberArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadState(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumberRef, string serialNumberRefPos, int serialNumberState, int duplicateSerialNumber, long bookDate, float cycleTime, string[] serialNumberUploadKeys, string[] serialNumberUploadValues, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadState(sessionContext, stationNumber, processLayer, serialNumberRef, serialNumberRefPos, serialNumberState, duplicateSerialNumber, bookDate, cycleTime, serialNumberUploadKeys, serialNumberUploadValues);
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetNextSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string partNumber, int numberOfRecords, ref SerialNumberData[] serialNumberArray)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetNextSerialNumber(sessionContext, stationNumber, workOrderNumber, partNumber, numberOfRecords);
                serialNumberArray=r.serialNumberArray;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadFailureAndResultData(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumberRef, string serialNumberRefPos, int serialNumberState, int duplicateSerialNumber, float cycleTime, long bookDate, string[] measureKeys, string[] measureValues, ref string[] measureResultValues, string[] failureKeys, string[] failureValues, ref string[] failureResultValues, string[] failureSlipKeys, string[] failureSlipValues, ref string[] failureSlipResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadFailureAndResultData(sessionContext, stationNumber, processLayer, serialNumberRef, serialNumberRefPos, serialNumberState, duplicateSerialNumber, cycleTime, bookDate, measureKeys, measureValues, failureKeys, failureValues, failureSlipKeys, failureSlipValues);
                measureResultValues=r.measureResultValues;
                failureResultValues=r.failureResultValues;
                failureSlipResultValues=r.failureSlipResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberHistoryData(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, int processLayer, int desolvingSerialNumber, int desolvingLevel, string[] bookingResultKeys, ref string[] bookingResultValues, string[] failureDataResultKeys, ref string[] failureDataResultValues, string[] failureSlipDataResultKeys, ref string[] failureSlipDataResultValues, string[] measureDataResultKeys, ref string[] measureDataResultValues, ref string workOrderNumber, ref string partNumber, ref string customerPartNumber, ref string partDesc, ref string quantity, ref long lastReportDate, ref string lotNumber, ref int isLocked)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberHistoryData(sessionContext, stationNumber, serialNumber, serialNumberPos, processLayer, desolvingSerialNumber, desolvingLevel, bookingResultKeys, failureDataResultKeys, failureSlipDataResultKeys, measureDataResultKeys);
                bookingResultValues=r.bookingResultValues;
                failureDataResultValues=r.failureDataResultValues;
                failureSlipDataResultValues=r.failureSlipDataResultValues;
                measureDataResultValues=r.measureDataResultValues;
                workOrderNumber=r.workOrderNumber;
                partNumber=r.partNumber;
                customerPartNumber=r.customerPartNumber;
                partDesc=r.partDesc;
                quantity=r.quantity;
                lastReportDate=r.lastReportDate;
                lotNumber=r.lotNumber;
                isLocked=r.isLocked;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadPmQuantity(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string workOrderNumber, double passQty, double failQty, double scrapQty)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadPmQuantity(sessionContext, stationNumber, processLayer, workOrderNumber, passQty, failQty, scrapQty);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetProductQuantity(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, int functionMode, KeyValue[] workorderFilters, KeyValue[] filterDataArray, string[] productQuantityResultKeys, ref string[] productQuantityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetProductQuantity(sessionContext, stationNumber, processLayer, functionMode, workorderFilters, filterDataArray, productQuantityResultKeys);
                productQuantityResultValues=r.productQuantityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadResultDataAndRecipe(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, int recipeVersionId, string serialNumberRef, string serialNumberRefPos, int serialNumberState, int duplicateSerialNumber, long bookDate, float cycleTime, int recipeVersionMode, string[] resultUploadKeys, string[] resultUploadValues, ref string[] resultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadResultDataAndRecipe(sessionContext, stationNumber, processLayer, recipeVersionId, serialNumberRef, serialNumberRefPos, serialNumberState, duplicateSerialNumber, bookDate, cycleTime, recipeVersionMode, resultUploadKeys, resultUploadValues);
                resultValues=r.resultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadStationResult(IMSApiSessionContextStruct sessionContext, string stationNumber, string partNumber, int bomVersion, string bomIndex, string bomVersionErp, string workOrderNumber, long bookDate, int serialUnitTrace, string[] stationResultUploadKeys, string[] stationResultUploadValues, ref string[] stationResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadStationResult(sessionContext, stationNumber, partNumber, bomVersion, bomIndex, bomVersionErp, workOrderNumber, bookDate, serialUnitTrace, stationResultUploadKeys, stationResultUploadValues);
                stationResultValues=r.stationResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trAssignSerialNumberMergeAndUploadState(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumberRef, string serialNumberRefPos, SerialNumberData[] serialNumberArray, string serialNumberSlave, int doUploadState, int serialNumberState, int multiplePanel)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trAssignSerialNumberMergeAndUploadState(sessionContext, stationNumber, processLayer, serialNumberRef, serialNumberRefPos, serialNumberArray, serialNumberSlave, doUploadState, serialNumberState, multiplePanel);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trAssignSerialNumberForProductOrWorkOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string partNumber, string bomVersion, string serialNumberRef, string serialNumberRefPos, int processLayer, SerialNumberData[] serialNumberArray, int activateWorkOrder)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trAssignSerialNumberForProductOrWorkOrder(sessionContext, stationNumber, workOrderNumber, partNumber, bomVersion, serialNumberRef, serialNumberRefPos, processLayer, serialNumberArray, activateWorkOrder);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trActivateWorkOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, string workOrderNumber, string serialNumber, string serialNumberPos, int processLayer, int flag)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trActivateWorkOrder(sessionContext, stationNumber, workOrderNumber, serialNumber, serialNumberPos, processLayer, flag);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trTestPaa(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, int processLayer, int model, ref int resultPaa, ref string infoText)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trTestPaa(sessionContext, stationNumber, serialNumber, processLayer, model);
                resultPaa=r.resultPaa;
                infoText=r.infoText;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trTestSpa(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, int processLayer, int model, ref int resultCp, ref int resultCpk, ref string infoText)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trTestSpa(sessionContext, stationNumber, serialNumber, processLayer, model);
                resultCp=r.resultCp;
                resultCpk=r.resultCpk;
                infoText=r.infoText;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetWorkOrderForStation(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] workorderFilter, string[] workorderResultKeys, ref string[] workorderResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetWorkOrderForStation(sessionContext, stationNumber, workorderFilter, workorderResultKeys);
                workorderResultValues=r.workorderResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetResultDataForSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumber, int serialNumberPos, string type, string name, int allProductEntries, int onlyLastEntry, KeyValue[] resultDataFilters, string[] resultDataKeys, ref string[] resultDataValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetResultDataForSerialNumber(sessionContext, stationNumber, processLayer, serialNumber, serialNumberPos, type, name, allProductEntries, onlyLastEntry, resultDataFilters, resultDataKeys);
                resultDataValues=r.resultDataValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberForWorkOrderAndWorkstep(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string workOrderNumber, int sequenceType, int workstepNumber, int multiplePanel, int state, int maxRows, int confirmFlag, int sortFlag, string[] serialNumberResultKeys, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberForWorkOrderAndWorkstep(sessionContext, stationNumber, processLayer, workOrderNumber, sequenceType, workstepNumber, multiplePanel, state, maxRows, confirmFlag, sortFlag, serialNumberResultKeys);
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trRemoveSerialNumberFromSerialNumberPool(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, string serialNumberPoolName)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trRemoveSerialNumberFromSerialNumberPool(sessionContext, stationNumber, serialNumber, serialNumberPos, serialNumberPoolName);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trAddSerialNumberToSerialNumberPool(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, string serialNumberPoolName, ref int state, ref string partNumber, ref string workOrderNumber)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trAddSerialNumberToSerialNumberPool(sessionContext, stationNumber, serialNumber, serialNumberPos, serialNumberPoolName);
                state=r.state;
                partNumber=r.partNumber;
                workOrderNumber=r.workOrderNumber;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trCreateSerialNumberPool(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, string serialNumberPoolDesc, string changeOrderNumber, string infoTxt, int serialNumberPoolType)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trCreateSerialNumberPool(sessionContext, stationNumber, serialNumberPoolName, serialNumberPoolDesc, changeOrderNumber, infoTxt, serialNumberPoolType);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trDeleteSerialNumberPool(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trDeleteSerialNumberPool(sessionContext, stationNumber, serialNumberPoolName);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberPoolInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, int workOrderInfo, string[] poolInfoResultKeys, ref string[] poolInfoResultValues, ref string changeOrder, ref string partNumber, ref string erpBomIndex, ref string infoTxtChangeOrder, ref string infoTxtSnrPool, ref int qtyAssignedSerialNumbers, ref int qtyIdentifiedSerialNumbers, ref int qtyCOAssignedSerialNumbers, ref int snrPoolState, ref string snrPoolDescription)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberPoolInfo(sessionContext, stationNumber, serialNumberPoolName, workOrderInfo, poolInfoResultKeys);
                poolInfoResultValues=r.poolInfoResultValues;
                changeOrder=r.changeOrder;
                partNumber=r.partNumber;
                erpBomIndex=r.erpBomIndex;
                infoTxtChangeOrder=r.infoTxtChangeOrder;
                infoTxtSnrPool=r.infoTxtSnrPool;
                qtyAssignedSerialNumbers=r.qtyAssignedSerialNumbers;
                qtyIdentifiedSerialNumbers=r.qtyIdentifiedSerialNumbers;
                qtyCOAssignedSerialNumbers=r.qtyCOAssignedSerialNumbers;
                snrPoolState=r.snrPoolState;
                snrPoolDescription=r.snrPoolDescription;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetPoolSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, string serialNumber, string serialNumberPos, int startPosition, int maxRowCount, int processingStateFlag, int snrStateFlag, string[] poolSerialNumberResultKeys, ref string[] poolSerialNumberResultValues, ref bool hasMore, ref string outSerialNumberPoolName)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetPoolSerialNumber(sessionContext, stationNumber, serialNumberPoolName, serialNumber, serialNumberPos, startPosition, maxRowCount, processingStateFlag, snrStateFlag, poolSerialNumberResultKeys);
                poolSerialNumberResultValues=r.poolSerialNumberResultValues;
                hasMore=r.hasMore;
                outSerialNumberPoolName=r.outSerialNumberPoolName;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetPools(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, string changeOrder, int snrPoolState, string[] serialNumberPoolResultKeys, ref string[] serialNumberPoolResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetPools(sessionContext, stationNumber, serialNumberPoolName, changeOrder, snrPoolState, serialNumberPoolResultKeys);
                serialNumberPoolResultValues=r.serialNumberPoolResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trIdentifyPoolSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, string serialNumberPoolName)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trIdentifyPoolSerialNumber(sessionContext, stationNumber, serialNumber, serialNumberPos, serialNumberPoolName);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trAddSerialNumberToPool(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, string[] serialNumberPoolKeys, string[] serialNumberPoolValues, ref string[] serialNumberPoolResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trAddSerialNumberToPool(sessionContext, stationNumber, serialNumberPoolName, serialNumberPoolKeys, serialNumberPoolValues);
                serialNumberPoolResults=r.serialNumberPoolResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trChangeSerialNumberPool(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, KeyValue[] serialNumberPoolData)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trChangeSerialNumberPool(sessionContext, stationNumber, serialNumberPoolName, serialNumberPoolData);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetTestplanData(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, int processLayer, string workorderNumber, KeyValue[] testplanFilters, string[] varParamResultKeys, ref string[] varParamResultValues, string[] varFailCodeResultKeys, ref string[] varFailCodeResultValues, string[] attribParamResultKeys, ref string[] attribParamResultValues, string[] attribParamValueResultKeys, ref string[] attribParamValueResultValues, string[] attribFailCodeResultKeys, ref string[] attribFailCodeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetTestplanData(sessionContext, stationNumber, serialNumber, serialNumberPos, processLayer, workorderNumber, testplanFilters, varParamResultKeys, varFailCodeResultKeys, attribParamResultKeys, attribParamValueResultKeys, attribFailCodeResultKeys);
                varParamResultValues=r.varParamResultValues;
                varFailCodeResultValues=r.varFailCodeResultValues;
                attribParamResultValues=r.attribParamResultValues;
                attribParamValueResultValues=r.attribParamValueResultValues;
                attribFailCodeResultValues=r.attribFailCodeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetNextProductionStep(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumber, string serialNumberPos, int functionMode, int stateCheck, int confirmFlag, string[] productionStepResultKeys, ref string[] productionStepResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetNextProductionStep(sessionContext, stationNumber, serialNumber, serialNumberPos, functionMode, stateCheck, confirmFlag, productionStepResultKeys);
                productionStepResultValues=r.productionStepResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trSimulateMerge(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberMaster, string serialNumberMasterPos, string workorderNumberMaster, string serialNumberSlave, string serialNumberSlavePos, string workorderNumberSlave, string[] simulateMergeResultKeys, ref string[] simulateMergeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trSimulateMerge(sessionContext, stationNumber, serialNumberMaster, serialNumberMasterPos, workorderNumberMaster, serialNumberSlave, serialNumberSlavePos, workorderNumberSlave, simulateMergeResultKeys);
                simulateMergeResultValues=r.simulateMergeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetStationResult(IMSApiSessionContextStruct sessionContext, string stationNumber, string workorderNumber, string partNumber, int bomVersion, string bomIndex, string bomVersionErp, long fromDate, long toDate, string[] measurementNames, int functionMode, string[] stationResultKeys, ref string[] stationResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetStationResult(sessionContext, stationNumber, workorderNumber, partNumber, bomVersion, bomIndex, bomVersionErp, fromDate, toDate, measurementNames, functionMode, stationResultKeys);
                stationResultValues=r.stationResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trCheckUserSkill(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string userId, KeyValue[] checkUserSkillFilter)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trCheckUserSkill(sessionContext, stationNumber, processLayer, userId, checkUserSkillFilter);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadActivity(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, string serialNumberRef, string serialNumberRefPos, int serialNumberState, int duplicateSerialNumber, long bookDate, float cycleTime, string[] activityDataKeys, string[] activityDataValues, ref string[] activityDataResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadActivity(sessionContext, stationNumber, processLayer, serialNumberRef, serialNumberRefPos, serialNumberState, duplicateSerialNumber, bookDate, cycleTime, activityDataKeys, activityDataValues);
                activityDataResults=r.activityDataResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetSerialNumberActivityUploadInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberRefPos, KeyValue[] activityFilter, string[] activityDataResultKeys, ref string[] activityDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetSerialNumberActivityUploadInfo(sessionContext, stationNumber, serialNumberRef, serialNumberRefPos, activityFilter, activityDataResultKeys);
                activityDataResultValues=r.activityDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetTopFailures(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] trGetTopFailuresFilter, string[] topFailuresResultKeys, ref string[] topFailuresResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetTopFailures(sessionContext, stationNumber, trGetTopFailuresFilter, topFailuresResultKeys);
                topFailuresResultValues=r.topFailuresResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetCapturedRepairHistoryData(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, KeyValue[] repairHistoryFilter, string[] failureDataResultKey, string[] failureSlipDataResultKey, ref string[] failureDataResultValues, ref string[] failureSlipDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetCapturedRepairHistoryData(sessionContext, stationNumber, processLayer, repairHistoryFilter, failureDataResultKey, failureSlipDataResultKey);
                failureDataResultValues=r.failureDataResultValues;
                failureSlipDataResultValues=r.failureSlipDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetMergeHistory(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mergedHistoryFilters, string[] mergedHistoryResultKeys, ref string[] mergedHistoryResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetMergeHistory(sessionContext, stationNumber, mergedHistoryFilters, mergedHistoryResultKeys);
                mergedHistoryResultValues=r.mergedHistoryResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trUploadFailuresForMergedParts(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] uploadMasterSerialNumberKeys, string[] uploadSlaveSerialNumberKeys, string[] uploadSlaveSerialNumberValues, ref string[] uploadSlaveSerialNumberResults, string[] uploadFailuresForSlaveSerialNumberKeys, string[] uploadFailuresForSlaveSerialNumberValues, ref string[] uploadFailuresForSlaveSerialNumberResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trUploadFailuresForMergedParts(sessionContext, stationNumber, uploadMasterSerialNumberKeys, uploadSlaveSerialNumberKeys, uploadSlaveSerialNumberValues, uploadFailuresForSlaveSerialNumberKeys, uploadFailuresForSlaveSerialNumberValues);
                uploadSlaveSerialNumberResults=r.uploadSlaveSerialNumberResults;
                uploadFailuresForSlaveSerialNumberResults=r.uploadFailuresForSlaveSerialNumberResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trChangePoolSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberPoolName, string[] poolSerialNumberKeys, string[] poolSerialNumberValues, ref string[] poolSerialNumberResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trChangePoolSerialNumber(sessionContext, stationNumber, serialNumberPoolName, poolSerialNumberKeys, poolSerialNumberValues);
                poolSerialNumberResults=r.poolSerialNumberResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trSplitPanel(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberRefPos, int functionMode, string[] splitPanelKeys, string[] splitPanelValues, ref string[] splitPanelResults)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trSplitPanel(sessionContext, stationNumber, serialNumberRef, serialNumberRefPos, functionMode, splitPanelKeys, splitPanelValues);
                splitPanelResults=r.splitPanelResults;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trAddExternalSerialNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string serialNumberRef, string serialNumberRefPos, int serialNumberState, long bookDate, float cycleTime, KeyValue[] workOrderUploadData, string[] workOrderResultKeys, ref string[] workOrderResultValues, string[] serialNumberUploadKeys, string[] serialNumberUploadValues, ref string[] serialNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trAddExternalSerialNumber(sessionContext, stationNumber, serialNumberRef, serialNumberRefPos, serialNumberState, bookDate, cycleTime, workOrderUploadData, workOrderResultKeys, serialNumberUploadKeys, serialNumberUploadValues);
                workOrderResultValues=r.workOrderResultValues;
                serialNumberResultValues=r.serialNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trAssignSerialnumberToOrderCluster(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] orderClusterSerialnumberHeader, string[] orderClusterSerialnumberAssignKeys, string[] orderClusterSerialnumberAssignValues, ref string[] orderClusterSerialnumberAssignResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trAssignSerialnumberToOrderCluster(sessionContext, stationNumber, orderClusterSerialnumberHeader, orderClusterSerialnumberAssignKeys, orderClusterSerialnumberAssignValues);
                orderClusterSerialnumberAssignResultValues=r.orderClusterSerialnumberAssignResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trActivateOrderCluster(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] orderClusterActivateData)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trActivateOrderCluster(sessionContext, stationNumber, orderClusterActivateData);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trGetMultiStationSettings(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] stationMultiSettingsResultKeys, ref string[] stationMultiSettingsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trGetMultiStationSettings(sessionContext, stationNumber, stationMultiSettingsResultKeys);
                stationMultiSettingsResultValues=r.stationMultiSettingsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trActivateWorkstep(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] activateWorkstepKeys)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trActivateWorkstep(sessionContext, stationNumber, activateWorkstepKeys);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trSerialNumberPassing(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] serialNumberPassingKeys, string[] serialNumberPassingValues, string[] serialNumberPassingResultKeys, ref string[] serialNumberPassingResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trSerialNumberPassing(sessionContext, stationNumber, serialNumberPassingKeys, serialNumberPassingValues, serialNumberPassingResultKeys);
                serialNumberPassingResultValues=r.serialNumberPassingResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trCheckUserSkills(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] checkUserSkillsFilter, string[] checkUserSkillsResultKeys, ref string[] checkUserSkillsResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trCheckUserSkills(sessionContext, stationNumber, checkUserSkillsFilter, checkUserSkillsResultKeys);
                checkUserSkillsResultValues=r.checkUserSkillsResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trRemoveSerialNumberFromOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] removeSerialNumberKeys)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trRemoveSerialNumberFromOrder(sessionContext, stationNumber, removeSerialNumberKeys);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int trReplaceMergedPart(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] replaceMergedPartKeys, string[] replaceMergedPartValues, ref string[] replaceMergedPartResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.trReplaceMergedPart(sessionContext, stationNumber, replaceMergedPartKeys, replaceMergedPartValues);
                replaceMergedPartResultValues=r.replaceMergedPartResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mslBeginDryObject(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mslBeginDryEventParams, string[] mslObjectKeys, string[] mslObjectValues, ref string[] mslResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mslBeginDryObject(sessionContext, stationNumber, mslBeginDryEventParams, mslObjectKeys, mslObjectValues);
                mslResultValues=r.mslResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mslEndDryObject(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mslEventParams, string[] mslObjectKeys, string[] mslObjectValues, ref string[] mslResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mslEndDryObject(sessionContext, stationNumber, mslEventParams, mslObjectKeys, mslObjectValues);
                mslResultValues=r.mslResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mslStartObjectExpiration(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mslEventParams, string[] mslObjectKeys, string[] mslObjectValues, ref string[] mslResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mslStartObjectExpiration(sessionContext, stationNumber, mslEventParams, mslObjectKeys, mslObjectValues);
                mslResultValues=r.mslResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mslStopObjectExpiration(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mslEventParams, string[] mslObjectKeys, string[] mslObjectValues, ref string[] mslResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mslStopObjectExpiration(sessionContext, stationNumber, mslEventParams, mslObjectKeys, mslObjectValues);
                mslResultValues=r.mslResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mslGetObjectInfo(IMSApiSessionContextStruct sessionContext, string stationNumber, int objectType, KeyValue[] mslInfoFilters, string[] mslInfoResultKeys, ref string[] mslInfoResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mslGetObjectInfo(sessionContext, stationNumber, objectType, mslInfoFilters, mslInfoResultKeys);
                mslInfoResultValues=r.mslInfoResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mslGetMinDryTimeForSerialnumber(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] mslInfoFilters, string[] mslWorstCaseMinDryTimeResultKeys, ref string[] mslWorstCaseMinDryTimeResultValues, string[] mslMinDryTimeResultKeys, ref string[] mslMinDryTimeResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mslGetMinDryTimeForSerialnumber(sessionContext, stationNumber, mslInfoFilters, mslWorstCaseMinDryTimeResultKeys, mslMinDryTimeResultKeys);
                mslWorstCaseMinDryTimeResultValues=r.mslWorstCaseMinDryTimeResultValues;
                mslMinDryTimeResultValues=r.mslMinDryTimeResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmUploadQuantityAndFailureData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] bookingFailureData, string[] failureDataUploadKeys, string[] failureDataUploadValues, ref string[] failureDataUploadResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmUploadQuantityAndFailureData(sessionContext, stationNumber, bookingFailureData, failureDataUploadKeys, failureDataUploadValues);
                failureDataUploadResultValues=r.failureDataUploadResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmGetFailureData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] failureDataFilters, string[] failureDataResultKeys, ref string[] failureDataResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmGetFailureData(sessionContext, stationNumber, failureDataFilters, failureDataResultKeys);
                failureDataResultValues=r.failureDataResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmGetProductQuantity(IMSApiSessionContextStruct sessionContext, string stationNumber, int processLayer, long dateFrom, long dateTo, int functionMode, KeyValue[] productQuantityFilters, string[] filterDataKeys, string[] filterDataValues, string[] productQuantityResultKeys, ref string[] productQuantityResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmGetProductQuantity(sessionContext, stationNumber, processLayer, dateFrom, dateTo, functionMode, productQuantityFilters, filterDataKeys, filterDataValues, productQuantityResultKeys);
                productQuantityResultValues=r.productQuantityResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmUploadBooking(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] pmUploadBookingData, string[] pmBookingFailureKeys, string[] pmBookingFailureValues, ref long bookingId)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmUploadBooking(sessionContext, stationNumber, pmUploadBookingData, pmBookingFailureKeys, pmBookingFailureValues);
                bookingId=r.bookingId;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmUpdateBooking(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] pmUpdateBookingData, string[] pmBookingFailureKeys, string[] pmBookingFailureValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmUpdateBooking(sessionContext, stationNumber, pmUpdateBookingData, pmBookingFailureKeys, pmBookingFailureValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmGetBooking(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] pmBookingFilters, string[] pmBookingResultKeys, ref string[] pmBookingResultValues, string[] pmBookingFailureKeys, ref string[] pmBookingFailureValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmGetBooking(sessionContext, stationNumber, pmBookingFilters, pmBookingResultKeys, pmBookingFailureKeys);
                pmBookingResultValues=r.pmBookingResultValues;
                pmBookingFailureValues=r.pmBookingFailureValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmUploadQuantityFailureTallyCardAndFailureData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] bookingFailureData, KeyValue[] failureTallyCardData, string[] failureDataUploadKeys, string[] failureDataUploadValues, ref string[] failureDataUploadResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmUploadQuantityFailureTallyCardAndFailureData(sessionContext, stationNumber, bookingFailureData, failureTallyCardData, failureDataUploadKeys, failureDataUploadValues);
                failureDataUploadResultValues=r.failureDataUploadResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int pmGetFailureTallyCard(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] failureTallyCardFilters, string[] failureTallyCardKeys, ref string[] failureTallyCardResultValues, string[] failureTallyCardFailureKeys, ref string[] failureTallyCardFailureResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.pmGetFailureTallyCard(sessionContext, stationNumber, failureTallyCardFilters, failureTallyCardKeys, failureTallyCardFailureKeys);
                failureTallyCardResultValues=r.failureTallyCardResultValues;
                failureTallyCardFailureResultValues=r.failureTallyCardFailureResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetWorkorders(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetWorkordersFilters, string[] apsGetWorkordersResultKeys, ref string[] apsGetWorkordersResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetWorkorders(sessionContext, stationNumber, apsGetWorkordersFilters, apsGetWorkordersResultKeys);
                apsGetWorkordersResultValues=r.apsGetWorkordersResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetWorkorderDetails(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetWorkorderDetailsFilters, string[] apsGetWorkorderDetailResultKeys, ref string[] apsGetWorkorderDetailResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetWorkorderDetails(sessionContext, stationNumber, apsGetWorkorderDetailsFilters, apsGetWorkorderDetailResultKeys);
                apsGetWorkorderDetailResultValues=r.apsGetWorkorderDetailResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetWorkorderDetailsOptGroup(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetWorkorderDetailsOptGroupFilters, string[] apsGetWorkorderDetailsOptGroupResultKeys, ref string[] apsGetWorkorderDetailsOptGroupResultValues, KeyValue[] apsWorkorderOptimizationFilters, string[] apsWorkorderOptimizationResultDataKeys, ref string[] apsWorkorderOptimizationResultDataValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetWorkorderDetailsOptGroup(sessionContext, stationNumber, apsGetWorkorderDetailsOptGroupFilters, apsGetWorkorderDetailsOptGroupResultKeys, apsWorkorderOptimizationFilters, apsWorkorderOptimizationResultDataKeys);
                apsGetWorkorderDetailsOptGroupResultValues=r.apsGetWorkorderDetailsOptGroupResultValues;
                apsWorkorderOptimizationResultDataValues=r.apsWorkorderOptimizationResultDataValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetStations(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetStationsFilters, string[] apsGetStationsResultKeys, ref string[] apsGetStationsResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetStations(sessionContext, stationNumber, apsGetStationsFilters, apsGetStationsResultKeys);
                apsGetStationsResultValues=r.apsGetStationsResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetWorkers(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetWorkersFilters, string[] apsGetWorkersResultKeys, ref string[] apsGetWorkersResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetWorkers(sessionContext, stationNumber, apsGetWorkersFilters, apsGetWorkersResultKeys);
                apsGetWorkersResultValues=r.apsGetWorkersResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetWorkergroups(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetWorkergroupsFilters, string[] apsGetWorkergroupsResultKeys, ref string[] apsGetWorkergroupsResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetWorkergroups(sessionContext, stationNumber, apsGetWorkergroupsFilters, apsGetWorkergroupsResultKeys);
                apsGetWorkergroupsResultValues=r.apsGetWorkergroupsResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int apsGetEquipments(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] apsGetEquipmentsFilters, string[] apsGetEquipmentsResultKeys, ref string[] apsGetEquipmentsResultValues, ref bool hasMore)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.apsGetEquipments(sessionContext, stationNumber, apsGetEquipmentsFilters, apsGetEquipmentsResultKeys);
                apsGetEquipmentsResultValues=r.apsGetEquipmentsResultValues;
                hasMore=r.hasMore;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpManageRoute(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] routeUploadKeyValues, string[] routeSegmentUploadKeys, string[] routeSegmentUploadValues, ref string[] routeSegmentUploadResult, string[] routeSegmentTransportOrderUploadKeys, string[] routeSegmentTransportOrderUploadValues, ref string[] routeSegmentTransportOrderUploadResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpManageRoute(sessionContext, stationNumber, routeUploadKeyValues, routeSegmentUploadKeys, routeSegmentUploadValues, routeSegmentTransportOrderUploadKeys, routeSegmentTransportOrderUploadValues);
                routeSegmentUploadResult=r.routeSegmentUploadResult;
                routeSegmentTransportOrderUploadResult=r.routeSegmentTransportOrderUploadResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpGetRoute(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] routeFilter, string[] routeResultKeys, ref string[] routeResultValues, string[] routeSegmentResultKeys, ref string[] routeSegmentResultValues, string[] routeSegmentTransportOrderResultKeys, ref string[] routeSegmentTransportOrderResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpGetRoute(sessionContext, stationNumber, routeFilter, routeResultKeys, routeSegmentResultKeys, routeSegmentTransportOrderResultKeys);
                routeResultValues=r.routeResultValues;
                routeSegmentResultValues=r.routeSegmentResultValues;
                routeSegmentTransportOrderResultValues=r.routeSegmentTransportOrderResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpCreateTransportOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] transportOrderUploadKeyValues, string[] productionOrderUploadKeys, string[] productionOrderUploadValues, string[] pickingItemUploadKeys, string[] pickingItemUploadValues, string[] commissionItemUploadKeys, string[] commissionItemUploadValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpCreateTransportOrder(sessionContext, stationNumber, transportOrderUploadKeyValues, productionOrderUploadKeys, productionOrderUploadValues, pickingItemUploadKeys, pickingItemUploadValues, commissionItemUploadKeys, commissionItemUploadValues);
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpChangeTransportOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] transportOrderUploadKeyValues, string[] productionOrderUploadKeys, string[] productionOrderUploadValues, ref string[] productionOrderUploadResult, string[] pickingItemUploadKeys, string[] pickingItemUploadValues, ref string[] pickingItemUploadResult, string[] commissionItemUploadKeys, string[] commissionItemUploadValues, ref string[] commissionItemUploadResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpChangeTransportOrder(sessionContext, stationNumber, transportOrderUploadKeyValues, productionOrderUploadKeys, productionOrderUploadValues, pickingItemUploadKeys, pickingItemUploadValues, commissionItemUploadKeys, commissionItemUploadValues);
                productionOrderUploadResult=r.productionOrderUploadResult;
                pickingItemUploadResult=r.pickingItemUploadResult;
                commissionItemUploadResult=r.commissionItemUploadResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpGetTransportOrder(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] transportOrderFilterKeyValues, string[] transportOrderResultKeys, ref string[] transportOrderResultValues, string[] productionOrderResultKeys, ref string[] productionOrderResultValues, string[] pickingItemResultKeys, ref string[] pickingItemResultValues, string[] commissionItemResultKeys, ref string[] commissionItemResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpGetTransportOrder(sessionContext, stationNumber, transportOrderFilterKeyValues, transportOrderResultKeys, productionOrderResultKeys, pickingItemResultKeys, commissionItemResultKeys);
                transportOrderResultValues=r.transportOrderResultValues;
                productionOrderResultValues=r.productionOrderResultValues;
                pickingItemResultValues=r.pickingItemResultValues;
                commissionItemResultValues=r.commissionItemResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpGetTopology(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] topologyKeyValues, string[] topologyResultKeys, ref string[] topologyResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpGetTopology(sessionContext, stationNumber, topologyKeyValues, topologyResultKeys);
                topologyResultValues=r.topologyResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpCreateTopology(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] topologyCreateKeys, string[] topologyCreateValues, ref string[] topologyCreateResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpCreateTopology(sessionContext, stationNumber, topologyCreateKeys, topologyCreateValues);
                topologyCreateResult=r.topologyCreateResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpUpdateTopology(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] topologyUpdateKeys, string[] topologyUpdateValues, ref string[] topologyUpdateResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpUpdateTopology(sessionContext, stationNumber, topologyUpdateKeys, topologyUpdateValues);
                topologyUpdateResult=r.topologyUpdateResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int crpDeleteTopology(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] topologyDeleteKeys, string[] topologyDeleteValues, ref string[] topologyDeleteResult)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.crpDeleteTopology(sessionContext, stationNumber, topologyDeleteKeys, topologyDeleteValues);
                topologyDeleteResult=r.topologyDeleteResult;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        // IMSAPI 10.0.0-59 additions. These methods are intentionally public on the
        // concrete class but are not added to the legacy IIMSApiDotNet interface, so
        // binaries compiled against the 10.0.0-3 interface remain source-compatible.
        public int batchCompleteBatch(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] batchCompleteKeyValues, string[] batchFailUploadKeys, string[] batchFailUploadValues, ref string[] batchFailResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchCompleteBatch(sessionContext, stationNumber, batchCompleteKeyValues, batchFailUploadKeys, batchFailUploadValues);
                batchFailResultValues=r.batchFailResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int batchSplitBatchNumber(IMSApiSessionContextStruct sessionContext, string stationNumber, string batchNumber, int processLayer, string[] splitBatchNumberKeys, string[] splitBatchNumberUploadValues, ref string[] splitBatchNumberResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.batchSplitBatchNumber(sessionContext, stationNumber, batchNumber, processLayer, splitBatchNumberKeys, splitBatchNumberUploadValues);
                splitBatchNumberResultValues=r.splitBatchNumberResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int equCheckEquipments(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] equipmentsCheckFilter, string[] equipmentNoKeys, string[] equipmentNoValues, string[] equipmentsCheckResultKeys, ref string[] equipmentsCheckResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.equCheckEquipments(sessionContext, stationNumber, equipmentsCheckFilter, equipmentNoKeys, equipmentNoValues, equipmentsCheckResultKeys);
                equipmentsCheckResultValues=r.equipmentsCheckResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlGetMaterialChainData(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] materialChainFilters, string[] materialChainResultKeys, ref string[] materialChainResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlGetMaterialChainData(sessionContext, stationNumber, materialChainFilters, materialChainResultKeys);
                materialChainResultValues=r.materialChainResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlSpliceMaterialChain(IMSApiSessionContextStruct sessionContext, string stationNumber, string[] spliceMaterialChainUploadKeys, string[] spliceMaterialChainUploadValues, string[] spliceMaterialChainResultKeys, ref string[] spliceMaterialChainResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlSpliceMaterialChain(sessionContext, stationNumber, spliceMaterialChainUploadKeys, spliceMaterialChainUploadValues, spliceMaterialChainResultKeys);
                spliceMaterialChainResultValues=r.spliceMaterialChainResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int mlSplitMaterialChain(IMSApiSessionContextStruct sessionContext, string stationNumber, KeyValue[] splitMaterialChainUploadValues, string[] splitMaterialChainResultKeys, ref string[] splitMaterialChainResultValues)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.mlSplitMaterialChain(sessionContext, stationNumber, splitMaterialChainUploadValues, splitMaterialChainResultKeys);
                splitMaterialChainResultValues=r.splitMaterialChainResultValues;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int msgPublish(IMSApiSessionContextStruct sessionContext, string topic, string message, ref string msgId)
        {
            if(!initialized) return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.msgPublish(sessionContext, topic, message);
                msgId=r.msgId;
                return r.return_value;
            }
            catch { return IMSAPI_REMOTE_SERVER_CALL_FAILED; }
        }

        public int msgSubscribe(IMSApiSessionContextStruct sessionContext, string[] topics, IMSApiDotNetEventListener listener)
        {
            if(!initialized)return IMSAPI_NOT_INITIALIZED;
            try
            {
                var r=service.msgSubscribe(sessionContext,topics); if(r.return_value!=0)return r.return_value;
                _subscriptionStop=false;
                _subscriptionThread=new Thread(()=>SubscriptionLoop(sessionContext,topics,listener)){IsBackground=true,Name="IMSApiDotNet-msgCallback"};
                _subscriptionThread.Start(); return 0;
            }
            catch{return IMSAPI_REMOTE_SERVER_CALL_FAILED;}
        }
        private void SubscriptionLoop(IMSApiSessionContextStruct ctx,string[] topics,IMSApiDotNetEventListener listener)
        {
            KeyValue[] ids=new KeyValue[0]; string nodeId=string.Empty;
            while(!_subscriptionStop)
            {
                try
                {
                    var r=service.msgCallback(ctx,topics,ids,nodeId);
                    if(r.return_value==0){ids=r.msgIds??ids;nodeId=r.nodeId??nodeId;if(listener!=null && r.records!=null)foreach(var rec in r.records)listener.onMessage(rec);}
                    else Thread.Sleep(500);
                }
                catch{Thread.Sleep(1000);}
            }
        }
        public int msgUnsubscribe(IMSApiSessionContextStruct sessionContext)
        {
            if(!initialized)return IMSAPI_NOT_INITIALIZED;
            try{_subscriptionStop=true;var r=service.msgUnsubscribe(sessionContext);return r.return_value;}catch{return IMSAPI_REMOTE_SERVER_CALL_FAILED;}
        }
        public override void Dispose(){_subscriptionStop=true;base.Dispose();}

    }
}
