Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sherry Ann Hernandez 320 posts 344 karma points
    Apr 19, 2011 @ 14:52
    Sherry Ann Hernandez
    0

    Another way of pulling the nodes data

    Hi,

    I have this code to pull the data from different nodes.

     

     

    private void BuildHotelListing()

    {

     

     

    DataTable dt = new DataTable();

     

     

    DataColumn col1 = new DataColumn("NodeID");

     

     

    DataColumn col2 = new DataColumn("NodeName");

     

     

    DataColumn col3 = new DataColumn("MapThumbnail");

     

     

    DataColumn col4 = new DataColumn("StreetAddress");

     

     

    DataColumn col5 = new DataColumn("City");

     

     

    DataColumn col6 = new DataColumn("Country");

     

     

    DataColumn col7 = new DataColumn("Region");

     

     

    DataColumn col8 = new DataColumn("ZipCode");

     

     

    DataColumn col9 = new DataColumn("BanquetTelephone");

     

     

    DataColumn col10 = new DataColumn("Telephone");

     

     

    DataColumn col11 = new DataColumn("HotelName");

     

     

    DataColumn col12 = new DataColumn("HotelID");

     

     

    DataColumn col13 = new DataColumn("Amenities");

     

     

    DataColumn col14 = new DataColumn("VirtualTour");

     

     

    DataColumn col15 = new DataColumn("ImageThumbnail");

     

     

    DataColumn col16 = new DataColumn("ImageGalleryTitle");

     

     

    DataColumn col17 = new DataColumn("ImageGalleryRel");

     

     

    DataColumn col18 = new DataColumn("DimensionM");

     

     

    DataColumn col19 = new DataColumn("AreaSQM");

     

     

    DataColumn col20 = new DataColumn("Theatre");

     

     

    DataColumn col21 = new DataColumn("Classroom");

     

     

    DataColumn col22 = new DataColumn("HollowSQ");

     

     

    DataColumn col23 = new DataColumn("Boardroom");

     

     

    DataColumn col24 = new DataColumn("Cabaret");

     

     

    DataColumn col25 = new DataColumn("Banquet");

     

     

    DataColumn col26 = new DataColumn("UShape");

     

     

    DataColumn col27 = new DataColumn("FloorPlan");

     

     

    DataColumn col28 = new DataColumn("BanquetType");

     

     

    DataColumn col29 = new DataColumn("AreaSQF");

    dt.Columns.Add(col1);

    dt.Columns.Add(col2);

    dt.Columns.Add(col3);

    dt.Columns.Add(col4);

    dt.Columns.Add(col5);

    dt.Columns.Add(col6);

    dt.Columns.Add(col7);

    dt.Columns.Add(col8);

    dt.Columns.Add(col9);

    dt.Columns.Add(col10);

    dt.Columns.Add(col11);

    dt.Columns.Add(col12);

    dt.Columns.Add(col13);

    dt.Columns.Add(col14);

    dt.Columns.Add(col15);

    dt.Columns.Add(col16);

    dt.Columns.Add(col17);

    dt.Columns.Add(col18);

    dt.Columns.Add(col19);

    col20.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col20);

    col21.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col21);

    col22.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col22);

    col23.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col23);

    col24.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col24);

    col25.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col25);

    col26.DataType = System.

     

    Type.GetType("System.Int32");

    dt.Columns.Add(col26);

    dt.Columns.Add(col27);

    dt.Columns.Add(col28);

    dt.Columns.Add(col29);

     

     

    string[] strHomeArray = new string[] { "flora grand home node", "florida home node", "florida in home node", "flora creek home node", "flora park home node", "flora home node"};

     

     

    string[] strMeetingArray = new string[] { "flora grand meeting node", "florida meeting node", "florida in meeting node", "flora creek meeting node", "flora park meeting node", "flora meeting node"};

     

     

    int ctr = 0;

     

     

    foreach (string str in strMeetingArray)

    {

     

     

    var rowCtr = umbraco.library.GetDictionaryItem(str);

     

     

    var rowHomeCtr = Convert.ToInt32(umbraco.library.GetDictionaryItem(strHomeArray[ctr]));

     

     

    var hotelID = ctr+1;

     

     

    if ((_hotelID == "") || (_hotelID == Convert.ToString(hotelID)))

    {

     

     

    if (!string.IsNullOrEmpty(rowCtr))

    {

     

     

     

    Node n = new Node(Convert.ToInt32(rowCtr));

     

     

    foreach (Node node in n.Children)

    {

     

     

    if (node.GetProperty("banquetType").Value.IndexOf(_banquetType) != -1)

    {

     

     

    if (string.IsNullOrEmpty(_nodeID) || (_nodeID.Contains(node.Id.ToString())))

    {

     

     

    DataRow row = dt.NewRow();

    row[col1] = node.Id;

    row[col2] = node.Name;

    row[col3] = GetMediaName(GetPropertyFromAliasAndNodeID(

     

    "mapThumbnail", rowHomeCtr), true);

    row[col4] = GetPropertyFromAliasAndNodeID(

     

    "streetAddress", rowHomeCtr);

    row[col5] = GetPropertyFromAliasAndNodeID(

     

    "city", rowHomeCtr);

    row[col6] = GetPropertyFromAliasAndNodeID(

     

    "country", rowHomeCtr);

    row[col7] = GetPropertyFromAliasAndNodeID(

     

    "region", rowHomeCtr);

    row[col8] = GetPropertyFromAliasAndNodeID(

     

    "zipCode", rowHomeCtr);

    row[col9] = GetPropertyFromAliasAndNodeID(

     

    "banquetTelephone", rowHomeCtr);

    row[col10] = GetPropertyFromAliasAndNodeID(

     

    "telephone", rowHomeCtr);

    row[col11] = GetPropertyFromAliasAndNodeID(

     

    "hotelName", rowHomeCtr);

    row[col12] = hotelID;

    row[col13] = GetAmenitiesList(node.GetProperty(

     

    "listOfAmenities").Value);

    row[col14] = GetMediaName(node.GetProperty(

     

    "virtualTourFile").Value, true);

    row[col15] = GetMediaName(node.GetProperty(

     

    "imageThumbnail").Value, false);

    row[col16] = GetMediaGalleryTitle(node.GetProperty(

     

    "imageGallery").Value, GetPropertyFromAliasAndNodeID("hotelName", rowHomeCtr), GetPropertyFromAliasAndNodeID("banquetTelephone", rowHomeCtr));

    row[col17] = GetMediaGalleryRel(node.GetProperty(

     

    "imageGallery").Value);

    row[col18] = node.GetProperty(

     

    "dimensionM").Value;

    row[col19] = node.GetProperty(

     

    "areSQM").Value;

    row[col20] = node.GetProperty(

     

    "theatre").Value != "" ? Convert.ToInt32(node.GetProperty("theatre").Value) : 0;

    row[col21] = node.GetProperty(

     

    "classroom").Value != "" ? Convert.ToInt32(node.GetProperty("classroom").Value) : 0;

    row[col22] = node.GetProperty(

     

    "hollowSQ").Value != "" ? Convert.ToInt32(node.GetProperty("hollowSQ").Value) : 0;

    row[col23] = node.GetProperty(

     

    "boardroom").Value != "" ? Convert.ToInt32(node.GetProperty("boardroom").Value) : 0;

    row[col24] = node.GetProperty(

     

    "cabaret").Value != "" ? Convert.ToInt32(node.GetProperty("cabaret").Value) : 0;

    row[col25] = node.GetProperty(

     

    "banquet").Value != "" ? Convert.ToInt32(node.GetProperty("banquet").Value) : 0;

    row[col26] = node.GetProperty(

     

    "u-Shape").Value != "" ? Convert.ToInt32(node.GetProperty("u-Shape").Value) : 0;

    row[col27] = GetMediaName(node.GetProperty(

     

    "floorPlan").Value, true);

    row[col28] = node.GetProperty(

     

    "banquetType").Value.Replace(",", ",<br/>");

    row[col29] = node.GetProperty(

     

    "areSQM").Value != "" ? (Math.Round(Convert.ToDouble(node.GetProperty("areSQM").Value) / 0.09290304)).ToString() : "";

    dt.Rows.Add(row);

    }

    }

    }

     

    }

    }

    ctr++;

    }

     

     

    // currentTable is a datatable of non-sorted rows

     

     

    if (!string.IsNullOrEmpty(_sortBy))

    {

     

     

    DataSet dsSorted = new DataSet();

    dt.DefaultView.Sort =

     

    string.Format("{0} {1}", _sortBy, _sortOrder);

    dsSorted.Tables.Add(dt.DefaultView.ToTable());

    lvMeetingsAndEventsList.DataSource = dsSorted;

    lvMeetingsAndEventsList.DataBind();

     

    }

     

     

    else

    {

    lvMeetingsAndEventsList.DataSource = dt;

    lvMeetingsAndEventsList.DataBind();

    }

     

    }

     

    Anybody, have a better idea on how to do it? Basically what it does is to pull the meetings and events data from the different hotel. Each meetings and events nodes have several meeting rooms that I need to display.

    I use dictionary object to save the node id because we are using 12 language for our multilingual site.

     

Please Sign in or register to post replies

Write your reply to:

Draft