Beispiel #1
0
        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;
        }
Beispiel #2
0
 private void ShowWindowIfNewPosition(Position pos, DecisionHandler action)
 {
     string[] questions = new string[] {"Czy chcesz przerwac?", "Szczegoly: " + pos.ToString()};
     OkCancelForm<QuestionUserCtrl> dlg =
         new OkCancelForm<QuestionUserCtrl>(20, questions);
     
     dlg.HandleUserDecison += action;
     dlg.Show();
 }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        public Position GetCurrentPosition()
        {
            CallTrace("Getting current position..");

            int value = 0;
            Ie.GoTo(Navig.UrlPosition);

            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(value);
            CallTrace("Current position: " + pos.ToString());

            return pos;
        }
Beispiel #6
0
        public bool ChangePositionTo(Position newPosition)
        {
            CallTrace("Change position called to: " + newPosition.ToString());
            Ie.GoTo(Navig.UrlNewOrder);

            string s = Ie.Html;
            //PL0GF0000281 - U09
            //PL0GF0000281 - Z09
            //{"No item was found in the selectlist matching constraint: Attribute 'value' equals 'PL0GF0000281' ignoring case"}
            try
            {
                Ie.SelectList(Find.ByName("SecCode")).SelectByValue("PL0GF0000281"); //fw20
                Ie.SelectList(Find.ByName("OrdType")).SelectByValue(newPosition.Direct); //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);

                try
                {
                    Ie.Button(Find.ByName("bc")).Click(); //przelicz 
                }
                catch(ElementDisabledException)
                {
                    //swallow ex, only for Live testing, when after session
                }
            }
            catch (Exception ex)
            {
                string mess = "Failed to place order on account: " + acc.Id + "\n";
                Exception excc = new Exception(mess, ex);
                logSpider.Fatal(excc);
                logGuilog.Fatal(mess + "Most likely contract not added to list!");
                return false;
            }

            if (EnableOrdering)
            {
                try
                {
                    CallTrace("Executing order...");
                    var confirmDialogHandler = new ConfirmDialogHandler();
                    Ie.DialogWatcher.Add(confirmDialogHandler);

                    try
                    {
                        Ie.Button(Find.ByName("bs")).ClickNoWait(); //ORDER !!!
                    }
                    catch (ElementDisabledException)
                    {
                        //swallow ex, only for Live testing, when after session
                    }
                    
                    confirmDialogHandler.WaitUntilExists();
                    confirmDialogHandler.OKButton.Click(); //CONFIRM
                    Ie.WaitForComplete();
                    Ie.DialogWatcher.RemoveAll(confirmDialogHandler); 
                }
                catch (Exception ex)
                {
                    string mess = "Failed to execute order on account: " + acc.Id + "\n";
                    Exception excc = new Exception(mess, ex);
                    logSpider.Fatal(excc);
                    logGuilog.Fatal(mess);
                    return false;
                }
            }

            CallTrace("Change position OK. CurrentPos: " + newPosition.ToString());
            return true;
        }