/// <summary>
        /// Update a device in the database.
        /// </summary>
        /// <param name="device"></param>
        /// <returns><b>true</b> if the record is updated successfully. <b>false</b> otherwise.</returns>
        public bool UpdateDevice(Device device)
        {
            Platform.Log(LogLevel.Info, "Updating device Key={0} : AETitle={1}", device.Key, device.AeTitle);
            bool ok = _adapter.Update(device);
            Platform.Log(LogLevel.Info, "Device Key={0} {1}", device.Key, ok ? "updated" : " failed to update");

            return ok;
        }
        /// <summary>
        /// Delete a device from the database.
        /// </summary>
        /// <param name="device"></param>
        /// <returns><b>true</b> if the record is deleted successfully. <b>false</b> otherwise.</returns>
        public bool DeleteDevice(Device device)
        {
            Platform.Log(LogLevel.Info, "Deleting {0}, Key={1}", device.AeTitle, device.Key);

            bool ok = _adapter.DeleteDevice(device);

            Platform.Log(LogLevel.Info, "Delete of {0} {1}", device.AeTitle, ok ? "Successful" : "Failed");

            return ok;
        }
		public StorageFilestreamHandler(DicomScpContext context, Device remoteDevice, ServerAssociationParameters assoc)
		{
			_context = context;
			_remoteDevice = remoteDevice;
			_importContext = new SopInstanceImporterContext(
				String.Format("{0}_{1}", assoc.CallingAE, assoc.TimeStamp.ToString("yyyyMMddhhmmss")),
				assoc.CallingAE, assoc.CalledAE);

			if (_remoteDevice != null && _remoteDevice.DeviceTypeEnum.Equals(DeviceTypeEnum.PrimaryPacs))
			{
				_importContext.DuplicateProcessing = DuplicateProcessingEnum.OverwriteSopAndUpdateDatabase;
			}
		}
        /// <summary>
        /// Add a device in the database.
        /// </summary>
        /// <param name="device"></param>
        public Device AddDevice(Device device)
        {
            Platform.Log(LogLevel.Info, "Adding new device : AETitle = {0}", device.AeTitle);

            Device dev = _adapter.AddDevice(device);

            if (dev!=null)
                Platform.Log(LogLevel.Info, "New device added :AE={0}, Key={1}",dev.AeTitle, dev.Key);
            else
                Platform.Log(LogLevel.Info, "Failed to add new device : AETitle={0}", dev.AeTitle);

            return dev;
        }
Beispiel #5
0
 static public Device Insert(IUpdateContext update, Device entity)
 {
     var broker = update.GetBroker<IDeviceEntityBroker>();
     var updateColumns = new DeviceUpdateColumns();
     updateColumns.Dhcp = entity.Dhcp;
     updateColumns.Enabled = entity.Enabled;
     updateColumns.AllowStorage = entity.AllowStorage;
     updateColumns.AcceptKOPR = entity.AcceptKOPR;
     updateColumns.AllowRetrieve = entity.AllowRetrieve;
     updateColumns.AllowQuery = entity.AllowQuery;
     updateColumns.AllowAutoRoute = entity.AllowAutoRoute;
     updateColumns.ThrottleMaxConnections = entity.ThrottleMaxConnections;
     updateColumns.LastAccessedTime = entity.LastAccessedTime;
     updateColumns.DeviceTypeEnum = entity.DeviceTypeEnum;
     updateColumns.ServerPartitionKey = entity.ServerPartitionKey;
     updateColumns.AeTitle = entity.AeTitle;
     updateColumns.Port = entity.Port;
     updateColumns.Description = entity.Description;
     updateColumns.IpAddress = entity.IpAddress;
     Device newEntity = broker.Insert(updateColumns);
     return newEntity;
 }
Beispiel #6
0
 static public Device Insert(Device entity)
 {
     using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
     {
         Device newEntity = Insert(update, entity);
         update.Commit();
         return newEntity;
     }
 }
