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 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 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 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); } } }
public void Start() { Task.Factory.StartNew(() => { var upsExportWatcher = _applicationController.GetContainer().Resolve <ISmartShipmentFileWatcher>(); var upsFileProvider = _applicationController.GetContainer().Resolve <ISmartShipmentFileProvider>(ApplicationTypes.UpsWorldShip.ToString()); _messagesProvider.Log(string.Format(InformationResources.INFO_START_EXPORTFILE_MONITORING, _settings.UpsExportFilePath)); upsExportWatcher.InitFileWatcher(upsFileProvider, _settings.UpsExportFilePath); }); Task.Factory.StartNew(() => { var fedexExportWatcher = _applicationController.GetContainer().Resolve <ISmartShipmentFileWatcher>(); var fedexFileProvider = _applicationController.GetContainer().Resolve <ISmartShipmentFileProvider>(ApplicationTypes.FedExShipmentManager.ToString()); _messagesProvider.Log(string.Format(InformationResources.INFO_START_EXPORTFILE_MONITORING, _settings.FedexExportFilePath)); fedexExportWatcher.InitFileWatcher(fedexFileProvider, _settings.FedexExportFilePath); }); }
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); } }
protected void ProcessDataFile(string fileName, IReadOnlyCollection <string> exportFileData) { var rowCount = exportFileData.Count; var exportedData = ParseExportedData(exportFileData); try { var shipmentFileExportRows = exportedData.ToShipmentExportedRows(ExportParameterParser); _exportContext.ExportData(shipmentFileExportRows).UpdateAcumatica(); _messagesProvider.Log(string.Format(InformationResources.INFO_EXPORT_FILE_PROCESSED, fileName, rowCount)); } finally { ClearFile(fileName, exportFileData); } }
public void UpdateShipments(List <Shipment> shipments, ISmartShipmentExportContext smartShipmentExportContext, ref string currentProcessedShipmentNumber) { using (var soapClient = new ShipmentSoapClient(_settings)) { foreach (var shipment in shipments.ToList()) { currentProcessedShipmentNumber = shipment.ShipmentNbr.Value; var targetShipment = soapClient.GetShipmentByShipmentId(shipment.ShipmentNbr.Value); smartShipmentExportContext.MapTargetToExportedShipment(targetShipment, shipment); soapClient.UpdateShipment(targetShipment, _messagesProvider); } } if (shipments.Any() && shipments.Last() != null) { _browserHelper.ReloadActiveBrowserPage(shipments.Last().ShipmentNbr.Value); } var shipmentsNumbers = shipments.Select(s => s.ShipmentNbr.Value); _messagesProvider.Log(string.Format(InformationResources.INFO_SUCCESS_UPDATE_SHIPMENT, shipments.Count, string.Join(", ", shipmentsNumbers))); }
private void _app_Shutdown(object sender, EventArgs e) { _messagesProvider.Log(InformationResources.INFO_APPLICATION_STOPED); }
public void Save() { _messagesProvider.Log(InformationResources.INFO_PROPERTIES_SAVED); _settings.Save(); }