/// <summary>
        /// 删除仪器管理系统仪器信息时同步删除业务系统中的仪器数据(注:这里只做逻辑删除,将仪器状态改为停用)
        /// </summary>
        /// <param name="itemCode"></param>
        /// <param name="businessType"></param>
        /// <returns></returns>
        public string DeleteInstrumentData(string instrumentJsonData)
        {
            string msg = "Error";

            try
            {
                InstrumentModel model = ToolsLib.Utility.CommonUtils.JsonDeserialize(instrumentJsonData, typeof(InstrumentModel)) as InstrumentModel;
                switch (model.InstrumentCate)
                {
                case (int)UtilConstants.LabType.MeasureLab:
                    WSProvider.MeasureLabProvider.DeleteInstrumentData(model.ItemCode, (int)UtilConstants.InstrumentState.停用);
                    break;

                case (int)UtilConstants.LabType.Environment:
                    WSProvider.Environment.DeleteInstrumentData(model.ItemCode, UtilConstants.InstrumentState.停用.GetHashCode());
                    break;

                case (int)UtilConstants.LabType.EMC:
                    //SBusiness.ServiceProvider.emcLabInstrumentService.UpdateRecordStateByItemCode(model.ItemCode, UtilConstants.InstrumentState.停用.GetHashCode());
                    break;
                }
                msg = "OK";
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                msg = ex.Message;
            }
            return(msg);
        }
Beispiel #2
0
        public string AddCirculationRecord(string barCode, string sOperator, string currentPosition, string reason, string accessToKen)
        {
            try
            {
                if (!ToKenHelper.CheckAccessToKen(accessToKen))
                {
                    return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = commonErrorMsg }));
                }

                InstrumentModel instrumentModel = ServiceProvider.InstrumentService.GetByBarCode(barCode);
                if (instrumentModel == null)
                {
                    return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = "不存在该设备!" }));
                }
                Global.Common.Models.UserModel user = Global.Business.ServiceProvider.UserService.GetByLoginName(sOperator);
                if (user == null)
                {
                    return("用户不存在!");
                }
                InstrumentFlowModel model = new InstrumentFlowModel();
                model.Creator      = user.UserName;
                model.Flow_Type    = 1;
                model.InstrumentId = instrumentModel.InstrumentId;
                model.Place        = currentPosition;
                model.Reason       = reason;

                ServiceProvider.InstrumentFlowService.Save(model);
                return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = "OK" }));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(ToolsLib.Utility.CommonUtils.JsonSerialize(new { Msg = ex.Message }));
            }
        }
Beispiel #3
0
        private void Print(DataGridView gv, string cb_chck, Constants.BarCodeLayout layout)
        {
            bool R     = false;
            int  count = Convert.ToInt32(gv.Rows.Count.ToString());

            for (int i = 0; i < count; i++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)gv.Rows[i].Cells[cb_chck];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (!flag)
                {
                    continue;
                }
                R = true;
                DataGridViewRow row  = gv.Rows[i];
                InstrumentModel item = (InstrumentModel)row.DataBoundItem;
                for (int j = 0; j < int.Parse(txtinstrumentNum.Text); j++)
                {
                    Print(item, layout);
                }
            }
            if (!R)
            {
                MessageBox.Show("未勾选任何记录");
            }
        }
Beispiel #4
0
        public override async Task <IList <IInstrumentModel> > GetInstruments(IDictionary <dynamic, dynamic> inputs)
        {
            var instruments = new List <IInstrumentModel>();
            var response    = await GetResponse <InputInstrumentDataModel>($"/v1/markets/quotes", inputs);

            foreach (var inputPoint in response?.Quotes?.Quote ?? new List <InputInstrumentModel>())
            {
                var pointModel = new PointModel
                {
                    Ask     = inputPoint.Ask,
                    Bid     = inputPoint.Bid,
                    AskSize = inputPoint.AskSize,
                    BidSize = inputPoint.BidSize,
                    Price   = inputPoint.Price
                };

                var instrumentModel = new InstrumentModel
                {
                    Point  = pointModel,
                    Name   = inputPoint.Symbol,
                    Volume = inputPoint.Volume
                };

                instruments.Add(instrumentModel);
            }

            return(instruments);
        }
