private void DownloadOrganizer_Completed(object sender, TaskProcessOrganizer <StateManager.Item> .CompletedEventArgs e) { string fullFileName = m_DownloadFileOrganizer.Data.GetValueAndRemove <StateManager.Item, string>(e.Value); if (!fullFileName.IsNullOrEmpty()) { var temp = new DirectoryInfo(Path.GetTempPath()); var gdir = temp.Combine(e.Value.SessionID.ToString()); gdir.EnsureDirectory(); e.Value.FileInfoList.AddRange(ZipFileAccess.Instance.ExtractFileZip(fullFileName, gdir.FullName)); var cover = ServiceDataAccess.Instance.ReadCoverInfo(e.Value.Id); if (!string.IsNullOrWhiteSpace(cover)) { var covers = cover.ToObject <List <Rectangle> >(); var voucherFile = e.Value.FileInfoList.Max((i1, i2) => i1.Length > i2.Length); using (var bmp = (Bitmap)Bitmap.FromFile(voucherFile.FullName)) { using (Graphics g = Graphics.FromImage(bmp)) { foreach (var area in covers) { bmp.Pixellate(area); g.DrawString(string.Format("{0}", area), this.Font, Brushes.BlueViolet, area.Left, area.Top); } } var newvoucherfile = voucherFile.Rename((i) => i.GetFileNameWithoutExtension() + "_new"); e.Value.FileInfoList.Remove(voucherFile); e.Value.FileInfoList.Add(newvoucherfile); bmp.Save(newvoucherfile.FullName, ImageFormat.Jpeg); } voucherFile.DeleteSafe(); } var sgn = e.Value.FileInfoList.FirstOrDefault(f => f.Extension == ".sgn"); if (sgn != null) { var sec = new CertificateSecurity(X509FindType.FindBySerialNumber, Strings.CERTNUMBER, StoreLocation.LocalMachine); if (sec.Loaded) { FileInfo fi = null; long max = 0; foreach (var f in e.Value.FileInfoList) { if (f.Length > max) { max = f.Length; fi = f; } } byte[] voucher = fi.ReadAllBytes(); byte[] signature = e.Value.Signature = sgn.ReadAllBytes(); e.Value.IsSignatureValid = sec.Verify(voucher, signature); } } var vi = e.Value as StateManager.VoucherItem; if (vi != null) { ServiceDataAccess.Instance.SaveHistory(OperationHistory.FileDownloaded, e.Value.CountryID, vi.RetailerID, vi.VoucherID, 0, 1, e.Value.ToString()); } if (m_DownloadFileOrganizer.Data.ContainsKey(e.Value.SessionID)) { ItemControl selectedItemCnt = m_DownloadFileOrganizer.Data.GetValueAndRemove <Guid, ItemControl>(e.Value.SessionID); this.InvokeSf(() => { selectedItemCnt.UnLock(); }); } this.InvokeSf(() => SelectFilesForm.ShowFiles(this, e.Value.FileInfoList)); } }