private void InternalTransfer()
        {
            var s = Computing.ComputeChecksum("001168340011225033158321");

            try
            {
                var action    = new AccountActionModel(eActionType.InternalTransfer, DestinationOwnerName, DestinationIdNumber, OwnerName, BankIdNumber, Title, Amount);
                var actionDto = Mapper.Map <AccountActionDto>(action);
                ErrorLabel = Visibility.Hidden;
                using (var client = new Service.AccountManagerClient())
                {
                    var result = client.Transfer(actionDto);
                    if (result.Success())
                    {
                        _navigationService.NavigateTo("BankPage", "");
                    }
                    else
                    {
                        ErrorMessage = result.Result.ExceptionMessage;
                        ErrorLabel   = Visibility.Visible;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                ErrorLabel   = Visibility.Visible;
            }
        }
        public void TestRaiseValueChanged2()
        {
            Order order = new Order();
            PropertyAccessing <string> propertyAccessing = new Computing <Order>(() => order.ParentOrder).PropertyAccessing <string>("Num").For(consumer);
            string result = null;
            bool   raised = false;

            propertyAccessing.PropertyChanged += (sender, eventArgs) =>
            {
                if (eventArgs.PropertyName != nameof(PropertyAccessing <string> .Value))
                {
                    return;
                }
                string currentResult = propertyAccessing.Value;
                raised = true;
                Assert.AreEqual(currentResult, result);
            };

            Assert.IsTrue(propertyAccessing.Value == null);

            result                = null;
            order.ParentOrder     = new Order();
            result                = "1";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result = "2";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);

            result                = null;
            order.ParentOrder     = new Order();
            result                = "3";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result            = null;
            order.ParentOrder = null;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result                = null;
            order.ParentOrder     = new Order();
            result                = "4";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result = null;
            consumer.Dispose();
        }
Beispiel #3
0
        public void TestComputingsExecutingUserCode()
        {
            OcConfiguration.TrackComputingsExecutingUserCode = true;
            _computing = new Computing <int>(() => test());
            OcConsumer consumer = new OcConsumer();

            _computing.For(consumer);
            consumer.Dispose();
        }
 public TradesPosition(IReadScalar <decimal> buy, IReadScalar <decimal> sell, IReadScalar <int> count,
                       OcConsumer consumer)
 {
     Buy       = buy;
     Sell      = sell;
     _count    = count;
     Position  = new Computing <decimal>(() => Buy.Value - Sell.Value).For(consumer);
     CountText = new Computing <string>(() => "Order".Pluralise(_count.Value)).For(consumer);
     Negative  = new Computing <bool>(() => Position.Value < 0).For(consumer);
 }
Beispiel #5
0
        public async Task Delete(Guid item)
        {
            Computing comput = await unitOfWork.ComputingsRepository.GetById(item);

            if (comput == null)
            {
                return;
            }
            unitOfWork.ComputingsRepository.Delete(comput);
            await unitOfWork.Save();
        }
Beispiel #6
0
        public async Task <ComputingViewModel> Insert(ComputingCreateViewModel model)
        {
            Computing computing = mapper.Map <ComputingCreateViewModel, Computing>(model);

            computing.Outcome = computingModule.CountOperation(model.Expression);

            await unitOfWork.ComputingsRepository.Insert(computing);

            await unitOfWork.Save();

            return(mapper.Map <Computing, ComputingViewModel>(computing));
        }
Beispiel #7
0
        public void TestRaiseValueChanged2()
        {
            Order  order             = new Order();
            var    propertyAccessing = new Computing <Order>(() => order.ParentOrder).PropertyAccessing <string>("Num");
            string result            = null;
            bool   raised            = false;

            propertyAccessing.PropertyChanged += (sender, eventArgs) =>
            {
                string currentResult = propertyAccessing.Value;
                raised = true;
                Assert.AreEqual(currentResult, result);
            };

            Assert.IsTrue(propertyAccessing.Value == null);

            result                = null;
            order.ParentOrder     = new Order();
            result                = "1";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result = "2";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);

            result                = null;
            order.ParentOrder     = new Order();
            result                = "3";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result            = null;
            order.ParentOrder = null;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;

            result                = null;
            order.ParentOrder     = new Order();
            result                = "4";
            order.ParentOrder.Num = result;
            Assert.IsTrue(raised);
            Assert.AreEqual(propertyAccessing.Value, result);
            raised = false;
        }
        public void TestRaiseValueChanged()
        {
            bool  raised = false;
            Order order  = new Order();
            Computing <string> computing = new Computing <string>(() => order.Num).For(consumer);

            computing.PropertyChanged += (sender, args) => { if (args.PropertyName == "Value")
                                                             {
                                                                 raised = true;
                                                             }
            };
            order.Num = "1";
            Assert.IsTrue(raised);
        }