Beispiel #5
0
        public override void Init()
        {
            _keyboardSettings = _settingsService.GetSettings <ChartsSettings>().Keyboard;

            Account = _tradingService.CurrentAccount;

            _instrument = _tradingService.GetInstrument(_marketEpic);

            _currency          = _instrument.InstrumentData.currencies.First().code;
            DoublePlacesFactor = _instrument.SnapshotData.doublePlacesFactor;
            ScalingFactor      = _instrument.SnapshotData.scalingFactor;

            Title = _instrument.InstrumentData.name;

            LoadMarketSettings();

            PivotPoints = _tradingService.GetPivotPoints(_marketEpic);

            _tradingService.SubscribeToChartCandle();

            foreach (var position in _tradingService.Positions.Where(p => p.Instrument.Epic == _marketEpic))
            {
                AddPosition(position);
            }

            Messenger.Default.Register <PositionAddedMessage>(this, _marketEpic, PositionAddedMessageReceived);
            Messenger.Default.Register <PositionDeletedMessage>(this, _marketEpic, PositionDeletedMessageReceived);
            Messenger.Default.Register <SettingsChangedMessage>(this, SettingsUpdated);
        }
Beispiel #6
0
        public void AddAsync_NullCheck()
        {
            InstrumentModel instr = new InstrumentModel();

            _dataRepositoryMock.Setup(x => x.AddAsync((instr)));
            Assert.ThrowsAsync <ArgumentException>(() => _adminRepo.AddAsync(instr));
        }
Beispiel #7
0
        public InstrumentModel GetInstrument(string epic)
        {
            var market = Instruments.FirstOrDefault(m => m.Epic == epic);

            if (market == null)
            {
                var detail = GetMarketDetails(epic);

                market = new InstrumentModel();

                market.DealingRuleData = detail.dealingRules;
                market.InstrumentData  = detail.instrument;
                market.SnapshotData    = detail.snapshot;

                market.Epic           = epic;
                market.InstrumentName = market.InstrumentData.name;

                market.Offer = market.SnapshotData.offer;
                market.Bid   = market.SnapshotData.bid;
                market.High  = market.SnapshotData.high;
                market.Low   = market.SnapshotData.low;

                Instruments.Add(market);

                SubscribeL1WatchlistPrices();
            }

            return(market);
        }
