Beispiel #1
0
        public void ErrorEmail(int taskId, string error)
        {
            var activeImagingTaskServices = new ActiveImagingTaskServices();
            var task = activeImagingTaskServices.GetTask(taskId);

            activeImagingTaskServices.SendTaskErrorEmail(task, error);
        }
Beispiel #2
0
        public void ChangeStatusInProgress(int taskId)
        {
            var task = new ActiveImagingTaskServices().GetTask(taskId);

            task.Status = "3";
            new ActiveImagingTaskServices().UpdateActiveImagingTask(task);
        }
Beispiel #3
0
        public void UpdateProgress(int taskId, string progress, string progressType)
        {
            var activeImagingTaskServices = new ActiveImagingTaskServices();

            if (string.IsNullOrEmpty(progress))
            {
                return;
            }
            var task = activeImagingTaskServices.GetTask(taskId);

            if (progressType == "wim")
            {
                task.Elapsed   = progress;
                task.Remaining = "";
                task.Completed = "";
                task.Rate      = "";
            }
            else
            {
                var values = progress.Split('*').ToList();
                task.Elapsed   = values[1];
                task.Remaining = values[2];
                task.Completed = values[3];
                task.Rate      = values[4];
            }

            activeImagingTaskServices.UpdateActiveImagingTask(task);
        }
Beispiel #4
0
        public string CheckForCancelledTask(int taskId)
        {
            var task = new ActiveImagingTaskServices().GetTask(taskId);

            if (task == null)
            {
                return("true");
            }
            return("false");
        }
Beispiel #5
0
        public void UpdateProgressPartition(int taskId, string partition)
        {
            var activeImagingTaskServices = new ActiveImagingTaskServices();
            var task = activeImagingTaskServices.GetTask(taskId);

            task.Partition = partition;
            task.Elapsed   = "Please Wait...";
            task.Remaining = "";
            task.Completed = "";
            task.Rate      = "";
            activeImagingTaskServices.UpdateActiveImagingTask(task);
        }
        public void RecreatePermanentTasks(int userId)
        {
            var activeImagingServices = new ActiveImagingTaskServices();
            var permananentTasks      = activeImagingServices.GetAllPermanentTasks();

            foreach (var task in permananentTasks)
            {
                var computerId = task.ComputerId;

                activeImagingServices.DeleteActiveImagingTask(task.Id);
                new Workflows.Unicast(computerId, "permanentdeploy", userId, "").Start();
            }
        }
Beispiel #7
0
        public void PermanentTaskCheckOut(int taskId)
        {
            var activeImagingTaskServices = new ActiveImagingTaskServices();
            var task = activeImagingTaskServices.GetTask(taskId);

            task.Status    = "0";
            task.Partition = "";
            task.Completed = "";
            task.Elapsed   = "";
            task.Rate      = "";
            task.Remaining = "";
            activeImagingTaskServices.UpdateActiveImagingTask(task);

            activeImagingTaskServices.SendTaskCompletedEmail(task);
        }
Beispiel #8
0
        public void CheckOut(int taskId, int profileId)
        {
            var activeImagingTaskServices = new ActiveImagingTaskServices();
            var task = activeImagingTaskServices.GetTask(taskId);

            if (task.Type.Contains("upload"))
            {
            }

            if (task.Type.Contains("unreg"))
            {
                activeImagingTaskServices.DeleteUnregisteredOndTask(task.Id);
            }
            else
            {
                activeImagingTaskServices.DeleteActiveImagingTask(task.Id);
            }

            if (task.Type != "multicast" && task.Type != "ondmulticast")
            {
                activeImagingTaskServices.SendTaskCompletedEmail(task);
            }
        }
