public ActionResult Create(HttpPostedFileBase postedFile, Market market) { try { if (ModelState.IsValid) { if (postedFile != null && ProductsContainer.validateImage(postedFile.FileName)) { var filename = "img_" + market.Denumire.ToLower() + ".png"; var path = Path.Combine(Server.MapPath("~/Content/ProductsImages/"), filename); postedFile.SaveAs(path); market.Imagine = "img_" + market.Denumire.ToLower(); } MarketContainer.SaveMarket(market); return(RedirectToAction("Index")); } var model = new MarketModel(); model.Market = market; return(View(model)); }catch (Exception ex) { return(View()); } }
public ActionResult Save(MarketModel model) { TransactionMessage TransMessage = new TransactionMessage(); TransMessage.Status = MessageStatus.Error; try { if (ModelState.IsValid) { if (model.EncryptedID.IsValidEncryptedID() && model.EncryptedID.ToDecrypt().IsNumber()) { model.MarketId = Convert.ToInt32(model.EncryptedID.ToDecrypt()); } model = _market.Save(model); if (model.TransMessage.Status == MessageStatus.Success) { SuccessNotification(model.TransMessage.Message); } } else { TransMessage.Message = utilityHelper.ReadGlobalMessage("ManageMarket", "ErrorMessage"); } } catch (Exception ex) { // write exception log EventLogHandler.WriteLog(ex); } return(Json(model.TransMessage, JsonRequestBehavior.DenyGet)); }
public void Download(MarketModel model, SettingModel settings) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } Config.Set("data-directory", settings.DataFolder); switch (model.Access) { case MarketModel.AccessType.Demo: Config.Set("fxcm-terminal", "Demo"); break; case MarketModel.AccessType.Real: Config.Set("fxcm-terminal", "Real"); break; } Config.Set("fxcm-user-name", model.Login); Config.Set("fxcm-password", model.Password); IList <string> symbols = model.Symbols.Select(m => m.Name).ToList(); string resolution = model.Resolution.Equals(Resolution.Tick) ? "all" : model.Resolution.ToString(); FxcmVolumeDownloadProgram.FxcmVolumeDownload(symbols, resolution, model.LastDate, model.LastDate); }
public ActionResult Index() { MarketModel market = new MarketModel(); ViewBag.Message = market; return(View()); }
public MarketViewModel(MarketsViewModel marketsViewModel, MarketModel marketModel, SettingService settings) { if (marketsViewModel == null) { throw new ArgumentNullException(nameof(marketsViewModel)); } _parent = marketsViewModel; Model = marketModel; _settings = settings; CheckAllCommand = new RelayCommand <IList>(m => DoCheckAll(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null); AddSymbolCommand = new RelayCommand(() => DoAddSymbol(), () => !_parent.IsBusy); DownloadSymbolListCommand = new RelayCommand(() => DoDownloadSymbolList(), !_parent.IsBusy); DeleteSymbolsCommand = new RelayCommand <IList>(m => DoDeleteSymbols(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null); ImportSymbolsCommand = new RelayCommand(() => DoImportSymbols(), !_parent.IsBusy); ExportSymbolsCommand = new RelayCommand <IList>(m => DoExportSymbols(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null); AddToSymbolListCommand = new RelayCommand <IList>(m => DoAddToSymbolList(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null); DeleteCommand = new RelayCommand(() => _parent?.DoDeleteMarket(this), () => !_parent.IsBusy && !Active); NewFolderCommand = new RelayCommand(() => Folders.Add(new FolderViewModel(this, new FolderModel())), () => !_parent.IsBusy && !Active); ImportFolderCommand = new RelayCommand(() => DoImportFolder(), () => !_parent.IsBusy && !Active); ActiveCommand = new RelayCommand(() => DoActiveCommand(Model.Active), !_parent.IsBusy); StartCommand = new RelayCommand(() => DoStartCommand(), () => !_parent.IsBusy && !Active); StopCommand = new RelayCommand(() => DoStopCommand(), () => !_parent.IsBusy && Active); Model.ModelChanged += DataFromModel; DataFromModel(); DoActiveCommand(Active); }
public IEnumerable <SymbolModel> GetAllSymbols(MarketModel market, SettingService settings) { var list = new List <SymbolModel>(); list.AddRange(_majors.Select(m => new SymbolModel(m) { Properties = new Dictionary <string, object> { { "Category", "Majors" } } })); list.AddRange(_crosses.Select(m => new SymbolModel(m) { Properties = new Dictionary <string, object> { { "Category", "Crosses" } } })); list.AddRange(_metals.Select(m => new SymbolModel(m) { Properties = new Dictionary <string, object> { { "Category", "Metals" } } })); list.AddRange(_indices.Select(m => new SymbolModel(m) { Properties = new Dictionary <string, object> { { "Category", "Indices" } } })); var downloader = new DukascopyDataDownloader(); return(list.Where(m => downloader.HasSymbol(m.Name))); }
public ActionResult Index(MarketModel market) { MarketModel marketModel = new MarketModel { TemplateId = market.TemplateId, Name = market.Name, Environment = market.Environment, StringType = market.StringType }; var url = GetUrl(marketModel.Environment); if (string.IsNullOrEmpty(url)) { marketModel.Environment = "Wrong"; ViewBag.Message = marketModel; return(View()); } var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { var obj = new { strings = new[] { new { itemId = "1", name = marketModel.Name, tags = new { marketModel.StringType, sport = "4", domain = "Trading" } } }, correlationId = "34690f9d-1835-4b1c-bdd3-86bfa625a9a9", user = "******" }; var json = JsonConvert.SerializeObject(obj, Formatting.Indented); json = json.Replace("name", "string"); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); var resultList = JsonConvert.DeserializeObject <List <MarketModel> >(result); marketModel.Id = resultList[0].Id; marketModel.Error = resultList[0].Error; } ViewBag.Message = marketModel; return(View()); }
/// <summary> /// Creates a market recommendation using a fully sequential operation /// </summary> /// <returns>A market recommendation</returns> public MarketRecommendation DoAnalysisSequential() { StockDataCollection nyseData = LoadNyseData(); StockDataCollection nasdaqData = LoadNasdaqData(); StockDataCollection mergedMarketData = MergeMarketData(new[] { nyseData, nasdaqData }); StockDataCollection normalizedMarketData = NormalizeData(mergedMarketData); StockDataCollection fedHistoricalData = LoadFedHistoricalData(); StockDataCollection normalizedHistoricalData = NormalizeData(fedHistoricalData); StockAnalysisCollection analyzedStockData = AnalyzeData(normalizedMarketData); MarketModel modeledMarketData = RunModel(analyzedStockData); StockAnalysisCollection analyzedHistoricalData = AnalyzeData(normalizedHistoricalData); MarketModel modeledHistoricalData = RunModel(analyzedHistoricalData); MarketRecommendation recommendation = CompareModels(new[] { modeledMarketData, modeledHistoricalData }); return(recommendation); }
public IEnumerable <SymbolModel> GetAllSymbols(MarketModel market, SettingService settings) { if (market == null) { throw new ArgumentNullException(nameof(market)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } string directory = Path.Combine( settings.DataFolder, SecurityType.Equity.ToString().ToLowerInvariant(), market.Provider); string dailyFolder = Path.Combine(directory, "daily"); DirectoryInfo d = new DirectoryInfo(dailyFolder); if (!d.Exists) { return(Enumerable.Empty <SymbolModel>()); } IEnumerable <SymbolModel> symbols = d.GetFiles("*.zip") .Select(m => Path.GetFileNameWithoutExtension(m.Name)) .Select(n => new SymbolModel(n)); return(symbols); }
protected override void OnScheduledUpdate() { base.OnScheduledUpdate(); MarketModel.Balance.Amount = 1000; MarketModel.SetChanges(); Terminate(true); }
public ActionResult DeleteMarket(MarketModel marketModel) { var companiesUsingThisMarketInTheirNetworkSettings = new MongoRepository <TaxiHailNetworkSettings>() .Where(x => x.Market == marketModel.Market) .OrderBy(x => x.Id) .Select(x => x.Id) .ToList(); if (companiesUsingThisMarketInTheirNetworkSettings.Any()) { TempData["warning"] = "Couldn't delete the market because some companies are configured to use it:" + companiesUsingThisMarketInTheirNetworkSettings.Aggregate("", (current, company) => current + string.Format( company == companiesUsingThisMarketInTheirNetworkSettings.Last() ? "{0}" : "{0}, ", company)); } else { try { Repository.Delete(v => v.Name == marketModel.Market); } catch (Exception) { ViewBag.Error = "An error occured. Unable to delete the market"; } } return(RedirectToAction("Index")); }
public void Download(MarketModel model, SettingService settings, IList <string> symbols) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } Config.Set("map-file-provider", "QuantConnect.Data.Auxiliary.LocalDiskMapFileProvider"); Config.Set("data-directory", settings.DataFolder); string resolution = model.Resolution.Equals(Resolution.Tick) ? "all" : model.Resolution.ToString(); DateTime fromDate = model.LastDate.Date.AddDays(1); if (fromDate >= DateTime.Today) { // Do not download today data model.Active = false; return; } if (fromDate < _firstDate) { fromDate = _firstDate; } DukascopyDownloaderProgram.DukascopyDownloader(symbols, resolution, fromDate, fromDate.AddDays(1).AddTicks(-1)); model.LastDate = fromDate; }
public HttpResponseMessage DeletePartnerMerchant(MarketModel model) { string Result = string.Empty; try { //请求中包含的固定参数 model.SOURCE = ParametersFilter.FilterSqlHtml(model.SOURCE, 24); model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24); model.ADDRESS = HttpHelper.IPAddress(); model.TERMINAL = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1); model.INDEX = ParametersFilter.FilterSqlHtml(model.INDEX, 24); model.METHOD = ParametersFilter.FilterSqlHtml(model.METHOD, 24); //去除用户参数中包含的特殊字符 model.DATA = ParametersFilter.StripSQLInjection(model.DATA); //返回结果 Result = ApiHelper.HttpRequest(username, password, Url, model); ///写日志 string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":"; LogHelper.LogResopnse(RequestAction + Result); } catch (Exception ex) { LogHelper.LogError(ex.ToString()); } HttpResponseMessage Respend = new HttpResponseMessage { Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json") }; return(Respend); }
/// <summary> /// to get page full detail /// </summary> /// <param name="encryptedId"></param> /// <returns></returns> public MarketModel GetDetail(string encryptedId) { MarketModel model = new MarketModel(); try { int marketId = Convert.ToInt32(encryptedId.ToDecrypt()); #region get detail model = UnitofWork.RepoMarket.Where(x => x.MarketID == marketId).Select(x => new MarketModel { MarketId = x.MarketID, Name = x.Name }).FirstOrDefault(); #endregion if (model != null) { model.EncryptedID = model.MarketId.ToString().ToEnctypt(); } else { model = new MarketModel(); } } catch (Exception ex) { EventLogHandler.WriteLog(ex); } return(model); }
public void AddMarket(Client sender, string name) { sender.SendInfo("Ustaw się w pozycji NPC, a następnie wpisz /tu użyj ctrl + alt + shift + d aby poznać swoją obecną pozycję."); Vector3 center = null; void Handler(Client o, string message) { if (center == null && o == sender && message == "/tu") { center = o.Position; sender.SendInfo("Przejdź do pozycji końca promienia zasięgu i wpisz \"tu.\""); } else { float radius = float.MinValue; if (center != null && radius.Equals(float.MinValue) && o == sender && message == "tu") { radius = center.DistanceTo2D(o.Position); MarketModel market = new MarketModel { Id = XmlHelper.GetXmlObjects <MarketModel>(Path.Combine(Utils.XmlDirectory, "Markets")).Count, Name = name, Center = center, Radius = radius }; XmlHelper.AddXmlObject(market, Path.Combine(Utils.XmlDirectory, "Markets"), market.Name); Markets.Add(new MarketEntity(market)); } } } }
public ActionResult CreateMarket(MarketModel marketModel) { var existing = Repository.GetMarket(marketModel.Market); if (existing != null) { ViewBag.Error = "A market with that name already exists."; return(View(marketModel)); } if (!IsRegionValid(marketModel.Region)) { ViewBag.Error = "You must specify a valid region for the market"; return(View(marketModel)); } Repository.Add(new Market { Id = Guid.NewGuid().ToString(), Name = marketModel.Market, Region = marketModel.Region }); return(RedirectToAction("MarketIndex", marketModel)); }
public ActionResult DeleteConfirmed(int id) { MarketModel marketModel = db.Market.Find(id); db.Market.Remove(marketModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <BaseResponse <List <Market> > > SelectMarkets(MarketModel model) { var request = new RestRequest("markets", Method.POST); request.AddJsonBody(model); return(await base.Execute <BaseResponse <List <Market> > >(request)); }
public ManheimViewModel(IView view) { KBBModel = new KBBModel(); CarfaxModel = new CarfaxModel(); MainheimModel = new MainheimModel(); MarketModel = new MarketModel(); Initializer(); view.SetDataContext(this); }
public void Download(MarketModel model, SettingModel settings) { var uri = new Uri($"https://github.com/QuantConnect/Lean/archive/{_version}.zip"); string extract = $"Lean-{_version}/Data/"; string filename = "github.zip"; Log.Trace($"Download {uri}"); using (var client = new WebClient()) { client.DownloadFile(uri, filename); } Log.Trace($"Unpack {uri}"); IList <SymbolModel> symbols = new List <SymbolModel>(); string dest = settings.DataFolder; using (ZipArchive archive = new ZipArchive(File.OpenRead(filename))) { foreach (ZipArchiveEntry file in archive.Entries) { // skip directories if (string.IsNullOrEmpty(file.Name)) { continue; } if (!file.FullName.StartsWith(extract)) { continue; } string path = file.FullName.Substring(extract.Length); AddSymbol(symbols, path); string destPath = Path.Combine(dest, path); FileInfo outputFile = new FileInfo(destPath); if (!outputFile.Directory.Exists) { outputFile.Directory.Create(); } file.ExtractToFile(outputFile.FullName, true); } } // Adjust lastdate if (model.Symbols.Any()) { model.LastDate = DateTime.Today; } File.Delete(filename); // Update symbol list UpdateSymbols(model.Symbols, symbols); Log.Trace($"Unpack {uri} completed"); model.Active = false; }
public MarketModel Download(MarketModel market, SettingModel settings, ILogHandler logger) { if (market == null) { throw new ArgumentNullException(nameof(market)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } Log.LogHandler = logger; Config.Set("data-directory", settings.DataFolder); Config.Set("data-folder", settings.DataFolder); Config.Set("cache-location", settings.DataFolder); using (var writer = new StreamLogger(logger)) { Console.SetOut(writer); IProvider provider = CreateProvider(settings, market.Provider); if (provider == null) { market.Active = false; } else { try { // Check default values if (string.IsNullOrEmpty(market.Market)) { market.Market = market.Provider; } if (market.Security.Equals(SecurityType.Base)) { market.Security = SecurityType.Equity; } provider.Download(market, settings); } catch (Exception ex) { Log.Error(string.Format( CultureInfo.InvariantCulture, "{0}: {1}", ex.GetType(), ex.Message)); market.Active = false; } } } Log.LogHandler.Dispose(); return(market); }
private void OnSuccess(GetUserBalanceRequest.Response result, GetUserBalanceRequest.RequestParams request) { if (IsRunning) { MarketModel.Balance.Amount = result.amount; MarketModel.Balance.Currency = result.currency; MarketModel.SetChanges(); Terminate(true); } }
public ActionResult Add(string id) { MarketModel model = new MarketModel(); if (id != null) { model = _market.GetDetail(id); } return(View(model)); }
public ActionResult Edit([Bind(Include = "ID,CarId,Active")] MarketModel marketModel) { if (ModelState.IsValid) { db.Entry(marketModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(marketModel)); }
public void AddMarket(string marketProvince, string marketName, uint marketType) { MarketModel market = new MarketModel(); market.name = marketName; market.location = marketProvince; market.markettypeid = marketType; db.InsertSingleLine <MarketModel>("market", market); }
private MarketModel GetMarketModel(Market market = null) { var otherMarkets = market == null ? Repository.Collection.FindAll().ToList() : Repository.Collection.FindAll().Where(x => x.Name != market.Name).ToList(); var marketModel = new MarketModel { OtherMarkets = otherMarkets }; if (market == null) { return(marketModel); } // get companies in this market that are network enabled to be used as the future booking company var companiesInNetworkWithThisMarket = new MongoRepository <TaxiHailNetworkSettings>() .Where(x => x.IsInNetwork && x.Market == market.Name) .Select(x => new SelectListItem { Text = x.Id, Value = x.Id }) .ToList(); // add an empty default value companiesInNetworkWithThisMarket.Insert(0, new SelectListItem { Text = "No company (will cause error if using future booking)", Value = string.Empty }); marketModel.Market = market.Name; marketModel.DispatcherSettings = market.DispatcherSettings; marketModel.Vehicles = market.Vehicles; marketModel.EnableDriverBonus = market.EnableDriverBonus; marketModel.EnableFutureBooking = market.EnableFutureBooking; marketModel.FutureBookingReservationProvider = market.FutureBookingReservationProvider; marketModel.FutureBookingTimeThresholdInMinutes = market.FutureBookingTimeThresholdInMinutes; marketModel.CompaniesOrMarket = companiesInNetworkWithThisMarket; marketModel.DisableOutOfAppPayment = market.DisableOutOfAppPayment; marketModel.ReceiptFooter = market.ReceiptFooter; marketModel.EnableAppFareEstimates = market.EnableAppFareEstimates; marketModel.MarketTariff = market.MarketTariff; marketModel.ShowCallDriver = market.ShowCallDriver; marketModel.Region = market.Region; if (market.ReceiptLines == null) { marketModel.ReceiptLines = InitReceiptLabels(); } else { marketModel.ReceiptLines = market.ReceiptLines; } return(marketModel); }
public IActionResult Market(string id) { var Id = id; var product = db.Products.Where(p => p.Category.Url == id).Include(i => i.Image).ToList(); product.SelectMany(i => i.Image); var selectCategory = db.Categories.Where(c => c.Url == id).Select(s => s.Name).FirstOrDefault(); MarketModel marketModel = GetModelMarket(product, selectCategory); return(View("Market", marketModel)); }
public MarketModel GetModel() { model = new MarketModel(); model.Market_id = KillSqlIn.Form_ReplaceByString(this.txtMarketId.Text, 100); model.Market_name = KillSqlIn.Form_ReplaceByString(this.txtMarketName.Text, 200); model.Area_id = ddlAreaId.SelectedValue.Equals("0") ? "0" : ddlAreaId.SelectedValue; model.Map_x = KillSqlIn.Form_ReplaceByString(this.txtMapX.Text, 100); model.Map_y = KillSqlIn.Form_ReplaceByString(this.txtMapY.Text, 100); model.orderby = string.IsNullOrEmpty(txtSort.Text) ? 0 : Convert.ToInt32(txtSort.Text, 10); return(model); }
private MarketModel GetModelMarket(List <Models.Objects.Product> product, string selectCoty) { MarketModel marketModel = new MarketModel(); var contact = db.Contacts.OrderByDescending(x => x).FirstOrDefault(); marketModel.Contacts = contact == null ? new Models.Objects.Contact() : contact; marketModel.Categories = db.Categories.ToList(); marketModel.Products = product; marketModel.SelectedCategory = selectCoty; return(marketModel); }
public market GetMarketEntity(MarketModel model) { return(new market { market_id = model.Id, name = model.Name, url = model.Url, short_name = model.ShortName, contracts = GetContracts(model.Contracts ?? new List <ContractModel>(), model.Id) }); }
public static MarketRecommendation Run(MarketModel[] models) { return new MarketRecommendation("Buy"); }