Ejemplo n.º 1
0
            public int Compare(object x, object y)
            {
                BusinessInfo entity1 = (BusinessInfo)x;
                BusinessInfo entity2 = (BusinessInfo)y;

                return(string.Compare(entity1.Names[0].Value, entity2.Names[0].Value, true));
            }
Ejemplo n.º 2
0
 public void Remove(BusinessInfo businessInfo)
 {
     List.Remove(businessInfo);
 }
Ejemplo n.º 3
0
 public bool Contains(BusinessInfo businessInfo)
 {
     return(List.Contains(businessInfo));
 }
Ejemplo n.º 4
0
 public int IndexOf(BusinessInfo businessInfo)
 {
     return(List.IndexOf(businessInfo));
 }
Ejemplo n.º 5
0
 public void Insert(int index, BusinessInfo businessInfo)
 {
     List.Insert(index, businessInfo);
 }
Ejemplo n.º 6
0
 public int Add(BusinessInfo businessInfo)
 {
     return(List.Add(businessInfo));
 }
Ejemplo n.º 7
0
        public BusinessList Find()
        {
            BusinessList businessList = new BusinessList();

            QueryLog.Write(QueryType.Find, EntityType.BusinessEntity);

            //
            // Process each find constraint.
            //
            FindBuilder find = new FindBuilder(EntityType.BusinessEntity, FindQualifiers);

            //
            // If no search arguments are specified, return an empty result
            // set.
            //
            if (Utility.CollectionEmpty(Names) &&
                Utility.CollectionEmpty(DiscoveryUrls) &&
                Utility.CollectionEmpty(IdentifierBag) &&
                Utility.CollectionEmpty(CategoryBag) &&
                Utility.CollectionEmpty(TModelBag))
            {
                return(businessList);
            }

            //
            // Validate find parameters.
            //

            if (!Utility.CollectionEmpty(Names))
            {
                Names.ValidateForFind();
            }
            else
            {
                Debug.Verify(!find.CaseSensitiveMatch && !find.ExactNameMatch,
                             "UDDI_ERROR_UNSUPPORTED_FINDBE_NAMEFQNONAMES", ErrorType.E_unsupported);
            }


            //
            // TODO: Override may be better for these calls to KeyedReference.Validate because no parent key is used
            //
            if (!Utility.CollectionEmpty(IdentifierBag))
            {
                IdentifierBag.Validate("", KeyedReferenceType.IdentifierBag);
            }

            if (!Utility.CollectionEmpty(CategoryBag))
            {
                CategoryBag.Validate("", KeyedReferenceType.CategoryBag);
            }

            try
            {
                int rows = 1;

                //
                // Find entities with matching identifier bag items.
                //
                if (!Utility.CollectionEmpty(IdentifierBag))
                {
                    rows = find.FindByKeyedReferences(KeyedReferenceType.IdentifierBag, IdentifierBag);
                }

                //
                // Find entities with matching category bag items.
                //
                if (rows > 0 && !Utility.CollectionEmpty(CategoryBag))
                {
                    rows = find.FindByKeyedReferences(KeyedReferenceType.CategoryBag, CategoryBag);
                }

                //
                // Find entities with matching TModel bag items.
                //
                if (rows > 0 && !Utility.CollectionEmpty(TModelBag))
                {
                    rows = find.FindByTModelBag(TModelBag);
                }

                //
                // Find entities with matching discovery URLs
                //
                if (rows > 0 && !Utility.CollectionEmpty(DiscoveryUrls))
                {
                    rows = find.FindByDiscoveryUrls(DiscoveryUrls);
                }

                //
                // Find entities with matching names
                //
                if (rows > 0 && !Utility.CollectionEmpty(Names))
                {
                    rows = find.FindByNames(Names);
                }

                //
                // Process the find result set.
                //
                if (0 == rows)
                {
                    //
                    // Cleanup any temporary tables.
                    //
                    find.Abort();
                }                 // TODO: review
                else if (0 == MaxRows)
                {
                    businessList.Truncated = Truncated.True;
                    return(businessList);
                }
                else
                {
                    //
                    // Read in the find results.
                    //
                    SqlDataReaderAccessor      reader;
                    SqlStoredProcedureAccessor sp;
                    sp = find.RetrieveResults(MaxRows);
//
// TODO: return reader, not the whole SPA
//
                    reader = sp.ExecuteReader();

                    try
                    {
                        if (find.ServiceSubset)
                        {
                            //
                            // For a service subset search, we limit the result set
                            // to those services that matched the category bag
                            // search criteria.
                            //
                            BusinessInfo businessInfo = null;
                            string       prevKey      = null;

                            while (reader.Read())
                            {
                                string businessKey = reader.GetString("entityKey");

                                if (prevKey != businessKey)
                                {
                                    businessInfo = new BusinessInfo(businessKey);
                                    businessList.BusinessInfos.Add(businessInfo);
                                }

                                businessInfo.ServiceInfos.Add(
                                    reader.GetString("subEntityKey"),
                                    businessKey);

                                prevKey = businessKey;
                            }
                        }
                        else
                        {
                            //
                            // For non-service subset searches, we will simply
                            // return a list of businesses with all services.
                            //
                            while (reader.Read())
                            {
                                businessList.BusinessInfos.Add(reader.GetString("entityKey"));
                            }
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }

                    if (sp.Parameters.GetBool("@truncated"))
                    {
                        businessList.Truncated = Truncated.True;
                    }
                    else
                    {
                        businessList.Truncated = Truncated.False;
                    }

                    //
                    // Get the actual business info and service info data.  For
                    // a service subset, we'll grab just those services that we
                    // populated.  For all other searches, we'll get all service
                    // infos.
                    //
                    if (find.ServiceSubset)
                    {
                        foreach (BusinessInfo businessInfo in businessList.BusinessInfos)
                        {
                            businessInfo.Get(false);

                            foreach (ServiceInfo serviceInfo in businessInfo.ServiceInfos)
                            {
                                serviceInfo.Get();
                            }
                        }
                    }
                    else
                    {
                        foreach (BusinessInfo businessInfo in businessList.BusinessInfos)
                        {
                            businessInfo.Get(true);
                        }
                    }
                }
            }
            catch (Exception)
            {
                find.Abort();
                throw;
            }

            return(businessList);
        }