Esempio n. 1
0
 /// <summary>
 /// Shows blocked mode changes warning.
 /// </summary>
 private void ShowBlockedModeChangesWarning()
 {
     if (WPFNotifier.Question(string.Format("To make changes you have to get back to your document, make changes and then click 'Print' button once again.{0}{0}Do you want to abort and quit?", Environment.NewLine)) == MessageBoxResult.Yes)
     {
         Close();
     }
 }
        /// <summary>
        /// Tries to print first time
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="printerName"></param>
        /// <param name="printerSettings"></param>
        void PrintFirstTry(string fileName, string documentName, PrinterSettings printerSettings)
        {
            // check if it's Demo mode
            if (IsTestMode)
            {
                return;
            }

            if (ConfigData.Config_DontCheckUserBalance)
            {
                Print(fileName, documentName, printerSettings, PostScriptMetaData);
            }
            else
            {
                SetStatus("Checking user balance");
                var res = APIWrapper.CheckIfCanPrint(Environment.MachineName, Environment.UserName, printerSettings.DefaultPageSettings.Color, NumberOfPrints, ChosenPrinter.Name);
                if (res == null)
                {
                    WPFNotifier.Warning(string.Format("No response from server but still printing."));
                    Print(fileName, documentName, printerSettings, PostScriptMetaData);
                }
                else
                {
                    if (res.Result)
                    {
                        if (res.AllowedToPrint)
                        {
                            Print(fileName, documentName, printerSettings, PostScriptMetaData);
                        }
                        else
                        {
                            //WPFNotifier.Warning(string.Format("You are not allowed to print in the current time.{0}Reason: {1}", Environment.NewLine, res.Reason));
                            SetStatus("Not allowed to print");
                            if (WPFNotifier.Question(string.Format("You are not allowed to print at the current time.{0}Reason: {1}{0}{2}", Environment.NewLine, res.Reason, "Do you want to leave the printing (Yes) or continue waiting (No)?")) == MessageBoxResult.Yes)
                            {
                                Close();
                            }
                            else
                            {
                                StartTimerAllowedToPrint();
                            }
                        }
                    }
                    else
                    {
                        WPFNotifier.Warning(string.Format("Not successful request CheckIfCanPrint."));
                    }
                }
            }
        }
 /// <summary>
 /// Tries to resume the print job first time
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="printJob"></param>
 void ResumeJobFirstTry(PrintJobData printJob)
 {
     if (ConfigData.Config_DontCheckUserBalance)
     {
         ResumeJob(printJob);
     }
     else
     {
         SetStatus("Checking user balance");
         var res = APIWrapper.CheckIfCanPrint(Environment.MachineName, Environment.UserName, printJob.Color, NumberOfPrints, printJob.PrintJobTitle.PrinterName);
         if (res == null)
         {
             WPFNotifier.Warning(string.Format("No response from server but still printing."));
             ResumeJob(printJob);
         }
         else
         {
             if (res.Result)
             {
                 if (res.AllowedToPrint)
                 {
                     ResumeJob(printJob);
                 }
                 else
                 {
                     SetStatus("Not allowed to print");
                     if (WPFNotifier.Question(string.Format("You are not allowed to print at the current time.{0}Reason: {1}{0}{2}", Environment.NewLine, res.Reason, "Do you want to leave the printing (Yes) or continue waiting (No)?")) == MessageBoxResult.Yes)
                     {
                         CancelJob(printJob);
                     }
                     else
                     {
                         StartTimerAllowedToPrint();
                     }
                 }
             }
             else
             {
                 WPFNotifier.Warning(string.Format("Not successful request CheckIfCanPrint."));
             }
         }
     }
 }