public ProcessOrderStage()
            : base(Constants.ProcessStageName, ExecutionEngine.Config.InactivityTimeout.Value)
        {
            _confirmOrderScreen   = new ConfirmOrderScreen(this);
            _contactInfoScreen    = new ContactInfoScreen(this);
            _orderIdScreen        = new OrderIdScreen(this);
            _burningScreen        = new BurningScreen(this);
            _printingScreen       = new PrintingScreen(this);
            _thankYouScreen       = new ThankYouScreen(this);
            _thankYouCancelScreen = new ThankYouCancelScreen(this);

            LastVisitedPage = _confirmOrderScreen;

            _orderStoreManager = new FileOrderStorage();
            ExecutionEngine.EventLogger.Write("ProcessOrderStage created");
        }
Beispiel #2
0
 public ResetOrderDataCommand()
     : base(Constants.ResetOrderData)
 {
     FileOrderStorage.ClearBluetoothDirectory();
 }
Beispiel #3
0
        public ExecutionEngine(Frame frame, MainWindow mainWindow)
        {
            _lastInstance = this;
            _mainWindow   = mainWindow;
            _isBluetooth  = false;
            _showingFrame = frame;
            _resource     = mainWindow.Resources;
            _orderManager = new OrderManagerAddon();

            LoadDefaultResources();

            try
            {
                if (Mutex.OpenExisting(MutexName) != null)
                {
                    ShowMessageAndQuit(StringResources.GetString("MessageOnlyOneInstanceCanBeRun"));
                    return;
                }
            }
            catch (WaitHandleCannotBeOpenedException) { }    // no need to handle

            _namedMutex = new Mutex(false, MutexName);

            _errorLogger         = new WindowsAppLog(true);
            _errorLogger.Enabled = true;

            try
            {
                _config = new Config(true);
            }
            catch (Exception e)
            {
                _errorLogger.WriteExceptionInfo(e);
                ShowMessageAndQuit(StringResources.GetString("MessageConfigReadingError"));
                return;
            }

            try
            {
                _priceManager = new PriceManager(true, _config.PriceFile.Value);
            }
            catch (Exception e)
            {
                _errorLogger.WriteExceptionInfo(e);
                ShowMessageAndQuit(StringResources.GetString("MessagePriceReadingError"));
                return;
            }

            try
            {
                _crops = new CropManager(true, _config.CropFile.Value);
            }
            catch (Exception e)
            {
                _errorLogger.WriteExceptionInfo(e);
                ShowMessageAndQuit(StringResources.GetString("MessageCropsReadingError"));
                return;
            }

            _eventLogger         = new FileLog(Config.EventLogFile, false);
            _eventLogger.Enabled = _config.EnableEventLogging.Value;

            _dataContext = new DataContext();
            _dataContext[Constants.OrderContextName] = new Order();
            _lastUserActionTime = System.DateTime.Now;

            _eventLogger.Write(string.Format(CultureInfo.InvariantCulture, "ExecutionEngine:Load headers and backgrounds"));
            _headerDictionary     = new Dictionary <string, BitmapImage>();
            _backgroundDictionary = new Dictionary <string, ImageBrush>();

            // Add main banner to resources
            try
            {
                _resource.Add(Constants.ImageBannerKey, BitmapFrame.Create(new Uri(_config.MainBanner.Value)));
            }
            catch (Exception e)
            {
                _eventLogger.Write(string.Format(StringResources.GetString("MessageImageLoadError"), _config.MainBanner.Value, e.Message));
                _resource.Add(Constants.ImageBannerKey, null);
            }

            LoadScreenSettings(_config.Screens);

            LoadCustomResources();

            _stages = new List <StageBase>();
            _stages.Add(new WelcomeStage());
            _stages.Add(new SelectStage());
            _stages.Add(new ImageEditorStage());
            _stages.Add(new ProcessOrderStage());
            _stages.Add(new FindingPhotosStage());

            // Clear bluetooth folder
            FileOrderStorage.ClearBluetoothDirectory();

            NativeMethods.SetErrorMode(NativeMethods.SEM_FAILCRITICALERRORS);
        }
        public void CompleteOrder()
        {
            DisableTimeout();

            ProgressDialog progressDialog;

            ExecutionEngine.EventLogger.Write("ProcessOrderStage:CompleteOrder");

            if (ExecutionEngine.Instance.PrimaryAction == PrimaryActionType.BurnCd)
            {
                progressDialog = new ProgressDialog((string)ExecutionEngine.Instance.Resource[Constants.MessagePreparingImageKey]);
            }
            else
            {
                progressDialog = new ProgressDialog((string)ExecutionEngine.Instance.Resource[Constants.MessageProgressOrderKey]);
            }

            ExecutionEngine.EventLogger.Write("ProgressOrderStage:StartOrderProgress");

            _orderStoreManager.Add((IProgressCallback)progressDialog);
            bool     result         = false;
            DateTime showDialogTime = DateTime.Now.AddSeconds(Constants.ProgressDialogTimeout);

            while (DateTime.Now.Second < showDialogTime.Second)
            {
                if (progressDialog.IsComplete)
                {
                    result = true;
                    break;
                }
            }

            if (!result)
            {
                progressDialog.ShowDialog();
                result = progressDialog.DialogResult.Value;
            }

            if (result)
            {
                if (Engine.PrimaryAction == PrimaryActionType.BurnCd)
                {
                    if (ExecutionEngine.Config.CDBurningRequireConfirm.Value)
                    {
                        SwitchToThankYou();
                    }
                    else
                    {
                        SwitchToBurningScreen(null);
                    }
                }
                else if (Engine.PrimaryAction == PrimaryActionType.PrintPhotos)
                {
                    if (ExecutionEngine.Config.PhotoPrintingRequireConfirm.Value)
                    {
                        SwitchToThankYou();
                    }
                    else
                    {
                        SwitchToPrintingScreen(null);
                    }
                }
                else
                {
                    SwitchToThankYou();
                }
            }
            else
            {
                SwitchToThankYouCancel();
            }

            if (ExecutionEngine.Instance.IsBluetooth)
            {
                FileOrderStorage.ClearBluetoothDirectory();
            }
        }
 public void SwitchToContactInfo()
 {
     if (ExecutionEngine.Config.SkipContactInfo.Value)
     {
         this.CurrentOrder.OrderId = string.Format("{0}{1}", ExecutionEngine.Config.PhotoKioskId.Value, FileOrderStorage.GetOrderIdFromFile() + 1);
         this.CompleteOrder();
     }
     else
     {
         ExecutionEngine.EventLogger.Write("ProcessOrderStage:SwitchToContactInfo");
         LastVisitedPage = _contactInfoScreen;
         Engine.ExecuteCommand(new SwitchToScreenCommand(_contactInfoScreen));
     }
 }
