Exemplo n.º 1
0
		private StorageScu SetupScu()
		{
			StorageScu scu = new StorageScu("TestAe", "AssocTestServer", "localhost", 2112);

			IList<DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID);

			foreach (DicomAttributeCollection collection in list)
			{
				DicomFile file = new DicomFile("test", new DicomAttributeCollection(), collection);
				file.TransferSyntax = TransferSyntax.ExplicitVrLittleEndian;
				file.MediaStorageSopClassUid = SopClass.MrImageStorage.Uid;
				file.MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString();

				scu.AddStorageInstance(new StorageInstance(file));
			}

			return scu;
		}
Exemplo n.º 2
0
        private void InsertStudy(SopGenerator generator, DateTime currentDay)
        {
            try
            {
                DicomFile file = generator.NewStudy(currentDay);

                if (_partition == null)
                {
                    var scu = new StorageScu("TESTTOOL", _aeTitle, _host, _port);

                    scu.AddStorageInstance(new StorageInstance(file));
                    int series = _rand.Next(1, generator.MaxSeries);
                    for (int i = 1; i < series; i++)
                    {
                        file = generator.NewSeries();
                        scu.AddStorageInstance(new StorageInstance(file));
                    }
                    scu.Send();
                }
                else
                {


                    InsertInstance(file);
                    int series = _rand.Next(1, generator.MaxSeries);
                    for (int i = 1; i < series; i++)
                    {
                        file = generator.NewSeries();
                        InsertInstance(file);
                    }
                }
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e, "Unexecpted exception inserting instance into the database.");
            }
        }
Exemplo n.º 3
0
 private void ResendImages()
 {
     if (_prevSentFiles != null && _prevSentFiles.Count>0)
     {
         using (StorageScu scu = new StorageScu(LocalAE.Text, ServerAE.Text, ServerHost.Text, int.Parse(ServerPort.Text)))
         {
             foreach (DicomFile file in _prevSentFiles)
             {
                 SetDicomFields(file);
                 scu.AddStorageInstance(new StorageInstance(file));
             }
             scu.ImageStoreCompleted += new EventHandler<ImageStoreEventArgs>(scu_ImageStoreCompleted);
             scu.Send();
             scu.Join();
         }
     }
     
 }
Exemplo n.º 4
0
        private void SendImages()
        {
            Random ran = new Random();
            textBox1.Clear();
            
                _seriesMap = new Dictionary<string, string>();
                _prevSentFiles = new List<DicomFile>();
                List<StorageScu> scuClients = new List<StorageScu>();
				StorageScu scu = new StorageScu(LocalAE.Text, ServerAE.Text, ServerHost.Text, int.Parse(ServerPort.Text));
                    scu.ImageStoreCompleted += new EventHandler<ImageStoreEventArgs>(scu_ImageStoreCompleted);
                    scuClients.Add(scu);

                int seriesCount = 0;
                do
                {
                    String seriesDescription = _seriesDesc[ran.Next(_seriesDesc.Count)];
                    string[] seriesUids = new string[_seriesToFilesMap.Count];
                    _seriesToFilesMap.Keys.CopyTo(seriesUids, 0);
                    String seriesToUse = seriesUids[ran.Next(_seriesToFilesMap.Count)];
                    List<string> files = _seriesToFilesMap[seriesToUse];

                
                    foreach (string path in files)
                    {
                        DicomFile file = new DicomFile(path);
                        file.Load();

                        RandomizeFile(file, seriesDescription);
                        _prevSentFiles.Add(file);


                        foreach (StorageScu client in scuClients)
                        {
                            client.AddStorageInstance(new StorageInstance(file));
                        }


                        if (ran.Next() % 50 == 0)
                            break; // don't use all images
                    }

                    seriesCount++;

                } while (ran.Next() % 5 != 0);

                Log(String.Format("Sending {0} images using {1} client(s)", _prevSentFiles.Count, scuClients.Count));
                    scu.BeginSend(InstanceSent, scu);
                    scu.Join();
                    scu.Dispose();
                
        }
