public override Position GetCurrentPosition() { Framework.CallTrace("Getting current position.."); int value = 0; Ie.GoTo(Links.Position); if (Ie.Tables.Count < 4) { string source = Ie.Html; throw new Exception("not logged in!"); } if (Ie.Tables[4].TableRows.Count > 2) { foreach (TableRow tr in Ie.Tables[4].TableRows) { if (tr.TableCells.Count > 1) { if (tr.TableCells[0].Text.StartsWith("FW20")) { value = tr.TableCells[2].Text.Parse<int>(); } } } } Position pos = new Position(0, value, DateTime.Now); Position = pos; Framework.CallTrace("Current position: " + pos.ToString()); return pos; }
public bool IsEqual(Position pos) { bool result = false; if (Direction == pos.Direction) { result = (Size == pos.Size); } return result; }
private async Task Init (GeoLocation geoLocation) { var location = new Position (geoLocation.Latitude, geoLocation.Longitude); var map = new CustomMap (MapSpan.FromCenterAndRadius (location, Distance.FromMiles (5))) { IsShowingUser = true }; //Show current location for Win Phone if (Device.OS == TargetPlatform.WinPhone) { map.CustomPins.Add (new CustomPin { Position = location, Label = "Current Location" }); } //Add the car wash pins Task.Run (async () => { var carWashPins = await _viewModel.GetMapPinsAsync (); Device.BeginInvokeOnMainThread (() => { foreach (var carWashPin in carWashPins) { map.CustomPins.Add (carWashPin); } }); }); var selectedPinLabel = new LargeLabel { HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black }; selectedPinLabel.BindingContext = map; selectedPinLabel.SetBinding<CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Label); var selectedPinAddress = new Label { HorizontalOptions = LayoutOptions.Center, TextColor = Color.Black }; selectedPinAddress.BindingContext = map; selectedPinAddress.SetBinding<CustomMap> (Label.TextProperty, vm => vm.SelectedPin.Address); var stack = new StackLayout { Spacing = 0, BackgroundColor = Color.FromHex ("#ecf0f1") }; map.VerticalOptions = LayoutOptions.FillAndExpand; stack.Children.Add (map); stack.Children.Add (selectedPinLabel); stack.Children.Add (selectedPinAddress); Content = stack; }
public override bool LookForNewPosition() { Framework.CallTrace("Looking for new position.."); bool result = false; Ie.GoTo(Links.Check4Changes); Frame fra = null; try { fra = Ie.Frame(Find.ByName("outlook1")); } catch (FrameNotFoundException ex) { Framework.CallTrace("RELOGING -> FrameNotFoundException"); Login(); fra = Ie.Frame(Find.ByName("outlook1")); } if (fra.Tables[0].TableRows.Count <= 1) return false; string operacja = fra.Tables[0].TableRows[1].TableCells[3].Text; int ilosc = fra.Tables[0].TableRows[1].TableCells[4].Text.Parse<int>(); if (operacja == "S") ilosc = ilosc*-1; Position pos = new Position(0, ilosc, DateTime.Now); if (!pos.IsEqual(Position)) //detect position change { Position = pos; result = true; Framework.CallTrace("New position detected -> " + pos.ToString()); } return result; }
public Position(Position pos) : this(pos.EntryPoint, pos.Size, pos.EntryDate) { }
public override bool ChangePositionTo(Position newPosition) { Framework.CallTrace("Change position called to: " + newPosition.ToString()); Ie.GoTo(Links.NewOrder); string s = Ie.Html; Ie.SelectList(Find.ByName("SecCode")).SelectByValue("PL0GF0000281"); //fw20 Ie.SelectList(Find.ByName("OrdType")).SelectByValue(newPosition.Direction); //order Ie.TextField(Find.ByName("OrdQty")).TypeText(newPosition.Size.ToString()); //size of position Ie.SelectList(Find.ByName("OrdLimitType")).SelectByValue("P"); //P = PKC Ie.WaitForComplete(1); Ie.Button(Find.ByName("bc")).Click(); //przelicz if (Framework.Inst.OrderingEnabled) { Framework.CallTrace("Executing order..."); var confirmDialogHandler = new ConfirmDialogHandler(); Ie.DialogWatcher.Add(confirmDialogHandler); Ie.Button(Find.ByName("bs")).ClickNoWait(); //ORDER !!! confirmDialogHandler.WaitUntilExists(); confirmDialogHandler.OKButton.Click(); //CONFIRM Ie.WaitForComplete(); Ie.DialogWatcher.RemoveAll(confirmDialogHandler); } Position = newPosition; Framework.CallTrace("Change position OK. CurrentPos: " + Position.ToString()); return true; }