Esempio n. 1
0
        internal override object FindById(object id)
        {
            Type          type          = Proxy.ProxyType;
            MethodInfo    mi            = type.GetMethod(MethodName());
            ParameterInfo pi            = mi.GetParameters().First();
            Type          parameterType = pi.ParameterType;
            object        qType         = r.InstanceFromType(parameterType);

            w.SetValue(qType, "WHERE", string.Format("{0}='{1}'", Metadata.Schema.IdAttribute.Name, id));
            var parameterList = MifUtils.GetParameterListForQuery(qType);

            Type[] typesFromParameters = DynamicProxyUtil.TypesFromParameters(parameterList);
            object result     = Proxy.CallMethod(MethodName(), typesFromParameters, parameterList.ToArray());
            var    enumerable = result as IEnumerable;

            if (enumerable == null)
            {
                return(null);
            }

            IEnumerator enumerator = enumerable.GetEnumerator();

            if (enumerator.MoveNext())
            {
                return(enumerator.Current);
            }
            return(null);
        }
Esempio n. 2
0
 public static void StubReset()
 {
     FinishedParsing = false;
     //TODO: remove this stub, monitor changes on XML?
     //TODO: create some sort of clear cache event, for distributing responsabilities in an easier way
     InitializeMetadata();
     DynamicProxyUtil.ClearCache();
 }
Esempio n. 3
0
        public override DynamicObject CreateProxy(EntityMetadata metadata)
        {
            //for ISM we have only a single wsdl for all the web-services
            //so we don´t need to specify one for each of the entities, like the other maximo providers
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                delegate { return(true); }
                );
            var wsdlPath = MetadataProvider.GlobalProperty(ISMConstants.GlobalWsdlProperty);

            return(DynamicProxyUtil.LookupProxy(wsdlPath, false));
        }
Esempio n. 4
0
        public MeaExecutionContext(IOperationData operationData, DynamicObject proxy = null)
            : base(operationData)
        {
            if (proxy == null)
            {
                proxy = DynamicProxyUtil.LookupProxy(operationData.EntityMetadata);
            }
            //            _queryProxy = DynamicProxyUtil.LookupProxy(operationData.EntityMetadata, true);
            var curUser = SecurityFacade.CurrentUser();

            BuildNotify(operationData, proxy, curUser);
        }
Esempio n. 5
0
        public MifExecutionContext(IOperationData operationData, DynamicObject proxy = null)
            : base(operationData)
        {
            Proxy = proxy ?? DynamicProxyUtil.LookupProxy(operationData.EntityMetadata);
            CheckCredentials(Proxy);

            var curUser       = SecurityFacade.CurrentUser();
            var operationType = operationData.OperationType;
            var isCreation    = OperationType.Add == operationType;

            _methodName = MifMethodNameUtils.GetMethodName(Metadata, operationType);
            var type = Proxy.ProxyType;

            var mi = type.GetMethod(_methodName);
            var pi = mi.GetParameters().First();
            // element array , like MXSW3_WO_TYPE[]
            var parameterType = pi.ParameterType;

            object notifyInterface;
            object integrationObject;

            if (parameterType.IsArray)
            {
                notifyInterface   = ReflectionUtil.InstantiateArrayWithBlankElements(parameterType.GetElementType(), 1);
                integrationObject = ((Array)notifyInterface).GetValue(0);
            }
            else
            {
                notifyInterface   = ReflectionUtil.InstanceFromType(parameterType);
                integrationObject = notifyInterface;
            }

            r.SetProperty(integrationObject, "actionSpecified", true);
            r.InstantiateProperty(integrationObject, "CHANGEDATE", new { Value = DateTime.Now.FromServerToRightKind() });
            //TODO: get current user, in the mobile case below code may be wrong
            r.InstantiateProperty(integrationObject, "CHANGEBY", new { Value = curUser.Login });
            //TODO: get from user
            r.InstantiateProperty(integrationObject, "ORGID", new { Value = curUser.OrgId });
            r.InstantiateProperty(integrationObject, "SITEID", new { Value = curUser.SiteId });
            r.SetProperty(integrationObject, "action", operationType.ToString());

            IntegrationObject   = integrationObject;
            RootInterfaceObject = notifyInterface;
        }