Exemplo n.º 5
0
        void S2S_CC()
        {
            try
            {
                isS2Sing = true;
                Utility.SetMsg(lblS2Smsg, "", false);

                if (grdStudyList.RowCount <= 0 || grdStudyList.SelectedRows == null) return;
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Chưa tồn tại danh sách các PACS Server nên bạn không thể thực hiện thao tác gửi ảnh tới Server.\nBạn hãy vào mục cấu hình và khai báo các Servers.", "Thông báo");
                    return;
                }
                DataRow dr = ((DataRowView)grdStudyList.CurrentRow.DataBoundItem).Row;
                long RegID = Convert.ToInt64(dr["Reg_ID"]);

                string ErrorMsg = "";
                string SuccessConnect = "";
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    try
                    {
                        if (Convert.ToInt32(dr1["isActive"]) == 1)
                        {
                            string LocalAETitle = dr1["CallingAETitle"].ToString();
                            string LocalAddress = dr1["LocalAddress"].ToString();
                            string RemoteAETitle = dr1["CalledAETitle"].ToString();
                            string RemoteHost = dr1["IPAddress"].ToString();
                            int Port = Convert.ToInt32(dr1["Port"]);
                            int LocalPort = Convert.ToInt32(dr1["LocalPort"]);
                            AppLogger.LogAction.AddLog2List(lstFPD560, "LocalAETitle=" + LocalAETitle);
                            AppLogger.LogAction.AddLog2List(lstFPD560, "RemoteAETitle=" + RemoteAETitle);
                            AppLogger.LogAction.AddLog2List(lstFPD560, "RemoteHost=" + RemoteHost);
                            AppLogger.LogAction.AddLog2List(lstFPD560, "Port=" + Port);

                            StorageScu _storageScu = new StorageScu(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                            AddFiles4Store_CC(_storageScu);

                            _storageScu.BeginSend(InstanceSent, _storageScu);
                            //_storageScu.Send(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                            AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Send OK");
                        }
                    }
                    catch (Exception ex)
                    {
                        AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex.Message);
                    }
                }
                //Update Datasource and reg Status

                if (new RegController().UpdateStatus(RegID, 3) == ActionResult.Success)
                {
                    DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    m_dtStudyListDataSource.AcceptChanges();
                    m_dtWLDataSource.AcceptChanges();
                    m_dtWLDataSource_Suspending.AcceptChanges();
                    if (ErrorMsg.Trim() == "") Utility.SetMsg(lblS2Smsg, "Đã gửi dữ liệu thành công!", false);
                    else Utility.SetMsg(lblS2Smsg, ErrorMsg, true);
                }

            }
            catch (Exception ex1)
            {
                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex1.Message);
            }
            finally
            {
                isS2Sing = false;
            }
        }
Exemplo n.º 6
0
		/// <summary>
		/// Builds the study tree and publishes all the created studies to the specified application entity.
		/// </summary>
		/// <remarks>
		/// <para>The <see cref="BuildTree"/> method is called automatically, and hence does not need to be explicitly called before invoking this method.</para>
		/// </remarks>
		/// <param name="localAE">The local AETITLE that is sending the studies.</param>
		/// <param name="remoteAE">The AETITLE of the device that is receiving the studies.</param>
		/// <param name="remoteHost">The hostname of the device that is receiving the studies.</param>
		/// <param name="remotePort">The port number on which the device receiving the studies is listening.</param>
		/// <returns>A list of the SOP instance UIDs that were created.</returns>
		public IList<string> Publish(string localAE, string remoteAE, string remoteHost, int remotePort)
		{
			List<SopInstanceNode> sops;

			try
			{
				sops = DoBuildTree();
			}
			catch (Exception ex)
			{
				throw new StudyBuilderException("Unexpected StudyBuilder error", ex);
			}

			List<string> uids = new List<string>(sops.Count);

			try
			{
				StorageScu scu = new StorageScu(localAE, remoteAE, remoteHost, remotePort);

				// queue each instance into scu
				foreach (SopInstanceNode sop in sops)
				{
					StorageInstance sInst = new StorageInstance(sop.DicomFile);
					scu.AddStorageInstance(sInst);
					uids.Add(sop.InstanceUid);
				}

				// begin asynch send operation
				scu.Send();
			}
			catch (Exception ex)
			{
				throw new StudyBuilderException("Storage SCU error", ex);
			}

			return uids.AsReadOnly();
		}
