Exemplo n.º 1
0
        public static IList <DC_M_masterattributevalue> GetMasterAttributesValues(string MasterFor, string Name)
        {
            List <DC_M_masterattributevalue> result = new List <DC_M_masterattributevalue>();

            using (var scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew, new System.Transactions.TransactionOptions()
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                Timeout = new TimeSpan(0, 2, 0)
            }))
            {
                using (TLGX_Entities context = new TLGX_Entities())
                {
                    result = (from ma in context.m_masterattribute
                              join mav in context.m_masterattributevalue on ma.MasterAttribute_Id equals mav.MasterAttribute_Id
                              join pav in context.m_masterattributevalue on mav.ParentAttributeValue_Id equals pav.MasterAttributeValue_Id into paval
                              from pavalid in paval.DefaultIfEmpty()
                              where ma.MasterFor == MasterFor && ma.Name == Name && (mav.IsActive ?? false) == true
                              select new DC_M_masterattributevalue
                    {
                        MasterAttribute_Id = mav.MasterAttribute_Id,
                        MasterAttributeValue_Id = mav.MasterAttributeValue_Id,
                        AttributeValue = mav.AttributeValue ?? "",
                        OTA_CodeTableValue = mav.OTA_CodeTableValue ?? "",
                        IsActive = mav.IsActive ?? false == true ? "Y" : "N",
                        ParentAttributeValue_Id = pavalid.MasterAttributeValue_Id,
                        ParentAttributeValue = pavalid.AttributeValue,
                    }).ToList();
                }
                scope.Complete();
                scope.Dispose();
            }
            return(result);
        }
