private void PieceFinishedAlert(piece_finished_alert a) { Interlocked.MemoryBarrier(); using (Core.TorrentHandle th = a.handle) using (Core.Sha1Hash hash = th.info_hash()) { if (TorrentList.ToList().Any(x => x.Hash == hash.ToString())) { Models.TorrentItem ti = TorrentList.First(z => z.Hash == hash.ToString()); if (!ReferenceEquals(null, ti.Pieces.Parts) && ti.Pieces.Parts.Any(q => q.Id == a.piece_index)) { ti.Pieces.Parts[a.piece_index].Downloaded = true; log.Debug("{0} for {1}", a.piece_index, ti.Name); foreach (Models.FileEntry item in ti.FileList) { foreach (Models.Part part in item.Pieces.Where(k => k.Id == a.piece_index)) { part.Downloaded = true; } } if (ti.SequentialDownload) { if (ti.Pieces.Parts.Any(w => w.Downloaded == false)) { Models.Part mp = ti.Pieces.Parts.First(w => w.Downloaded == false); mp.Priority = 7; th.piece_priority(mp.Id, 7); } } } } } }
private void torrentItem_PropertyChanged(object sender, PropertyChangedEventArgs e) { Interlocked.MemoryBarrier(); if (e.PropertyName == "SequentialDownload") { Models.TorrentItem ti = (Models.TorrentItem)sender; using (Core.Sha1Hash hash = new Core.Sha1Hash(ti.Hash)) using (Core.TorrentHandle th = _torrentSession.find_torrent(hash)) { th.set_sequential_download(ti.SequentialDownload); if (ti.SequentialDownload) { // lower all parts priority to 1 foreach (Models.Part mp in ti.Pieces.Parts.Where(x => x.Downloaded == false)) { mp.Priority = 1; th.piece_priority(mp.Id, 1); } // highest priority only at first an last part if not already downloaded if (ti.Pieces.Parts.First().Downloaded == false || ti.Pieces.Parts.Last().Downloaded == false) { Models.Part firstPart = ti.Pieces.Parts.First(); Models.Part lastPart = ti.Pieces.Parts.Last(); firstPart.Priority = 7; lastPart.Priority = 7; th.piece_priority(firstPart.Id, 7); th.piece_priority(lastPart.Id, 7); } else { // first and last part already downloaded, proceed with next undownloaded part if (ti.Pieces.Parts.Any(w => w.Downloaded == false)) { Models.Part mp = ti.Pieces.Parts.First(w => w.Downloaded == false); mp.Priority = 7; th.piece_priority(mp.Id, 7); } } } else { // not sequencial, all part with default priority foreach (Models.Part mp in ti.Pieces.Parts.Where(x => x.Downloaded == false)) { mp.Priority = 4; th.piece_priority(mp.Id, 4); } } } } }
public static double GetTotalUPH(Models.Part part) { double result = 0.0; List <Equipment> equipments = new List <Equipment>(); //List<Molding> moldings = new List<Molding>(); foreach (Molding molding in part.Moldings) { foreach (EquipmentCategory equipmentCategory in molding.EquipmentCategories) { equipments.AddRange(equipmentCategory.Equipments); } } foreach (Equipment equipment in equipments.Distinct()) { result += Utils.GetUPH(equipment); } return(result); }
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { XRControl control = (XRControl)sender; int orderItemID = (int)this.GetCurrentColumnValue("[ID]"); Models.OrderItem oItem = new Models.OrderItem(); oItem = dbContext.OrderItems.FirstOrDefault(o => o.ID == orderItemID); int partID = oItem.PartID; Models.Part prt = new Models.Part(); prt = dbContext.Parts.FirstOrDefault(p => p.ID == partID); if (prt.Files.Count > 0) { int fileID = prt.Files.FirstOrDefault().FileId; Models.File fileItem = new Models.File(); fileItem = dbContext.Files.FirstOrDefault(f => f.FileId == fileID); if (fileItem.Content != null) { PdfViewer pdfViewer = new PdfViewer(); Stream stream = new MemoryStream(fileItem.Content); pdfViewer.LoadDocument(stream); Bitmap bitmap = pdfViewer.CreateBitmap(1, 950); bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); pdfViewer.CloseDocument(); pdfViewer.Dispose(); xrPictureBox1.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource(bitmap); //string name = (string) this.GetCurrentColumnValue("FileName"); //xrLabel1.Text = name; } } }
public static string FullText(Models.Part part) { return(part.Code + " - " + part.Name); }
public PartPearl() { Part = new Models.Part(); SetDefaults(); }