Пример #1
0
		/// <summary>
		/// Пометить задачу на удаление
		/// </summary>
		/// <param name="deviceCopy"></param>
		/// <param name="taskID"></param>
		public void MarkTaskForDelete(IDevice deviceCopy, int taskID)
		{
			if (deviceCopy.IsPresentTask(taskID))
			{
				DeviceTask task = (DeviceTask)deviceCopy.GetTaskByID(taskID);

				if(task.IsNew)
				{
					(deviceCopy as Device).RemoveTask(task);
				}
				else
				{
					task.IsDelete = true;
				}
			}
		}
Пример #2
0
        /// <summary>
        /// Возвращает копию устройства
        /// </summary>
        /// <returns></returns>
        public IDevice Copy()
        {
            Device device = new Device
            {
                ID           = ID,
                Description  = Description,
                FirmwareType = FirmwareType,
                IP           = IPAddress.Parse(IP.ToString()),
                IsConnected  = IsConnected,
                Mac          = Mac,
                Name         = Name
            };

            foreach (IDeviceTask task in Tasks)
            {
                DeviceTask taskCopy = (DeviceTask)(task as DeviceTask).Copy();
                //taskCopy.OwnerIP = device.IP;
                device.AddTask(taskCopy);
            }

            return(device);
        }
Пример #3
0
		/// <summary>
		/// Создать задачу для устройства
		/// </summary>
		/// <param name="deviceCopy"></param>
		/// <returns></returns>
		public IDeviceTask CreateNewTaskFor(IDevice deviceCopy)
		{
			DeviceTask task = null;

			if (deviceCopy != null)
			{
				int tempID = 0;
				if ((deviceCopy as Device).Tasks.Count() > 0)
				{
					tempID = (deviceCopy as Device).Tasks.Min(t => t.ID);

					if (tempID > 0)
						tempID = 0;
					else
						tempID--;
				}

				task = new DeviceTask { ID = tempID, Description = "New task" };
				(deviceCopy as Device).AddTask(task);
			}
			return task;
		}