Beispiel #8
0
        ///// <summary>
        ///// 保存实体数据.
        ///// </summary>
        //public void Save(InstrumentModel model, InstrumentCertificationModel certModel, HttpFileCollectionBase Files)
        //{
        //    model.LastUpdateUser = LoginHelper.LoginUser.UserName;

        //    if (model.InstrumentId == 0)
        //    {
        //        if (Files != null && Files.Count > 0 && Files[0].ContentLength > 0 && certModel != null)
        //        {
        //            //if (certModel.RecordState == Constants.InstrumentCertificationState.未检.GetHashCode())

        //            string targetPath = WebUtils.GetSettingsValue("InstrumentCertificationPath") + @"/";
        //            string targetFile = string.Format(@"{0}/{1}{2}", targetPath, StrUtils.GetUniqueFileName(null), Path.GetExtension(Files[0].FileName));
        //            Global.Common.Models.AttachmentModel attModel = UtilsHelper.FileUpload(Files[0], targetFile, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));
        //            attModel.FileType = (int)UtilConstants.AttachmentType.仪器周检证书;
        //            attModel.UserId = LoginHelper.LoginUser.UserId;
        //            attModel.UserName = LoginHelper.LoginUser.UserName;
        //            Global.Business.ServiceProvider.AttachmentService.Save(attModel);
        //            certModel.FileId = attModel.FileId;
        //            //certModel.FileVirtualPath = WebUtils.GetSettingsValue("WebFileServer")+targetFile;
        //        }

        //        model.BarCode = DateTime.Now.ToString("yyyyMMddff") + ToolsLib.Utility.StrUtils.GetRandomNumb(6);
        //        model.ItemCode = Guid.NewGuid().ToString();
        //        DBProvider.InstrumentDAO.Add(model);
        //        if (certModel != null)
        //        {
        //            if (!string.IsNullOrEmpty(certModel.CreateUser))
        //            {
        //                certModel.InstrumentId = model.InstrumentId;
        //                //新增仪器时当是完成周检且仪器状态合格则设为正在使用的
        //                if (model.RecordState == UtilConstants.InstrumentState.合格.GetHashCode()
        //                    && certModel.RecordState == Constants.InstrumentCertificationState.完成周检.GetHashCode()) certModel.IsUseding = true;
        //                certModel.ItemCode = Guid.NewGuid().ToString();
        //                DBProvider.InstrumentCertificationDAO.Add(certModel);
        //            }
        //        }
        //    }

        //}

        /// <summary>
        /// 仪器保存
        /// </summary>
        /// <param name="model"></param>
        public void Save4Instrument(InstrumentModel model)
        {
            model.LastUpdateUser = LoginHelper.LoginUser.UserName;
            if (model.ManageLevel != "C")//当管理级别是免检不需要判断
            {
                //当状态为正常或者停用的时候,根据有效期结束时间重新调整器具状态,有效期结束时间等于当天属于正常。
                if (model.RecordState == (int)UtilConstants.InstrumentState.合格 || model.RecordState == (int)UtilConstants.InstrumentState.过期禁用)
                {
                    if (model.DueEndDate >= Convert.ToDateTime(DateTime.Now.ToShortDateString()))
                    {
                        model.RecordState = (int)UtilConstants.InstrumentState.合格;
                    }
                    else
                    {
                        model.RecordState = (int)UtilConstants.InstrumentState.过期禁用;
                    }
                }
            }
            if (model.InstrumentId == 0)
            {
                model.CreateUser = LoginHelper.LoginUser.UserName;
                model.BarCode    = DateTime.Now.ToString("yyyyMMddff") + ToolsLib.Utility.StrUtils.GetRandomNumb(6);
                model.ItemCode   = Guid.NewGuid().ToString();
                DBProvider.InstrumentDAO.Add4Instrument(model);
            }
            else
            {
                DBProvider.InstrumentDAO.Update4Instrument(model);
            }
            //同步仪器数据
            if (LoginHelper.LoginUserAuthorize.Contains("/Instrument/SynInstrument".ToLower()))
            {
                BeginSynInstrument(model.InstrumentId);
            }
        }
