Beispiel #1
0
        public static object GetNewFixedMxType(EntityMetadata entity, string mxtype, object value)
        {
            string             typeName = MifMethodNameUtils.GetBaseWsTypeName(entity.Name) + "." + mxtype;
            var                ob       = Activator.CreateInstance(null, typeName).Unwrap();
            PropertyDescriptor prop     = TypeDescriptor.GetProperties(ob)["Value"];

            prop.SetValue(ob, value);
            return(ob);
        }
        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;
        }
Beispiel #3
0
 public static object getNewWSEntity(string entity)
 {
     return(Activator.CreateInstance(null, MifMethodNameUtils.GetWSEntityName(entity)).Unwrap());
 }