Beispiel #9
0
            public Item(int num, int num2, OcDispatcher mainOcDispatcher, OcDispatcher backgroundOcDispatcher)
            {
                _num  = num;
                _num2 = num2;
                _numBackgroundToMainDispatching        = new PropertyDispatching <Item, int>(this, nameof(Num), mainOcDispatcher, backgroundOcDispatcher).For(Consumer);
                _num2MainToBackgroundDispatching       = new PropertyDispatching <Item, int>(this, nameof(Num2), backgroundOcDispatcher, mainOcDispatcher).For(Consumer);
                _numBackgroundToMainScalarDispatching  = new Computing <int>(() => Num).ScalarDispatching(mainOcDispatcher, backgroundOcDispatcher).For(Consumer);
                _num2MainToBackgroundScalarDispatching = new Computing <int>(() => Num2).ScalarDispatching(backgroundOcDispatcher, mainOcDispatcher).For(Consumer);

                _numBackgroundToMainScalarDispatching.SetValueRequestHandler = i =>
                {
                    backgroundOcDispatcher.Invoke(() => Num = i);
                };

                _num2MainToBackgroundDispatching.PropertyChanged += (sender, args) =>
                {
                    if (Thread.CurrentThread != backgroundOcDispatcher._thread)
                    {
                        throw new Exception("Wrong thread");
                    }
                };

                _num2MainToBackgroundScalarDispatching.PropertyChanged += (sender, args) =>
                {
                    if (Thread.CurrentThread != backgroundOcDispatcher._thread)
                    {
                        throw new Exception("Wrong thread");
                    }
                };

                _numBackgroundToMainDispatching.PropertyChanged += (sender, args) =>
                {
                    if (Thread.CurrentThread != mainOcDispatcher._thread)
                    {
                        throw new Exception("Wrong thread");
                    }
                };

                _numBackgroundToMainScalarDispatching.PropertyChanged += (sender, args) =>
                {
                    if (Thread.CurrentThread != mainOcDispatcher._thread)
                    {
                        throw new Exception("Wrong thread");
                    }
                };
            }
Beispiel #10
0
 public void Login(object parameter)
 {
     using (var client = new Service.AuthorizationClient())
     {
         var passwordBox  = parameter as PasswordBox;
         var passwordHash = Computing.Sha256(passwordBox.Password);
         var result       = client.AuthenticateUser(this._userName, passwordHash);
         if (result.Result.Status == eOperationStatus.Success)
         {
             var userModel = Mapper.Map <UserModel>(result.Data);
             _navigationService.NavigateTo("BankPage", userModel);
         }
         else
         {
             ErrorLabel = Visibility.Visible;
         }
     }
 }
