public async Task <IHttpActionResult> FindChannelLogo(bool searchArchive = false) { string srchDir = this._activeLogoDir; if (searchArchive) { srchDir = this._archiveLogoDir; } var readTask = await Request.Content.ReadAsStreamAsync(); var chLogos = new List <ChannelLogoInfo>(); foreach (var file in Directory.EnumerateFiles(srchDir, "*.png", SearchOption.TopDirectoryOnly)) { FileInfo fInfo = new FileInfo(file); int id; if (int.TryParse(fInfo.Name.Replace(".png", "").Trim(), out id)) { if (id > 0 && id < 10000) { using (var serverBM = new Bitmap(file)) using (var clientBM = new Bitmap(readTask)) { if (Toolset.CompareBitmaps(clientBM, serverBM)) { var chLogo = new ChannelLogoInfo(); chLogo.FileName = fInfo.Name; chLogo.BitmapId = id; chLogo.IsAssigned = await isAssignedAsync(id); chLogos.Add(chLogo); } } } } } if (chLogos.Count > 0) { return(Ok(chLogos)); } return(NotFound()); }
internal ChannelLogoInfo getLogoInfo(int bitmapId, bool active = true) { ChannelLogoInfo logo = null; string srchDir = active ? this._activeLogoDir : this._archiveLogoDir; string filePath = Path.Combine(srchDir, string.Format("{0}.png", bitmapId)); logo = new ChannelLogoInfo(); if (File.Exists(filePath)) { logo.FileName = filePath; } logo.BitmapId = bitmapId; logo.IsAssigned = isAssigned(bitmapId); return(logo); }