Beispiel #1
0
        public TransactionTO GetData(String token)
        {
            if (!mFilterManager.checkFilters(token))
            {
                return(null);
            }

            var random      = new Random();
            var amount      = random.Next() % 1001;
            var transaction = new TransactionTO(100.0f, amount, 1);

            return(transaction);
        }
Beispiel #2
0
        public void RegistryNewTransaction(TransactionTO t)
        {
            Stats.TotalAmount += t.Amount;

            //
            if (Stats.TotalAmount > 500)
            {
                State = new BuyState();
            }
            else if (Stats.TotalAmount > 1000)
            {
                State = new SellState();
            }

            Notify();
        }
Beispiel #3
0
        private void ListChanged(object sender, ListChangedEventArgs e)
        {
            //Console.WriteLine(e.ToString());

            if (e.ListChangedType.Equals(System.ComponentModel.ListChangedType.ItemAdded))
            {
                Console.WriteLine("zarejestrowanie nowej transakcji");
                if (bindingSource1.List[e.NewIndex].GetType().Equals(typeof(TransactionTO)))
                {
                    TransactionTO t = (TransactionTO)bindingSource1.List[e.NewIndex];
                    gui.RegistryNewTransaction(t);
                }
            }
            else if (e.ListChangedType.Equals(System.ComponentModel.ListChangedType.ItemChanged))
            {
                //// wyslanie zmodyfikowanego obiektu na serwer
                //Console.WriteLine("wyslanie zmodyfikowanego obiektu na serwer");
                //TransactionTO t = (TransactionTO)bindingSource1.List[e.NewIndex];

                //var sClient = new ServiceReference1.Service1Client();
                //sClient.Open();
                //bool result = sClient.Save(t);
                //sClient.Close();

                //if (result)
                //{
                //    MessageBox.Show("Zapisano zmiany");
                //}
                //else
                //{
                //    MessageBox.Show("Nie udało się zapisać zmian");
                //}

                //// dla celów dev, wyświetlenie obiektu w postaci json
                //MemoryStream stream1 = new MemoryStream();
                //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(TransactionTO));
                //ser.WriteObject(stream1, t);
                //stream1.Position = 0;
                //StreamReader sr = new StreamReader(stream1);
                //Console.Write("JSON of TransactionTO object: ");
                //Console.WriteLine(sr.ReadToEnd());
            }
        }
        public int UpdateOrInsert(TransactionTO t)
        {
            var existingT = GetSingle(t.ID);

            if (null == existingT)
            {
                // nowy rekord
                int newId = mData.Last().ID + 1;
                var newT  = new Transaction(t.Price, t.Amount, newId);
                mData.Add(newT);

                return(newId);
            }
            else
            {
                // aktualizacja rekordu
                existingT.Amount = t.Amount;
                existingT.Price  = t.Price;

                return(existingT.ID);
            }
        }
Beispiel #5
0
        public void Update()
        {
            TransactionTO t = Gui.LastTransaction;

            Robot.RegistryNewTransaction(t);
        }
Beispiel #6
0
        public TransactionTO GetLatestTransaction()
        {
            var trans = new TransactionTO(207.9f, 10000, 999);

            return(trans);
        }
Beispiel #7
0
 public void RegistryNewTransaction(TransactionTO t)
 {
     LastTransaction = t;
     Notify();
 }
Beispiel #8
0
        protected TransactionTO createTransferObject(Transaction src)
        {
            var dst = new TransactionTO(src.Price, src.Amount, src.ID);

            return(dst);
        }
Beispiel #9
0
        public int Insert(TransactionTO t)
        {
            var newId = mMP.UpdateOrInsert(t);

            return(newId);
        }
Beispiel #10
0
 public bool Delete(TransactionTO t)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public bool Update(TransactionTO t)
 {
     mMP.UpdateOrInsert(t);
     return(true);
 }
Beispiel #12
0
 public bool Save(TransactionTO t)
 {
     return(mDAO.Update(t));
 }