Beispiel #11
0
        public void TestScalarDefaultValue()
        {
            Computing <int> computing = new Computing <int>(() => 1).SetDefaultValue(3);

            Assert.IsTrue(computing.IsDefaulted);
            Assert.AreEqual(computing.Value, 3);

            OcConsumer consumer = new OcConsumer();

            computing.For(consumer);
            Assert.IsFalse(computing.IsDefaulted);
            Assert.AreEqual(computing.Value, 1);

            consumer.Dispose();
            Assert.IsTrue(computing.IsDefaulted);
            Assert.AreEqual(computing.Value, 3);
            computing.SetDefaultValue(5);
            Assert.AreEqual(computing.Value, 5);
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            int TotalNumber = 17099033;                       //the totalNumber of the serial number,for example:17099033
            int QuotaNumber = 6383;                           //the totalNumber of quota

            int[]     myNumber  = { 000000, 111111, 222222 }; //your codes which you find via the FindCode.py
            Computing computing = new Computing(TotalNumber, QuotaNumber, myNumber);

            for (int i = 0; i < 10; i++)
            {
                computing.setBaseline(i * 100000);
                ThreadStart thread1      = new ThreadStart(computing.Thread1);
                Thread      childThread1 = new Thread(thread1);
                childThread1.Start();

                ThreadStart thread2      = new ThreadStart(computing.Thread2);
                Thread      childThread2 = new Thread(thread2);
                childThread2.Start();

                ThreadStart thread3      = new ThreadStart(computing.Thread3);
                Thread      childThread3 = new Thread(thread3);
                childThread3.Start();

                ThreadStart thread4      = new ThreadStart(computing.Thread4);
                Thread      childThread4 = new Thread(thread4);
                childThread4.Start();

                ThreadStart thread5      = new ThreadStart(computing.Thread5);
                Thread      childThread5 = new Thread(thread5);
                childThread5.Start();

                childThread1.Join();
                childThread2.Join();
                childThread3.Join();
                childThread4.Join();
                childThread5.Join();
            }
            Console.WriteLine("共计:{0}", computing.LukyNumber);
            Double probability = computing.LukyNumber / 1000000D;

            Console.WriteLine("中签概率为:{0:F6}", probability);
        }
Beispiel #13
0
        static void GetUpdate()
        {
            using (var webClient = new WebClient())
            {
                //Console.WriteLine("Запрос обновления {0}", LastUpdateID + 1);
                string response = webClient.DownloadString("https://api.telegram.org/bot" + Token + "/getUpdates" + "?offset=" + (LastUpdateID + 1));

                var N = JSON.Parse(response);



                foreach (JSONNode r in N["result"].AsArray)
                {
                    LastUpdateID = r["update_id"].AsInt;
                    Console.WriteLine("Пришло сообщение: {0}", r["message"]["text"]);


                    SendMessage(Computing.Comp(r["message"]["text"]).ToString(), r["message"]["chat"]["id"].AsInt);
                }
            }
        }