Exemplo n.º 7
0
        void S2S_CC_All()
        {
            try
            {
               

                isS2Sing = true;
                SetTextWithErr(lblS2Smsg, "", false);

                if (grdStudyList.RowCount <= 0 ) return;
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Chưa tồn tại danh sách các PACS Server nên bạn không thể thực hiện thao tác gửi ảnh tới Server.\nBạn hãy vào mục cấu hình và khai báo các Servers.", "Thông báo");
                    return;
                }
                int TotalPatient = m_dtStudyListDataSource.Rows.Count;
                int idx = 0;
                //Duyệt qua danh sách các BN
                //Lấy về danh sách các StoreServer
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    if (Convert.ToInt32(dr1["isActive"]) == 1)//Nếu StoreServer đang được kích hoạt
                    {
                        idx = 0;
                        string LocalAETitle = dr1["CallingAETitle"].ToString();
                        string LocalAddress = dr1["LocalAddress"].ToString();
                        string RemoteAETitle = dr1["CalledAETitle"].ToString();
                        string RemoteHost = dr1["IPAddress"].ToString();
                        int Port = Convert.ToInt32(dr1["Port"]);
                        int LocalPort = Convert.ToInt32(dr1["LocalPort"]);

                        List<StorageInstance> _storageList = new List<StorageInstance>();
                        StorageScu _storageScu = new StorageScu(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                        _storageScu.ImageStoreCompleted += new EventHandler<StorageInstance>(_storageScu_ImageStoreCompleted);
                        //Lấy danh sách các ảnh để đóng gói gửi vào Server
                        foreach (DataRow dr in m_dtStudyListDataSource.Rows)
                        {
                            idx++;
                            SetTextWithErr(lblS2Smsg, "Đang gửi: " + idx.ToString() + " / " + TotalPatient.ToString(), false);
                            if (dr["CHON"].ToString() == "1")//Nếu Bn đó chọn để gửi
                            {
                                long RegID = Convert.ToInt64(dr["Reg_ID"]);
                                DataTable _dtAcquisitionDataSource = new RegDetailController().GetAllData(RegID).Tables[0];
                                if (_dtAcquisitionDataSource != null && _dtAcquisitionDataSource.Rows.Count > 0)
                                {   
                                    #region Add file để gửi tới Store Server
                                    foreach (DataRow drimage in _dtAcquisitionDataSource.Rows)
                                    {
                                        string RegNumber2 = dr["Reg_NUMBER"].ToString();
                                        string sourceimgfile = txtImgDir.Text.Trim() + @"\" + SubDirLv1(RegNumber2) + @"\" + SubDirLv2_Patient(Utility.sDbnull(dr["Patient_Code"]), Utility.sDbnull(dr["Patient_Name"]), Utility.sDbnull(dr["Age"])) + @"\" + RegNumber2 + "_" + Utility.Int32Dbnull(drimage["DETAIL_ID"]).ToString() + "_" + Utility.sDbnull(drimage["ANATOMY_CODE"], "") + "_" + Utility.sDbnull(drimage["PROJECTION_CODE"], "") + ".DCM";
                                        if (File.Exists(sourceimgfile))
                                        {
                                            string ErrorMsg = "";
                                            string SuccessConnect = "";
                                            try
                                            {
                                                if (_storageScu == null) return;
                                                _storageList.Add(new StorageInstance(sourceimgfile));
                                                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->CStore Added file:" + sourceimgfile);

                                            }
                                            catch (Exception ex)
                                            {
                                                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex.Message);
                                            }
                                        }

                                    }
                                    #endregion

                                    //_storageScu.Send(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                                        AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Send OK");

                                        if (new RegController().UpdateStatus(RegID, 3) == ActionResult.Success)
                                        {
                                            DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + RegID);
                                            if (arrDr.GetLength(0) > 0)
                                            {
                                                if (arrDr[0]["REGSTATUS"].ToString() != "2")
                                                    arrDr[0]["REGSTATUS"] = 3;
                                            }
                                            arrDr = m_dtWLDataSource.Select("REG_ID=" + RegID);
                                            if (arrDr.GetLength(0) > 0)
                                            {
                                                if (arrDr[0]["REGSTATUS"].ToString() != "2")
                                                    arrDr[0]["REGSTATUS"] = 3;
                                            }
                                            arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + RegID);
                                            if (arrDr.GetLength(0) > 0)
                                            {
                                                if (arrDr[0]["REGSTATUS"].ToString() != "2")
                                                    arrDr[0]["REGSTATUS"] = 3;
                                            }
                                            m_dtStudyListDataSource.AcceptChanges();
                                            m_dtWLDataSource.AcceptChanges();
                                            m_dtWLDataSource_Suspending.AcceptChanges();

                                        }
                                }

                            }
                        }
                        if (_storageList.Count > 0)
                        {
                            while (!canbeContinued)
                            {
                            }
                            canbeContinued = false;
                            _storageScu.AddStorageInstanceList(_storageList);
                            _storageScu.BeginSend(InstanceSent, _storageScu);
                        }
                    }
                }
                //Update Datasource and reg Status
                SetTextWithErr(lblS2Smsg, "Đã gửi dữ liệu thành công!", false);
            }
            catch (Exception ex1)
            {
                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex1.Message);
            }
            finally
            {
                isS2Sing = false;
            }
        }