Beispiel #6
0
        private void ButtonNextStageClickHandler(object sender, RoutedEventArgs e)
        {
            if (_enteredName.Text.Length < 2)
            {
                MessageDialog.Show((string)ExecutionEngine.Instance.Resource[Constants.MessageEnterYourNameKey]);
                return;
            }

            if (ExecutionEngine.Config.EnableCustomerPhone.Value && _enteredPhone.Text.Length < 2)
            {
                MessageDialog.Show((string)ExecutionEngine.Instance.Resource[Constants.MessageEnterYourPhoneKey]);
                return;
            }

            if (ExecutionEngine.Config.EnableCustomerEmail.Value && (_enteredEmail.Text.Length < 2 /*|| !EmailValidator.IsValid(_enteredEmail.Text)*/))
            {
                MessageDialog.Show((string)ExecutionEngine.Instance.Resource[Constants.MessageEnterYourEmailKey]);
                return;
            }

            _stage.CurrentOrder.UserName  = _enteredName.Text;
            _stage.CurrentOrder.UserPhone = _enteredPhone.Text;
            _stage.CurrentOrder.UserEmail = _enteredEmail.Text;

            if (ExecutionEngine.Config.EnableCustomerOrderId.Value)
            {
                _stage.SwitchToOrderId();
            }
            else if (ExecutionEngine.Config.EnableCustomerNameOrderId.Value)
            {
                _stage.CurrentOrder.OrderId = string.Format("{0}{1}", _stage.CurrentOrder.UserName, FileOrderStorage.GetOrderIdFromFile() + 1);
                _stage.CompleteOrder();
            }
            else
            {
                _stage.CurrentOrder.OrderId = string.Format("{0}{1}", ExecutionEngine.Config.PhotoKioskId.Value, FileOrderStorage.GetOrderIdFromFile() + 1);
                _stage.CompleteOrder();
            }
        }
 public void UseBluetooth()
 {
     Engine.IsBluetooth = true;
     FileOrderStorage.ClearBluetoothDirectory();
     SwitchToBluetoothLoadSceen();
 }