Beispiel #14
0
        public ParentViewModel(Person parent, ObservableCollection <Person> people, ObservableCollection <Relation> relations, Action <ParentViewModel> editAction, OcConsumer consumer)
        {
            _consumer  = consumer;
            _people    = people;
            _relations = relations;

            Parent = parent;

            Children = relations.Filtering(r => r.Parent == parent).Selecting(r => r.Child).For(_consumer);

            ChildrenNames =
                new Computing <string>(() =>
                                       Children.Count == 0
                                         ? "<None>"
                                         : Children
                                       .Selecting(c => c.Name)
                                       .Ordering(cn => cn)
                                       .StringsConcatenating(", ").Value)
                .For(_consumer);

            EditCommand = new Command(() => editAction(this));
        }
        public PagedDataViewer(ITradeService tradeService, SearchHints searchHints)
        {
            SearchHints = searchHints;

            SortParameters = new SortParameterData(
                tradeService.Live
                .Selecting(t => new TradeProxy(t))
                .CollectionDisposing(),
                _consumer);

            AllData =
                new Computing <ObservableCollection <TradeProxy> >(
                    () => SortParameters.SelectedItem.SortedData)
                .Filtering(t =>
                           t.Trade.CurrencyPair.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase) ||
                           t.Trade.Customer.Contains(SearchHints.SearchTextThrottled.Value, StringComparison.OrdinalIgnoreCase));

            Data = AllData.Paging(25, 1).For(_consumer);

            _nextPageCommand     = new Command(() => Data.CurrentPage = Data.CurrentPage + 1, () => Data.CurrentPage < Data.PageCount);
            _previousPageCommand = new Command(() => Data.CurrentPage = Data.CurrentPage - 1, () => Data.CurrentPage > 1);
        }
        public void TestComputing()
        {
            Item       item     = new Item(0, "0");
            OcConsumer consumer = new OcConsumer();

            Expression <Func <int> > valueExpression = () => item.Id;
            Computing <int>          computing       = new Computing <int>(valueExpression);

            Assert.AreEqual(computing.GetValueExpression, valueExpression);
            Differing <int> differing = computing.Differing();

            item.Computing = computing;

            bool activationInProgress   = true;
            bool inActivationInProgress = false;

            computing.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "ActivationInProgress" || args.PropertyName == "InactivationInProgress")
                {
                    return;
                }
                Assert.AreEqual(computing.ActivationInProgress, activationInProgress);
                Assert.AreEqual(computing.InactivationInProgress, inActivationInProgress);
            };

            differing.For(consumer);

            activationInProgress = false;
            Assert.IsTrue(computing.Consumers.Contains(consumer));

            Assert.IsTrue(((IComputingInternal)differing).Consumers.Contains(consumer));
            Assert.IsTrue(computing.UserCodeIsCalledFrom == null);

            Action <int> computingSetValueRequestHandler = i =>
            {
                item.Id = i;
            };

            computing.SetValueRequestHandler += computingSetValueRequestHandler;
            Assert.AreEqual(computing.SetValueRequestHandler, computingSetValueRequestHandler);

            bool disposing = false;

            int value = 1;

            computing.PreValueChanged += (sender, args) =>
            {
                if (disposing)
                {
                    return;
                }
                Assert.AreEqual(computing.NewValue, value);
                Assert.AreEqual(computing.NewValueObject, value);
                Assert.AreEqual(computing.HandledEventSender, item);
                Assert.AreEqual(computing.HandledEventArgs, item._lastPropertyChangedEventArgs);
            };

            computing.PostValueChanged += (sender, args) =>
            {
                if (disposing)
                {
                    return;
                }
                Assert.AreEqual(computing.NewValue, value);
                Assert.AreEqual(computing.NewValueObject, value);
                Assert.AreEqual(computing.HandledEventSender, item);
                Assert.AreEqual(computing.HandledEventArgs, item._lastPropertyChangedEventArgs);
            };

            computing.Value = 1;

            Assert.AreEqual(computing.Value, 1);
            Assert.AreEqual(computing.ValueObject, 1);

            value = 2;
            computing.ValueObject = 2;

            Assert.AreEqual(computing.Value, 2);
            Assert.AreEqual(computing.ValueObject, 2);

            Assert.AreEqual(computing.ValueType, typeof(int));

            Assert.IsNotNull(computing.ToString());

            computing.DebugTag = "DebugTag";
            Assert.AreEqual(computing.DebugTag, "DebugTag");

            computing.Tag = "Tag";
            Assert.AreEqual(computing.Tag, "Tag");

            Assert.IsTrue(computing.IsActive);

            Assert.IsTrue(computing.IsConsistent);

            Assert.IsNotNull(computing.ToString());

            if (OcConfiguration.SaveInstantiationStackTrace)
            {
                Assert.IsNotNull(computing.InstantiationStackTrace);
            }


            disposing = true;
            inActivationInProgress = true;
            consumer.Dispose();
        }
Beispiel #17
0
        public async Task <ComputingViewModel> GetComputingById(Guid id)
        {
            Computing countings = await unitOfWork.ComputingsRepository.GetById(id);

            return(mapper.Map <Computing, ComputingViewModel>(countings));
        }
Beispiel #18
0
        public void DoSetDebugTagTest()
        {
            Computing <string> computing = new Computing <string>(() => "").Do(c => c.SetDebugTag("DebugTag"));

            Assert.AreEqual(computing.DebugTag, "DebugTag");
        }