/// <summary> /// This should only run after the Post exists in the data store. /// </summary> /// <returns>The newly created ContentItemID from the data store.</returns> /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks> internal ContentItem CreateContentItem(AlbumInfo objPost, int tabId) { var typeController = new ContentTypeController(); var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t); int contentTypeID; if (colContentTypes.Count() > 0) { var contentType = colContentTypes.Single(); contentTypeID = contentType == null ? CreateContentType() : contentType.ContentTypeId; } else { contentTypeID = CreateContentType(); } var objContent = new ContentItem { Content = objPost.ShortContent, ContentTypeId = contentTypeID, Indexed = false, ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objPost.AlbumID, ModuleID = objPost.ModuleID, TabID = tabId }; objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent); // Add Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objPost, objContent); return objContent; }
/// <summary> /// Informs the core journal that the user has provided an answer. /// </summary> /// <param name="objPost"></param> /// <param name="questionTitle"></param> /// <param name="portalId"></param> /// <param name="journalUserId"></param> /// <param name="url"></param> internal void AddAnswerToJournal(AlbumInfo objPost, string questionTitle, int portalId, int journalUserId, string url) { var objectKey = Constants.ContentTypeName + "_" + Constants.JournalAnswerTypeName + "_" + string.Format("{0}:{1}", objPost.AlbumID, objPost.AlbumID); var ji = JournalController.Instance.GetJournalItemByKey(portalId, objectKey); if ((ji != null)) { JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey); } ji = new JournalItem { PortalId = portalId, ProfileId = journalUserId, UserId = journalUserId, ContentItemId = objPost.ContentItemId, Title = questionTitle, ItemData = new ItemData { Url = url }, Summary = "", //objPost.Body, Body = null, JournalTypeId = GetAnswerJournalTypeID(portalId), ObjectKey = objectKey, SecuritySet = "E," }; JournalController.Instance.SaveJournalItem(ji, objPost.TabID); }
public ActionResult Cart(string AddProduct) { List <AlbumInfo> ShoppingBag; // reference to null if (Session["Cart"] == null) // the cart is empty! { Session.Add("Cart", new List <AlbumInfo>()); ShoppingBag = new List <AlbumInfo>(); } else// user has items in the cart, so go and retrive it! { ShoppingBag = (List <AlbumInfo>)Session["Cart"]; } /////////////////////////// vmrdataEntities DB = new vmrdataEntities(); AlbumInfo Option = DB.AlbumInfoes.Find(AddProduct); ShoppingBag.Add(Option); Session["Cart"] = ShoppingBag;// save changes you made to your cart! ViewBag.PList = ShoppingBag; // double sum = 0; for (int i = 0; i < ShoppingBag.Count; i++) { sum = sum + ShoppingBag[i].Price; } ViewBag.Sum = sum; return(View("Checkout")); }
public static AlbumInfo[] GetSpaceAlbumsInfo(DataTable dt) { if (dt == null || dt.Rows.Count == 0) { return(null); } AlbumInfo[] albumsinfoarray = new AlbumInfo[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { albumsinfoarray[i] = new AlbumInfo(); albumsinfoarray[i].Albumid = TypeConverter.ObjectToInt(dt.Rows[i]["albumid"]); albumsinfoarray[i].Userid = TypeConverter.ObjectToInt(dt.Rows[i]["userid"]); albumsinfoarray[i].Title = dt.Rows[i]["title"].ToString(); albumsinfoarray[i].Description = dt.Rows[i]["description"].ToString(); albumsinfoarray[i].Logo = dt.Rows[i]["logo"].ToString(); albumsinfoarray[i].Password = dt.Rows[i]["password"].ToString(); albumsinfoarray[i].Imgcount = TypeConverter.ObjectToInt(dt.Rows[i]["imgcount"]); albumsinfoarray[i].Views = TypeConverter.ObjectToInt(dt.Rows[i]["views"]); albumsinfoarray[i].Type = TypeConverter.ObjectToInt(dt.Rows[i]["type"]); albumsinfoarray[i].Createdatetime = dt.Rows[i]["createdatetime"].ToString(); } dt.Dispose(); return(albumsinfoarray); }
private Actor GetActorForAlbumInfo(AlbumInfo info) { Actor actor = null; if (info == null || info.ArtworkId == null) { return(null); } if (actor_cache.TryGetValue(info.ArtworkId, out actor)) { return(actor); } if (!CoverArtSpec.CoverExists(info.ArtworkId)) { return(null); } actor = new AlbumArtActor(info, ActorSize) { Parent = this }; actor_cache.Add(info.ArtworkId, actor); return(actor); }
public async Task <bool> TryExtractRelationshipsAsync(IResourceAccessor mediaItemAccessor, IDictionary <Guid, IList <MediaItemAspect> > aspects, IList <IDictionary <Guid, IList <MediaItemAspect> > > extractedLinkedAspects) { AlbumInfo albumInfo = new AlbumInfo(); if (!albumInfo.FromMetadata(aspects)) { return(false); } AudioMetadataExtractor.TryUpdateAlbum(mediaItemAccessor, albumInfo); if (AudioMetadataExtractor.IncludeArtistDetails && !AudioMetadataExtractor.SkipOnlineSearches) { await OnlineMatcherService.Instance.UpdateAlbumPersonsAsync(albumInfo, PersonAspect.OCCUPATION_ARTIST, _category).ConfigureAwait(false); } foreach (PersonInfo person in albumInfo.Artists) { IDictionary <Guid, IList <MediaItemAspect> > personAspects = new Dictionary <Guid, IList <MediaItemAspect> >(); if (person.SetMetadata(personAspects) && personAspects.ContainsKey(ExternalIdentifierAspect.ASPECT_ID)) { extractedLinkedAspects.Add(personAspects); } } return(extractedLinkedAspects.Count > 0); }
public List <AlbumInfo> GetAlbumInfoListByKeywordID(int publishmentSystemID, int keywordID) { var albumInfoList = new List <AlbumInfo>(); string SQL_WHERE = $"WHERE {AlbumAttribute.PublishmentSystemID} = {publishmentSystemID} AND {AlbumAttribute.IsDisabled} <> '{true}'"; if (keywordID > 0) { SQL_WHERE += $" AND {AlbumAttribute.KeywordID} = {keywordID}"; } var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null); using (var rdr = ExecuteReader(SQL_SELECT)) { while (rdr.Read()) { var albumInfo = new AlbumInfo(rdr); albumInfoList.Add(albumInfo); } rdr.Close(); } return(albumInfoList); }
public override bool UpdateFromOnlineMusicTrackAlbumPerson(AlbumInfo albumInfo, PersonInfo person, string language, bool cacheOnly) { try { TrackArtist artistDetail = null; if (!string.IsNullOrEmpty(person.MusicBrainzId)) { artistDetail = _musicBrainzHandler.GetArtist(person.MusicBrainzId, cacheOnly); } if (artistDetail == null) { return(false); } person.Name = artistDetail.Name; person.DateOfBirth = artistDetail.LifeSpan != null ? artistDetail.LifeSpan.Begin : null; person.DateOfDeath = artistDetail.LifeSpan != null ? artistDetail.LifeSpan.End : null; person.IsGroup = string.IsNullOrEmpty(artistDetail.Type) ? false : artistDetail.Type.IndexOf("Group", StringComparison.InvariantCultureIgnoreCase) >= 0; person.Occupation = PersonAspect.OCCUPATION_ARTIST; return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug("MusicBrainzWrapper: Exception while processing person {0}", ex, person.ToString()); return(false); } }
public bool UpdateAlbum(AlbumInfo albumInfo, bool updateTrackList, bool importOnly) { bool success = false; foreach (IMusicMatcher matcher in MUSIC_MATCHERS.OrderByDescending(m => m.Primary).Where(m => m.Enabled)) { success |= matcher.UpdateAlbum(albumInfo, updateTrackList, matcher.Primary ? false : importOnly); } if (updateTrackList) { if (albumInfo.Tracks.Count == 0) { return(false); } for (int i = 0; i < albumInfo.Tracks.Count; i++) { //TrackInfo trackInfo = albumInfo.Tracks[i]; //foreach (IMusicMatcher matcher in MUSIC_MATCHERS.OrderByDescending(m => m.Primary).Where(m => m.Enabled)) //{ // matcher.FindAndUpdateTrack(trackInfo, importOnly); //} } } return(success); }
/// <summary> /// Informs the core journal that the user has provided an answer. /// </summary> /// <param name="objPost"></param> /// <param name="questionTitle"></param> /// <param name="portalId"></param> /// <param name="journalUserId"></param> /// <param name="url"></param> internal void AddAnswerToJournal(AlbumInfo objPost, string questionTitle, int portalId, int journalUserId, string url) { var objectKey = Constants.ContentTypeName + "_" + Constants.JournalAnswerTypeName + "_" + string.Format("{0}:{1}", objPost.ParentId, objPost.PostId); var ji = JournalController.Instance.GetJournalItemByKey(portalId, objectKey); if ((ji != null)) { JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey); } ji = new JournalItem { PortalId = portalId, ProfileId = journalUserId, UserId = journalUserId, ContentItemId = objPost.ContentItemId, Title = questionTitle, ItemData = new ItemData { Url = url }, Summary = "", //objPost.Body, Body = null, JournalTypeId = GetAnswerJournalTypeID(portalId), ObjectKey = objectKey, SecuritySet = "E," }; JournalController.Instance.SaveJournalItem(ji, objPost.TabID); }
public override bool UpdateFromOnlineMusicTrackAlbumCompany(AlbumInfo album, CompanyInfo company, string language, bool cacheOnly) { try { TrackLabel labelDetail = null; if (!string.IsNullOrEmpty(company.MusicBrainzId)) { labelDetail = _musicBrainzHandler.GetLabel(company.MusicBrainzId, cacheOnly); } if (labelDetail == null) { return(false); } if (labelDetail.Label == null) { return(false); } company.MusicBrainzId = labelDetail.Label.Id; company.Name = labelDetail.Label.Name; company.Type = CompanyAspect.COMPANY_MUSIC_LABEL; return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug("MusicBrainzWrapper: Exception while processing company {0}", ex, company.ToString()); return(false); } }
private void ChangeAlbum() { int targetAlbumId = TypeConverter.StrToInt(DNTRequest.GetFormString("alibumList")); int sourceAlbumId = albumid; string photoIdList = DNTRequest.GetFormString("photoid"); if (!Utils.IsNumericList(photoIdList)) { return; } if (DTOProvider.GetAlbumInfo(targetAlbumId).Userid != userid) { AddErrLine("您所选的目标相册不存在"); return; } DbProvider.GetInstance().ChangeAlbum(targetAlbumId, photoIdList, userid); AlbumInfo _sourceAlbum = DTOProvider.GetAlbumInfo(sourceAlbumId); _sourceAlbum.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(sourceAlbumId); DbProvider.GetInstance().SaveSpaceAlbum(_sourceAlbum); AlbumInfo _targetAlbum = DTOProvider.GetAlbumInfo(targetAlbumId); _targetAlbum.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(targetAlbumId); DbProvider.GetInstance().SaveSpaceAlbum(_targetAlbum); //生成json数据 Albums.CreateAlbumJsonData(albumid); SetUrl("usercpspacemanagephoto.aspx?albumid=" + albumid); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("照片转移完毕"); }
public async Task <bool> UpdateAlbumAsync(AlbumInfo albumInfo, bool updateTrackList, string category) { bool success = false; foreach (IAudioMatcher matcher in AUDIO_MATCHERS.Where(m => category == null || m.Key == category).SelectMany(m => m.Value).Where(m => m.Enabled)) { success |= await matcher.UpdateAlbumAsync(albumInfo, updateTrackList).ConfigureAwait(false); } if (updateTrackList) { if (albumInfo.Tracks.Count == 0) { return(false); } for (int i = 0; i < albumInfo.Tracks.Count; i++) { //TrackInfo trackInfo = albumInfo.Tracks[i]; //foreach (IMusicMatcher matcher in _audioMatchers.Where(m => category == null || m.Key == category).SelectMany(m => m.Value).Where(m => m.Enabled)) //{ // matcher.FindAndUpdateTrack(trackInfo, importOnly); //} } } return(success); }
public AttachedImage(PlatformClient client, AttachedImageData data) : base(client) { _data = data; Image = new ImageInfo(client, data.Image); Album = new AlbumInfo(client, data.Album); }
public void CacheExtractedItem(Guid extractedItemId, IDictionary <Guid, IList <MediaItemAspect> > extractedAspects) { AlbumInfo album = new AlbumInfo(); album.FromMetadata(extractedAspects); AddToCache(extractedItemId, album, false); }
protected override void AfterPageClose() { EventManager.RemoveHandler(EventType.UncleSamsParty, DropTeam); _album = null; albumNameInput.SetTextWithoutNotify(string.Empty); }
/// <summary> /// This should only run after the Post exists in the data store. /// </summary> /// <returns>The newly created ContentItemID from the data store.</returns> /// <remarks>This is for the first question in the thread. Not for replies or items with ParentID > 0.</remarks> internal ContentItem CreateContentItem(AlbumInfo objPost, int tabId) { var typeController = new ContentTypeController(); var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == Constants.ContentTypeName select t); int contentTypeID; if (colContentTypes.Count() > 0) { var contentType = colContentTypes.Single(); contentTypeID = contentType == null?CreateContentType() : contentType.ContentTypeId; } else { contentTypeID = CreateContentType(); } var objContent = new ContentItem { Content = objPost.ShortContent, ContentTypeId = contentTypeID, Indexed = false, ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objPost.AlbumID, ModuleID = objPost.ModuleID, TabID = tabId }; objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent); // Add Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objPost, objContent); return(objContent); }
/// <summary> /// データベースからアルバム情報をロードする。 /// </summary> public void Load() { if (this.Albums.Count > 0) { // アルバムの読み込みは一度のみ。 throw new InvalidOperationException(); } var dbContext = this._database.Context; var albums = dbContext.Albums.ToArray(); var artworksByAlbumId = dbContext.AlbumArtworks.ToDictionary(aw => aw.AlbumId); var registeredAlbums = new List <AlbumInfo>(albums.Length); foreach (var album in albums) { var artwork = artworksByAlbumId.TryGetValue(album.Id, out var aw) ? aw : default; var albumInfo = new AlbumInfo(album, artwork); this._albumIdMap.Add(albumInfo.Id, albumInfo); this._albumKeyMap.Add(albumInfo.Key, albumInfo); registeredAlbums.Add(albumInfo); } this.Albums.AddRange(registeredAlbums); if (this.Albums.Count > 0) { this._albumLatestIdx = this.Albums.Max(a => a.Id); } }
/// <summary> /// トラック情報からアルバム情報を取得する。アルバム情報が存在しない場合はトラック情報から抽出して登録する。 /// </summary> /// <param name="track">トラック情報</param> /// <returns>アルバム情報</returns> public AlbumInfo GetOrAddAlbum(Track track) { var albumKey = track.GetAlbumKey(); if (this._albumKeyMap.TryGetValue(albumKey, out var albumInfo)) { return(albumInfo); } byte[] artwork = track.GetArtworkData(); string artworkId; if (artwork?.Length > 0) { artworkId = Guid.NewGuid().ToString("D"); } else { artworkId = null; artwork = null; } albumInfo = new AlbumInfo(this.GenerateId(), albumKey, track, artworkId); this.Add(albumInfo, artwork); return(albumInfo); }
/// <summary> /// アルバム情報を登録する。 /// </summary> /// <param name="albumInfo">アルバム情報</param> /// <param name="artworkData">アートワーク</param> public void Add(AlbumInfo albumInfo, byte[] artworkData) { // データベースに登録する byte[]? artwork = null; if (artworkData?.Length > 0) { artwork = ImageUtil.ShrinkImageData(artworkData, ImageUtil.AlbumArtworkMaxSize); } var dbContext = this._database.Context; dbContext.Albums.Insert(new AlbumDataModel { Id = albumInfo.Id, Key = albumInfo.Key, ArtworkId = albumInfo.ArtworkId, Name = albumInfo.Name, Artist = albumInfo.Artist, IsCompilation = albumInfo.IsCompilation, CreatedAt = albumInfo.RegisteredAt, UpdatedAt = albumInfo.UpdatedAt, }); if (artwork?.Length > 0) { this.Artwork.Add(albumInfo, artwork); } this.AddImpl(albumInfo); }
public int Insert(AlbumInfo albumInfo) { var albumID = 0; IDataParameter[] parms = null; var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(albumInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms); using (var conn = GetConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { ExecuteNonQuery(trans, SQL_INSERT, parms); albumID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, TABLE_NAME); trans.Commit(); } catch { trans.Rollback(); throw; } } } return(albumID); }
/// <summary> /// Informs the core journal that the user has voted for a post (positive or negative). /// </summary> /// <param name="objPost"></param> /// <param name="title"></param> /// <param name="voteId"></param> /// <param name="summary"></param> /// <param name="portalId"></param> /// <param name="journalUserId"></param> /// <param name="url"></param> /// <remarks>Do not send flagged posts to this method (they are technically 'votes'), keep those out of the journal.</remarks> internal void AddVoteToJournal(AlbumInfo objPost, int voteId, string title, string summary, int portalId, int journalUserId, string url) { var objectKey = Constants.ContentTypeName + "_" + Constants.JournalVoteTypeName + "_" + string.Format("{0}:{1}", objPost.ModuleID, voteId); var ji = JournalController.Instance.GetJournalItemByKey(portalId, objectKey); if ((ji != null)) { JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey); } ji = new JournalItem { PortalId = portalId, ProfileId = journalUserId, UserId = journalUserId, ContentItemId = objPost.ContentItemId, Title = title, ItemData = new ItemData { Url = url }, Summary = summary, Body = null, JournalTypeId = GetVoteJournalTypeID(portalId), ObjectKey = objectKey, SecuritySet = "E," }; JournalController.Instance.SaveJournalItem(ji, objPost.TabID); }
public AttachedAlbum(PlatformClient client, AttachedAlbumData data) : base(client) { _data = data; Album = new AlbumInfo(client, data.Album); Pictures = _data.Pictures.Select(dt => new AttachedImage(client, dt)).ToArray(); }
public ActionResult DeletePhoto(string PhotoId = "", string AlbumId = "") { try { int _photoId; int _albumId; PhotoInfo _photoInfo = null; AlbumInfo _albumInfo = null; if (!int.TryParse(PhotoId, out _photoId) || !int.TryParse(AlbumId, out _albumId)) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Something went wrong, please try again later."); return(RedirectToAction("Manage", "Gallery")); } using (AlbumRepository Repo = new AlbumRepository()) { _albumInfo = Repo.GetAlbumById(_albumId); } if (_albumInfo == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Album does not exist."); return(RedirectToAction("Manage", "Gallery")); } using (PhotoRepository Repo = new PhotoRepository()) { _photoInfo = Repo.GetPhotoById(_photoId); if (_photoInfo == null) { TempData["Msg"] = AlertMessageProvider.FailureMessage("Photo does not exist."); return(RedirectToAction("Manage", "Gallery")); } string fullPath = Request.MapPath(_photoInfo.Path); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } Repo.DeletePhoto(_photoId); TempData["Msg"] = AlertMessageProvider.SuccessMessage("Photos deleted successfully."); return(RedirectToAction("UploadPhotos", "Gallery", new { id = AlbumId })); } } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Gallery", "DeletePhoto"))); } }
private void setupNewAlbum() { AlbumInfo ai = new AlbumInfo(m_album_type, null); ai.ClickEventHandler += NewAlbum; ai.AlbumName = "新建专辑"; m_albums.Add(ai); }
private void SaveAlbum(object sender, EditAlbumEventArgs <AlbumInfo, bool, string> e) { //Store Model Info to Data base var albumInfo = new AlbumInfo(); albumInfo.Title = e.Album.Title; Controller.AddAlbum(albumInfo); }
/// <summary> /// Конвертирует альбом в свойство карусели /// </summary> private CarouselProps ConvertAlbumToCarouselProps(AlbumInfo albumInfo) { return(new CarouselProps { Text = albumInfo.Name, Value = albumInfo }); }
public ActionResult DeleteConfirmed(int id) { AlbumInfo albuminfo = _db.AlbumInfos.Find(id); _db.AlbumInfos.Remove(albuminfo); _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IEnumerable <AlbumInfo> > FindMatchingAlbumsAsync(AlbumInfo albumInfo) { var tasks = MUSIC_MATCHERS.Where(m => m.Enabled) .Select(m => m.FindMatchingAlbumsAsync(albumInfo)).ToList(); //Merge results return(await MergeResults(tasks).ConfigureAwait(false)); }
public AlbumInfo GetAlbumInfo2(int id) { RestCommand command = new RestCommand(); command.MethodName = "getAlbumInfo"; command.AddParameter("id", id); return(AlbumInfo.Create(Client.GetResponseXDocument(command).RealRoot())); }
/// <summary> /// Показывает результат /// </summary> public void Show(AlbumInfo album) { _albumInfo = album; albumAnalyzer.Analyze(album); DisplayResult(album); Open(); }
public override bool UpdateFromOnlineMusicTrackAlbum(AlbumInfo album, string language, bool cacheOnly) { if (!string.IsNullOrEmpty(album.MusicBrainzGroupId)) { return(true); } return(false); }
public override bool UpdateFromOnlineMusicTrackAlbumPerson(AlbumInfo albumInfo, PersonInfo person, string language, bool cacheOnly) { if (!string.IsNullOrEmpty(person.MusicBrainzId)) { return(true); } return(false); }
public override bool UpdateFromOnlineMusicTrackAlbumCompany(AlbumInfo albumInfo, CompanyInfo company, string language, bool cacheOnly) { if (!string.IsNullOrEmpty(company.MusicBrainzId)) { return(true); } return(false); }
/// <summary> /// This should run only after the post has been added/updated in data store and the ContentItem exists. /// </summary> /// <param name="objPost">The content item we are associating categories with. In this module, it will always be a question (first post).</param> /// <param name="objContent"></param> internal void ManageQuestionTerms(AlbumInfo objAlbum, ContentItem objContent) { RemoveQuestionTerms(objContent); var terms = Util.GetContentController().GetContentItem(objAlbum.AlbumID).Terms; foreach (var term in terms) { Util.GetTermController().AddTermToContent(term, objContent); } }
public AlbumInfo GetAlbumInfo(Album album, Session session, Context context) { var albumInfo = new AlbumInfo(); var directoryName = album.SourceDirectory.Parent.Name + @"\" + album.SourceDirectory.Name; var formats = new[] { new Regex(@"^.*\\(?<artist>.*)-(?<album>.*)-.*-(?<year>\d{4})$"), new Regex(@"^.*\\(?<artist>.*)-( )*(?<album>.*)( )*\(?(?<year>\d{4})\)?$"), new Regex(@"^.*\\(?<artist>.*)-( )*(?<year>\d{4})( )*-(?<album>.*)$"), new Regex(@"^(?<artist>.*)\\(?<year>\d{4}) - (?<album>.*)$"), new Regex(@"^(?<artist>.*)\\(?<album>.*)$") }; foreach (var format in formats) { var match = format.Match(directoryName); if (match.Success) { albumInfo.ArtistName = StringHelper.Normalize(match.Groups["artist"].Value); albumInfo.Name = StringHelper.Normalize(match.Groups["album"].Value); albumInfo.ReleaseYear = StringHelper.Trim(match.Groups["year"].Value); break; } } foreach (var disc in album.Discs) { albumInfo.DiscNames[disc] = null; var discTrackNames = new Dictionary<Track, string>(); foreach (var track in disc.Tracks) discTrackNames[track] = Path.GetFileNameWithoutExtension(track.SourceFile.Name).Replace("_", " "); TrimLeft(discTrackNames); TrimRight(discTrackNames); foreach (var pair in new Dictionary<Track, string>(albumInfo.TrackNames)) discTrackNames[pair.Key] = StringHelper.MakeProperCase(StringHelper.Trim(pair.Value)); foreach (var pair in discTrackNames) albumInfo.TrackNames[pair.Key] = pair.Value; } var imageFiles = album.SourceDirectory.EnumerateFilesEx(@"\.jpg|\.png|\.gif").ToArray(); var coverImageFile = SelectCoverImage(imageFiles, albumInfo); if (coverImageFile != null) albumInfo.Cover = Picture.Load(coverImageFile.FullName); return albumInfo; }
/// <summary> /// This should run only after the post has been added/updated in data store and the ContentItem exists. /// </summary> /// <param name="objPost">The content item we are associating categories with. In this module, it will always be a question (first post).</param> /// <param name="objContent"></param> public void ManageQuestionTerms(AlbumInfo objAlbum, ContentItem objContent) { RemoveQuestionTerms(objContent); if (Util.GetContentController().GetContentItem(objAlbum.TabID).Terms != null) { var terms = Util.GetContentController().GetContentItem(objAlbum.TabID).Terms; foreach (var term in terms) { Util.GetTermController().AddTermToContent(term, objContent); } } }
/// <summary> /// Sets a single sitemap item. /// </summary> /// <param name="objQuestion"></param> /// <param name="ps"></param> /// <returns></returns> private static SitemapUrl GetQuestionUrl(AlbumInfo objQuestion, PortalSettings ps) { var pageUrl = new SitemapUrl { Url = Links.ViewQuestion(objQuestion.AlbumID, objQuestion.TabID, ps), Priority = (float) 0.5, LastModified = objQuestion.LastModifiedOnDate, ChangeFrequency = SitemapChangeFrequency.Daily }; return pageUrl; }
/// <summary> /// This method will create a new notification message in the data store. /// </summary> /// <param name="objEntity"></param> /// <param name="portalId"></param> /// <param name="tabId"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <remarks>The last part of this method is commented out but was setup to send to a role (based on a group). You can utilize this and/or also pass a list of users.</remarks> public void ItemNotification(AlbumInfo objEntity, int portalId, int tabId, string subject, string body) { var notificationType = NotificationsController.Instance.GetNotificationType(Constants.NotificationQaFlag); var notificationKey = string.Format("{0}:{1}:{2}", Constants.ContentTypeName, objEntity.TabID, tabId); var objNotification = new Notification { NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = objEntity.CreatedByUserID, Context = notificationKey }; //// invite the members of the group //var colRoles = new List<RoleInfo>(); //var objGroup = TestableRoleController.Instance.GetRole(portalId, r => r.RoleID == objEntity.GroupId); //colRoles.Add(objGroup); //NotificationsController.Instance.SendNotification(objNotification, portalId, colRoles, null); }
public AlbumInfo GetAlbumInfo(Album album, Session session, Context context) { var albumInfo = new AlbumInfo(); var artistNames = new List<string>(); var albumNames = new List<string>(); var releaseYears = new List<string>(); var covers = new List<Picture>(); foreach (var disc in album.Discs) { var discNames = new List<string>(); foreach (var track in disc.Tracks) { try { var tag = Id3Tagv2.Load(track.SourceFile.FullName); if (tag == null) continue; var tpe1Frame = tag.Frames[Tpe1Frame.FrameId].FirstOrDefault() as Tpe1Frame; var talbFrame = tag.Frames[TalbFrame.FrameId].FirstOrDefault() as TalbFrame; var tyerFrame = tag.Frames[TyerFrame.FrameId].FirstOrDefault() as TyerFrame; var tit2Frame = tag.Frames[Tit2Frame.FrameId].FirstOrDefault() as Tit2Frame; var tsstFrame = tag.Frames[TsstFrame.FrameId].FirstOrDefault() as TsstFrame; var apicFrame = tag.Frames[ApicFrame.FrameId].FirstOrDefault() as ApicFrame; if (tpe1Frame != null && !string.IsNullOrEmpty(tpe1Frame.Text)) artistNames.Add(tpe1Frame.Text); if (talbFrame != null && !string.IsNullOrEmpty(talbFrame.Text)) albumNames.Add(talbFrame.Text); if (tyerFrame != null && !string.IsNullOrEmpty(tyerFrame.Text)) releaseYears.Add(tyerFrame.Text); if (tit2Frame != null && !string.IsNullOrEmpty(tit2Frame.Text)) albumInfo.TrackNames[track] = tit2Frame.Text; if (tsstFrame != null && !string.IsNullOrEmpty(tsstFrame.Text)) discNames.Add(tsstFrame.Text); if (apicFrame != null && apicFrame.PictureType == PictureType.FrontCover) covers.Add(apicFrame.Picture); } catch (NotSupportedException) { } } albumInfo.DiscNames[disc] = discNames.MostCommon(); } albumInfo.ArtistName = artistNames.MostCommon(); albumInfo.Name = albumNames.MostCommon(); albumInfo.ReleaseYear = releaseYears.MostCommon(); albumInfo.Cover = covers.FirstOrDefault(); if (albumInfo.Name != null) { while (true) { var match = Regex.Match(albumInfo.Name, @"^(?<name>.*) \[(?<mark>.*)\]$"); if (!match.Success) break; albumInfo.Name = match.Groups["name"].Value; if (match.Groups["mark"].Value != "Damaged") albumInfo.Type = match.Groups["mark"].Value; } } return albumInfo; }
internal void AddAlbum(AlbumInfo albumInfo) { throw new NotImplementedException(); }
/// <summary> /// Handles any content item/taxonomy updates, then deals with cache clearing. /// </summary> /// <param name="objAlbum"></param> /// <param name="tabId"></param> private static void CompleteQuestionUpdate(AlbumInfo objAlbum, int tabId) { var cntTaxonomy = new Content(); cntTaxonomy.UpdateContentItem(objAlbum, tabId); DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.HomeQuestionsCacheKey + objAlbum.ModuleID); if (objAlbum.ParentId >= 1) return; DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.HomeTermsCacheKey + objAlbum.ModuleID); DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.ModuleTermsCacheKey + objAlbum.ModuleID); DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.ModuleQuestionsCacheKey + objAlbum.ModuleID); DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.ContentTermsCacheKey + objAlbum.ContentID); }
public static AlbumInfo ParseAlbumHTML(string albumHTML, string strAlbum, string strAlbumArtist) { // Image URL var imgURL = string.Empty; var imgMatch = AlbumImgURLRegEx.Match(albumHTML); if (imgMatch.Success) { imgURL = imgMatch.Groups["imageURL"].Value; imgURL = imgURL.Replace(@"\", @""); if (!string.IsNullOrEmpty(imgURL)) { imgURL = "http" + imgURL; } } // Rating var dRating = 0.0; var ratingMatch = AlbumRatingRegEx.Match(albumHTML); if (ratingMatch.Success) { double.TryParse(ratingMatch.Groups["rating"].Value.Trim(), out dRating); } // year var iYear = 0; var yearMatch = AlbumYearRegEx.Match(albumHTML); if (yearMatch.Success) { int.TryParse(yearMatch.Groups["year"].Value.Trim(), out iYear); } // review var reviewMatch = AlbumReviewRegEx.Match(albumHTML); var strReview = string.Empty; if (reviewMatch.Success) { strReview = HTMLRegEx.Replace(reviewMatch.Groups["review"].Value.Trim(), ""); } // build up track listing into one string var strTracks = string.Empty; var trackMatch = AlbumTracksRegEx.Match(albumHTML); if (trackMatch.Success) { var trackURLs = TrackURLRegEx.Matches(trackMatch.Groups["tracks"].Value.Trim()); var tracks = TrackRegEx.Matches(trackMatch.Groups["tracks"].Value.Trim()); foreach (Match track in tracks) { var strDuration = track.Groups["time"].Value; var iDuration = 0; var iPos = strDuration.IndexOf(":", StringComparison.Ordinal); if (iPos >= 0) { var strMin = strDuration.Substring(0, iPos); var strSec = strDuration.Substring(iPos + 1); int iMin = 0, iSec = 0; Int32.TryParse(strMin, out iMin); Int32.TryParse(strSec, out iSec); iDuration = (iMin * 60) + iSec; } strTracks += track.Groups["trackNo"].Value + "@" + track.Groups["title"].Value + "@" + iDuration.ToString(CultureInfo.InvariantCulture) + "@" + trackURLs[int.Parse(track.Groups["trackNo"].Value) - 1].Groups["url"].Value + "|"; } } // build up genres into one string var strGenres = string.Empty; var genreMatch = AlbumGenreRegEx.Match(albumHTML); if (genreMatch.Success) { var genres = HTMLListRegEx.Matches(genreMatch.Groups["genres"].Value.Trim()); foreach (var genre in genres) { var cleanGenre = HTMLRegEx.Replace(genre.ToString(), ""); strGenres += cleanGenre + ", "; } strGenres = strGenres.TrimEnd(new[] { ' ', ',' }); } // build up styles into one string var strStyles = string.Empty; var styleMatch = AlbumStylesRegEx.Match(albumHTML); if (styleMatch.Success) { var styles = HTMLListRegEx.Matches(styleMatch.Groups["styles"].Value.Trim()); foreach (var style in styles) { var cleanStyle = HTMLRegEx.Replace(style.ToString(), ""); strStyles += cleanStyle + ", "; } strStyles = strStyles.TrimEnd(new[] { ' ', ',' }); } // build up moods into one string var strMoods = string.Empty; var moodMatch = AlbumMoodsRegEx.Match(albumHTML); if (moodMatch.Success) { var moods = HTMLListRegEx.Matches(moodMatch.Groups["moods"].Value.Trim()); foreach (var mood in moods) { var cleanMood = HTMLRegEx.Replace(mood.ToString(), ""); strMoods += cleanMood + ", "; } strMoods = strMoods.TrimEnd(new[] { ' ', ',' }); } var album = new AlbumInfo { Album = strAlbum, Artist = strAlbumArtist, Genre = string.Empty, Tones = strMoods, Styles = strStyles, Review = strReview, Image = imgURL, Rating = (int)(dRating * 2), Tracks = strTracks, AlbumArtist = strAlbumArtist, Year = iYear }; return album; }
/// <summary> /// This completes the things necessary for creating a content item in the data store. /// </summary> /// <param name="objPost">The PostInfo entity we just created in the data store.</param> /// <param name="tabId">The page we will associate with our content item.</param> /// <returns>The ContentItemId primary key created in the Core ContentItems table.</returns> private static int CompleteQuestionCreation(AlbumInfo objPost, int tabId) { var cntTaxonomy = new ContentItemController(); var objContentItem = cntTaxonomy.CreateContentItem(objPost, tabId); return objContentItem.ContentItemId; }
/// <summary> /// Add Album To DataBase /// I - Steps : /// 1 . first : Add ContentItem /// 2 . Second :Add Album to DataBase /// 3 . Store Album into Cache /// </summary> /// <param name="album"></param> /// <returns> /// Id of album /// </returns> public int AddAlbum(AlbumInfo album, int tabid) { int rt = -1; // # 1 Save ContentItem to DataBase ContentItemController content = new ContentItemController(); content.CreateContentItem(album, tabid); // # 2 Store Album to DataBase rt = int.Parse(SqlServerDb.GetInstance().Insert(album).ToString()); // # 3 Store Cache return rt; }
/// <summary> /// This is used to update the content in the ContentItems table. Should be called when a question is updated. /// </summary> internal void UpdateContentItem(AlbumInfo objAlbum, int tabId) { var objContent = Util.GetContentController().GetContentItem(objAlbum.ContentItemId); if (objContent == null) return; objContent.Content = objAlbum.ShortContent; objContent.TabID = tabId; objContent.ContentKey = "view=" + Constants.PageScope.Question.ToString().ToLower() + "&id=" + objAlbum.AlbumID; Util.GetContentController().UpdateContentItem(objContent); // Update Terms var cntTerm = new Terms(); cntTerm.ManageQuestionTerms(objAlbum, objContent); }
void ArtistInspector_Load(object sender, EventArgs e) { if (_EnArtist != null) { _Artist.Text = _EnArtist.name; _Hotness.Value = (int)(100.0 * _EnArtist.hotttness); _Familiarity.Value = (int)(100.0 * _EnArtist.familiarity); string text = "Similar Artists: "; foreach (string a in _SimilarArtists) text += a + ", "; // TODO: Extra comma. _ArtistInfo.Text = text; } _AlbumInfo = FindAlbumOnLastFm(); string info = ""; if (_AlbumInfo != null) { info = string.Format("{0}:\r\n\r\n{1:d} listeners\r\n{2:d} plays\r\nreleased: {3}\r\n\r\n", _AlbumInfo.AlbumName, _AlbumInfo.NumListeners, _AlbumInfo.PlayCount, _AlbumInfo.ReleaseDate.ToShortDateString()); info += "Tags: "; if (_AlbumInfo.Tags != null) foreach (string key in _AlbumInfo.Tags.Keys) info += key + ", "; } ArtistInfo _LastFmArtist = FindArtistOnLastFm(); if (_LastFmArtist != null) { info += string.Format("{0}:\r\n\r\n{1:d} listeners\r\n{2:d} plays\r\n\r\n", _LastFmArtist.Name, _LastFmArtist.NumListeners, _LastFmArtist.PlayCount); info += "Tags: "; if (_LastFmArtist.Tags != null) foreach (string key in _LastFmArtist.Tags.Keys) info += key + ", "; info += "Similar Artists: "; if (_LastFmArtist.SimilarArtists != null) foreach (string key in _LastFmArtist.SimilarArtists.Keys) info += key + ", "; } if (info == "") info = "Couldn't find album/artist on last.fm"; _LastFmInfo.Text = info; _LastFmInfo.Select(0,0); }
private static FileInfo SelectCoverImage(IEnumerable<FileInfo> imageFiles, AlbumInfo albumInfo) { var cachedImageFiles = imageFiles.Cache(); var patterns = new List<Regex>(); patterns.Add(new Regex(@"cover", RegexOptions.IgnoreCase)); patterns.Add(new Regex(@"front", RegexOptions.IgnoreCase)); if (albumInfo.Name != null) patterns.Add(new Regex(Regex.Escape(albumInfo.Name), RegexOptions.IgnoreCase)); foreach (var pattern in patterns) foreach (var imageFile in cachedImageFiles) if (pattern.IsMatch(imageFile.Name)) return imageFile; return null; }
/// <summary> /// Sets the Page Meta information for the Question.ascx view. /// </summary> /// <param name="defaultPage"></param> /// <param name="objQuestion"></param> /// <param name="modContext"></param> /// <remarks>Need to wire in page to accept page param in URL.</remarks> public static void SetQuestionPageMeta(CDefault defaultPage,AlbumInfo objQuestion, ModuleInstanceContext modContext) { var title = TruncateString(objQuestion.AlbumName + " - " + modContext.PortalSettings.PortalName, Constants.SeoTitleLimit, false); var content = TruncateString(objQuestion.ShortContent, Constants.SeoDescriptionLimit, false); var link = Links.ViewQuestion(objQuestion.AlbumID, objQuestion.AlbumName, modContext.PortalSettings.ActiveTab, modContext.PortalSettings); var keyWords = ""; var keyCount = 1; var count = keyCount; var terms=Conten foreach (var term in objQuestion.Terms.TakeWhile(term => count <= Constants.SeoKeywordsLimit)) { keyWords += "," + term.Name; keyCount += 1; } SetPageMetaAndOpenGraph(defaultPage, modContext, title, content, keyWords, link); }
internal AlbumStatus(Album Ial, AlbumInfo ai) { Found = Ial; Status = ai; switch (ai) { case AlbumInfo.NewToTransaction: case AlbumInfo.ValidatedByEU: if (Found == null) throw new Exception(); break; case AlbumInfo.RefusedByEU: if (Found!=null) throw new Exception(); break; } }