public bool GetDicomFileFromServer(string remotefile, string localfile) { try { ClassFtpSocketClient sk = new ClassFtpSocketClient(); bool bSucc = sk.RecvDataFromFtpServer(GlobalData.RunParams.RemoteIP, GlobalData.RunParams.RemotePort, remotefile); if (bSucc) { byte[] l_bytes = sk.GetBytes(); System.IO.FileStream l_filestream = System.IO.File.Create(localfile); l_filestream.Write(l_bytes, 0, l_bytes.Length); l_filestream.Close(); } return(bSucc); } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); return(false); } }
public void smallscreengrab(int sc, int x, int y, int x1, int y1) // grab part of screen { for (int j = 0; j < noofscreens; j++) { grabwindow[j].Close(); grabwindow[j].Dispose(); } int finalx, finaly, finalwidth, finalheight; int X1 = Math.Min(x, x1), X2 = Math.Max(x, x1), Y1 = Math.Min(y, y1), Y2 = Math.Max(y, y1); finalx = X1 + screens[sc].Bounds.X; finaly = Y1 + screens[sc].Bounds.Y; finalwidth = X2 - X1 + 1; finalheight = Y2 - Y1 + 1; Image image = capture_class.CaptureScreentoClipboard(finalx, finaly, finalwidth, finalheight); //开始发送给 ClassFtpSocketClient sk = new ClassFtpSocketClient(); try { string ImagePath = GetRemoteFilePath(); string ImageId = GetMaxIDFormImageBack(); if (Conn.isOracle()) { string sqlstr = string.Format("insert into imageback(imgid,id,imagepath,flag,modulename) values('{0}','{1}','{2}','1','{3}')", ImageId, GlobalData.RunParams.AccessionNumber, ImagePath, GlobalData.RunParams.RunMode); OracleCommand sqlCmd = new OracleCommand(); sqlCmd.Connection = GlobalData.MainConn.ChangeTypeOracle(); sqlCmd.CommandText = sqlstr; sqlCmd.ExecuteNonQuery(); } else { string sqlstr = string.Format("insert into imageback(imgid,id,imagepath,flag,modulename) values('{0}','{1}','{2}','1','{3}')", ImageId, GlobalData.RunParams.AccessionNumber, ImagePath, GlobalData.RunParams.RunMode); SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = GlobalData.MainConn.ChangeType(); sqlCmd.CommandText = sqlstr; sqlCmd.ExecuteNonQuery(); } string JpegFile = GetRemoteFilePath() + ImageId + ".jpg"; Image tmpImage = image; System.IO.Stream mStream = new System.IO.MemoryStream(); tmpImage.Save(mStream, System.Drawing.Imaging.ImageFormat.Jpeg); sk.PutFileIntoFtpServer(GlobalData.RunParams.RemoteIP, GlobalData.RunParams.RemotePort, JpegFile, mStream); mStream.Dispose(); image.Dispose(); } catch (Exception ex) { MessageBox.Show("网络断开。。。请重启浏览器!!"); return; } IntPtr WINDOW_HANDLER = new IntPtr(Convert.ToInt32(GlobalData.RunParams.CallerHwnd)); if ((int)WINDOW_HANDLER == 0) { } else { User32.SendMessage(WINDOW_HANDLER, WM_SNDRIS, 0, new IntPtr(0)); } }