Beispiel #1
0
        /// <summary>
        /// Renders a range of businesses.
        /// </summary>
        /// <param name="writer">Writer to use to write our HTML.</param>
        /// <param name="startIndex">The beginning of our range of businesses to render.</param>
        /// <param name="endIndex">The end of our range of businesses to render.</param>
        private void RenderRange(HtmlTextWriter writer, int startIndex, int endIndex)
        {
            while (startIndex < endIndex)
            {
                BusinessResultInfo businessResultInfo = ( BusinessResultInfo )results[startIndex];

                //
                // Render the business name.
                //
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "3");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.RenderBeginTag(HtmlTextWriterTag.B);
                writer.Write(Server.HtmlEncode(businessResultInfo.businessName));
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.RenderEndTag();

                foreach (ServiceResultInfo serviceResultInfo in businessResultInfo.serviceResultInfos)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    //
                    // Write a placeholder cell so we can indent each service info under its
                    // business name.
                    //
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "space_cell");
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.Write("&nbsp;");
                    writer.RenderEndTag();

                    //
                    // Render the service.
                    //
                    RenderServiceInfo(serviceResultInfo, writer);

                    writer.RenderEndTag();
                }

                startIndex++;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Use this function to populate a ResultsList instance with raw values from the database.
        /// The results from the database must be returned in the following order:
        ///
        /// businessName
        /// businessKey
        /// serviceName
        /// serviceKey
        ///
        /// ParseResults will use indexes to read these values from the SqlDataReaderAccessor so this
        /// order must be maintained from the database.
        /// </summary>
        /// <param name="values">Reader returned from the database.</param>
        /// <returns></returns>
        public int ParseResults(SqlDataReaderAccessor values)
        {
            results = new ArrayList();

            string             currentBusinessName = null;
            string             lastBusinessName    = null;
            BusinessResultInfo businessInfo        = new BusinessResultInfo();

            while (values.Read())
            {
                currentBusinessName = values.GetString(0);

                ServiceResultInfo serviceInfo = new ServiceResultInfo();
                serviceInfo.serviceName = values.GetString(2);
                serviceInfo.serviceKey  = values.GetString(3);

                if (null != lastBusinessName && false == lastBusinessName.Equals(currentBusinessName))
                {
                    results.Add(businessInfo);
                    businessInfo = new BusinessResultInfo();
                }

                businessInfo.businessName = currentBusinessName;
                businessInfo.serviceResultInfos.Add(serviceInfo);

                lastBusinessName = currentBusinessName;
            }

            //
            // Add our last one.
            //
            if (businessInfo.serviceResultInfos.Count > 0)
            {
                results.Add(businessInfo);
            }

            return(results.Count);
        }