Exemplo n.º 8
0
 void AutoAddFiles2StoreWhenFinish_CC(StorageScu _storageScu)
 {
     try
     {
         if (_storageScu == null) return;
         List<StorageInstance> _storageList = new List<StorageInstance>();
         foreach (Control ctrl in pnlScheduled.Controls)
         {
             ScheduledControl _ScheduledControl = ctrl as ScheduledControl;
             if ( File.Exists(_ScheduledControl.DcmfileName))
             {
                  _storageList.Add(new StorageInstance(_ScheduledControl.DcmfileName));
                 AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->CStore Added file:" + _ScheduledControl.DcmfileName);
             }
         }
        
         _storageScu.AddStorageInstanceList(_storageList);
        
     }
     catch
     {
     }
 }
Exemplo n.º 9
0
        void AddFiles4Store_CC(StorageScu _storageScu, List<StorageInstance> _storageList, string filename)
        {
            try
            {

                if (_storageScu == null) return;

                _storageList.Add(new StorageInstance(filename));
                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->CStore Added file:" + filename);

            }
            catch
            {
            }
        }
Exemplo n.º 10
0
 void AddFiles4Store_CC(StorageScu _storageScu)
 {
     try
     {
          
         if (_storageScu == null) return;
         List<StorageInstance> _storageList=new List<StorageInstance>();
         foreach (OScheduledControl _OScheduledControl in pnlThumbnailResult.Controls)
         {
             if (_OScheduledControl.isPressed && _OScheduledControl.Status == 1 && File.Exists(_OScheduledControl.DcmfileName))
             {
                 _storageList.Add(new StorageInstance(_OScheduledControl.DcmfileName));
                 AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->CStore Added file:" + _OScheduledControl.DcmfileName);
             }
         }
         _storageScu.AddStorageInstanceList(_storageList);
     }
     catch
     {
     }
 }
Exemplo n.º 11
0
        void AutoSend2miPACS_CC()
        {
            try
            {
                //if (!_DicomMedicalViewer.IsValidCell()) return;
               // CreateCStoreObject(false);
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    return;
                }
                string ErrorMsg = "";
                string SuccessConnect = "";
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    try
                    {
                        if (Convert.ToInt32(dr1["isActive"]) == 1)
                        {
                            string LocalAddress = Utility.sDbnull(dr1["LocalAddress"].ToString(), "");
                            string LocalAETitle = dr1["CallingAETitle"].ToString();
                            string RemoteAETitle = dr1["CalledAETitle"].ToString();
                            string RemoteHost = dr1["IPAddress"].ToString();
                            int Port = Utility.Int32Dbnull(dr1["Port"], 104);
                            int LocalPort = Utility.Int32Dbnull(dr1["LocalPort"], 0);
                            StorageScu _storageScu = new StorageScu(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                            AutoAddFiles2StoreWhenFinish_CC(_storageScu);                            
                            _storageScu.BeginSend(InstanceSent, _storageScu);
                            //_storageScu.Send(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                            AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Send OK");
                        }

                    }
                    catch (Exception ex)
                    {
                        AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex.Message);
                    }
                }
                pnlScheduled.Controls.Clear();
                //Update Datasource and reg Status

                if (new RegController().UpdateStatus(currREGID, 3) == ActionResult.Success)
                {
                    DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + currREGID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource.Select("REG_ID=" + currREGID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + currREGID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    m_dtStudyListDataSource.AcceptChanges();
                    m_dtWLDataSource.AcceptChanges();
                    m_dtWLDataSource_Suspending.AcceptChanges();
                }

            }
            catch (Exception ex)
            {
                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex.Message);
            }
        }