Beispiel #9
0
        public async Task <ActionResult <InstrumentModel> > Post(InstrumentModel model)
        {
            try
            {
                var existing = await _repository.GetInstrumentAsync(model.Code);

                if (existing != null)
                {
                    return(BadRequest("Code in use"));
                }

                var location = _linkGenerator.GetPathByAction("Get",
                                                              "Instruments",
                                                              new { code = model.Code });

                if (string.IsNullOrWhiteSpace(location))
                {
                    return(BadRequest("Could not use current name"));
                }

                var instrument = _mapper.Map <Instrument>(model);
                _repository.Add(instrument);
                if (await _repository.SaveChangesAsync())
                {
                    return(Created("", _mapper.Map <InstrumentModel>(instrument)));
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to get the Instrument"));
            }

            return(BadRequest());
        }
        /// <summary>
        /// 计量仪器管理系统同步仪器数据到各个业务系统
        /// </summary>
        /// <param name="instrumentDataJson"></param>
        /// <param name="businessType"></param>
        /// <returns></returns>
        public string SendInstrumentData(string instrumentDataJson)
        {
            string msg = "Error";

            try
            {
                InstrumentModel model = ToolsLib.Utility.CommonUtils.JsonDeserialize(instrumentDataJson, typeof(InstrumentModel)) as InstrumentModel;
                switch (model.InstrumentCate)
                {
                case (int)UtilConstants.LabType.MeasureLab:
                    WSProvider.MeasureLabProvider.SendInstrumentData(instrumentDataJson);
                    break;

                case (int)UtilConstants.LabType.Environment:
                    WSProvider.Environment.SendInstrumentData(instrumentDataJson);
                    break;

                case (int)UtilConstants.LabType.EMC:
                    //SBusiness.ServiceProvider.emcLabInstrumentService.BeginSynInstrumentData(model);
                    break;
                }
                msg = "OK";
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                msg = ex.Message;
            }

            return(msg);
        }
Beispiel #11
0
        /// <summary>
        /// 是否存在管理编号
        /// </summary>
        /// <param name="manageNo"></param>
        /// <returns></returns>
        public bool IsExistManageNo(int instrumentId, string manageNo)
        {
            InstrumentModel model = new InstrumentModel();

            model.ManageNo     = manageNo;
            model.InstrumentId = instrumentId;
            return(DBProvider.InstrumentDAO.IsExistManageNo(model));
        }
        public InstrumentModel CreateInstrument(InstrumentModel newInstrument)
        {
            var newId = instruments.OrderByDescending(i => i.Id).First().Id + 1;

            newInstrument.Id = newId;
            instruments.Add(newInstrument);
            return(newInstrument);
        }
Beispiel #13
0
        /// <summary>
        /// 是否存在资产编号
        /// </summary>
        /// <param name="manageNo"></param>
        /// <returns></returns>
        public bool IsExistAssetsNo(int instrumentId, string assetsNo)
        {
            InstrumentModel model = new InstrumentModel();

            model.AssetsNo     = assetsNo;
            model.InstrumentId = instrumentId;
            return(DBProvider.InstrumentDAO.IsExistAssetsNo(model));
        }
    // Use this for initialization
    void Awake()
    {
        view  = GetComponent <InstrumentView>();
        model = GetComponent <InstrumentModel>();

        audioSource = GetComponent <AudioSource>();

        mixerDimensions = new Vector3(1f, 0.5f, 2f);
    }
        public bool UpdateInstrument(int id, InstrumentModel instrument)
        {
            var instrumentUpdate = GetInstrument(id);

            instrumentUpdate.Name        = instrument.Name ?? instrumentUpdate.Name;
            instrumentUpdate.Price       = instrument.Price ?? instrumentUpdate.Price;
            instrumentUpdate.Description = instrument.Description ?? instrumentUpdate.Description;
            instrumentUpdate.Discount    = instrument.Discount ?? instrumentUpdate.Discount;
            return(true);
        }
Beispiel #16
0
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        private void FindInstrument(IList <InstrumentKey> keys)
        {
            if ((keys.Count > 0) && (keys.Count <= MAX_INSTRUMENT_COUNT))
            {
                SetComponentText(toolStripStatusLabel1, "Drag & Drop detected.  Initializing instrument...");

                // dispose of any current instrument models
                if (m_bindingModels != null)
                {
                    foreach (var entry in m_bindingModels)
                    {
                        entry.Value.ThreadID  = "";
                        entry.Value.Exchange  = "";
                        entry.Value.Product   = "";
                        entry.Value.ProdType  = "";
                        entry.Value.Contract  = "";
                        entry.Value.BidPrice  = "";
                        entry.Value.AskPrice  = "";
                        entry.Value.LastPrice = "";

                        entry.Value.Dispatcher.BeginInvokeShutdown();
                    }
                }

                // Release any current data bindings
                ReleaseDataBinding();

                // (re) instantiate our binding instrument model
                m_bindingModels = new Dictionary <InstrumentKey, InstrumentModel>(MAX_INSTRUMENT_COUNT);

                // index assigned to each instrument which corresponds to the GUI output
                int index = 1;
                foreach (InstrumentKey key in keys)
                {
                    Console.WriteLine(String.Format("TT API FindInstrument {0}", key.ToString()));

                    // create the model for the instrument & set the component data bindings
                    InstrumentModel model = new InstrumentModel(this);
                    SetDataBinding(index++, model);

                    // add the instrument model to our lookup table
                    m_bindingModels.Add(key, model);

                    // Instrument lookups are all still on the main application thread
                    InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                    instrRequest.Update += instrRequest_Completed;
                    instrRequest.Start();
                }
            }
            else
            {
                MessageBox.Show("This application accepts a maximum of " + MAX_INSTRUMENT_COUNT + " contracts.");
            }
        }
Beispiel #17
0
        public void AddAsync_InstrumentTypeLength()
        {
            InstrumentModel instr = new InstrumentModel();

            instr.Id    = "1";
            instr.Model = "Yamaha psr i455";
            instr.Type  = "keyboard";

            _dataRepositoryMock.Setup(x => x.AddAsync((instr)));
            Assert.ThrowsAsync <ArgumentException>(() => _adminRepo.AddAsync(instr));
        }
Beispiel #18
0
        public override Task OnLoad()
        {
            var span        = TimeSpan.FromMinutes(1);
            var instrumentX = new InstrumentModel {
                Name = _assetX, TimeFrame = span
            };
            var instrumentY = new InstrumentModel {
                Name = _assetY, TimeFrame = span
            };

            var account = new AccountModel
            {
                Balance     = 50000,
                Name        = _account,
                Instruments = new NameCollection <string, IInstrumentModel>
                {
                    [_assetX] = instrumentX,
                    [_assetY] = instrumentY
                }
            };

            var gateway = new GatewayClient
            {
                Name     = _account,
                Account  = account,
                Evaluate = Parse,
                Source   = ConfigurationManager.AppSettings["DataLocation"].ToString()
            };

            _performanceIndicator = new PerformanceIndicator {
                Name = "Balance"
            };
            _scaleIndicatorX = new ScaleIndicator {
                Max = 1, Min = -1, Interval = 1, Name = "Indicators : " + _assetX
            };
            _scaleIndicatorY = new ScaleIndicator {
                Max = 1, Min = -1, Interval = 1, Name = "Indicators : " + _assetY
            };

            _disposables.Add(gateway
                             .Account
                             .Instruments
                             .Values
                             .Select(o => o.PointGroups.ItemStream)
                             .Merge()
                             .Subscribe(OnData));

            CreateCharts(instrumentX, instrumentY);
            CreateGateways(gateway);

            return(Task.FromResult(0));
        }
Beispiel #19
0
        public void AddAsync_TestOfAdding()
        {
            InstrumentModel instr = new InstrumentModel();

            instr.Id    = "1";
            instr.Model = "Yamaha psr i455";
            instr.Price = 20000;
            instr.Type  = "keyboard";

            //var instrumentDbSetMock = Builder<InstrumentModel>.CreateListOfSize(1).Build().ToAsyncDbSetMock();
            _dataRepositoryMock.Setup(x => x.AddAsync((instr)));
            Assert.NotNull(_adminController.Add(instr));
        }
Beispiel #20
0
        public static Instrument ToInstrument(InstrumentModel instrumentModel)
        {
            if (instrumentModel == null)
            {
                return(null);
            }

            return(new Instrument
            {
                Id = instrumentModel.Id,
                Name = instrumentModel.Name
            });
        }
Beispiel #21
0
        public async Task AddAsync([FromBody] InstrumentModel model)
        {
            try
            {
                var instrument = Mapper.Map <Instrument>(model);

                await _instrumentsService.AddAsync(instrument);
            }
            catch (FailedOperationException exception)
            {
                throw new ValidationApiException(HttpStatusCode.BadRequest, exception.Message);
            }
        }
Beispiel #22
0
        private void Print(InstrumentModel m, Constants.BarCodeLayout layout)
        {
            // 打开 打印机 端口.
            try
            {
                if (string.IsNullOrEmpty(comboBox1.SelectedItem.ToString()))
                {
                    MessageBox.Show("请选择打印机。");
                    return;
                }
                TSCLIB_DLL.openport(comboBox1.SelectedItem.ToString());                                                //Open
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}打印机安装出错或没有安装驱动。", comboBox1.SelectedItem.ToString()));
                return;
            }
            switch (layout)
            {
            case Constants.BarCodeLayout.二维码左:
                QRCode_ABPrint(m);
                break;

            case Constants.BarCodeLayout.二维码右:
                QRCode_BAPrint(m);
                break;

            case Constants.BarCodeLayout.条码上:
                BarCode_ABPrint(m);
                break;

            case Constants.BarCodeLayout.条码下:
                BarCode_BAPrint(m);
                break;

            case Constants.BarCodeLayout.混合条码上:
                MixCode_ABPrint(m);
                break;

            case Constants.BarCodeLayout.混合条码下:
                MixCode_BAPrint(m);
                break;
            }

            //// if (radioButton1.Checked)//二维码
            //     QRCodePrint(m, layout);//二维码
            // //else if (radioButton2.Checked)//条形码
            //     BarCodePrint(m, layout);//条形码
            // //else
            // MixCodePrint(m, layout);//混合
        }
