Beispiel #1
0
        private void AddOutputToProcess(Process objProcess, string sData)
        {
            //Check the data for Regexp stats (procentage and time left)
            //Regex x = new Regex(@"[,] (.*) [%] .*[ETA ](.*)\)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            Regex           x  = new Regex(@"[,] (?<procentage>.*?)\.\d\d [%] .*[ETA] (?<eta>.*?)\)", RegexOptions.IgnoreCase);
            MatchCollection mc = x.Matches(sData);

            //If nothing was found, try the rar-way
            if (mc.Count == 0)
            {
                Regex x2 = new Regex(@"\b(?<procentage>\d+)(?:\%)$(?<eta>)", RegexOptions.IgnoreCase);
                mc = x2.Matches(sData);
            }

            for (int i = 0; i < aProcessRunning.Count; i++)
            {
                ProcessRunning structProcess = (ProcessRunning)aProcessRunning[i];
                if (structProcess.objProcess == objProcess)
                {
                    for (int o = 0; o < aQueue.Count; o++)
                    {
                        QueueStruct structQueue = (QueueStruct)aQueue[o];
                        if (structQueue.nQueueID == structProcess.nQueueID)
                        {
                            if (mc.Count == 0) //Handbrake output not found, just add data
                            {
                                structQueue.aProcessOutput.Add(sData);
                            }
                            else //Now we got handbreak data, parse and extract, then update if nessesary
                            {
                                int iOldProcentage = structQueue.iProcentage;
                                structQueue.iProcentage = Convert.ToInt32(mc[0].Groups["procentage"].Value);
                                structQueue.sETA        = mc[0].Groups["eta"].Value;
                                aQueue.RemoveAt(o);
                                aQueue.Insert(o, structQueue);

                                //If the procentage has change, then trigger en update
                                if (iOldProcentage < structQueue.iProcentage)
                                {
                                    QueueIDEventArg eventArg = new QueueIDEventArg();
                                    eventArg.iProcentage = structQueue.iProcentage;
                                    eventArg.nQueueID    = structQueue.nQueueID;
                                    eventArg.sETA        = structQueue.sETA;
                                    this.QueueProcentageUpdate(eventArg);
                                }
                            }
                            break;
                        }
                    }
                    break;
                }
            }
        }
Beispiel #2
0
        public void HandleEventUpdateProcentage(object sender, QueueIDEventArg args)
        {
            _logger.Debug(typeof(MOTR_Webserver), "Procentage: " + args.iProcentage + " - Queue: " + args.nQueueID);
            ArrayList aProc = new ArrayList();

            aProc.Add(args.nQueueID);
            aProc.Add(args.iProcentage);
            aProc.Add(args.sETA);
            for (int i = 0; i < aWebservers.Count; i++)
            {
                aWebservers[i].server.SendAllWebsockets("QUEUEPROCENTAGE", aProc);
            }
        }
Beispiel #3
0
        //Update the queue based on process
        private void SetQueueExitInformation(Process objProcess)
        {
            for (int i = 0; i < aProcessRunning.Count; i++)
            {
                ProcessRunning structProcess = (ProcessRunning)aProcessRunning[i];
                if (structProcess.objProcess == objProcess)
                {
                    for (int o = 0; o < aQueue.Count; o++)
                    {
                        QueueStruct structQueue = (QueueStruct)aQueue[o];
                        if (structQueue.nQueueID == structProcess.nQueueID)
                        {
                            structQueue.nStatus = QueueStatus.FINISHED;
                            string sETA = "Finished " + DateTime.Now.ToString() + PrettyDurationFormat(DateTime.Now - structQueue.dateRunning);

                            if (objProcess.ExitCode != 0)
                            {
                                structQueue.nStatus = QueueStatus.FINISHEDANDFAIL;
                                sETA = "Finished, with errors " + DateTime.Now.ToString() + PrettyDurationFormat(DateTime.Now - structQueue.dateRunning);;
                            }
                            structQueue.sETA = sETA;
                            aQueue.RemoveAt(o);
                            aQueue.Insert(o, structQueue);

                            //Update queue data everywhere
                            QueueIDEventArg eventArg = new QueueIDEventArg();
                            eventArg.iProcentage = 100;
                            eventArg.nQueueID    = structQueue.nQueueID;
                            eventArg.sETA        = sETA;
                            this.QueueProcentageUpdate(eventArg);

                            //Last check the next item in queue, if executed update the queue
                            CheckNextItemInQueue();

                            //Update the new queue
                            this.QueueUpdate(EventArgs.Empty);
                        }
                    }
                }
            }
        }
Beispiel #4
0
 //Triggers an event to the MOTR-Webserver class that updates the specified queue for procentage
 public void QueueProcentageUpdate(QueueIDEventArg e)
 {
     OnQueueProcentage?.Invoke(this, e);
 }