Beispiel #7
0
        public void OnDeleteDevice(DeviceConfigurationController controller, ServerPartition serverPartition, Device dev)
        {
            if (controller.GetRelatedWorkQueueCount(dev) > 0)
            {
                DeleteConfirmation.Message = string.Format(ErrorMessages.AdminDevices_DeleteDevice_PendingWorkQueue,dev.AeTitle);
                DeleteConfirmation.MessageType = MessageBox.MessageTypeEnum.ERROR;             
            }
            else
            {
                DeleteConfirmation.Message = string.Format(SR.AdminDevices_DeleteDevice_AreYouSure, dev.AeTitle, serverPartition.AeTitle);
                DeleteConfirmation.MessageType = MessageBox.MessageTypeEnum.YESNO;
            }

            DeleteConfirmation.Data = dev;
            DeleteConfirmation.Show();
        }
Beispiel #8
0
 public void OnEditDevice(DeviceConfigurationController controller, ServerPartition serverPartition, Device dev)
 {
     // Populate the edit device dialog and display it
     AddEditDeviceControl1.EditMode = true;
     AddEditDeviceControl1.Device = dev;
     AddEditDeviceControl1.Partitions = controller.GetServerPartitions();
     AddEditDeviceControl1.Show(true);
 }
        private bool DeviceIsBusy(Device device)
        {
            bool busy = false;
            if (device.ThrottleMaxConnections != UNLIMITED)
            {
                if (_tempBlackoutDevices.ContainsKey(device.Key))
                {
                    busy = true;
                }
                else
                {
                    List<Model.WorkQueue> currentMoves;

                    using(IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                    {
                        currentMoves = device.GetAllCurrentMoveEntries(context);
                    }

                    if (currentMoves!=null && currentMoves.Count > device.ThrottleMaxConnections)
                    {
                        // sort the list to see where this entry is
                        // and postpone it if its position is greater than the ThrottleMaxConnections 
                        currentMoves.Sort(delegate(Model.WorkQueue item1, Model.WorkQueue item2)
                                              {
                                                  return item1.ScheduledTime.CompareTo(item2.ScheduledTime);
                                              });
                        int index = currentMoves.FindIndex(delegate(Model.WorkQueue item) { return item.Key.Equals(WorkQueueItem.Key); });

                        if (index >= device.ThrottleMaxConnections)
                        {
                            Platform.Log(LogLevel.Warn, "Connection limit on device {0} has been reached. Max = {1}.", device.AeTitle, device.ThrottleMaxConnections);
                            
                            // blackout for 5 seconds
                            _tempBlackoutDevices.Add(device.Key, device);
                            busy = true;
                        }
                    }
                }

            }

            return busy;
        }
        private void SaveData()
        {
            if (Device == null)
            {
                Device = new Device();
            }

            Device.Enabled = ActiveCheckBox.Checked;
            Device.AeTitle = AETitleTextBox.Text;
            Device.Description = DescriptionTextBox.Text;
            Device.Dhcp = DHCPCheckBox.Checked;
            Device.IpAddress = IPAddressTextBox.Text;
            int port;
            if (Int32.TryParse(PortTextBox.Text, out port))
                Device.Port = port;
            Device.ServerPartitionKey = DevicePage.CurrentPartition;
            Device.AllowStorage = AllowStorageCheckBox.Checked;
            Device.AllowQuery = AllowQueryCheckBox.Checked;
            Device.AllowRetrieve = AllowRetrieveCheckBox.Checked;
            Device.AllowAutoRoute = AllowAutoRouteCheckBox.Checked;

            if (AllowStorageCheckBox.Checked)
            {
                Device.AcceptKOPR = AcceptKOPR.Checked;
            }
            else
            {
                Device.AcceptKOPR = false;
            }

            Device.ThrottleMaxConnections = ThrottleSettingsTab.MaxConnections;
            Device.DeviceTypeEnum = DeviceTypeEnum.GetEnum(DeviceTypeDropDownList.SelectedItem.Value);
        }
 public int GetRelatedWorkQueueCount(Device device)
 {
     WorkQueueAdaptor workQueueAdaptor = new WorkQueueAdaptor();
     WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria();
     criteria.DeviceKey.EqualTo(device.Key);
     return workQueueAdaptor.GetCount(criteria);
 }
        private bool DeviceIsBusy(Device device)
        {
            bool busy = false;
            if (device.ThrottleMaxConnections != UNLIMITED)
            {
                if (_tempBlackoutDevices.ContainsKey(device.Key))
                {
                    busy = true;
                }
                else
                {
                    List<Model.WorkQueue> currentMoves;

                    using(IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                    {
                        currentMoves = device.GetAllCurrentMoveEntries(context);
                    }

                    if (currentMoves!=null && currentMoves.Count > device.ThrottleMaxConnections)
                    {
						Platform.Log(LogLevel.Warn, "Connection limit on device {0} has been reached. Max = {1}.",
						             device.AeTitle, device.ThrottleMaxConnections);
                            
                            // blackout for 5 seconds
                            _tempBlackoutDevices.Add(device.Key, device);
                            busy = true;
                        }
                    }
                }

            return busy;
        }
 /// <summary>
 /// Constructor for Storage SCU Component.
 /// </summary>
 /// <param name="partition">The <see cref="ServerPartition"/> instagating the association.</param>
 /// <param name="remoteDevice">The <see cref="Device"/> being connected to.</param>
 /// <param name="moveOriginatorAe">The Application Entity Title of the application that orginated this C-STORE association.</param>
 /// <param name="moveOrginatorMessageId">The Message ID of the C-MOVE-RQ message that orginated this C-STORE association.</param>
 public ImageServerStorageScu(ServerPartition partition, Device remoteDevice, string moveOriginatorAe, ushort moveOrginatorMessageId)
     : base(partition.AeTitle, remoteDevice.AeTitle, remoteDevice.IpAddress, remoteDevice.Port, moveOriginatorAe, moveOrginatorMessageId)
 {
 	_remoteDevice = remoteDevice;
 }
 /// <summary>
 /// Constructor for Storage SCU Component.
 /// </summary>
 public ImageServerStorageScu(ServerPartition partition, Device remoteDevice)
     :base(partition.AeTitle,remoteDevice.AeTitle,remoteDevice.IpAddress,remoteDevice.Port)
 {
     _remoteDevice = remoteDevice;
 }
        private static ServerDirectoryEntry FromDeviceToServerDirectoryEntry(Device theDevice)
        {
            var entry = new ServerDirectoryEntry(new ApplicationEntity
                                                     {
                                                         AETitle = theDevice.AeTitle,
                                                         Description = theDevice.Description,
                                                         Name = theDevice.Name,
                                                         ScpParameters =
                                                             new ScpParameters(theDevice.IpAddress, theDevice.Port)
                                                     });

            return entry;
        }
 public bool MoveStudy(Study study, Device device)
 {
     return MoveStudy(study, device, null);
 }
        public bool MoveStudy(Study study, Device device, IList<Series> seriesList)
        {            
			if (seriesList != null)
			{
                using (
					IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
				{
                    ServerPartition partition = ServerPartition.Load(study.ServerPartitionKey);

				    List<string> seriesUids = new List<string>();
                    foreach (Series series in seriesList)
					{
					    seriesUids.Add(series.SeriesInstanceUid);    
					}

                    IList<WorkQueue> entries = StudyEditorHelper.MoveSeries(context, partition, study.StudyInstanceUid, device.Key, seriesUids);
                        if(entries != null) context.Commit();

				    return true;
				}
			}
        	WorkQueueAdaptor workqueueAdaptor = new WorkQueueAdaptor();
			DateTime time = Platform.Time;
			WorkQueueUpdateColumns columns = new WorkQueueUpdateColumns
			                                 	{
			                                 		WorkQueueTypeEnum = WorkQueueTypeEnum.WebMoveStudy,
			                                 		WorkQueueStatusEnum = WorkQueueStatusEnum.Pending,
			                                 		ServerPartitionKey = study.ServerPartitionKey,
			                                 		StudyStorageKey = study.StudyStorageKey,
			                                 		FailureCount = 0,
			                                 		DeviceKey = device.Key,
			                                 		ScheduledTime = time,
			                                 		ExpirationTime = time.AddMinutes(4)
			                                 	};

        	workqueueAdaptor.Add(columns);

        	return true;
	    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
            }
            else
            {
                if (ViewState["EditMode"] != null)
                    _editMode = (bool) ViewState["EditMode"];

				if (ViewState["EditedDevice"] != null)
				{
					_device = ViewState["EditedDevice"] as Device;
				    DeviceValidator.OriginalAeTitle = _device.AeTitle;
				}

                DeviceValidator.Partition = DevicePage.CurrentPartition;
            }

            AllowStorageCheckBox.Attributes.Add("onclick", "AllowStorage_Changed()");
            AcceptKOPR.Attributes.Add("onclick", "AcceptKOPR_Changed()");
        }