Beispiel #9
0
        public string CheckQueue(int taskId)
        {
            var queueStatus = new QueueStatus();
            var activeImagingTaskServices = new ActiveImagingTaskServices();
            var thisComputerTask          = activeImagingTaskServices.GetTask(taskId);

            //var computer = new ComputerServices().GetComputer(thisComputerTask.ComputerId);
            //Check if already part of the queue

            if (thisComputerTask.Status == "2")
            {
                //Delete Any tasks that have passed the timeout value
                activeImagingTaskServices.CancelTimedOutTasks();
                //Check if the queue is open yet
                var inUse         = activeImagingTaskServices.GetCurrentQueue(thisComputerTask);
                var totalCapacity = 0;
                var dp            = new DistributionPointServices().GetDistributionPoint(thisComputerTask.DpId);
                totalCapacity = dp.QueueSize;
                if (inUse < totalCapacity)
                {
                    //queue is open, is this computer next
                    var firstTaskInQueue = activeImagingTaskServices.GetNextComputerInQueue(thisComputerTask);
                    if (firstTaskInQueue.ComputerId == thisComputerTask.ComputerId)
                    {
                        ChangeStatusInProgress(taskId);
                        queueStatus.Result   = "true";
                        queueStatus.Position = "0";
                        return(JsonConvert.SerializeObject(queueStatus));
                    }
                    //not time for this computer yet
                    queueStatus.Result   = "false";
                    queueStatus.Position = activeImagingTaskServices.GetQueuePosition(thisComputerTask);
                    return(JsonConvert.SerializeObject(queueStatus));
                }
                //queue not open yet
                queueStatus.Result   = "false";
                queueStatus.Position = activeImagingTaskServices.GetQueuePosition(thisComputerTask);
                return(JsonConvert.SerializeObject(queueStatus));
            }
            else
            {
                //New computer checking queue for the first time

                var inUse         = activeImagingTaskServices.GetCurrentQueue(thisComputerTask);
                var totalCapacity = 0;
                var dp            = new DistributionPointServices().GetDistributionPoint(thisComputerTask.DpId);
                totalCapacity = dp.QueueSize;
                if (inUse < totalCapacity)
                {
                    ChangeStatusInProgress(taskId);

                    queueStatus.Result   = "true";
                    queueStatus.Position = "0";
                    return(JsonConvert.SerializeObject(queueStatus));
                }
                //place into queue
                var lastQueuedTask = activeImagingTaskServices.GetLastQueuedTask(thisComputerTask);
                if (lastQueuedTask == null)
                {
                    thisComputerTask.QueuePosition = 1;
                }
                else
                {
                    thisComputerTask.QueuePosition = lastQueuedTask.QueuePosition + 1;
                }
                thisComputerTask.Status = "2";
                activeImagingTaskServices.UpdateActiveImagingTask(thisComputerTask);

                queueStatus.Result   = "false";
                queueStatus.Position = activeImagingTaskServices.GetQueuePosition(thisComputerTask);
                return(JsonConvert.SerializeObject(queueStatus));
            }
        }
Beispiel #10
0
        public string CheckIn(string taskId)
        {
            var checkIn          = new CheckIn();
            var computerServices = new ComputerServices();

            var task = new ActiveImagingTaskServices().GetTask(Convert.ToInt32(taskId));

            if (task == null)
            {
                checkIn.Result  = "false";
                checkIn.Message = "Could Not Find Task With Id" + taskId;
                return(JsonConvert.SerializeObject(checkIn));
            }

            var computer = computerServices.GetComputer(task.ComputerId);

            if (computer == null)
            {
                checkIn.Result  = "false";
                checkIn.Message = "The Computer Assigned To This Task Was Not Found";
                return(JsonConvert.SerializeObject(checkIn));
            }

            var imageDistributionPoint = new GetImageServer(computer, task.Type).Run();

            task.Status = "1";
            task.DpId   = imageDistributionPoint;

            ImageEntity image = null;

            if (task.Type == "multicast")
            {
                var mcTask = new ActiveMulticastSessionServices().Get(task.MulticastId);
                var group  = new GroupServices().GetGroupByName(mcTask.Name);
                image = new ImageServices().GetImage(group.ImageId);
            }
            else
            {
                image = new ImageServices().GetImage(computer.ImageId);
            }
            if (image.Protected == 1 && task.Type.Contains("upload"))
            {
                checkIn.Result  = "false";
                checkIn.Message = "This Image Is Protected";
                return(JsonConvert.SerializeObject(checkIn));
            }

            if (new ActiveImagingTaskServices().UpdateActiveImagingTask(task))
            {
                checkIn.Result = "true";

                if (image != null)
                {
                    if (image.Environment == "")
                    {
                        image.Environment = "linux";
                    }
                    checkIn.ImageEnvironment = image.Environment;
                }

                if (image.Environment == "winpe")
                {
                    checkIn.TaskArguments = task.Arguments + "dp_id=\"" +
                                            imageDistributionPoint + "\"\r\n";
                }
                else
                {
                    checkIn.TaskArguments = task.Arguments + " dp_id=\"" +
                                            imageDistributionPoint + "\"";
                }
                return(JsonConvert.SerializeObject(checkIn));
            }
            checkIn.Result  = "false";
            checkIn.Message = "Could Not Update Task Status";
            return(JsonConvert.SerializeObject(checkIn));
        }