Beispiel #23
0
        public IHttpActionResult Get(int instrumentId)
        {
            var item = _instrumentsService.GetInstrument(instrumentId);

            if (item == null)
            {
                return(NotFound());
            }

            var model = new InstrumentModel();

            Mapper.Map(item, model);
            return(Ok(model));
        }
Beispiel #24
0
 /// <summary>
 /// 固定资产保存
 /// </summary>
 /// <param name="model"></param>
 public void Save4Assets(InstrumentModel model)
 {
     model.LastUpdateUser = LoginHelper.LoginUser.UserName;
     if (model.InstrumentId == 0)
     {
         model.CreateUser = LoginHelper.LoginUser.UserName;
         model.BarCode    = DateTime.Now.ToString("yyyyMMddff") + ToolsLib.Utility.StrUtils.GetRandomNumb(6);
         model.ItemCode   = Guid.NewGuid().ToString();
         DBProvider.InstrumentDAO.Add4Assets(model);
     }
     else
     {
         DBProvider.InstrumentDAO.Update4Assets(model);
     }
 }
Beispiel #25
0
 public ActionResult <bool> UpdateInstrument(int id, [FromBody] InstrumentModel instrument)
 {
     try
     {
         return(Ok(service.UpdateInstrument(id, instrument)));
     }
     catch (NotFoundException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #26
0
 public ActionResult <bool> UpdateInstrument(int id, [FromBody] InstrumentModel instrument)
 {
     try
     {
         return(Ok(service.UpdateInstrument(id, instrument)));
     }
     catch (NotFoundException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));;
     }
 }
