public DicomState Print(string clientAETitle, string remoteAE, string remoteHost, int remotePort, BasicFilmSessionModuleIod basicFilmSessionModuleIod, BasicFilmBoxModuleIod basicFilmBoxModuleIod, IList <ImageBoxPixelModuleIod> imageBoxPixelModuleIods) { this._results = null; this._filmBoxUid = null; this._basicFilmSessionModuleIod = basicFilmSessionModuleIod; this._basicFilmBoxModuleIod = basicFilmBoxModuleIod; this._imageBoxPixelModuleIods = imageBoxPixelModuleIods; this._firstFilmBoxResponseMessage = null; this._currentImageBoxIndex = 0; base.Connect(clientAETitle, remoteAE, remoteHost, remotePort); return(base.ResultStatus); }
/// <summary> /// Prints with the specified parameters. /// </summary> /// <param name="clientAETitle">The client AE title.</param> /// <param name="remoteAE">The remote AE.</param> /// <param name="remoteHost">The remote host.</param> /// <param name="remotePort">The remote port.</param> /// <param name="basicFilmSessionModuleIod">The basic film session module iod.</param> /// <param name="basicFilmBoxModuleIod">The basic film box module iod.</param> /// <param name="imageBoxPixelModuleIods">The image box pixel module iods.</param> public DicomState Print(string clientAETitle, string remoteAE, string remoteHost, int remotePort, BasicFilmSessionModuleIod basicFilmSessionModuleIod, BasicFilmBoxModuleIod basicFilmBoxModuleIod, IList <ImageBoxPixelModuleIod> imageBoxPixelModuleIods) { _results = null; _filmSessionUid = null; _basicFilmSessionModuleIod = basicFilmSessionModuleIod; _basicFilmBoxModuleIod = basicFilmBoxModuleIod; _imageBoxPixelModuleIods = imageBoxPixelModuleIods; _filmBoxResponseMessages.Clear(); _currentImageBoxIndex = 0; _filmBoxUids.Clear(); Connect(clientAETitle, remoteAE, remoteHost, remotePort); if (Status == ScuOperationStatus.AssociationRejected || Status == ScuOperationStatus.Failed || Status == ScuOperationStatus.ConnectFailed || Status == ScuOperationStatus.NetworkError || Status == ScuOperationStatus.TimeoutExpired) { return(DicomState.Failure); } return(ResultStatus); }
// Methods public IAsyncResult BeginPrint(string clientAETitle, string remoteAE, string remoteHost, int remotePort, BasicFilmSessionModuleIod basicFilmSessionModuleIod, BasicFilmBoxModuleIod basicFilmBoxModuleIod, IList <ImageBoxPixelModuleIod> imageBoxPixelModuleIods, AsyncCallback callback, object asyncState) { PrintDelegate delegate2 = new PrintDelegate(this.Print); return(delegate2.BeginInvoke(clientAETitle, remoteAE, remoteHost, remotePort, basicFilmSessionModuleIod, basicFilmBoxModuleIod, imageBoxPixelModuleIods, callback, asyncState)); }
private void InternalPrint(PrintJob job) { BasicFilmSessionModuleIod basicFilmSessionModuleIod = new BasicFilmSessionModuleIod { NumberOfCopies = job.Copies, MediumType = job.MediumType, FilmDestination = job.FilmDestination }; BasicFilmBoxModuleIod basicFilmBoxModuleIod = new BasicFilmBoxModuleIod { //ImageDisplayFormat = @"STANDARD\1,1", ImageDisplayFormat = ImageDisplayFormat.Standard_1x1, FilmSizeId = job.FilmSize, Illumination = job.Illumination, FilmOrientation = job.FilmOrientation, ReflectedAmbientLight = job.ReflectedAmbientLight, MagnificationType = job.MagnificationType }; IList <ImageBoxPixelModuleIod> imageBoxPixelModuleIods = new List <ImageBoxPixelModuleIod>(); bool userCancelled = false; BackgroundTask task = new BackgroundTask(delegate(IBackgroundTaskContext context) { try { BackgroundTaskProgress progress; ushort num = 1; int percent = 0; new List <string>(); ImageBoxPixelModuleIod item = new ImageBoxPixelModuleIod { ImageBoxPosition = 1 }; BasicGrayscaleImageSequenceIod iod2 = new BasicGrayscaleImageSequenceIod { PhotometricInterpretation = job.MonochormeType }; Size size = this.CalcMaxSize(job.Format, job.Images); Bitmap image = new Bitmap(size.Width, size.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); foreach (PreviewTile tile in job.Images) { percent = (int)((((float)(num - 1)) / ((float)job.Images.Count)) * 80f); num = (ushort)(num + 1); progress = new BackgroundTaskProgress(percent, string.Format(SR.CreatingImageBuffer, num, job.Images.Count)); context.ReportProgress(progress); if (tile.ImageData != null) { Platform.Log(LogLevel.Error, "TITLE IMAGEDATA"); Bitmap printImagePixel = tile.GetPrintImagePixel(false); float x = tile.NormalizedRectangle.X * size.Width; float y = tile.NormalizedRectangle.Y * size.Height; float width = tile.NormalizedRectangle.Width * size.Width; float height = tile.NormalizedRectangle.Height * size.Height; g.DrawImage(printImagePixel, x, y, width, height); g.DrawRectangle(Pens.White, x, y, width, height); Rectangle destination = new Rectangle(((int)x) + 2, ((int)y) + 2, ((int)width) - 4, ((int)height) - 4); try { IconCreator.DrawTextOverlay(g, destination, tile.ImageData); } catch (Exception ex) { Platform.Log(LogLevel.Error, " exception: " + ex.ToString()); } printImagePixel.Dispose(); if (context.CancelRequested) { userCancelled = true; break; } } } //clear foreach (PreviewTile tile in job.Images) { ImageSop sop = ((IImageSopProvider)tile.ImageData).ImageSop; string strUID = sop.SopInstanceUid; //获取UID 的 accession try { if (Conn.isOracle()) { string sqlstr = string.Format(" update examrecord set filmprint='{0}' where id=(select AccessionNumber from images where SopInstanceUID='{1}') and modulename='RIS' ", "1", strUID); OracleCommand sqlCmd = new OracleCommand(); sqlCmd.Connection = GlobalData.MainConn.ChangeTypeOracle(); sqlCmd.CommandText = sqlstr; sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); } else { string sqlstr = string.Format(" update examrecord set filmprint='{0}' where id=(select AccessionNumber from images where SopInstanceUID='{1}') and modulename='RIS' ", "1", strUID); SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = GlobalData.MainConn.ChangeType(); sqlCmd.CommandText = sqlstr; sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); Platform.Log(LogLevel.Error, " sql is " + sqlstr); } } catch (Exception ex) { Platform.Log(LogLevel.Error, "exception is " + ex.ToString()); } //tile.Dispose(); tile.RemoveImage(); } job.Images.Clear(); g.Dispose(); //iod2.AddBitmap(image); Unlock(); RasterImage lRasterImage = null; RasterCodecs lRasterCodecs = new RasterCodecs(); lRasterImage = RasterImageConverter.ConvertFromImage(image, ConvertFromImageOptions.None); lRasterCodecs.Save(lRasterImage, System.Windows.Forms.Application.StartupPath + @"\print.jpg", RasterImageFormat.Tif, 8); string lDicomFile = "1" + DateTime.Now.ToString("HHmmss", DateTimeFormatInfo.InvariantInfo); lRasterCodecs.Save(lRasterImage, System.Windows.Forms.Application.StartupPath + @"\PrintFiles\" + lDicomFile, RasterImageFormat.DicomGray, 16); //image.Save("d:\\test.jpg"); image.Dispose(); lRasterImage.Dispose(); lRasterCodecs.Dispose(); //item.BasicGrayscaleImageSequenceList.Add(iod2); //imageBoxPixelModuleIods.Add(item); if (userCancelled) { Platform.Log(LogLevel.Info, SR.UserCancel); } else { progress = new BackgroundTaskProgress(80, SR.BeginSendImage); context.ReportProgress(progress); PrintDicomFiles(lDicomFile, 1, 1, lDicomFile, job); //BasicGrayscalePrintScu scu = new BasicGrayscalePrintScu(); //scu.Print(job.Printer.AET, job.Printer.CalledAET, job.Printer.Host, job.Printer.Port, basicFilmSessionModuleIod, basicFilmBoxModuleIod, imageBoxPixelModuleIods); //if (scu.ResultStatus == DicomState.Success) //{ // this.UpdateStudyPrintStatus(this.GetStudyInstanceUIDs(job.Images)); // PrintToolComponent.TilesComponent.ResetTiles(); //} //else //{ // this._component.ShowMessageBox(SR.FilmError); //} } } catch (OutOfMemoryException) { Platform.Log(LogLevel.Error, "内存不够"); BackgroundTaskProgress progress2 = new BackgroundTaskProgress(100, SR.OutOfMemory); context.ReportProgress(progress2); this._component.ShowMessageBox(SR.OutOfMemory); } catch (Exception exception) { Platform.Log(LogLevel.Error, exception.Message); BackgroundTaskProgress progress3 = new BackgroundTaskProgress(100, exception.Message); context.ReportProgress(progress3); this._component.ShowMessageBox(SR.PrinterError); } finally { context.Complete(null); } }, true); ProgressDialog.Show(task, this._window, true, ProgressBarStyle.Blocks); }
private bool GoPrint(PrintJob printJob, out int successSend) { successSend = 0; try { BasicFilmSessionModuleIod basicFilmSessionModuleIod = new BasicFilmSessionModuleIod { NumberOfCopies = printJob.Copies, MediumType = printJob.MediumType, FilmDestination = printJob.FilmDestination }; BasicFilmBoxModuleIod basicFilmBoxModuleIod = new BasicFilmBoxModuleIod { //ImageDisplayFormat = printJob.Format, FilmSizeId = printJob.FilmSize, Illumination = printJob.Illumination, FilmOrientation = printJob.FilmOrientation, ReflectedAmbientLight = printJob.ReflectedAmbientLight, MagnificationType = printJob.MagnificationType }; IList <ImageBoxPixelModuleIod> imageBoxPixelModuleIods = new List <ImageBoxPixelModuleIod>(); ushort num = 1; foreach (PreviewTile tile in printJob.Images) { this.ChangeSendStatus(printJob.ID, string.Format(SR.CreatingImageBuffer, num, printJob.Images.Count)); ImageBoxPixelModuleIod item = new ImageBoxPixelModuleIod { ImageBoxPosition = tile.Position }; BasicGrayscaleImageSequenceIod iod4 = new BasicGrayscaleImageSequenceIod { PhotometricInterpretation = printJob.MonochormeType }; Bitmap printImagePixel = tile.GetPrintImagePixel(true); iod4.AddBitmap(printImagePixel); printImagePixel.Dispose(); item.BasicGrayscaleImageSequenceList.Add(iod4); imageBoxPixelModuleIods.Add(item); } if (this.StopKey) { return(false); } this.ChangeSendStatus(printJob.ID, SR.BeginSendImage); try { for (int i = 0; i < printJob.Copies; i++) { BasicGrayscalePrintScu scu = new BasicGrayscalePrintScu(); this.ChangeSendStatus(printJob.ID, string.Format(SR.Sending, i.ToString(), printJob.Copies.ToString())); if (scu.Print(printJob.Printer.AET, printJob.Printer.CalledAET, printJob.Printer.Host, printJob.Printer.Port, basicFilmSessionModuleIod, basicFilmBoxModuleIod, imageBoxPixelModuleIods) == DicomState.Success) { successSend++; } } } catch (Exception exception) { Platform.Log(LogLevel.Error, exception); } } catch (Exception exception2) { Platform.Log(LogLevel.Error, exception2); } if (successSend == 0) { return(false); } return(true); }