private static MaximoResult DoExecuteCrud(OperationWrapper operationWrapper, IMaximoConnector connector) { if (!OperationConstants.IsCrud(operationWrapper.OperationName)) { //custom operation return(null); } var crudConnector = new MaximoCrudConnectorEngine((IMaximoCrudConnector)connector); var crudOperationData = (CrudOperationData)operationWrapper.OperationData(null); switch (operationWrapper.OperationName) { case OperationConstants.CRUD_CREATE: return(crudConnector.Create(crudOperationData)); case OperationConstants.CRUD_UPDATE: return(crudConnector.Update(crudOperationData)); case OperationConstants.CRUD_DELETE: return(crudConnector.Delete(crudOperationData)); case OperationConstants.CRUD_FIND_BY_ID: return(crudConnector.FindById(crudOperationData)); } return(null); }
private static IMaximoConnector DoGetConnector(string operation, string customConnectorTypeName) { if (customConnectorTypeName == null) { return(null); } //TODO: use spring try { var connector = (IMaximoConnector)ReflectionUtil.InstanceFromName(customConnectorTypeName); if (OperationConstants.IsCrud(operation) && !(connector is IMaximoCrudConnector)) { throw ExceptionUtil.InvalidOperation(WrongCrudConnectorType, customConnectorTypeName, typeof(IMaximoCrudConnector).Name); } return(connector); } catch (InvalidCastException) { throw ExceptionUtil.InvalidOperation(WrongConnectorType, customConnectorTypeName, typeof(IMaximoConnector).Name); } catch (Exception) { throw ExceptionUtil.InvalidOperation("Custom connector {0} not found", customConnectorTypeName); } }