private bool SaveNewEdition(Edition newEdition, DWStaging.Edition stagingEdition) { try { _unitOfWork.EditionRepository.Insert(newEdition); _unitOfWork.Save(); } catch (Exception exc) { var extraInfo = "StagingEditionEventBEID=" + stagingEdition.EventBEID; var log = CreateInternalLog(exc, extraInfo); ExternalLogHelper.Log(log, LoggingEventType.Error); return(false); } return(true); }
private void UpdateSingleCedEventFromKentico(Edition cedEdition, Clnd_KenticoEvents kenticoEdition, ref bool logoFound) { try { var cedEditionTranslations = _unitOfWork.EditionTranslationRepository.GetManyQueryable(x => x.EditionId == cedEdition.EditionId && x.LanguageCode == LanguageHelper.GetBaseLanguageCultureName()).ToList(); if (cedEditionTranslations.Any() && cedEditionTranslations.Count == 1) { var cedEditionTranslation = cedEditionTranslations.First(); cedEdition.InternationalName = kenticoEdition.EventName; cedEdition.ManagingOfficeName = kenticoEdition.Organiser; cedEdition.ManagingOfficeEmail = kenticoEdition.EmailAddress; cedEdition.ManagingOfficePhone = "+" + kenticoEdition.InternationalDial + " " + kenticoEdition.Telephone; cedEdition.ManagingOfficeWebsite = kenticoEdition.Website; cedEdition.EventWebSite = kenticoEdition.Website; cedEdition.AllDayEvent = Convert.ToBoolean(kenticoEdition.EventAllDay); cedEdition.DisplayOnIteI = Convert.ToBoolean(kenticoEdition.ITEI); cedEdition.DisplayOnIteGermany = Convert.ToBoolean(kenticoEdition.GiMA); cedEdition.DisplayOnIteAsia = Convert.ToBoolean(kenticoEdition.ASIA); cedEdition.DisplayOnIteTurkey = Convert.ToBoolean(kenticoEdition.Turkey); cedEdition.DisplayOnTradeLink = Convert.ToBoolean(kenticoEdition.TradeLink); cedEdition.DisplayOnIteModa = Convert.ToBoolean(kenticoEdition.MODA); cedEdition.UpdateTimeByAutoIntegration = DateTime.Now; cedEditionTranslation.Summary = kenticoEdition.EventSummary.ReplaceBrWithNewLine().StripHtml(); cedEditionTranslation.Description = kenticoEdition.EventDetails.ReplaceBrWithNewLine().StripHtml(); cedEditionTranslation.BookStandUrl = kenticoEdition.BookTicketLink; // Get venue coordinates if (kenticoEdition.VenueLocation.HasValue) { var venue = _unitOfWork.EditionRepository.Context.Clnd_customtable_Venue.SingleOrDefault(x => x.ItemID == kenticoEdition.VenueLocation); if (venue != null) { cedEdition.VenueCoordinates = venue.VenueLocation.Replace(",", ", "); cedEditionTranslation.VenueName = venue.VenueName; } } if (logoFound) { cedEditionTranslation.WebLogoFileName = UploadEventImage(cedEditionTranslation, kenticoEdition.EventImage, true); } logoFound = cedEditionTranslation.WebLogoFileName != null; cedEditionTranslation.PeopleImageFileName = UploadEventImage(cedEditionTranslation, kenticoEdition.EventBackGroundImage, false); cedEditionTranslation.UpdateTimeByAutoIntegration = DateTime.Now; _unitOfWork.Save(); } } catch (Exception exc) { var extraInfo = "Error on UpdateSingleCedEventFromKentico() | EditionId=" + cedEdition + " | KenticoEventBEID=" + kenticoEdition.EventBEID; var log = CreateInternalLog(exc, extraInfo); ExternalLogHelper.Log(log, LoggingEventType.Error); } }
private bool UpdateBeIdOfKenticoEvents() { var kenticoEditions = _unitOfWork.EventRepository.Context.Clnd_KenticoEvents.Where(x => x.EventBEID == null || x.EventBEID == 0).ToList(); //var kenticoEditions = _unitOfWork.EventRepository.Context.Clnd_KenticoEvents.ToList(); // Örn: Worldfood Ukraine foreach (var kenticoEdition in kenticoEditions) { var edition = kenticoEdition; //var similarEditions = _unitOfWork.EditionRepository.GetManyQueryable(x => // x.StartDate == edition.EventDate.GetValueOrDefault().Date && x.EndDate == edition.EventEndDate.GetValueOrDefault().Date // // && x.Event.Country.ToLower() == edition.Country.ToLower() // && x.Event.City.ToLower() == edition.City.ToLower()) // .ToList(); var similarEditions = _unitOfWork.EditionRepository.GetManyQueryable(x => x.StartDate == edition.EventDate.GetValueOrDefault().Date&& x.EndDate == edition.EventEndDate.GetValueOrDefault().Date // && x.Event.Country.ToLower() == edition.Country.ToLower() && x.City.ToLower() == edition.City.ToLower()) .ToList(); // Aynı tarih ve aynı şehirde 2 adet edition bulundu: // Worldfood Ukraine, WorldFood Tech & WorldFood Pack if (similarEditions.Any()) { if (similarEditions.Count == 1) { var editionFound = similarEditions.First(); kenticoEdition.EventBEID = Convert.ToInt32(editionFound.AxEventId); kenticoEdition.UpdatedOn = DateTime.Now; kenticoEdition.Desc = "Tam isabet"; editionFound.MatchedKenticoEventId = kenticoEdition.KenticoEventID; editionFound.MatchedOn = DateTime.Now; _unitOfWork.Save(); } else { var kenticoEventName = kenticoEdition.EventName; //kenticoEventName = SplitOnCapitals(kenticoEdition.EventName); kenticoEventName = kenticoEventName.RemoveNonAlphaNumerics(); var wordsOfKenticoEditionName = kenticoEventName.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); Edition mostSimilarEdition = similarEditions.First(); var mostSimilarity = 0; foreach (var similarEdition in similarEditions) { // Eğer bu Edition, daha önce başka bir KenticoEdition ile eşleşmişse dikkate alma (continue döndür) if (similarEdition.MatchedKenticoEventId > 0) { continue; } var similarEventName = similarEdition.Event.MasterName.RemoveNonAlphaNumerics(); var wordsOfEventMasterName = similarEventName.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var matchedWordCount = 0; foreach (var word in wordsOfEventMasterName) { foreach (var wordKentico in wordsOfKenticoEditionName) { if (word.ToLower() == wordKentico.ToLower()) { matchedWordCount++; } } } if (matchedWordCount > mostSimilarity) { mostSimilarEdition = similarEdition; mostSimilarity = matchedWordCount; } } if (mostSimilarity > 0) { // We found the most similar edition, so we'll update it. kenticoEdition.EventBEID = Convert.ToInt32(mostSimilarEdition.AxEventId); kenticoEdition.UpdatedOn = DateTime.Now; kenticoEdition.Desc = "Ad benzerliği ile bulundu (tarihler tam eşleşti)"; mostSimilarEdition.MatchedKenticoEventId = kenticoEdition.KenticoEventID; mostSimilarEdition.MatchedOn = DateTime.Now; _unitOfWork.Save(); } else { kenticoEdition.UpdatedOn = DateTime.Now; kenticoEdition.Desc = "Tarih ve lokasyonu eşleşen kayıtlar içinde adı eşleşen kayıt bulunamadı"; _unitOfWork.Save(); } // var editionTranslations = _unitOfWork.EditionTranslationRepository // .GetMany(x => // x.EditionName.ToLower() == kenticoEdition.EventName.ToLower() // && x.LanguageCode == LanguageHelper.GetBaseLanguageCultureName()).ToList(); // if (editionTranslations.Any()) // { // if (editionTranslations.Count == 1) // { // kenticoEdition.EventBEID = Convert.ToInt32(editionTranslations.First().Edition.AxEventId); // _unitOfWork.Save(); // } // } // foreach (var similarEdition in similarEditions) // { // var similarEditionName = similarEdition.Event.MasterName; // if (kenticoEdition.EventName.ToLower() == similarEditionName.ToLower()) // { // var editionFound = similarEdition; // kenticoEdition.EventBEID = Convert.ToInt32(editionFound.AxEventId); // _unitOfWork.Save(); // } // // TODO: Levenshtein Distance Algorithm // } } } else { kenticoEdition.UpdatedOn = DateTime.Now; kenticoEdition.Desc = "Tarih ve lokasyonu eşleşen hiçbir kayıt bulunamadı"; _unitOfWork.Save(); } } return(true); }