Example #1
0
        public CloudPrintProxy(IPrintJobProcessor printjobprocessor, Action <CloudPrintProxy> operationCancelledCallback)
        {
            if (printjobprocessor == null)
            {
                throw new ArgumentNullException("printjobprocessor");
            }

            OAuthTicketLock      = new object();
            _PrintJobs           = new ConcurrentDictionary <string, CloudPrintJob>();
            _Queues              = new List <CloudPrinter>();
            OperationCancelled   = operationCancelledCallback;
            PrintJobsLastUpdated = DateTime.MinValue;
            PrintJobProcessor    = printjobprocessor;
            UpdateLock           = new object();
        }
        public CloudPrintProxy(IPrintJobProcessor printjobprocessor, Action<CloudPrintProxy> operationCancelledCallback)
        {
            if (printjobprocessor == null)
            {
                throw new ArgumentNullException("printjobprocessor");
            }

            OAuthTicketLock = new object();
            _PrintJobs = new ConcurrentDictionary<string,CloudPrintJob>();
            _Queues = new List<CloudPrinter>();
            OperationCancelled = operationCancelledCallback;
            PrintJobsLastUpdated = DateTime.MinValue;
            PrintJobProcessor = printjobprocessor;
            UpdateLock = new object();
        }
        protected override void OnStart(string[] args)
        {
            this.Stopped.Reset();
            Logger.Log(LogLevel.Info, "Starting service");
            PrintProcessor = new WindowsPrintJobProcessor();

            PrintProxy = new CloudPrintProxy(PrintProcessor, (p) => Stop());

            InfoServer = new CloudPrintInfoServer(Config.UserAuthHttpPort, PrintProxy);
            InfoServer.Start();

            if (PrintProxy.IsRegistered)
            {
                PrintProxy.Start(true);
            }
            Logger.Log(LogLevel.Info, "Service started");
        }
        protected override void OnStart(string[] args)
        {
            this.Stopped.Reset();
            Logger.Log(LogLevel.Info, "Starting service");
            PrintProcessor = new WindowsPrintJobProcessor();

            PrintProxy = new CloudPrintProxy(PrintProcessor, (p) => Stop());

            InfoServer = new CloudPrintInfoServer(Config.UserAuthHttpPort, PrintProxy);
            InfoServer.Start();

            if (PrintProxy.IsRegistered)
            {
                PrintProxy.Start(true);
            }
            Logger.Log(LogLevel.Info, "Service started");
        }
        protected override void OnStop()
        {
            Logger.Log(LogLevel.Info, "Stopping service");
            if (InfoServer != null)
            {
                InfoServer.Dispose();
                InfoServer = null;
            }

            if (PrintProxy != null)
            {
                PrintProxy.Dispose();
                PrintProxy = null;
            }

            if (PrintProcessor != null)
            {
                PrintProcessor.Dispose();
                PrintProcessor = null;
            }
            Logger.Log(LogLevel.Info, "Service stopped");
            this.Stopped.Set();
        }
        protected override void OnStop()
        {
            Logger.Log(LogLevel.Info, "Stopping service");
            if (InfoServer != null)
            {
                InfoServer.Dispose();
                InfoServer = null;
            }

            if (PrintProxy != null)
            {
                PrintProxy.Dispose();
                PrintProxy = null;
            }

            if (PrintProcessor != null)
            {
                PrintProcessor.Dispose();
                PrintProcessor = null;
            }
            Logger.Log(LogLevel.Info, "Service stopped");
            this.Stopped.Set();
        }