예제 #1
0
        private void printWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            PrintWorkingState = true;
            string     filename = "";
            PrintJob   job      = (PrintJob)e.Argument;
            RestClient client   = new RestClient(appURL + job.url);

            client.UserAgent = "PrintServer";
            // var request = new RestRequest(appURL + listURL, Method.POST);
            filename = Guid.NewGuid().ToString() + ".pdf";

            var request = new RestRequest(Method.GET);

            byte[] file = client.DownloadData(request);

            if (file.Count() > 0)
            {
                filename = path + filename;
                file.SaveAs(filename);
                printfile(filename);
                job.url  = filename;
                e.Result = job;
            }
            Console.WriteLine("Download " + job.id);
        }
예제 #2
0
 private void printWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     PrintWorkingState = false;
     if (e.Error == null && e.Cancelled == false)
     {
         PrintJob job = (PrintJob)e.Result;
         deleteFile(job);
         Console.WriteLine("print " + job.id);
     }
 }
예제 #3
0
        private void deleteFile(PrintJob job)
        {
            if (File.Exists(job.url))
            {
                File.Delete(job.url);

                RestClient client = new RestClient(appURL);
                client.UserAgent = "PrintServer";
                var request = new RestRequest(appURL + updateURL, Method.POST);
                request.AddParameter("username", user);
                request.AddParameter("password", password);
                request.AddParameter("docid", job.document_id);
                request.AddParameter("jobid", job.id);
                //request.AddHeader("x-token", "1234567890");
                var printJob = client.Execute(request);
            }
        }