public bool RunShipmentApplication(string shipmentNumber) { _messagesProvider.Log(InformationResources.INFO_FEDEX_STARTING_APPLICATION); var process = RunApplication(_settings.FedexProcessName); if (process != null) { _mainWindow = AutomationElement.RootElement.FindChildByProcessId(process.Id); if (_mainWindow != null) { _messagesProvider.Log(InformationResources.INFO_FEDEX_START_APPLICATION); return(true); } else { _messagesProvider.Warn(string.Format(InformationResources.WARN_NO_PROCESS_INIT_FOR_FEDEX_APPLICATION, shipmentNumber)); return(false); } } else { _messagesProvider.Warn(string.Format(InformationResources.WARN_NO_PROCESS_FOUND_FOR_FEDEX_APPLICATION, shipmentNumber)); return(false); } }
public bool RunShipmentApplication(string shipmentNumber) { _messagesProvider.Log(InformationResources.INFO_UPS_STARTING_APPLICATION); _process = RunApplication(_settings.UpsProcessName); if (_process != null) { var delayCount = 0; while (delayCount < 10 && (_mainWindow == null || _workplace == null)) { _mainWindow = AutomationElement.RootElement.FindChildByProcessId(_process.Id); _workplace = _mainWindow.FindDescendentByIdPath(new[] { _workplaceAutomationId }); delayCount++; } if (_mainWindow != null && _workplace != null) { _messagesProvider.Log(string.Format(InformationResources.INFO_UPS_START_APPLICATION, shipmentNumber)); return(true); } else { _messagesProvider.Warn(string.Format(InformationResources.WARN_NO_PROCESS_INIT_FOR_UPS_APPLICATION, shipmentNumber)); return(false); } } else { _messagesProvider.Warn(string.Format(InformationResources.WARN_NO_PROCESS_FOUND_FOR_UPS_APPLICATION, shipmentNumber)); return(false); } }
public ShipmentMapper GetShipment(string shipmentNbr) { try { if (string.IsNullOrEmpty(shipmentNbr)) { shipmentNbr = _browserHelper.GetShipmentUriData().ShipmentNbr; } return(_webServiceHelper.GetShipmentByShipmentId(shipmentNbr)); } catch (NetworkActiveBrowserNotFoundException e) { _messagesProvider.Warn(string.Format(InformationResources.WARN_NO_WAY_TO_GET_SHIPMENT_EXTENDED, e.Message)); throw; } catch (NetworkActiveUriNotFoundException e) { _messagesProvider.Warn(string.Format(InformationResources.WARN_NO_WAY_TO_GET_SHIPMENT_EXTENDED, e.Message)); throw; } catch (Exception e) { _messagesProvider.Error(new NetworkException(InformationResources.ERROR_CANNOT_CONNECT_TO_ACUMATICA)); _messagesProvider.Log(e.Message); throw; } }
public void SetValueToControl(string value) { //if (string.IsNullOrEmpty(value)) //{ // return; //} Value = value.Trim(); try { var currentValue = GetCurrentValue(); var isValueValid = (string.IsNullOrEmpty(currentValue) || !ValidateFunc.Invoke(currentValue)); if (!isValueValid) { return; } this.AutomationElement.SetFocus(); //_messagesProvider.Log(Name + " - " + this.Value); SetControlValue(); //Thread.Sleep(_transferSpeed); //var delayCount = 5; //while (delayCount > 0 && (string.IsNullOrEmpty(GetCurrentValue()) || !ValidateFunc.Invoke(GetCurrentValue()))) //{ // //var attempts = 0; // //if (attempts > 3) throw new Exception($"After 3 attempts: Unable to perform of set value to control operation. AutomationId: {AutomaitonId}, Name: {Name}, Value: {value}"); // //try // { // _messagesProvider.Log(this.Name + " - " + this.Value); // SetControlValue(); // delayCount--; // Thread.Sleep(delayCount == 4 ? 100 : 1000); // //Thread.Sleep(3000); // } // //catch // //{ // // attempts ++; // //} // //if (attempts <= 0) continue; // //Thread.Sleep(1000); // //SetControlValue(); // //delayCount--; //} } catch (Exception e) { _messagesProvider.Warn($"Unable to perform of set value to control operation. AutomationId: {AutomaitonId}, Name: {Name}, Value: {value}"); _messagesProvider.Log(e.ToString()); } }
public SmartShipmentSettingDialogPresenter(IApplicationController controller, ISmartSettingsDialogView view, ISettings settings, IAcumaticaNetworkProvider acumaticaNetworkProvider, ISmartShipmentMessagesProvider messagesProvider) : base(controller, view) { _acumaticaNetworkProvider = acumaticaNetworkProvider; _messagesProvider = messagesProvider; View.OnSettingsSave += () => { if (!settings.Validate()) { _messagesProvider.Warn(InformationResources.WARN_PARAMETERS_ARE_NOT_SAVED); View.Form.DialogResult = DialogResult.None; } settings.Save(); }; View.OnSettingsCancel += settings.Reload; View.OnTestLoginClick += View_OnTestLoginClick; View.OnFormLoad += () => { View.Form.BringToFront(); View.TextAcumaticaBaseUrl.Focus(); }; BindControlsToDataSource(settings); SetDefaults(settings); View.SetFormAttributes(); }
public void Start(IApplicationController applicationController, SingleInstanceApplication app) { _applicationController = applicationController; if (_app == null && _applicationController != null) { _app = app; _app.StartupNextInstance += _app_StartNewInstance; _app.Startup += _app_Startup; _app.Shutdown += _app_Shutdown; if (_settings.IsSettingsRequireSetValues()) { _messagesProvider.Info(InformationResources.MESSAGE_PARAMETERS_NEED_BE_INSTALLED); InitSettingsForm(); } if (_settings.IsSettingsRequireSetValues()) { _messagesProvider.Warn(InformationResources.MESSAGE_PARAMETERS_NOT_INSTALLED); return; } InitMainForm(); _app.Run(Environment.GetCommandLineArgs()); } }
public void RunShipmentApplication(IShipmentApplicationHelper applicationHelper, string shipmentNbr = null) { try { var shipment = GetShipment(shipmentNbr); //Validate shipment var shipmentValidationResult = new ShipmentValidationContext(shipment, _acumaticaNetworkProvider).Validate(); if (shipmentValidationResult.Any()) { _messagesProvider.Warn(shipmentValidationResult.First().Value); return; } if (applicationHelper.RunShipmentApplication(shipment.ShipmentNbr.Value) && applicationHelper.PopulateApplicaitonControlMap()) { _messagesProvider.Log(string.Format(InformationResources.INFO_RECEIVED_SHIPMENT, shipment.ShipmentNbr.Value, shipment.Packages.Count)); applicationHelper.PopulateApplicaitonByShipmentData(shipment); } } catch (Exception e) { if (!(e is NetworkException)) //IAcumaticaNetworkProvider handles own errors someself { _messagesProvider.Fatal(e); } } }
protected bool CheckShipmentProgrammWarnings(ISmartShipmentMessagesProvider messagesProvider) { if (IsWarnDialogFired) { StopTimer(); messagesProvider.Warn(InformationResources._WARN_INCORRECT_DATA_AND_DIALOGS); return(true); } return(false); }
protected bool CheckShipmentFieldsFilled(List <ShipmentAutomationControl> requiredShipmentPanes, ISmartShipmentMessagesProvider messagesProvider) { var notValidFields = CheckRequiredFieldsFilled(requiredShipmentPanes); if (!notValidFields.Any()) { return(true); } else { messagesProvider.Warn(string.Format(InformationResources.WARN_NOT_ALL_FIELDS_FILLED, string.Join(", ", notValidFields.Select(c => c.Name)))); return(false); } }
private void View_OnTestLoginClick() { try { View.TestButton.Enabled = false; _acumaticaNetworkProvider.TestNetworkSettings(); _messagesProvider.Info(InformationResources.INFO_CHECK_NETWORK_PARAMETERS); } catch (Exception e) { _messagesProvider.Warn(string.Format(InformationResources.ERROR_CHECK_NETWORK_PARAMETERS, InformationResources.Warn_Invalid_credentials_or_URL_string, e.Message)); } finally { View.TestButton.Enabled = true; } }
public void UpdateShipment(Shipment shipment, ISmartShipmentMessagesProvider messagesProvider) { if (_settings.AcumaticaConfirmShipment && shipment.Packages.All(p => !string.IsNullOrEmpty(p.TrackingNumber.Value))) //User ship shipment and { var invokeResult = _soapClient.Invoke(shipment, new ConfirmShipment()); var processResult = _soapClient.GetProcessStatus(invokeResult); while (processResult.Status == ProcessStatus.InProcess) { Thread.Sleep(1000); //pause for 1 second processResult = _soapClient.GetProcessStatus(invokeResult); } } else if (_settings.AcumaticaConfirmShipment && shipment.Packages.All(p => string.IsNullOrEmpty(p.TrackingNumber.Value))) { messagesProvider.Warn(string.Format(InformationResources.WARN_SHIPMENT_IS_CONFIRMED_AND_CANNOT_BE_UPDATED, shipment.ShipmentNbr.Value)); } else { _soapClient.Put(shipment); } }