Beispiel #27
0
 public ActionResult <InstrumentModel> CreateInstrument([FromBody] InstrumentModel instrument)
 {
     try
     {
         var newInstrument = service.CreateInstrument(instrument);
         return(Created($"/api/Instruments/{newInstrument.Id}", newInstrument));
     }
     catch (NotFoundException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
Beispiel #28
0
 /// <summary>
 /// Binds the controls text property to the corresponding InstrumentModel property
 /// </summary>
 /// <param name="index">index of which set of controls to bind</param>
 /// <param name="model">model to bind the controls to</param>
 private void SetDataBinding(int index, InstrumentModel model)
 {
     if (index == 1)
     {
         this.txtThreadID_1.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_1.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_1.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_1.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_1.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_1.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_1.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_1.DataBindings.Add("Text", model, "LastPrice", true);
     }
     else if (index == 2)
     {
         this.txtThreadID_2.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_2.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_2.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_2.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_2.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_2.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_2.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_2.DataBindings.Add("Text", model, "LastPrice", true);
     }
     else if (index == 3)
     {
         this.txtThreadID_3.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_3.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_3.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_3.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_3.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_3.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_3.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_3.DataBindings.Add("Text", model, "LastPrice", true);
     }
     else if (index == 4)
     {
         this.txtThreadID_4.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_4.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_4.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_4.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_4.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_4.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_4.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_4.DataBindings.Add("Text", model, "LastPrice", true);
     }
 }
Beispiel #29
0
        public async Task UpdateAsync([FromBody] InstrumentModel model)
        {
            try
            {
                var instrument = Mapper.Map <Instrument>(model);

                await _instrumentsService.UpdateAsync(instrument);
            }
            catch (EntityNotFoundException)
            {
                throw new ValidationApiException(HttpStatusCode.NotFound, "Instrument does not exist.");
            }
            catch (FailedOperationException exception)
            {
                throw new ValidationApiException(HttpStatusCode.BadRequest, exception.Message);
            }
        }
        public async Task <InstrumentModel> CreateInstrumentAsync(int storeId, InstrumentModel newInstrument)
        {
            await ValidateStoreAsync(storeId);

            newInstrument.StoreId = storeId;
            var instrumentEntity = mapper.Map <InstrumentEntity>(newInstrument);

            repository.CreateInstrument(instrumentEntity);

            var res = await repository.SaveChangesAsync();

            if (res)
            {
                return(mapper.Map <InstrumentModel>(instrumentEntity));
            }
            throw new Exception("Database Exception");
        }
        /// <summary>
        /// Function to find a list of InstrumentKeys.
        /// </summary>
        /// <param name="keys">List of InstrumentKeys.</param>
        private void FindInstrument(IList<InstrumentKey> keys)
        {
            if ((keys.Count > 0) && (keys.Count <= MAX_INSTRUMENT_COUNT))
            {
                SetComponentText(toolStripStatusLabel1, "Drag & Drop detected.  Initializing instrument...");

                // dispose of any current instrument models
                if (m_bindingModels != null)
                {
                    foreach (var entry in m_bindingModels)
                    {
                        entry.Value.ThreadID = "";
                        entry.Value.Exchange = "";
                        entry.Value.Product = "";
                        entry.Value.ProdType = "";
                        entry.Value.Contract = "";
                        entry.Value.BidPrice = "";
                        entry.Value.AskPrice = "";
                        entry.Value.LastPrice = "";

                        entry.Value.Dispatcher.BeginInvokeShutdown();
                    }
                }

                // Release any current data bindings
                ReleaseDataBinding();

                // (re) instantiate our binding instrument model
                m_bindingModels = new Dictionary<InstrumentKey, InstrumentModel>(MAX_INSTRUMENT_COUNT);

                // index assigned to each instrument which corresponds to the GUI output
                int index = 1;
                foreach (InstrumentKey key in keys)
                {
                    Console.WriteLine(String.Format("TT API FindInstrument {0}", key.ToString()));

                    // create the model for the instrument & set the component data bindings
                    InstrumentModel model = new InstrumentModel(this);
                    SetDataBinding(index++, model);

                    // add the instrument model to our lookup table
                    m_bindingModels.Add(key, model);

                    // Instrument lookups are all still on the main application thread
                    InstrumentLookupSubscription instrRequest = new InstrumentLookupSubscription(m_TTAPI.Session, Dispatcher.Current, key);
                    instrRequest.Update += instrRequest_Completed;
                    instrRequest.Start();
                }
            }
            else
            {
                MessageBox.Show("This application accepts a maximum of " + MAX_INSTRUMENT_COUNT + " contracts.");
            }
        }
 /// <summary>
 /// Binds the controls text property to the corresponding InstrumentModel property
 /// </summary>
 /// <param name="index">index of which set of controls to bind</param>
 /// <param name="model">model to bind the controls to</param>
 private void SetDataBinding(int index, InstrumentModel model)
 {
     if (index == 1)
     {
         this.txtThreadID_1.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_1.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_1.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_1.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_1.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_1.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_1.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_1.DataBindings.Add("Text", model, "LastPrice", true);
     }
     else if (index == 2)
     {
         this.txtThreadID_2.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_2.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_2.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_2.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_2.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_2.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_2.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_2.DataBindings.Add("Text", model, "LastPrice", true);
     }
     else if (index == 3)
     {
         this.txtThreadID_3.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_3.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_3.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_3.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_3.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_3.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_3.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_3.DataBindings.Add("Text", model, "LastPrice", true);
     }
     else if (index == 4)
     {
         this.txtThreadID_4.DataBindings.Add("Text", model, "ThreadID", true);
         this.txtExchange_4.DataBindings.Add("Text", model, "Exchange", true);
         this.txtProduct_4.DataBindings.Add("Text", model, "Product", true);
         this.txtProdType_4.DataBindings.Add("Text", model, "ProdType", true);
         this.txtContract_4.DataBindings.Add("Text", model, "Contract", true);
         this.txtBidPrice_4.DataBindings.Add("Text", model, "BidPrice", true);
         this.txtAskPrice_4.DataBindings.Add("Text", model, "AskPrice", true);
         this.txtLastPrice_4.DataBindings.Add("Text", model, "LastPrice", true);
     }
 }