/// <summary> /// 定时刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void dtimer_Tick(object sender, EventArgs e) { timenum++; PrintBLL printbll = new PrintBLL(); //PrintServer ps = new PrintServer(); //PrintQueue queue = ps.GetPrintQueue(ConfigurationManager.AppSettings["printer"]); //LocalPrintServer lps = new LocalPrintServer(); PrintQueue queue = LocalPrintServer.GetDefaultPrintQueue(); printbll.GetJobs(ConfigurationManager.AppSettings["printer"]); string str = getStatus(); if (queue.IsInError || queue.IsPaperJammed || queue.IsServerUnknown || queue.IsOutOfPaper || queue.HasPaperProblem || sameJobNum > 30)//|| str == "2" || str == "8") { wrongnum++; if (wrongnum > 3) { PrintWrong(); closeThis(); } //ps.Dispose(); queue.Dispose(); return; } //界面反馈 if (queue.NumberOfJobs > 0) { if (queue.NumberOfJobs == preJobNum) { sameJobNum++; progress.Value += 1; } else { preJobNum = queue.NumberOfJobs; sameJobNum = 0; progress.Value = (100 * (App.psta.Count - preJobNum) / App.psta.Count); } num = 0; nowCountText.Text = (App.psta.Count - preJobNum).ToString(); //ps.Dispose(); queue.Dispose(); return; } //打印结束 if (queue.NumberOfJobs == 0) { progress.Value = 100; num++; //ps.Dispose(); queue.Dispose(); if (num >= 3) { //成功结束 if (PrintSuccess() == 0 || num > 6) { if (num > 6) { messgeBoxBll.Show("与服务器通信失败", "因网络问题通信失败,本次打印不会扣费"); } closeThis(); } } } }