Beispiel #1
0
        protected byte[] GetServices(ServiceType returnServiceTypes, out int rowCount, out CommonContentType contentType)
        {
            NetworkNodeType networkNodeType = GetServices(returnServiceTypes);

            rowCount = networkNodeType.NodeServiceList.Length;

            NetworkNodeListType networkNodeListType = new NetworkNodeListType();

            networkNodeListType.NetworkNodeDetails = new NetworkNodeType[1] {
                networkNodeType
            };

            byte[] content = _serializationHelper.Serialize(networkNodeListType);

            contentType = CommonContentType.XML;
            content     = CheckToXsltTransformContent(content, "xml_schema.XsltTransforms.zip",
                                                      _xsltTransformName, ref contentType);

            string docId =
                _documentManager.AddDocument(_dataRequest.TransactionId, CommonTransactionStatusCode.Completed,
                                             null, new Document(null, contentType, content));

            return(content);
        }
Beispiel #2
0
        protected NetworkNodeType GetServices(ServiceType returnServiceTypes)
        {
            LatLongRectangle    nodeBox             = _settingsProvider.NodeBoundingBox;
            EndpointVersionType endpointVersionType =
                _transactionManager.GetTransactionEndpointVersionType(_dataRequest.TransactionId);

            if (endpointVersionType == EndpointVersionType.Undefined)
            {
                endpointVersionType = EndpointVersionType.EN20;
            }
            Dictionary <ServiceType, NodeMethodTypeCode> publishServiceTypeMap = new Dictionary <ServiceType, NodeMethodTypeCode>();

            if (EnumUtils.IsFlagSet(returnServiceTypes, ServiceType.Query))
            {
                publishServiceTypeMap.Add(ServiceType.Query, NodeMethodTypeCode.Query);
            }
            if (EnumUtils.IsFlagSet(returnServiceTypes, ServiceType.Solicit))
            {
                publishServiceTypeMap.Add(ServiceType.Solicit, NodeMethodTypeCode.Solicit);
            }
            if (EnumUtils.IsFlagSet(returnServiceTypes, ServiceType.Submit))
            {
                publishServiceTypeMap.Add(ServiceType.Submit, NodeMethodTypeCode.Submit);
            }
            if (EnumUtils.IsFlagSet(returnServiceTypes, ServiceType.Execute))
            {
                publishServiceTypeMap.Add(ServiceType.Execute, NodeMethodTypeCode.Execute);
            }
            if (publishServiceTypeMap.Count == 0)
            {
                throw new ArgumentException(string.Format("Invalid ServiceType specified: \"{0}\"", returnServiceTypes));
            }

            NetworkNodeType networkNodeType = new NetworkNodeType();

            networkNodeType.NodeServiceList    = new ServiceDescriptionListTypeService[0];
            networkNodeType.BoundingBoxDetails = new NodeBoundingBoxType();
            networkNodeType.BoundingBoxDetails.BoundingCoordinateNorth = nodeBox.North;
            networkNodeType.BoundingBoxDetails.BoundingCoordinateEast  = nodeBox.East;
            networkNodeType.BoundingBoxDetails.BoundingCoordinateSouth = nodeBox.South;
            networkNodeType.BoundingBoxDetails.BoundingCoordinateWest  = nodeBox.West;
            if (endpointVersionType == EndpointVersionType.EN20)
            {
                networkNodeType.NodeAddress           = _settingsProvider.Endpoint20Url;
                networkNodeType.NodeVersionIdentifier = NodeVersionCode.Item20;
            }
            else
            {
                networkNodeType.NodeAddress           = _settingsProvider.Endpoint11Url;
                networkNodeType.NodeVersionIdentifier = NodeVersionCode.Item11;
            }
            networkNodeType.NodeContact = _settingsProvider.NodeAdminEmail;
            if (_settingsProvider.IsProductionNode)
            {
                networkNodeType.NodeDeploymentTypeCode = NodeStageCode.Production;
            }
            else
            {
                networkNodeType.NodeDeploymentTypeCode = NodeStageCode.Development;
            }
            networkNodeType.NodeIdentifier         = _settingsProvider.NodeId + " - " + (_settingsProvider.IsProductionNode ? "Prod" : "Test");
            networkNodeType.NodeName               = networkNodeType.NodeIdentifier;
            networkNodeType.OrganizationIdentifier = _settingsProvider.NodeOrganizationName;
            networkNodeType.NodeStatus             = NodeStatusCode.Operational;

            string username = _transactionManager.GetTransactionUsername(_dataRequest.TransactionId);

            AppendAuditLogEvent("Loading information for all data flows for user: {0}", username);
            IList <DataFlow> dataFlows = _flowManager.GetAllDataFlows(true, true);


            if (!CollectionUtils.IsNullOrEmpty(dataFlows))
            {
                AppendAuditLogEvent("Loaded information for {0} data flows for user: {1}", dataFlows.Count.ToString(), username);

                DataServicePublishFlags validPublishFlags = (endpointVersionType == EndpointVersionType.EN20) ?
                                                            DataServicePublishFlags.PublishToEndpointVersion20 : DataServicePublishFlags.PublishToEndpointVersion11;
                List <ServiceDescriptionListTypeService> services = null;
                foreach (DataFlow dataFlow in dataFlows)
                {
                    if (!CollectionUtils.IsNullOrEmpty(dataFlow.Services))
                    {
                        foreach (DataService dataService in dataFlow.Services)
                        {
                            if (EnumUtils.IsFlagSet(dataService.PublishFlags, validPublishFlags) && dataService.IsActive &&
                                (dataService.PluginInfo != null) && !string.IsNullOrEmpty(dataService.PluginInfo.ImplementingClassName))
                            {
                                foreach (KeyValuePair <ServiceType, NodeMethodTypeCode> pair in publishServiceTypeMap)
                                {
                                    if (EnumUtils.IsFlagSet(dataService.Type, pair.Key))
                                    {
                                        ServiceDescriptionListTypeService nodeService = new ServiceDescriptionListTypeService();
                                        nodeService.Dataflow           = dataFlow.FlowName;
                                        nodeService.MethodName         = pair.Value;
                                        nodeService.ServiceDescription = string.Format("{0} - {1} Service", dataFlow.FlowName,
                                                                                       dataService.Name);
                                        nodeService.ServiceDocumentURL = dataFlow.InfoUrl;
                                        nodeService.ServiceIdentifier  = dataService.Name;

                                        int publishParamCount = GetPublishParamCount(dataService.ServiceParameters);
                                        if (publishParamCount > 0)
                                        {
                                            nodeService.Parameter = new RequestParameterType[publishParamCount];
                                            for (int i = 0, index = 0; i < dataService.ServiceParameters.Count; ++i)
                                            {
                                                TypedParameter typedParameter = dataService.ServiceParameters[i];
                                                if (typedParameter.DoPublishParam)
                                                {
                                                    RequestParameterType requestParameter = new RequestParameterType();
                                                    requestParameter.ParameterName              = typedParameter.Name;
                                                    requestParameter.ParameterSortIndex         = index.ToString();
                                                    requestParameter.ParameterRequiredIndicator = typedParameter.IsRequired;
                                                    nodeService.Parameter[index++]              = requestParameter;
                                                }
                                            }
                                        }

                                        CollectionUtils.Add(nodeService, ref services);
                                    }
                                }
                            }
                        }
                    }
                }
                if (!CollectionUtils.IsNullOrEmpty(services))
                {
                    services.Sort(delegate(ServiceDescriptionListTypeService s1, ServiceDescriptionListTypeService s2)
                    {
                        int result = string.Compare(s1.Dataflow, s2.Dataflow);
                        if (result != 0)
                        {
                            return(result);
                        }
                        result = string.Compare(s1.ServiceIdentifier, s2.ServiceIdentifier);
                        if (result != 0)
                        {
                            return(result);
                        }
                        return(string.Compare(s1.MethodName.ToString(), s2.MethodName.ToString()));
                    });
                    networkNodeType.NodeServiceList = services.ToArray();
                }
            }

            return(networkNodeType);
        }