Exemplo n.º 2
0
        //public void LoadHotelDefinitions()
        //{
        //    try
        //    {
        //        using (TLGX_Entities context = new TLGX_Entities())
        //        {

        //            _database = MongoDBHandler.mDatabase();

        //            _database.DropCollection("Accommodations");

        //            var collection = _database.GetCollection<BsonDocument>("Accommodations");
        //            var AccoList = (from a in context.Accommodations
        //                           where a.CompanyHotelID != null
        //                           select a).Take(100);


        //            List<BsonDocument> docs = new List<BsonDocument>();

        //            foreach (var Acco in AccoList)
        //            {

        //                var document = new BsonDocument
        //                {
        //                    //{
        //                        //Acco.CompanyHotelID.ToString(), new BsonDocument
        //                        //{
        //                            {"SupplierHotelID",string.Empty},
        //                            {"HotelId",Acco.CompanyHotelID.ToString()},
        //                            {"name",Acco.HotelName},
        //                            //{"starrating",(Acco.HotelRating ?? string.Empty)},
        //                            {"credicards",string.Empty},
        //                            {"areatransportation",string.Empty},
        //                            {"restaurants",string.Empty},
        //                            {"meetingfacility",string.Empty},
        //                            {"description",string.Empty},
        //                            {"highlight", string.Empty},
        //                            {"overview", string.Empty},
        //                            {"checkintime", (Acco.CheckInTime ?? string.Empty)},
        //                            {"checkouttime", (Acco.CheckOutTime ?? string.Empty)},
        //                            {"email", string.Empty},
        //                            {"website", string.Empty},
        //                            {"rooms", (Acco.TotalRooms ?? string.Empty)},
        //                            {"LandmarkCategory",string.Empty},
        //                            {"Landmark",string.Empty},
        //                            {"theme",string.Empty},
        //                            {"HotelChain",(Acco.Chain ?? string.Empty)},
        //                            {"BrandName",(Acco.Brand ?? string.Empty)},
        //                            {"recommends", (Acco.CompanyRecommended ?? false)},
        //                            {"latitude",(Acco.Latitude ?? string.Empty)},
        //                            {"longitude", (Acco.Longitude ?? string.Empty)},
        //                            {"LandmarkDescription",string.Empty},
        //                            {"starrating", new BsonDocument
        //                                {
        //                                    {"level", (Acco.HotelRating ?? string.Empty) }
        //                                }
        //                            },
        //                            //{"Address", new BsonDocument
        //                            //    {
        //                            //        {"address",(Acco.StreetName ?? string.Empty)},
        //                            //        {"city", (Acco.city ?? string.Empty)},
        //                            //        {"state",(Acco.State_Name ?? string.Empty)},
        //                            //        {"country", (Acco.country ?? string.Empty)},
        //                            //        {"pincode", (Acco.PostalCode ?? string.Empty)},
        //                            //        {"location",string.Empty}
        //                            //        //{"phone",string.Empty},
        //                            //        //{"fax",string.Empty}
        //                            //    }
        //                            //},
        //                            {"thumb",string.Empty},
        //                            //{"image", new BsonDocument
        //                            //    {
        //                            //        {"image0",string.Empty},
        //                            //        {"image1", string.Empty}
        //                            //    }
        //                            //},
        //                            {"video",string.Empty},
        //                            //{"HotelFacility", new BsonDocument
        //                            //    {
        //                            //        {"hotelfacility0",string.Empty},
        //                            //        {"hotelfacility1",string.Empty}
        //                            //    }
        //                            //},
        //                            {"HotelAmenity", new BsonDocument
        //                                {
        //                                    {"Restaurant",1},
        //                                    {"conference",0}
        //                                }
        //                            },
        //                            {"HotelDistance",new BsonDocument
        //                                {
        //                                    {"DistancefromAirport",12},
        //                                    {"DistancefromStation",5}
        //                                }
        //                            },
        //                            {"type1","Standard"},
        //                            {"facility1", new BsonDocument
        //                                {
        //                                    {"facility0","Ac Room"},
        //                                    {"facility1","Attached Bath"}
        //                                }
        //                            },
        //                            {"type2","Premium Suite"},
        //                            {"facility2", new BsonDocument
        //                                {
        //                                    {"facility0","Ac Room"},
        //                                    {"facility1","Attached Bath"}
        //                                }
        //                            }

        //                        //}
        //                    //}
        //                };

        //                var AccoContact = (from c in context.Accommodation_Contact
        //                                   orderby c.Create_Date descending
        //                                   where c.Accommodation_Id == Acco.Accommodation_Id
        //                                   select c).FirstOrDefault();
        //                if (AccoContact != null)
        //                {
        //                    document.Add(new BsonElement("Address", new BsonDocument {{"address",(Acco.StreetName ?? string.Empty)},
        //                                    {"city", (Acco.city ?? string.Empty)},
        //                                    {"state",(Acco.State_Name ?? string.Empty)},
        //                                    {"country", (Acco.country ?? string.Empty)},
        //                                    {"pincode", (Acco.PostalCode ?? string.Empty)},
        //                                    {"location",string.Empty},
        //                                    { "phone", AccoContact.Telephone ?? string.Empty },
        //                                    { "fax", AccoContact.Fax ?? string.Empty } }));
        //                }
        //                else
        //                {
        //                    document.Add(new BsonElement("Address", new BsonDocument {{"address",(Acco.StreetName ?? string.Empty)},
        //                                    {"city", (Acco.city ?? string.Empty)},
        //                                    {"state",(Acco.State_Name ?? string.Empty)},
        //                                    {"country", (Acco.country ?? string.Empty)},
        //                                    {"pincode", (Acco.PostalCode ?? string.Empty)},
        //                                    {"location",string.Empty}
        //                                     }));
        //                }


        //                var AccoImages = from m in context.Accommodation_Media
        //                                 where m.Accommodation_Id == Acco.Accommodation_Id
        //                                 select m;
        //                var bHM = new BsonDocument(true);
        //                foreach (var media in AccoImages)
        //                {
        //                    bHM.Add("path", media.Media_URL);
        //                }
        //                document.Add("image", bHM);

        //                var AccoFacility = from f in context.Accommodation_Facility
        //                                   where f.Accommodation_Id == Acco.Accommodation_Id
        //                                   select f;
        //                var bHF = new BsonDocument(true);
        //                foreach (var facility in AccoFacility)
        //                {
        //                    bHF.Add("name", facility.FacilityType);
        //                }
        //                document.Add("HotelFacility", bHF);

        //                docs.Add(document);
        //                document = null;



        //                //    //Address
        //                //    if (objProducts.Address != null)
        //                //    {
        //                //        BsonArray ba = new BsonArray();

        //                //        ba.Add(objProducts.Address);

        //                //        var tx_details = (from t in Transformations
        //                //                          where t.TX_Column == "AddressLine"
        //                //                          select new
        //                //                          {
        //                //                              t.Keyword,
        //                //                              t.Value
        //                //                          }).ToList();

        //                //        if (tx_details.Count > 0)
        //                //        {
        //                //            foreach (var txval in tx_details)
        //                //            {
        //                //                if (Regex.IsMatch(objProducts.Address, txval.Keyword, RegexOptions.IgnoreCase))
        //                //                {
        //                //                    ba.Add(Regex.Replace(objProducts.Address, txval.Keyword, txval.Value, RegexOptions.IgnoreCase));
        //                //                }

        //                //            }
        //                //        }

        //                //        document.Add("AddressLine", ba);
        //                //        ba = null;
        //                //    }



        //                //    docs.Add(document);
        //                //    docs = null;

        //                //}



        //            }

        //            collection.InsertMany(docs);
        //            docs = null;
        //            collection = null;
        //            _database = null;
        //        }
        //    }
        //    catch (FaultException<DataContracts.ErrorNotifier> ex)
        //    {
        //        throw ex;
        //    }
        //}

        public void LoadHotelDefinitions()
        {
            using (TLGX_Entities context = new TLGX_Entities())
            {
                _database = MongoDBHandler.mDatabase();

                //_database.DropCollection("Accommodations");

                var collection = _database.GetCollection <HotelsHotel>("Accommodations");
                var AccoList   = from a in context.Accommodations
                                 where a.CompanyHotelID != null
                                 select a;

                List <HotelsHotel> docs = new List <HotelsHotel>();

                foreach (var Acco in AccoList)
                {
                    //if hotel id is null then don't insert else check for duplicates
                    if (Acco.CompanyHotelID == null)
                    {
                        continue;
                    }
                    else
                    {
                        //check if record is already exists
                        var searchResultCount = collection.Find(f => f.HotelId == Acco.CompanyHotelID.ToString()).Count();
                        if (searchResultCount > 0)
                        {
                            continue;
                        }
                    }

                    var AccoClassAttr = (from a in context.Accommodation_ClassificationAttributes
                                         where a.Accommodation_Id == Acco.Accommodation_Id
                                         select a).ToList();

                    var AccoDesc = (from a in context.Accommodation_Descriptions
                                    where a.Accommodation_Id == Acco.Accommodation_Id
                                    select a).ToList();

                    var AccoNearBy = (from a in context.Accommodation_NearbyPlaces
                                      where a.Accomodation_Id == Acco.Accommodation_Id
                                      select a).ToList();

                    var AccoContacts = (from a in context.Accommodation_Contact
                                        where a.Accommodation_Id == Acco.Accommodation_Id
                                        select a).ToList();

                    var AccoFacilities = (from a in context.Accommodation_Facility
                                          where a.Accommodation_Id == Acco.Accommodation_Id
                                          select a).ToList();

                    var AccoRoutes = (from a in context.Accommodation_RouteInfo
                                      where a.Accommodation_Id == Acco.Accommodation_Id
                                      select a).ToList();

                    var AccoMedia = (from a in context.Accommodation_Media
                                     where a.Accommodation_Id == Acco.Accommodation_Id
                                     select a).ToList();

                    //create new mongo object record
                    var newHotel = new HotelsHotel();
                    newHotel.SupplierHotelID = string.Empty;
                    newHotel.HotelId         = Acco.CompanyHotelID.ToString();
                    newHotel.name            = Acco.HotelName;

                    var star = new HotelsHotelStarRating();
                    star.Level          = Acco.HotelRating ?? string.Empty;
                    newHotel.StarRating = star;
                    star = null;

                    newHotel.credicards = (from a in AccoClassAttr where a.Accommodation_Id == Acco.Accommodation_Id && a.AttributeType == "Product" && a.IsActive == true && a.AttributeSubType == "Credit Cards" select a.AttributeValue).FirstOrDefault();
                    newHotel.credicards = newHotel.credicards ?? string.Empty;

                    newHotel.areatransportation = (from a in AccoClassAttr where a.Accommodation_Id == Acco.Accommodation_Id && a.AttributeType == "Product" && a.IsActive == true && a.AttributeSubType == "Area" select a.AttributeValue).FirstOrDefault();
                    newHotel.areatransportation = newHotel.areatransportation ?? string.Empty;

                    newHotel.restaurants = (from a in AccoDesc where a.Accommodation_Id == Acco.Accommodation_Id && a.DescriptionType == "Restaurant Description" && a.IsActive == true select a.Description).FirstOrDefault();
                    newHotel.restaurants = newHotel.restaurants ?? string.Empty;

                    newHotel.meetingfacility = (from a in AccoDesc where a.Accommodation_Id == Acco.Accommodation_Id && a.DescriptionType == "Meeting Facilities" && a.IsActive == true select a.Description).FirstOrDefault();
                    newHotel.meetingfacility = newHotel.meetingfacility ?? string.Empty;

                    newHotel.description = (from a in AccoDesc where a.Accommodation_Id == Acco.Accommodation_Id && a.DescriptionType == "Long" && a.IsActive == true select a.Description).FirstOrDefault();
                    newHotel.description = newHotel.description ?? string.Empty;

                    newHotel.highlight = string.Empty;
                    newHotel.overview  = string.Empty;

                    newHotel.theme = (from a in AccoClassAttr where a.Accommodation_Id == Acco.Accommodation_Id && a.AttributeType == "Product" && a.IsActive == true && a.AttributeSubType == "Theme" select a.AttributeValue).FirstOrDefault();
                    newHotel.theme = newHotel.theme ?? string.Empty;

                    var landmark = (from a in AccoNearBy where a.Accomodation_Id == Acco.Accommodation_Id select a).FirstOrDefault();
                    if (landmark != null)
                    {
                        newHotel.Landmark            = landmark.PlaceName ?? string.Empty;
                        newHotel.LandmarkCategory    = landmark.PlaceCategory ?? string.Empty;
                        newHotel.LandmarkDescription = landmark.Description ?? string.Empty;
                    }
                    else
                    {
                        newHotel.Landmark            = string.Empty;
                        newHotel.LandmarkCategory    = string.Empty;
                        newHotel.LandmarkDescription = string.Empty;
                    }

                    newHotel.thumb = string.Empty;

                    newHotel.checkintime  = (Acco.CheckInTime ?? string.Empty);
                    newHotel.checkouttime = (Acco.CheckOutTime ?? string.Empty);
                    newHotel.rooms        = (Acco.TotalRooms ?? string.Empty);
                    newHotel.HotelChain   = (Acco.Chain ?? string.Empty);
                    newHotel.BrandName    = (Acco.Brand ?? string.Empty);
                    newHotel.recommends   = (Acco.CompanyRecommended ?? false).ToString();
                    newHotel.latitude     = (Acco.Latitude ?? string.Empty);
                    newHotel.longitude    = (Acco.Longitude ?? string.Empty);

                    var AccoContact = (from c in AccoContacts
                                       orderby c.Create_Date descending
                                       where c.Accommodation_Id == Acco.Accommodation_Id
                                       select c).FirstOrDefault();

                    var address = new HotelsHotelAddress();
                    address.address  = (Acco.StreetName ?? string.Empty);
                    address.city     = (Acco.city ?? string.Empty);
                    address.state    = (Acco.State_Name ?? string.Empty);
                    address.country  = (Acco.country ?? string.Empty);
                    address.pincode  = (Acco.PostalCode ?? string.Empty);
                    address.location = (from a in AccoClassAttr where a.Accommodation_Id == Acco.Accommodation_Id && a.AttributeType == "Product" && a.IsActive == true && a.AttributeSubType == "Location" select a.AttributeValue).FirstOrDefault();

                    if (AccoContact != null)
                    {
                        address.phone = (AccoContact.Telephone ?? string.Empty);
                        address.fax   = (AccoContact.Fax ?? string.Empty);

                        newHotel.email   = (AccoContact.Email ?? string.Empty);
                        newHotel.website = (AccoContact.WebSiteURL ?? string.Empty);
                    }
                    else
                    {
                        address.phone = string.Empty;
                        address.fax   = string.Empty;

                        newHotel.email   = string.Empty;
                        newHotel.website = string.Empty;
                    }
                    newHotel.Address = address;

                    AccoContact = null;
                    address     = null;

                    var AccoImages = (from m in AccoMedia
                                      where m.Accommodation_Id == Acco.Accommodation_Id
                                      select new HotelsHotelImage
                    {
                        path = m.Media_URL
                    }).ToArray();

                    newHotel.image = AccoImages;
                    AccoImages     = null;

                    var AccoFacility = (from f in AccoFacilities
                                        where f.Accommodation_Id == Acco.Accommodation_Id
                                        select new HotelsHotelFacility
                    {
                        name = f.FacilityType
                    }).ToArray();
                    newHotel.HotelFacility = AccoFacility;
                    AccoFacility           = null;

                    var amenity = new HotelsHotelHotelAmenity();
                    amenity.Air_Conditioning = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "General" && a.FacilityType == "Air conditioning" select a).Count() == 0 ? false : true;
                    amenity.banquet          = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Food and drink" && a.FacilityType == "Banquet facilities" select a).Count() == 0 ? false : true;
                    amenity.Bar             = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Food and drink" && a.FacilityType == "Lounges/bars" select a).Count() == 0 ? false : true;
                    amenity.Business_Centre = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Working Away" && a.FacilityType == "Business center" select a).Count() == 0 ? false : true;
                    amenity.Coffee_Shop     = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Food and drink" && a.FacilityType == "Coffee shop" select a).Count() == 0 ? false : true;
                    amenity.conference      = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Working Away" && a.FacilityType == "Conference facilities" select a).Count() == 0 ? false : true;
                    amenity.fitness         = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Things to do" && a.FacilityType == "Exercise gym" select a).Count() == 0 ? false : true;
                    amenity.forex           = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Services" && a.FacilityType == "Currency exchange" select a).Count() == 0 ? false : true;
                    amenity.games           = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Things to do" && a.FacilityType == "Game room" select a).Count() == 0 ? false : true;
                    amenity.Golf            = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Things to do" && a.FacilityType == "Golf" select a).Count() == 0 ? false : true;
                    amenity.Health_Club     = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Relaxation and Rejuvenation" && a.FacilityType == "Health club" select a).Count() == 0 ? false : true;
                    amenity.Internet_Access = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Internet" && a.FacilityType == "High speed internet access" select a).Count() == 0 ? false : true;
                    amenity.Parking         = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "General" && a.FacilityType == "On-Site parking" select a).Count() == 0 ? false : true;
                    amenity.Pets            = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "General" && a.FacilityType == "Pets allowed" select a).Count() == 0 ? false : true;
                    amenity.Restaurant      = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Food and drink" && a.FacilityType == "Restaurant" select a).Count() == 0 ? false : true;
                    amenity.Room_Service    = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Food and drink" && a.FacilityType == "Room service" select a).Count() == 0 ? false : true;
                    amenity.shopping        = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "General" && a.FacilityType == "Shops and commercial services" select a).Count() == 0 ? false : true;
                    amenity.Swimming_Pool   = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Things to do" && a.FacilityType == "Pool" select a).Count() == 0 ? false : true;
                    amenity.Tennis_Court    = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Things to do" && a.FacilityType == "Tennis court" select a).Count() == 0 ? false : true;
                    amenity.travel          = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "General" && a.FacilityType == "Travel Agency" select a).Count() == 0 ? false : true;
                    amenity.Wheel_Chair     = (from a in AccoFacilities where a.Accommodation_Id == Acco.Accommodation_Id && a.IsActive == true && a.FacilityCategory == "Accessibility" && a.FacilityType == "Wheelchair access" select a).Count() == 0 ? false : true;
                    newHotel.HotelAmenity   = amenity;
                    amenity = null;

                    var distance = new HotelsHotelHotelDistance();
                    distance.DistancefromAirport = (from a in AccoRoutes where a.Accommodation_Id == Acco.Accommodation_Id && a.FromPlace == "Airport" && a.IsActive == true select a.DistanceFromProperty + " " + a.DistanceUnit).FirstOrDefault();
                    distance.DistancefromAirport = distance.DistancefromAirport ?? string.Empty;

                    distance.DistancefromBus = (from a in AccoRoutes where a.Accommodation_Id == Acco.Accommodation_Id && a.FromPlace == "Bus Station" && a.IsActive == true select a.DistanceFromProperty + " " + a.DistanceUnit).FirstOrDefault();
                    distance.DistancefromBus = distance.DistancefromBus ?? string.Empty;

                    distance.DistancefromCityCenter = (from a in AccoRoutes where a.Accommodation_Id == Acco.Accommodation_Id && a.FromPlace == "City Centre" && a.IsActive == true select a.DistanceFromProperty + " " + a.DistanceUnit).FirstOrDefault();
                    distance.DistancefromCityCenter = distance.DistancefromCityCenter ?? string.Empty;

                    distance.DistancefromStation = (from a in AccoRoutes where a.Accommodation_Id == Acco.Accommodation_Id && a.FromPlace == "Train Station" && a.IsActive == true select a.DistanceFromProperty + " " + a.DistanceUnit).FirstOrDefault();
                    distance.DistancefromStation = distance.DistancefromStation ?? string.Empty;

                    newHotel.HotelDistance = distance;
                    distance = null;

                    collection.InsertOneAsync(newHotel);

                    newHotel = null;

                    AccoClassAttr  = null;
                    AccoDesc       = null;
                    AccoNearBy     = null;
                    AccoContacts   = null;
                    AccoFacilities = null;
                    AccoRoutes     = null;
                    AccoMedia      = null;
                }

                docs       = null;
                collection = null;
                _database  = null;
            }
        }