Esempio n. 1
0
        public static List <Document> StopPrinting()
        {
            source.Cancel();
            stop = true;
            var list = DocumentsQueue.ToList();

            return(list);
        }
Esempio n. 2
0
        public static async Task Print()
        {
            while (DocumentsQueue.Count != 0)
            {
                var document = DocumentsQueue.First();
                if (document != null)
                {
                    await Task.Delay(document.Type.PrintDuration * 1000, source.Token);

                    Console.WriteLine(document.Name);
                    PrintedDocuments.Add(document);
                    DocumentsQueue.Remove(document);
                }
            }
        }
Esempio n. 3
0
        public static bool CancelPrintDocument(string document)
        {
            string name = document.Split('.')[0];
            string type = document.Split('.')[1];
            var    doc  = DocumentsQueue.Where(x => x.Name == name && x.Type.Name == type).First();

            if (doc != null)
            {
                DocumentsQueue.Remove(doc);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        public static bool AcceptPrintDocument(string document)
        {
            string name    = document.Split('.')[0];
            string type    = document.Split('.')[1];
            var    typeDoc = DocumentTypes.Where(x => x.Name == type.ToLower()).First();

            if (document != null)
            {
                DocumentsQueue.Add(new Document(name, typeDoc));
                if (stop == true)
                {
                    stop = false;
                    Task.Run(() => Print());
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
 public DocumentController()
 {
     docsQueue = DocumentsQueue.Instance;
 }