Example #1
0
        public override DataSet Clone()
        {
            Map_Streets_DataSet cln = ((Map_Streets_DataSet)(base.Clone()));

            cln.InitVars();
            return(cln);
        }
        /// <summary> Build the information to display about the street, depending on what
        /// values are present in the Strongly typed street datarow </summary>
        /// <param name="thisStreet"> Strongly typed street datarow </param>
        /// <returns> text string (non-HTML) </returns>
        private string street_display( Map_Streets_DataSet.StreetsRow thisStreet )
        {
            // Start the return
            StringBuilder html = new StringBuilder(5000);

            // If there is a start and end streets, start with that
            if (( !thisStreet.IsStartAddressNull() ) && ( thisStreet.StartAddress > 0 ) && ( !thisStreet.IsEndAddressNull() ) && ( thisStreet.EndAddress > 0 ))
            {
                // Add this to the string
                html.Append( thisStreet.StartAddress + " - " + thisStreet.EndAddress );
            }

            // Add segment info if there is some
            if (( !thisStreet.IsSegmentDescriptionNull() ) && ( thisStreet.SegmentDescription.Length > 0 ))
            {
                // If there is already start and end info, add a comma
                if ( html.Length > 0 )
                    html.Append( ", " );

                // Add this segment info
                html.Append( thisStreet.SegmentDescription );
            }

            // Return this built string
            return html.ToString();
        }
        /// <summary> Insert the HTML for a single street column into the Stringbuilder </summary>
        /// <param name="streets"> Dataset containig all of the streets linked to this item </param>
        /// <param name="html"> Stringbuilder to feed the HTML into </param>
        /// <param name="startRow"> Row of the set of streets to begin on </param>
        /// <param name="endRow"> Last row in the set of streets </param>
        protected internal void Insert_One_Street_Column( StringBuilder html, Map_Streets_DataSet streets, int startRow, int endRow )
        {
            // Declare some variables for looping
            string lastStreetName = "%";

            // Start the table for this row
            html.AppendLine("\t\t\t<table width=\"100%\"> <!-- Table to display a single column of street information -->");

            // Now, loop through all the results
            int i = startRow;
            while ( i < endRow )
            {
                // Get this street
                Map_Streets_DataSet.StreetsRow thisStreet = streets.Streets[ i++ ];

                // If this street name starts with a new letter, add the letter now
                if ( thisStreet.StreetName.Trim()[0] != lastStreetName[0] )
                {
                    // Add a row for the letter
                    html.AppendLine("\t\t\t\t<tr> <td colspan=\"3\" class=\"bigletter\" align=\"center\">" + (thisStreet.StreetName.Trim())[0] + "</td> </tr>");
                    lastStreetName = thisStreet.StreetName.Trim();
                }

                // Start this row
                html.AppendLine("\t\t\t\t<tr class=\"index\">");

                // Add the street name and direction
                if (( !thisStreet.IsStreetDirectionNull() ) && ( thisStreet.StreetDirection.Length > 0 ))
                    html.AppendLine("\t\t\t\t\t<td>" + thisStreet.StreetName + ", " + thisStreet.StreetDirection + "<td>");
                else
                    html.AppendLine("\t\t\t\t\t<td>" + thisStreet.StreetName + "<td>");

                // Determine the second column of data and add it
                html.AppendLine("\t\t\t\t\t<td align=\"right\">" + street_display(thisStreet) + "</td>");

                // Add the link to the sheet
                CurrentMode.ViewerCode = thisStreet.PageSequence.ToString();
                html.AppendLine("\t\t\t\t\t<td><a href=\"" + CurrentMode.Redirect_URL() + "\">" + thisStreet.PageName.Replace("Sheet", "").Trim() + "</a></td>");

                // End this row
                html.AppendLine("\t\t\t\t</tr>");
            }

            // End this table
            html.AppendLine("\t\t\t</table>");
        }
        /// <summary> Build the HTML for the street index for this item </summary>
        /// <param name="html"> Stringbuilder to feed the HTML into </param>
        /// <param name="streets"> Dataset containig all of the streets linked to this item </param>
        protected internal void Create_Street_Index(StringBuilder html, Map_Streets_DataSet streets)
        {
            string currentView = CurrentMode.ViewerCode;

            // This will be presented in a table, so start the table
            html.AppendLine("\n\n<!-- Start output from GEMS_Map_Object.Street_Index -->");
            html.AppendLine("<table width=\"100%\">");

            // Determine (roughly) how many rows for each side
            // of the column
            int rows_per_column = streets.Streets.Count  / 3;
            if (( streets.Streets.Count % 3 ) > 0 )
                rows_per_column++;

            // Start the large table for each section
            html.AppendLine("\t<tr>");
            html.AppendLine("\t\t<td width=\"32%\" valign=\"top\">");

            // Create the first column of street information
            Insert_One_Street_Column( html, streets, 0, rows_per_column );

            // Move to second column of large table, after making a small margin column
            html.AppendLine("\t\t</td>");
            html.AppendLine("\t\t<td width=\"2%\"></td> <!-- Spacer Column -->");
            html.AppendLine("\t\t<td width=\"32%\" valign=\"top\">");

            // Create the second column of street information
            Insert_One_Street_Column( html, streets, rows_per_column, (2* rows_per_column) - 1 );

            // Move to third column of large table, after making a small margin column
            html.AppendLine("\t\t</td>");
            html.AppendLine("\t\t<td width=\"2%\"></td> <!-- Spacer Column -->");
            html.AppendLine("\t\t<td width=\"32%\" valign=\"top\">");

            // Create the third column of street information
            Insert_One_Street_Column( html, streets, (2 * rows_per_column), streets.Streets.Count );

            // Finish off the large table
            html.AppendLine("\t\t</td>");
            html.AppendLine("\t<tr>");
            html.AppendLine("</table>");
            html.AppendLine("<!-- End output from GEMS_Map_Object.Street_Index -->");

            CurrentMode.ViewerCode = currentView;
        }
        /// <summary> Gets the list of all streets linked to a particular item  </summary>
        /// <param name="ItemID"> ItemID for the item of interest</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> List of all streets linked to the item of interest </returns>
        /// <remarks> This calls the 'Auth_Get_All_Streets_By_Item' stored procedure </remarks> 
        public static Map_Streets_DataSet Get_All_Streets_By_Item(int ItemID, Custom_Tracer Tracer)
        {
            try
            {
                // Create the connection
                SqlConnection connect = new SqlConnection( connectionString );

                // Create the command
                SqlCommand executeCommand = new SqlCommand("Auth_Get_All_Streets_By_Item", connect)
                                                {CommandType = CommandType.StoredProcedure};
                executeCommand.Parameters.AddWithValue( "@itemid", ItemID );

                // Create the adapter
                SqlDataAdapter adapter = new SqlDataAdapter( executeCommand );

                // Add appropriate table mappings
                adapter.TableMappings.Add("Table", "Streets");

                // Fill the strongly typed dataset
                Map_Streets_DataSet streets = new Map_Streets_DataSet();
                adapter.Fill( streets );

                // Return the fully built object
                return streets;
            }
            catch ( Exception ee )
            {
                lastException = ee;
                if (Tracer != null)
                {
                    Tracer.Add_Trace("SobekCM_Database.Get_All_Streets_By_Item", "Exception caught during database work", Custom_Trace_Type_Enum.Error);
                    Tracer.Add_Trace("SobekCM_Database.Get_All_Streets_By_Item", ee.Message, Custom_Trace_Type_Enum.Error);
                    Tracer.Add_Trace("SobekCM_Database.Get_All_Streets_By_Item", ee.StackTrace, Custom_Trace_Type_Enum.Error);
                }
                return null;
            }
        }