Exemple #1
0
        private void CommunicationOnBlocksReceived(object sender, IReadOnlyList <IBlock> blocks)
        {
            if (Logger != null)
            {
                Logger.Log($"<Dispatcher> Blocks received: {blocks.Count}\r\n");
            }

            foreach (var blk in blocks)
            {
                if (blk == null)
                {
                    continue;
                }

                if (blk.StartLine.IndexOf("EVENT", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    if (Logger != null)
                    {
                        Logger.LogNetwork(blk.NativeBlock.Trim() + "\r\n");
                    }
                }

                if (_dataProvider != null)
                {
                    _dataProvider.Add(blk);
                }
            }

            if (UpdateUi != null)
            {
                UpdateUi(this, _trackWeaver);
            }
        }
        public ActionResult AddSchedule([DataSourceRequest] DataSourceRequest request, Schedule schedule)
        {
            if (schedule != null && ModelState.IsValid)
            {
                DataProvider.Add(schedule);
            }

            return(Json(new[] { schedule }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult AddTrailVisit(TrialVisit trialVisit)
        {
            if (trialVisit != null && ModelState.IsValid)
            {
                DataProvider.Add(trialVisit);
            }

            return(GetProceduresEditor(trialVisit.TrialCode, trialVisit.TrialVersion));
        }
Exemple #4
0
        public ActionResult AddTrial([DataSourceRequest] DataSourceRequest request, Trial trial)
        {
            if (trial != null && ModelState.IsValid)
            {
                DataProvider.Add(trial);
            }

            return(Json(new[] { trial }.ToDataSourceResult(request, ModelState)));
        }
Exemple #5
0
        public ActionResult AddCity([DataSourceRequest] DataSourceRequest request, City city)
        {
            if (city != null && ModelState.IsValid)
            {
                DataProvider.Add(city);
            }

            return(Json(new[] { city }.ToDataSourceResult(request, ModelState)));
        }
Exemple #6
0
        public ActionResult AddTrialIncomeArticle([DataSourceRequest] DataSourceRequest request, TrialIncomeArticle article)
        {
            if (article != null && ModelState.IsValid)
            {
                DataProvider.Add(article);
            }

            return(Json(new[] { article }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult AddUser([DataSourceRequest] DataSourceRequest request, User user)
        {
            if (user != null && ModelState.IsValid)
            {
                DataProvider.Add(user);
            }

            return(Json(new[] { user }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult AddProcedureGroup([DataSourceRequest] DataSourceRequest request, ProcedureGroup procedureGroup)
        {
            if (procedureGroup != null && ModelState.IsValid)
            {
                DataProvider.Add(procedureGroup);
            }

            return(Json(new[] { procedureGroup }.ToDataSourceResult(request, ModelState)));
        }
    void OnAddButtonClicked()
    {
        var id   = DataProvider.Count;
        var data = new ExampleListViewData(id, DataProvider);

        data.StringName.Value = "data" + id;

        DataProvider.Add(data);
    }
        public ActionResult AddProcedureRole([DataSourceRequest] DataSourceRequest request, ProcedureDefaultRole procedureRole)
        {
            if (procedureRole != null && ModelState.IsValid)
            {
                DataProvider.Add(procedureRole);
            }

            return(Json(new[] { procedureRole }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult AddPatient([DataSourceRequest] DataSourceRequest request, Patient patient)
        {
            if (patient != null && ModelState.IsValid)
            {
                DataProvider.Add(patient);
            }

            return(Json(new[] { patient }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult AddHospital([DataSourceRequest] DataSourceRequest request, Hospital hospital)
        {
            if (hospital != null && ModelState.IsValid)
            {
                DataProvider.Add(hospital);
            }

            return(Json(new[] { hospital }.ToDataSourceResult(request, ModelState)));
        }
Exemple #13
0
        public ActionResult AddTrialCenterProcedureRole([DataSourceRequest] DataSourceRequest request, TrialCenterProcedureRole role)
        {
            if (role != null && ModelState.IsValid)
            {
                DataProvider.Add(role);
            }

            return(Json(role));
        }
        public ActionResult AddTrialVisitMaterial([DataSourceRequest] DataSourceRequest request, TrialVisitMaterial trialVisitMaterial)
        {
            if (trialVisitMaterial != null && ModelState.IsValid)
            {
                DataProvider.Add(trialVisitMaterial);
            }

            var material = DataProvider.GetItem(new TrialMaterialDataFilter {
                Id = trialVisitMaterial.TrialMaterialId
            });

            return(Json(new[] { TrialVisitMaterialViewModel.Create(trialVisitMaterial, material == null ? null : material.Name) }
                        .ToDataSourceResult(request, ModelState)));
        }
        public void setData( List<OrderDataModel> orders )
        {
            OrderDataModel order = null;
            DataProvider data = new DataProvider();
            for (int i = 0; i < orders.Count; i++)
            {
                order = orders[i];
                data.Add(new RowDataProvider());
                data[i].id = i;

                data[i].Add(new GridColumnData());
                data[i][0].value = order.orderID.ToString();
                data[i][0].numeric = order.orderID;

                data[i].Add(new GridColumnData());
                data[i][1].value = order.orderStatus;
                data[i][1].numeric = order.orderStatus.Equals("closed") ? 0 : 1;

                data[i].Add(new GridColumnData());
                data[i][2].value = order.openDate.ToString();
                data[i][2].numeric = (int)(order.openDate.Ticks / 10000);

                data[i].Add(new GridColumnData());
                data[i][3].value = order.completionDate.ToString();
                data[i][3].numeric = (int)(order.completionDate.Ticks / 10000);

                data[i].Add(new GridColumnData());
                data[i][4].value = string.Format("{0:C}", order.orderFee);
                data[i][4].numeric = (int)(order.orderFee * 100);

                data[i].Add(new GridColumnData());
                data[i][5].value = order.orderType;
                data[i][5].numeric = order.orderType.Equals("buy") ? 1 : 0;

                data[i].Add(new GridColumnData());
                data[i][6].value = order.symbol;
                data[i][6].numeric = (int)(order.quantity * 100);

                data[i].Add(new GridColumnData());
                data[i][7].value = order.quantity.ToString();
                data[i][7].numeric = (int)(order.quantity * 100);
            }

            OrderGrid.setData(data);
        }
        public ActionResult UpdateScheduleVisit([DataSourceRequest] DataSourceRequest request, ScheduleVisit scheduleVisit)
        {
            //если дата не выбрана и не отменен визит
            if (!scheduleVisit.ScheduleDate.HasValue && !scheduleVisit.Canceled)
            {
                ModelState.AddModelError("ScheduleDate", "Дата не введена");
            }

            if (ModelState.IsValid)
            {
                if (scheduleVisit.Id.HasValue)
                {
                    DataProvider.Update(scheduleVisit);
                }
                else
                {
                    DataProvider.Add(scheduleVisit);
                }
            }

            return(Json(new[] { scheduleVisit }.ToDataSourceResult(request, ModelState)));
        }
Exemple #17
0
        public ActionResult UpdateScheduleVisit([DataSourceRequest] DataSourceRequest request, ScheduleVisit scheduleVisit)
        {
            if (scheduleVisit != null && ModelState.IsValid)
            {
                if (!scheduleVisit.ScheduleDate.HasValue)
                {
                    throw new DataException("Дата планирования не задана");
                }

                if (scheduleVisit.Id.HasValue)
                {
                    DataProvider.Update(scheduleVisit);
                }
                else
                {
                    DataProvider.Add(scheduleVisit);
                }
            }



            return(Json(new[] { scheduleVisit }.ToDataSourceResult(request, ModelState)));
        }
        public void LoadData()
        {
            if (App.BSL == null || Login.UserInfo == null)
            {
                this.Visibility = Visibility.Hidden;
                return;
            }

            OrderDataModel order = null;
            if (Action == TradeAction.Buy)
            {
                try
                {
                    if ((order = App.BSL.buy(Login.UserInfo.profileID, Trade.ID, Trade.Quantity, 0)) != null)
                    {
                        AlertMessage("Order " + order.orderID + " to buy " + order.quantity + " shares of " + order.symbol + " has been submitted for processing.");
                    }
                    
                }
                catch (Exception ex)
                {
                    AlertMessage("Failed to process buy order, exception: " + ex.ToString());
                }
            }
            else if( Action == TradeAction.Sell )
            {
                try
                {
                    if (Trade.Quantity == 0)
                    {
                        order = App.BSL.sell(Login.UserInfo.profileID, Convert.ToInt32(Trade.ID), 0);
                    }
                    else
                    {
                        order = App.BSL.sellEnhanced(Login.UserInfo.profileID, Convert.ToInt32(Trade.ID), Trade.Quantity);
                    }
                    if (order != null)
                    {
                        AlertMessage("Order " + order.orderID + " to sell " + order.quantity + " shares of " + order.symbol + " has been submitted for processing.");
                    }
                }
                catch (Exception ex)
                {
                    AlertMessage("Failed to process sell order, Exception: " + ex.ToString());
                }
            }
            Action = TradeAction.None;

            try
            {
                List<OrderDataModel> orders = App.BSL.getOrders(Login.UserInfo.profileID);
                Update.Text = "as of " + DateTime.Now;
                DataProvider data = new DataProvider();
                for (int i = 0; i < orders.Count; i++)
                {
                    order = orders[i];
                    data.Add(new RowDataProvider());
                    data[i].id = i;

                    data[i].Add(new GridColumnData());
                    data[i][0].value = order.orderID.ToString();
                    data[i][0].numeric = order.orderID;

                    data[i].Add(new GridColumnData());
                    data[i][1].value = order.orderStatus;
                    data[i][1].numeric = order.orderStatus.Equals("closed") ? 0 : 1;

                    data[i].Add(new GridColumnData());
                    data[i][2].value = order.openDate.ToString();
                    data[i][2].numeric = (int)(order.openDate.Ticks / 10000);

                    data[i].Add(new GridColumnData());
                    data[i][3].value = order.completionDate.ToString();
                    data[i][3].numeric = (int)(order.completionDate.Ticks / 10000);

                    data[i].Add(new GridColumnData());
                    data[i][4].value = string.Format("{0:C}", order.orderFee);
                    data[i][4].numeric = (int)(order.orderFee * 100);

                    data[i].Add(new GridColumnData());
                    data[i][5].value = order.orderType;
                    data[i][5].numeric = order.orderType.Equals("buy") ? 1 : 0;

                    data[i].Add(new GridColumnData());
                    data[i][6].value = order.symbol;
                    data[i][6].numeric = (int)(order.quantity * 100);

                    data[i].Add(new GridColumnData());
                    data[i][7].value = order.quantity.ToString();
                    data[i][7].numeric = (int)(order.quantity * 100);
                }

                OrderGrid.setData(data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            this.Visibility = Visibility.Visible;
        }
Exemple #19
0
 IDataProviderDefinition IDataProviderDefinition.Provides <T>(string scope)
 {
     _dataProvider.Add <T>(scope);
     return(this);
 }
        public override void onSectionReady()
        {
            PortfolioGrid.ApplyEffects();

            // load data
            if (App.BSL == null || Login.UserInfo == null)
            {
                this.Visibility = Visibility.Hidden;
                return;
            }

            try
            {
                List<HoldingDataModel> holdings = App.BSL.getHoldings(Login.UserInfo.profileID);
                Update.Text = "as of " + DateTime.Now;
                DataProvider data = new DataProvider();
                List<PieElement> graphData = rowsGraphData = new List<PieElement>();
                for (int i = 0; i < holdings.Count; i++)
                {
                    QuoteDataModel quote = App.BSL.getQuote(holdings[i].quoteID);

                    decimal marketValue = (decimal)holdings[i].quantity * quote.price;
                    decimal basis = (decimal)holdings[i].quantity * (decimal)holdings[i].purchasePrice;
                    decimal gain = marketValue - basis;

                    graphData.Add(new PieElement(quote.symbol, (double)marketValue));


                    RowDataProvider row = new RowDataProvider();
                    row.id = i;

                    // id, date, symbol, quantity, purchase price, current price, basis, market value, gain, trade
                    row.Add(new GridColumnData());
                    row[0].value = holdings[i].holdingID.ToString();
                    row[0].numeric = holdings[i].holdingID;

                    row.Add(new GridColumnData());
                    row[1].value = holdings[i].purchaseDate.ToString();
                    row[1].numeric = (int)(holdings[i].purchaseDate.Ticks / 10000);

                    row.Add(new GridColumnData());
                    row[2].value = holdings[i].quoteID;
                    row[2].numeric = i;

                    row.Add(new GridColumnData());
                    row[3].value = string.Format("{0:0,0}", holdings[i].quantity);
                    row[3].numeric = (int)holdings[i].quantity;

                    row.Add(new GridColumnData());
                    row[4].value = string.Format("{0:C}", holdings[i].purchasePrice);
                    row[4].numeric = (int)(holdings[i].purchasePrice * 100);

                    row.Add(new GridColumnData());
                    row[5].value = string.Format("{0:C}", quote.price);
                    row[5].numeric = (int)(quote.price * 100);

                    row.Add(new GridColumnData());
                    row[6].value = string.Format("{0:C}", basis);
                    row[6].numeric = (int)(basis * 100);

                    row.Add(new GridColumnData());
                    row[7].value = string.Format("{0:C}", marketValue);
                    row[7].numeric = (int)(marketValue * 100);

                    row.Add(new GridColumnGainData());
                    row[8].value = string.Format("{0:C}", gain);
                    row[8].numeric = (int)(gain * 100);
                    (row[8] as GridColumnGainData).increased = gain == 0 ? 0 : (gain > 0 ? 1 : -1);

                    row.Add(new GridColumnData());
                    row[9].value = "SELL";
                    row[9].numeric = i;

                    data.Add(row);
                }

                PortfolioGrid.setData(data);
                ToolTip.setData(graphData);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            this.Visibility = Visibility.Visible;
        }
Exemple #21
0
        public override void onSectionReady()
        {
            if (App.BSL == null || Login.UserInfo == null)
            {
                this.Visibility = Visibility.Hidden;
                return;
            }

            Update.Text = "as of " + DateTime.Now;

            try
            {
                GetHoldingsAsync caller1 = new GetHoldingsAsync(GetHoldings);
                // Initiate the asychronous call.
                IAsyncResult result1 = caller1.BeginInvoke(null, null);
                // Repeat
                GetCustomerAsync caller2 = new GetCustomerAsync(GetCustomer);
                // Initiate the asychronous call.
                IAsyncResult result2 = caller2.BeginInvoke(null, null);
                MarketSummaryDataModelWS summary = App.BSL.getMarketSummary();
                List<HoldingDataModel> holdings = caller1.EndInvoke(result1);
                AccountDataModel customer = caller2.EndInvoke(result2);
                decimal marketValue = 0;
                decimal gain = 0;
                decimal basis = 0;
                decimal _gain = (decimal)0.00;
                decimal percentGain = (decimal)0.00;

                for (int i = 0; i < holdings.Count; i++)
                {
                    QuoteDataModel quote = App.BSL.getQuote(holdings[i].quoteID);
                    decimal _marketValue = (decimal)holdings[i].quantity * quote.price;
                    decimal _basis = (decimal)holdings[i].quantity * (decimal)holdings[i].purchasePrice;
                    gain += _marketValue - _basis;
                    marketValue += _marketValue;
                    basis += _basis;
                }

                AccountID.Text = customer.accountID.ToString();
                CreationDate.Text = customer.creationDate.ToString();
                LoginCount.Text = customer.loginCount.ToString();
                OpenBalance.Text = string.Format("{0:C}", customer.openBalance);
                Balance.Text = string.Format("{0:C}", customer.balance);
                NumHoldings.Text = holdings.Count.ToString();
                HoldingsTotal.Text = string.Format("{0:C}", marketValue);
                decimal totalcashandholdings = marketValue + customer.balance;
                SumOfCashHoldings.Text = string.Format("{0:C}", totalcashandholdings);
                _gain = totalcashandholdings - customer.openBalance;
                if (customer.openBalance != 0)
                    percentGain = gain / customer.openBalance * 100;
                else
                    percentGain = 0;

                Gain.Text = string.Format("{0:C}", _gain);
                PercentGain.Text = string.Format("{0:N}%", percentGain);
                if (_gain > 0)
                {
                    PercentGain.Foreground = new SolidColorBrush(Color.FromRgb(37, 120, 32));

                    GainIcon icon = new GainIcon();
                    icon.VerticalAlignment = VerticalAlignment.Bottom;
                    icon.HorizontalAlignment = HorizontalAlignment.Left;
                    icon.Margin = new Thickness(PercentGain.Margin.Left + PercentGain.ActualWidth + 40, PercentGain.Margin.Top, PercentGain.Margin.Right, PercentGain.Margin.Bottom);
                    LayoutRoot.Children.Add(icon);
                }
                else if (_gain < 0)
                {
                    PercentGain.Foreground = new SolidColorBrush(Color.FromRgb(191, 0, 0));
                    LossIcon icon = new LossIcon();
                    icon.VerticalAlignment = VerticalAlignment.Bottom;
                    icon.HorizontalAlignment = HorizontalAlignment.Left;
                    icon.Margin = new Thickness(PercentGain.Margin.Left + PercentGain.ActualWidth + 40, PercentGain.Margin.Top, PercentGain.Margin.Right, PercentGain.Margin.Bottom);
                    LayoutRoot.Children.Add(icon);

                }
                else
                    PercentGain.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));

                
                TSIA.Text = String.Format("{0:N}", summary.TSIA);
                Volume.Text = String.Format("{0:N}", summary.volume);

                DataProvider data = new DataProvider();
                for (int i = 0; i < summary.topGainers.Count; i++)
                {
                    QuoteDataModel quote = summary.topGainers[i];



                    RowDataProvider row = new RowDataProvider();
                    row.id = i;

                    // symbol, current price, gain
                    row.Add(new GridColumnData());
                    row[0].value = quote.symbol;
                    row[0].numeric = i;

                    row.Add(new GridColumnGainData());
                    row[1].value = string.Format("{0:C}", quote.price);
                    row[1].numeric = (int)(quote.price * 100);
                    (row[1] as GridColumnGainData).increased = quote.change == 0 ? 0 : (quote.change > 0 ? 1 : -1);

                    row.Add(new GridColumnGainData());
                    row[2].value = string.Format("{0:C}", quote.change);
                    row[2].numeric = (int)(quote.change * 100);
                    (row[2] as GridColumnGainData).increased = quote.change == 0 ? 0 : (quote.change > 0 ? 1 : -1);

                    data.Add(row);
                }

                GainGrid.setData(data);

                data = new DataProvider();
                for (int i = 0; i < summary.topLosers.Count; i++)
                {
                    QuoteDataModel quote = summary.topLosers[i];




                    RowDataProvider row = new RowDataProvider();
                    row.id = i;

                    // symbol, current price, gain
                    row.Add(new GridColumnData());
                    row[0].value = quote.symbol;
                    row[0].numeric = i;

                    row.Add(new GridColumnGainData());
                    row[1].value = string.Format("{0:C}", quote.price);
                    row[1].numeric = (int)(quote.price * 100);
                    (row[1] as GridColumnGainData).increased = quote.change == 0 ? 0 : (quote.change > 0 ? 1 : -1);

                    row.Add(new GridColumnGainData());
                    row[2].value = string.Format("{0:C}", quote.change);
                    row[2].numeric = (int)(quote.change * 100);
                    (row[2] as GridColumnGainData).increased = quote.change == 0 ? 0 : (quote.change > 0 ? 1 : -1);

                    data.Add(row);
                }

                LoseGrid.setData(data);

                SessionCreateDate.Text = Login.LoginTime.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            this.Visibility = Visibility.Visible;
        }
        public void LoadData()
        {
            // get quotes based on QuotesParameter
            if (App.BSL == null || Login.UserInfo == null) return;

            try
            {
                Update.Text = "as of " + DateTime.Now;
                GetQuote.Text = QuotesParameter;
                string[] quotes = QuotesParameter.Split(new char[] { ' ', ',', ';' });
                DataProvider data = new DataProvider();
                foreach (string quote in quotes)
                {
                    string quoteTrim = quote.Trim();
                    if (!quoteTrim.Equals(""))
                    {
                        QuoteDataModel quoteData = App.BSL.getQuote(quoteTrim);
                        if (quoteData == null) continue;

                        RowDataProvider row = new RowDataProvider();
                        data.Add(row);
                        row.id = data.Count - 1;

                        GridColumnData symbol = new GridColumnData();
                        symbol.value = quoteData.symbol;
                        symbol.numeric = (int)(quoteData.price * 100);
                        row.Add(symbol);

                        GridColumnData company = new GridColumnData();
                        company.value = quoteData.companyName;
                        company.numeric = (int)(quoteData.price * 100);
                        row.Add(company);

                        GridColumnData volume = new GridColumnData();
                        volume.value = string.Format("{0:0,0}", quoteData.volume);
                        volume.numeric = (int)(quoteData.volume * 100);
                        row.Add(volume);

                        GridColumnData range = new GridColumnData();
                        range.value = string.Format("{0:C}", quoteData.low) + " - " + string.Format("{0:C}", quoteData.high);
                        range.numeric = (int)(quoteData.low * 100);
                        row.Add(range);

                        GridColumnData open = new GridColumnData();
                        open.value = string.Format("{0:C}", quoteData.open);
                        open.numeric = (int)(quoteData.low * 100);
                        row.Add(open);

                        GridColumnGainData current = new GridColumnGainData();
                        current.value = string.Format("{0:C}", quoteData.price);
                        current.numeric = (int)(quoteData.price * 100);
                        current.increased = quoteData.change == 0 ? 0 : (quoteData.change > 0 ? 1 : -1);
                        row.Add(current);

                        GridColumnGainData gain = new GridColumnGainData();
                        gain.value = string.Format("{0:C}", quoteData.change);
                        gain.numeric = (int)(quoteData.change * 100);
                        gain.increased = quoteData.change == 0 ? 0 : (quoteData.change > 0 ? 1 : -1);
                        row.Add(gain);

                        GridColumnData buy = new GridColumnData();
                        buy.value = "BUY";
                        buy.numeric = (int)(quoteData.change * 100);
                        row.Add(buy);
                    }
                }

                QuoteGrid.setData(data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Exemple #23
0
 public IActionResult PostData([FromBody] Item data)
 {
     provider.Add(data);
     return(Ok());
 }
        public ActionResult AddTrialProcedureVisit(TrialProcedureVisit visit)
        {
            DataProvider.Add(visit);

            return(Json(visit));
        }