public BusinessInfo(AppTypes.MarketTrend shortTerm, AppTypes.MarketTrend mediumTerm, AppTypes.MarketTrend longTerm, double weight) { this.ShortTermTrend = shortTerm; this.MediumTermTrend = mediumTerm; this.LongTermTrend = longTerm; this.Weight = weight; }
public int Parent; // 0 if none public AppInfo( int id, string name = null, AppTypes type = AppTypes.Unknown, AppPlatforms platforms = AppPlatforms.All ) { this.Id = id; this.Name = name; this.AppType = type; this.Platforms = platforms; }
public static IServiceCollection AddWxChatOfficialSyncService(this IServiceCollection collection) { var appfilters = new AppTypes[] { AppTypes.Official }; var apps = "https://www.yourc.club/api/sharing/QueryMerchantDetails" .GetUriJsonContent <JObject>().TryGetValues <MerchantDetails>("$.data") .SelectMany((merchant) => { return(merchant.Apps.Where(app => appfilters.Any(x => x == app.AppType)) .Select(x => new { App = x, MerchantId = merchant.Id, MerchantName = merchant.BrandName })); }); foreach (var app in apps) { var state = new WeChatUserSyncState(new WeChatUserSyncSettings() { AppId = app.App.AppId, AppType = app.App.AppType, Secret = app.App.Secret, MerchantId = app.MerchantId, BrandName = app.MerchantName }); collection.Add(new ServiceDescriptor(typeof(IASfPWorkItem), new WorkItemWithDataflow <WeChatUserSyncState, WeChatUserInfo>(state))); } return(collection); }
public int Parent; // 0 if none public AppInfo(int id, string name = null, AppTypes type = AppTypes.Unknown, AppPlatforms platforms = AppPlatforms.All) { this.Id = id; this.Name = name; this.AppType = type; this.Platforms = platforms; }
public databases.baseDS.priceDataRow getPriceDataToDay(string code) { //Gateway.ServiceConnector.InitService(); string timeScaleCode = AppTypes.TimeScaleTypeToCode(AppTypes.TimeScaleTypes.Day); databases.baseDS.priceDataDataTable tbl = DataAccess.Libs.GetPriceData(code, timeScaleCode, DateTime.Now.AddDays(-1), DateTime.Today); return(tbl.Rows[0] as databases.baseDS.priceDataRow); }
public AppInfo(int id, string name = null, AppTypes type = AppTypes.Unknown, AppPlatforms platforms = AppPlatforms.All) { Id = id; Name = name; AppType = type; Platforms = platforms; }
public bool IncludeItemInGameList(int id, AppTypes scheme) { if (Games.ContainsKey(id)) { return(scheme.HasFlag(Games[id].AppType)); } return(scheme.HasFlag(AppTypes.Unknown)); }
public List <decimal[]> Estimate_Matrix_Profit(AppTypes.TimeRanges timeRange, string timeScaleCode, string[] stockCodeList, string[] strategyList, EstimateOptions option) { return(application.Strategy.Libs.Estimate_Matrix_Profit(timeRange, AppTypes.TimeScaleFromCode(timeScaleCode), common.system.List2Collection(stockCodeList), common.system.List2Collection(strategyList), option)); }
public FrmReportMain() { InitializeComponent(); CultureInfo newCulture = AppTypes.Code2Culture(commonTypes.AppTypes.LanguageCodes.VI); common.language.myCulture = newCulture; common.language.SetLanguage(); commonClass.SysLibs.SetLanguage(); }
private void Init(DateTime startDateTime, DateTime endDateTime, AppTypes.TimeScale timeScale, StringCollection stockCodes) { this.Cache.Clear(); this.StartDateTime = startDateTime; this.EndDateTime = endDateTime; if (stockCodes != null && stockCodes.Count != 0) this.StockCodeList = common.system.MakeConditionStr(stockCodes, "'", "'", ","); else this.StockCodeList = null; this.TimeScale = timeScale; }
public TradeAlertItem(string stockCode, string strategy, AppTypes.TimeScale timeScale, DateTime onDateTime, double price, double volume, TradePointInfo tradePoint) { this.StockCode = stockCode; this.TimeScale = timeScale; this.Strategy = strategy; this.OnDateTime = onDateTime; this.Price = price; this.Volume = volume; this.TradePoint = tradePoint; }
/// <summary> /// Get data and store in cache. Depend on forceReadNew, cached data can be used to boost perfomance /// </summary> /// <param name="timeRange"></param> /// <param name="timeScaleCode"></param> /// <param name="code"></param> /// <param name="forceReadNew"> if true always read from database, ignore the cached data</param> /// <returns>Data key used for data accessing</returns> public string LoadAnalysisData(AppTypes.TimeRanges timeRange, string timeScaleCode, string code, bool forceReadNew) { string cacheName = MakeCacheKey(timeRange, timeScaleCode, code); if (forceReadNew || sysDataCache.Find(cacheName) == null) { AnalysisData myData = new AnalysisData(timeRange, AppTypes.TimeScaleFromCode(timeScaleCode), code, DataAccessMode.Local); sysDataCache.Add(cacheName, myData); } return(cacheName); }
/// <summary> /// Showing VNIndex and HNXIndex for 2 months from now /// </summary> private void Market_Indexes() { DateTime toDate = DateTime.Now; DateTime frDate = toDate.AddMonths(-2); string timeScaleCode = AppTypes.TimeScaleTypeToCode(AppTypes.TimeScaleTypes.Day); DrawLineChart(vnIdxChart, 0, true, "VN-IDX", frDate, toDate, timeScaleCode); DrawLineChart(hnxChart, 0, true, "VN30-IDX", frDate, toDate, timeScaleCode); //DrawLineChart(hnxChart, 0, true, "HNX-IDX", frDate, toDate, timeScaleCode); }
public databases.baseDS.portfolioRow ShowNew(AppTypes.PortfolioTypes type,string investorCode) { codeEd.Text = Consts.constMarkerNEW; nameEd.Text = ""; descriptionEd.Text = ""; this.nameEd.Focus(); this.myInvestorCode = investorCode; this.myPortfolioType = type; this.ShowDialog(); return (myPortfolioTbl.Count>0?myPortfolioTbl[0]:null); }
public static double[] GetDataList(databases.baseDS.priceDataDataTable dataTbl, int startIdx,int endIdx,AppTypes.PriceDataType type) { double[] data = new double[endIdx - startIdx+1]; switch (type) { case AppTypes.PriceDataType.High: for (int i = startIdx, j = 0; i <= endIdx; i++, j++) { if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue; data[j] = (double)dataTbl[i].highPrice; } break; case AppTypes.PriceDataType.Low: for (int i = startIdx, j = 0; i <=endIdx; i++, j++) { if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue; data[j] = (double)dataTbl[i].lowPrice; } break; case AppTypes.PriceDataType.Open: for (int i = startIdx, j = 0; i <= endIdx; i++, j++) { if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue; data[j] = (double)dataTbl[i].openPrice; } break; case AppTypes.PriceDataType.Close: for (int i = startIdx, j = 0; i <= endIdx; i++, j++) { if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue; data[j] = (double)dataTbl[i].closePrice; } break; case AppTypes.PriceDataType.Volume: for (int i = startIdx, j = 0; i <= endIdx; i++, j++) { if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue; data[j] = (double)dataTbl[i].volume; } break; case AppTypes.PriceDataType.DateTime: for (int i = startIdx, j = 0; i <= endIdx; i++, j++) { if (dataTbl[i].RowState == System.Data.DataRowState.Deleted) continue; data[j] = dataTbl[i].onDate.ToOADate(); } break; default: common.system.ThrowException("Invalid dataField in MakeDataList()"); break; } return data; }
private void DoRankingDB() { this.myValueType = ValueTypes.Amount; this.Amount2PercentDenominator = Settings.sysStockTotalCapAmt; resultTab.TabPages.Clear(); StringCollection stockCodeList = codeListLb.myValues; StringCollection timeRangeList = timeRangeLb.myCheckedValues; string[] strategyList = common.system.Collection2List(strategyClb.myCheckedValues); progressBar.Value = 0; progressBar.Minimum = 0; progressBar.Maximum = stockCodeList.Count * timeRangeList.Count; EstimateOptions estimateOption = new EstimateOptions(); for (int stockCodeId = 0; stockCodeId < stockCodeList.Count; stockCodeId++) { string stockCode = stockCodeList[stockCodeId].ToString(); DataTable testRetsultTbl = CreateDataTable(timeRangeList, strategyList); common.controls.baseDataGridView resultGrid = CreateResultGrid(stockCode, testRetsultTbl); for (int colId = 0; colId < timeRangeList.Count; colId++) { try { progressBar.Value++; Application.DoEvents(); this.ShowReccount(progressBar.Value.ToString() + "/" + progressBar.Maximum.ToString()); AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(timeRangeList[colId]); application.AnalysisData analysisData = new application.AnalysisData(timeRange, timeScaleCb.myValue, stockCode, commonClass.DataAccessMode.WebService); for (int rowId = 0; rowId < strategyList.Length; rowId++) { testRetsultTbl.Rows[rowId][colId + 1] = 0; //Analysis cached data so we MUST clear cache to ensure the system run correctly application.Strategy.Data.ClearCache(); application.Strategy.Data.TradePoints advices = application.Strategy.Libs.Analysis(analysisData, strategyList[rowId]); if (advices != null) { testRetsultTbl.Rows[rowId][colId + 1] = application.Strategy.Libs.EstimateTrading_Profit(analysisData, application.Strategy.Libs.ToTradePointInfo(advices), estimateOption); } } } catch (Exception er) { this.WriteError(stockCodeList[stockCodeId] + " : " + timeRangeList[colId] + " : " + strategyList[colId], er.Message); //this.ShowError(er); } } } }
public void ShowForm(string stockCode, StringCollection strategyCodes, AppTypes.TimeScale timeScale) { watchListLb.LoadData(commonClass.SysLibs.sysLoginCode, false); this.myStrategyCodes = strategyCodes; this.codeEd.Text = stockCode; this.timeScaleCb.myValue = timeScale; strategyLb.Items.Clear(); for (int idx = 0; idx < strategyCodes.Count; idx++) { strategyLb.Items.Add(application.Strategy.StrategyLibs.GetMetaName(strategyCodes[idx])); } this.timeScaleCb.myValue = timeScale; this.ShowDialog(); }
public static databases.tmpDS.codeListDataTable GetTradeActions() { databases.tmpDS.codeListDataTable tbl = new databases.tmpDS.codeListDataTable(); databases.tmpDS.codeListRow row; foreach (AppTypes.TradeActions item in Enum.GetValues(typeof(AppTypes.TradeActions))) { row = tbl.NewcodeListRow(); row.code = ((byte)item).ToString(); row.byteValue = (byte)item; row.description = AppTypes.Type2Text(item); tbl.AddcodeListRow(row); } return(tbl); }
private void allProfitDetailMenu_Click(object sender, EventArgs e) { try { using (new DataAccess.PleaseWait()) { common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView; if (resultDataGrid == null) { return; } string stockCode = resultTab.SelectedTab.Name; data.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode); if (stockCodeRow == null) { return; } if (resultDataGrid.SelectedRows.Count > 0) { for (int rowId = 0; rowId < resultDataGrid.SelectedRows.Count; rowId++) { application.Strategy.Meta meta = application.Strategy.Libs.FindMetaByName(resultDataGrid.SelectedRows[rowId].Cells[0].Value.ToString()); for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++) { AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName); ShowTradeTransactions(stockCodeRow, meta.Code, timeRange, timeScaleCb.myValue); } } } else { if (resultDataGrid.CurrentRow != null) { application.Strategy.Meta meta = application.Strategy.Libs.FindMetaByName(resultDataGrid.CurrentRow.Cells[0].Value.ToString()); for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++) { AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName); ShowTradeTransactions(stockCodeRow, meta.Code, timeRange, timeScaleCb.myValue); } } } } } catch (Exception er) { this.ShowError(er); } }
public int ImportSteamData() { AppTypes included = AppTypes.InclusionNormal; if (BypassIgnoreOnImport) { included = AppTypes.InclusionAll; } else if (IncludeUnknown) { included |= AppTypes.Unknown; } return(GameData.ImportSteamConfig(SteamID64, IgnoreList, included, IncludeShortcuts)); }
private void profitEstimateMenu_Click(object sender, EventArgs e) { try { common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView; if (resultDataGrid == null) { return; } string stockCode = resultTab.SelectedTab.Name; string strategyCode = ""; data.baseDS.stockCodeRow stockCodeRow = application.dataLibs.FindAndCache(myDataSet.stockCode, stockCode); if (stockCodeRow == null) { return; } if (resultDataGrid.SelectedRows.Count > 0) { for (int rowId = 0; rowId < resultDataGrid.SelectedRows.Count; rowId++) { strategyCode = resultDataGrid.SelectedRows[rowId].Cells[0].Value.ToString(); for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++) { AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName); ShowTradeTransactions(stockCodeRow, strategyCode, timeRange, cbTimeScale.myValue); } } } else { if (resultDataGrid.CurrentRow != null) { strategyCode = resultDataGrid.CurrentRow.Cells[0].Value.ToString(); for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++) { AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName); ShowTradeTransactions(stockCodeRow, strategyCode, timeRange, cbTimeScale.myValue); } } } } catch (Exception er) { this.ShowError(er); } }
/// <summary> /// 指定したアプリのInstallDirをレジストリに格納された情報から返す /// </summary> /// <param name="types"></param> /// <returns></returns> static internal string GetInstallDir(AppTypes types) { const string INSTALLDIR = @"InstallDir"; const string REALVERSION = @"RealVersion"; string installDir = string.Empty; RegistryKey agskey = null; System.Object installKey = null; try { System.Object tempDesk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\ArcGIS").GetValue(REALVERSION); string curVer = tempDesk.ToString().Substring(0, 4); //LocalMachineレジストリ検索用に4文字を返す(10.6.x ⇒ 10.6 ) switch (types) { case AppTypes.DESKTOP: agskey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\Desktop" + curVer); // 32bitのレジストリ(64bitではWow6432Node) break; case AppTypes.ENGINE: agskey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\Engine" + curVer); // 32bitのレジストリ(64bitではWow6432Node) break; } installKey = agskey.GetValue(INSTALLDIR); installDir = installKey.ToString(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace); //MessageBox.Show(ex.StackTrace); throw; } finally { if (agskey != null) { agskey.Close(); } } return(installDir); }
protected override void MergeEntity(AppGroup source, bool clone) { base.MergeEntity(source, clone); if (AppGroupName != source.AppGroupName) { AppGroupName = source.AppGroupName; } _LastAppInfoID = source._LastAppInfoID; AppTypes.Combine(source.AppTypes, clone); if (clone) { ReInitImages(); //StartLoadImages(); } }
/// <summary> /// Transfer concurrent data from scan to analyze result with sorted, simplier types for callers /// </summary> public void PrepareReport() { Metadata.CPUTargets = CPUTargets.ToImmutableSortedDictionary().Keys.ToList(); Metadata.AppTypes = AppTypes.ToImmutableSortedDictionary().Keys.ToList(); Metadata.OSTargets = OSTargets.ToImmutableSortedDictionary().Keys.ToList(); Metadata.UniqueDependencies = UniqueDependencies.ToImmutableSortedDictionary().Keys.ToList(); Metadata.UniqueTags = UniqueTags.ToImmutableSortedDictionary().Keys.ToList(); Metadata.CloudTargets = CloudTargets.ToImmutableSortedDictionary().Keys.ToList(); Metadata.PackageTypes = PackageTypes.ToImmutableSortedDictionary().Keys.ToList(); Metadata.FileExtensions = FileExtensions.ToImmutableSortedDictionary().Keys.ToList(); Metadata.Outputs = Outputs.ToImmutableSortedDictionary().Keys.ToList(); Metadata.Targets = Targets.ToImmutableSortedDictionary().Keys.ToList(); Metadata.Languages = Languages.ToImmutableSortedDictionary(); foreach (MetricTagCounter metricTagCounter in TagCounters.Values) { Metadata?.TagCounters?.Add(metricTagCounter); } }
private void DoRanking() { this.myValueType = ValueTypes.Amount; this.Amount2PercentDenominator = application.Settings.sysStockTotalCapAmt; resultTab.TabPages.Clear(); StringCollection stockCodeList = stockCodeSelectLb.myValues; StringCollection strategyList = strategyClb.myCheckedValues; StringCollection timeRangeList = timeRangeLb.myCheckedValues; progressBar.Value = 0; progressBar.Minimum = 0; progressBar.Maximum = stockCodeList.Count * timeRangeList.Count; for (int stockCodeId = 0; stockCodeId < stockCodeList.Count; stockCodeId++) { string stockCode = stockCodeList[stockCodeId].ToString(); DataTable testRetsultTbl = CreateDataTable(timeRangeList, strategyList); common.controls.baseDataGridView resultGrid = CreateResultGrid(stockCode, testRetsultTbl); for (int colId = 0; colId < timeRangeList.Count; colId++) { AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(timeRangeList[colId]); decimal profit = 0; application.Data analysisData = new application.Data(timeRange, cbTimeScale.myValue, stockCode); for (int rowId = 0; rowId < strategyList.Count; rowId++) { profit = 0; //Analysis cached data so we MUST clear cache to ensure the system run correctly Strategy.Data.ClearCache(); Strategy.TradePoints advices = Strategy.Libs.Analysis(analysisData, strategyList[rowId]); if (advices != null) { myTmpDS.tradeEstimate.Clear(); Strategy.Libs.EstimateTrading(analysisData, advices, new Strategy.Libs.EstimateOptions(), myTmpDS.tradeEstimate); profit = (myTmpDS.tradeEstimate.Count == 0 ? 0 : profit = myTmpDS.tradeEstimate[myTmpDS.tradeEstimate.Count - 1].profit); } testRetsultTbl.Rows[rowId][colId + 1] = profit; } progressBar.Value++; Application.DoEvents(); } } FormResize(); }
private void dataGrid_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (resultDataGrid.CurrentRow == null) { return; } string stockCode = resultDataGrid.CurrentRow.Cells[0].Value.ToString(); if (e.ColumnIndex == 0) { //ShowStock(stockCode, Settings.sysScreeningTimeRange, Settings.sysScreeningTimeScale); ShowStock(stockCode, Settings.sysGlobal.DefaultTimeRange, AppTypes.TimeScaleFromCode(Settings.sysGlobal.ScreeningTimeScaleCode)); return; } } catch (Exception er) { this.ShowError(er); } }
public async Task <AccountTip> GetAccountTipAsync(AppTypes appType) { if (New <AxCryptOnlineState>().IsOffline) { return(new AccountTip()); } if (Identity.IsEmpty) { return(new AccountTip()); } Uri resource = BaseUrl.PathCombine($"users/my/account/tip?apptype={(int)appType}"); RestResponse response = await Caller.RestAsync(Identity, new RestRequest("GET", resource, Timeout)); ApiCaller.EnsureStatusOk(response); AccountTip tip = Serializer.Deserialize <AccountTip>(response.Content); return(tip); }
private void LoadSettings() { //General accessLogMediaCb.myValue = Settings.sysGlobal.WriteLogAccess; passwordMinLenEd.Value = Settings.sysGlobal.PasswordMinLen; useStrongPassChk.Checked = Settings.sysGlobal.UseStrongPassword; dayScanForLastPriceEd.myValue = Settings.sysGlobal.DayScanForLastPrice; alertDataCountEd.myValue = Settings.sysGlobal.AlertDataCount; chartMaxLoadFirstEd.myValue = Settings.sysGlobal.ChartMaxLoadCount_FIRST; chartMaxLoadNextEd.myValue = Settings.sysGlobal.ChartMaxLoadCount_MORE; //Auto number sysDataKeyPrefixEd.Text = Settings.sysGlobal.DataKeyPrefix; sysAutoDataKeySizeEd.myValue = Settings.sysGlobal.DataKeySize; sysAutoEditKeySizeEd.myValue = Settings.sysGlobal.AutoEditKeySize; timeOutAutoKeyEd.Value = Settings.sysGlobal.TimeOut_AutoKey; //email smtpServerEd.Text = Settings.sysGlobal.smtpAddress; smtpPortEd.Text = Settings.sysGlobal.smtpPort.ToString(); smtpAuthAccountEd.Text = (Settings.sysGlobal.smtpAuthAccount == null ? "" : Settings.sysGlobal.smtpAuthAccount); smtpAuthPasswordEd.Text = (Settings.sysGlobal.smtpAuthPassword == null ? "" : Settings.sysGlobal.smtpAuthPassword); smtpSSLChk.Checked = Settings.sysGlobal.smtpSSL; //Default defaLanguageCb.myValue = Settings.sysGlobal.DefautLanguage; defaTimeRangeCb.myValue = Settings.sysGlobal.DefaultTimeRange; defaTimeScaleCb.myValue = AppTypes.TimeScaleFromCode(Settings.sysGlobal.DefaultTimeScaleCode); screenDataCountEd.Value = Settings.sysGlobal.ScreeningDataCount; screenTimeScaleCb.myValue = AppTypes.TimeScaleFromCode(Settings.sysGlobal.ScreeningTimeScaleCode); //Timming timerIntervalEd.myValue = Settings.sysGlobal.TimerIntervalInSecs; refreshDataEd.myValue = Settings.sysGlobal.RefreshDataInSecs; tradeAlertCreationEd.myValue = Settings.sysGlobal.CheckAlertInSeconds; autoCheckEd.myValue = Settings.sysGlobal.AutoCheckInSeconds; }
private void loadPriceBtn_Click(object sender, EventArgs e) { try { this.ShowMessage(""); if (!DataValid_Edit()) { return; } loadPriceBtn.Enabled = false; DateTime frDate = editFrDateEd.myDateTime; DateTime toDate = editToDateEd.myDateTime; System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); string timeScaleCode = AppTypes.TimeScaleTypeToCode(AppTypes.TimeScaleTypes.RealTime); databases.baseDS.priceDataDataTable priceTbl = DataAccess.Libs.GetPriceData(dataCodeEd.Text.Trim(), timeScaleCode, editFrDateEd.myDateTime, editToDateEd.myDateTime); if (priceTbl == null) { return; } priceDataSource.DataSource = priceTbl; priceDataSource.Sort = priceTbl.onDateColumn.ColumnName + " DESC"; watch.Stop(); this.ShowMessage(Languages.Libs.GetString("finished") + " : " + common.dateTimeLibs.TimeSpan2String(watch.Elapsed)); this.ShowReccount(priceDataSource.Count); fullMode = true; } catch (Exception er) { this.ShowError(er); } finally { loadPriceBtn.Enabled = true; } }
private static DataTable CreateDataTable(StringCollection timeRangeList, StringCollection strategyList) { // Define the new datatable DataTable tbl = new DataTable(); // Define columns DataColumn col = new DataColumn("item"); tbl.Columns.Add(col); for (int idx = 0; idx < timeRangeList.Count; idx++) { string colName = timeRangeList[idx]; col = new DataColumn(colName, typeof(Decimal)); col.Caption = AppTypes.Type2Text(AppTypes.TimeRangeFromCode(timeRangeList[idx])); tbl.Columns.Add(col); } for (int rowId = 0; rowId < strategyList.Count; rowId++) { tbl.Rows.Add(strategyList[rowId]); } return(tbl); }
/// <summary> /// Set Output property from a formated string. /// </summary> /// <param name="str"> In the format ([key]=[Color]:[Weight*]:[ChartType*]) </param> /// <returns></returns> private static common.DictionaryList String2OutputList(string str) { common.DictionaryList list = new common.DictionaryList(); common.myKeyValueItem[] keyValues = common.system.String2KeyValueList(str, ",", "="); Color color = Data.sysDefaultLineColor; int weight = 1; AppTypes.ChartTypes chartType = Data.sysDefaultLineChartType; for (int idx = 0; idx < keyValues.Length; idx++) { string[] parts = common.system.String2List(keyValues[idx].Value, ":", StringSplitOptions.None); color = (parts.Length > 0 ? ColorTranslator.FromHtml(parts[0]) : Data.sysDefaultLineColor); weight = Data.sysDefaultLineWeight; if (parts.Length > 1) { int.TryParse(parts[1], out weight); } chartType = (parts.Length > 2 ? AppTypes.Text2ChartType(parts[2]) : Data.sysDefaultLineChartType); list.Add(keyValues[idx].Key, new Meta.OutputInfo(color, weight, chartType)); } return(list); }
private DataTable CreateCriteriaTable() { //Type data DataTable typeTbl = new DataTable(); DataColumn col1 = new DataColumn("code", typeof(byte)); typeTbl.Columns.Add(col1); DataColumn col2 = new DataColumn("description"); typeTbl.Columns.Add(col2); foreach (AppTypes.ScreeningCriteriaTypes item in Enum.GetValues(typeof(AppTypes.ScreeningCriteriaTypes))) { DataRow row = typeTbl.Rows.Add((byte)item); row[1] = AppTypes.Type2Text(item); } //Binding this.scrTypeCol.DataPropertyName = "type"; this.scrTypeCol.DisplayMember = typeTbl.Columns[1].ColumnName; this.scrTypeCol.ValueMember = typeTbl.Columns[0].ColumnName; this.scrTypeCol.DataSource = typeTbl; this.scrMinCol.DataPropertyName = "min"; this.scrMaxCol.DataPropertyName = "max"; //Grid datasource DataTable tbl = new DataTable(); tbl.Columns.Add(new DataColumn("type", typeof(byte))); tbl.Columns.Add(new DataColumn("min", typeof(double))); tbl.Columns.Add(new DataColumn("max", typeof(double))); scrCriteriaGrid.DataSource = tbl; common.system.AutoFitGridColumn(scrCriteriaGrid, this.scrTypeCol.Name); return(tbl); }
/// <summary> /// Get meta data from meta file /// </summary> /// <param name="meta"></param> /// <returns></returns> public static bool GetMeta(Meta meta) { StringCollection aFields = new StringCollection(); aFields.Clear(); aFields.Add("Type"); aFields.Add("Code"); aFields.Add("Name"); aFields.Add("Description"); aFields.Add("Category"); aFields.Add("Parameters"); aFields.Add("ParameterPrecision"); aFields.Add("ParameterDescriptions"); aFields.Add("URL"); aFields.Add("Authors"); aFields.Add("Version"); common.configuration.GetConfiguration(Data.sysXmlDocument, "STRATEGY", meta.ClassType.Name, aFields, false); meta.Type = AppTypes.Text2StrategyType(aFields[0]); meta.Code = aFields[1]; meta.Name = aFields[2]; meta.Description = aFields[3]; meta.Category = aFields[4]; meta.ParameterList = String2ParameterList(aFields[5]); int num = 0; int.TryParse(aFields[6], out num); meta.ParameterPrecision = num; meta.ParameterDescriptions = common.system.String2List(aFields[7]); meta.URL = aFields[8]; meta.Authors = aFields[9]; meta.Version = aFields[10]; return(true); }
private static DataTable CreateDataTable(StringCollection timeRangeList, string[] strategyList) { // Define the new datatable DataTable tbl = new DataTable(); // Define columns DataColumn col = new DataColumn("item"); tbl.Columns.Add(col); for (int idx = 0; idx < timeRangeList.Count; idx++) { string colName = timeRangeList[idx]; col = new DataColumn(colName, typeof(Decimal)); col.Caption = AppTypes.Type2Text(AppTypes.TimeRangeFromCode(timeRangeList[idx])); tbl.Columns.Add(col); } application.Strategy.StrategyMeta meta; for (int rowId = 0; rowId < strategyList.Length; rowId++) { meta = application.Strategy.StrategyLibs.FindMetaByCode(strategyList[rowId]); tbl.Rows.Add(meta.Name.Trim()); } return(tbl); }
private void openMenuItem_Click(object sender, EventArgs e) { try { string stockCode = resultTab.SelectedTab.Name; if (this.CurrentDataGridView == null) { return; } AppTypes.TimeRanges timeRange = AppTypes.TimeRanges.All; common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView; if (resultDataGrid.CurrentCell != null && resultDataGrid.CurrentCell.ColumnIndex > 0) { int colId = resultDataGrid.CurrentCell.ColumnIndex; timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[colId].DataPropertyName); } ShowStock(stockCode, timeRange, timeScaleCb.myValue); } catch (Exception er) { this.ShowError(er); } }
private void profitDetailMenu_Click(object sender, EventArgs e) { try { common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView; if (resultDataGrid == null || resultDataGrid.CurrentRow == null || resultDataGrid.CurrentCell == null) { return; } //TUAN - 29 Sept 2012 fix bug profit detail and all profit details if (resultDataGrid.CurrentCell.ColumnIndex < 0) { return; } //TUAN - 29 Sept 2012 fix bug profit detail and all profit details string stockCode = resultTab.SelectedTab.Name; databases.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode); if (stockCodeRow == null) { return; } application.Strategy.StrategyMeta meta = application.Strategy.StrategyLibs.FindMetaByName(resultDataGrid.CurrentRow.Cells[0].Value.ToString()); //TUAN - 29 Sept 2012 fix bug profit detail and all profit details int colId = resultDataGrid.CurrentCell.ColumnIndex == 0 ? 1 : resultDataGrid.CurrentCell.ColumnIndex; //TUAN - 29 Sept 2012 fix bug profit detail and all profit details DataParams dataParam = new DataParams(timeScaleCb.myValue.Code, AppTypes.TimeRangeFromCode(resultDataGrid.Columns[colId].DataPropertyName), 0); ShowTradeTransactions(stockCodeRow, meta.Code, dataParam); } catch (Exception er) { this.ShowError(er); } }
/// <summary> /// Get LastPlayed date from a VDF node containing a list of games. /// Any games in the node not found in the game list will be added to the gamelist. /// </summary> /// <param name="appsNode">Node containing the game nodes</param> /// <param name="ignore">Set of games to ignore</param> /// <param name="forceInclude">Include games even if their type is not an included type</param> private void GetLastPlayedFromVdf(VdfFileNode appsNode, SortedSet<int> ignore, AppTypes includedTypes) { Dictionary<string, VdfFileNode> gameNodeArray = appsNode.NodeArray; if (gameNodeArray != null) { foreach (KeyValuePair<string, VdfFileNode> gameNodePair in gameNodeArray) { int gameId; if (int.TryParse(gameNodePair.Key, out gameId)) { if ((ignore != null && ignore.Contains(gameId)) || !Program.GameDB.IncludeItemInGameList(gameId, includedTypes)) { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameData_SkippedProcessingGame, gameId); } else if (gameNodePair.Value != null && gameNodePair.Value.NodeType == ValueType.Array) { GameInfo game = null; // Add the game to the list if it doesn't exist already if (!Games.ContainsKey(gameId)) { game = new GameInfo(gameId, Program.GameDB.GetName(gameId), this); Games.Add(gameId, game); Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameData_AddedNewGame, gameId, game.Name); } else { game = Games[gameId]; } if (gameNodePair.Value.ContainsKey("LastPlayed") && gameNodePair.Value["LastPlayed"].NodeInt != 0) { DateTime dt = Utility.GetDTFromUTime(gameNodePair.Value["LastPlayed"].NodeInt); if (dt > game.LastPlayed) game.LastPlayed = dt; Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameData_ProcessedGame, gameId, game.LastPlayed.ToString()); } } } } } }
/// <summary> /// Updates the game list based on data from the localconfig file and the package cache, including LastPlayed. /// </summary> /// <param name="accountId">64-bit account ID to update for</param> /// <param name="ignored">Set of games to ignore</param> /// <param name="includeUnknown">If true, include games that do not exist in the database or are of unknown type in the database</param> public int UpdateGameListFromOwnedPackageInfo( Int64 accountId, SortedSet<int> ignored, AppTypes includedTypes, out int newApps ) { newApps = 0; int totalApps = 0; Dictionary<int, PackageInfo> allPackages = PackageInfo.LoadPackages( string.Format( Properties.Resources.PackageInfoPath, Settings.Instance.SteamPath ) ); Dictionary<int, GameListingSource> ownedApps = new Dictionary<int, GameListingSource>(); string localConfigPath = string.Format( Properties.Resources.LocalConfigPath, Settings.Instance.SteamPath, Profile.ID64toDirName( accountId ) ); VdfFileNode vdfFile = VdfFileNode.LoadFromText( new StreamReader( localConfigPath ) ); if( vdfFile != null ) { VdfFileNode licensesNode = vdfFile.GetNodeAt( new string[] { "UserLocalConfigStore", "Licenses" }, false ); if( licensesNode != null && licensesNode.NodeType == ValueType.Array ) { foreach( string key in licensesNode.NodeArray.Keys ) { int ownedPackageId; if( int.TryParse( key, out ownedPackageId ) ) { PackageInfo ownedPackage = allPackages[ownedPackageId]; if( ownedPackageId != 0 && !ownedPackage.IsExpired ) { GameListingSource src = ( ownedPackage.BillingType == PackageBillingType.FreeOnDemand || ownedPackage.BillingType == PackageBillingType.AutoGrant ) ? GameListingSource.PackageFree : GameListingSource.PackageNormal; foreach( int ownedAppId in ownedPackage.AppIds ) { if( !ownedApps.ContainsKey( ownedAppId ) || ( src == GameListingSource.PackageNormal && ownedApps[ownedAppId] == GameListingSource.PackageFree ) ) ownedApps[ownedAppId] = src; } } } } } // update LastPlayed VdfFileNode appsNode = vdfFile.GetNodeAt(new string[] { "UserLocalConfigStore", "Software", "Valve", "Steam", "apps" }, false); GetLastPlayedFromVdf(appsNode, ignored, includedTypes); } foreach( KeyValuePair<int, GameListingSource> kv in ownedApps ) { bool isNew; string name = Program.GameDB.GetName( kv.Key ); GameInfo newGame = IntegrateGame( kv.Key, name, false, ignored, includedTypes, kv.Value, out isNew ); if( newGame != null ) totalApps++; if( isNew ) newApps++; } return totalApps; }
/// <summary> /// Integrates list of games from an XmlDocument into the loaded game list. /// </summary> /// <param name="doc">The XmlDocument containing the new game list</param> /// <param name="overWrite">If true, overwrite the names of games already in the list.</param> /// <param name="ignore">A set of item IDs to ignore.</param> /// <param name="ignoreDlc">Ignore any items classified as DLC in the database.</param> /// <param name="newItems">The number of new items actually added</param> /// <returns>Returns the number of games successfully processed and not ignored.</returns> public int IntegrateXmlGameList( XmlDocument doc, bool overWrite, SortedSet<int> ignore, AppTypes includedTypes, out int newItems ) { newItems = 0; if( doc == null ) return 0; int loadedGames = 0; XmlNodeList gameNodes = doc.SelectNodes( "/gamesList/games/game" ); foreach( XmlNode gameNode in gameNodes ) { int appId; XmlNode appIdNode = gameNode["appID"]; if( appIdNode != null && int.TryParse( appIdNode.InnerText, out appId ) ) { XmlNode nameNode = gameNode["name"]; if( nameNode != null ) { bool isNew; GameInfo integratedGame = IntegrateGame( appId, nameNode.InnerText, overWrite, ignore, includedTypes, GameListingSource.WebProfile, out isNew ); if( integratedGame != null ) { loadedGames++; if( isNew ) { newItems++; } } } } } Program.Logger.Write( LoggerLevel.Info, GlobalStrings.GameData_IntegratedXMLDataIntoGameList, loadedGames, newItems ); return loadedGames; }
public TradePointInfo(AppTypes.TradeActions action, int dataIdx, BusinessInfo info) { this.TradeAction = action; this.DataIdx = dataIdx; this.BusinessInfo.Set(info); }
public static databases.baseDS.portfolioDataTable GetPortfolio_ByInvestorAndType(string investorCode, AppTypes.PortfolioTypes type) { try { lock (myClient) { return myClient.GetPortfolio_ByInvestorAndType(investorCode, type); } } catch (Exception er) { if (OnError != null) OnError(er); } return null; }
private void AddStockToWatchList(string stockCode,StringCollection strategyCodes,AppTypes.TimeScale timeScale) { baseClass.Forms.addToWatchList_StockAndStrategy myForm = baseClass.Forms.addToWatchList_StockAndStrategy.GetForm(""); myForm.ShowForm(stockCode,strategyCodes,timeScale); }
/// <summary> /// Loads category info from the steam config file for the given Steam user. /// </summary> /// <param name="SteamId">Identifier of Steam user</param> /// <param name="ignore">Set of games to ignore</param> /// <param name="forceInclude">If true, include games that do not match the included types</param> /// <param name="includeShortcuts">If true, also import shortcut data</param> /// <returns>The number of game entries found</returns> public int ImportSteamConfig( long SteamId, SortedSet<int> ignore, AppTypes includedTypes, bool includeShortcuts ) { string filePath = string.Format( Properties.Resources.ConfigFilePath, Settings.Instance.SteamPath, Profile.ID64toDirName( SteamId ) ); int result = ImportSteamConfigFile( filePath, ignore, includedTypes ); if( includeShortcuts ) { result += ImportSteamShortcuts( SteamId ); } return result; }
private void ShowStockHandler(string stockCode,AppTypes.TimeRanges timeRange, AppTypes.TimeScale timeScale) { try { ShowStockChart(stockCode, timeRange, timeScale); } catch (Exception er) { this.ShowError(er); } }
/// <summary> /// Set language for the application /// </summary> /// <param name="code"></param> /// <param name="force"></param> private void SetCulture(AppTypes.LanguageCodes code,bool force) { Settings.sysLanguage = code; CultureInfo newCulture = AppTypes.Code2Culture(code); if (!force && (newCulture == common.language.myCulture)) return; common.language.myCulture = newCulture; switch (code) { case AppTypes.LanguageCodes.VI: vietnameseMenuItem.Checked = true; englishMenuItem.Checked = false; break; default: vietnameseMenuItem.Checked = false; englishMenuItem.Checked = true; break; } common.language.SetLanguage(); commonClass.SysLibs.SetLanguage(); application.Strategy.StrategyData.Clear(); application.Indicators.Data.Clear(); SetLanguage(); SetLanguageAllOpenForms(); }
public TradePointInfo(AppTypes.TradeActions action, int dataIdx) { this.TradeAction = action; this.DataIdx = dataIdx; }
public DataParams(string timeScale,AppTypes.TimeRanges timeRange,int maxDataCount) { this.TimeRange = timeRange; this.MaxDataCount = maxDataCount; this.TimeScale = timeScale; }
/// <summary> /// Add constructor that initiates DateTime /// </summary> /// <param name="action"></param> /// <param name="dataIdx"></param> /// <param name="dt"></param> /// <param name="info"></param> public TradePointInfo(AppTypes.TradeActions action, int dataIdx, DateTime dt, BusinessInfo info) { this.TradeAction = action; this.DataIdx = dataIdx; this.BusinessInfo.Set(info); this.date_time = dt; }
/// <summary> /// Adds a new game to the database, or updates an existing game with new information. /// </summary> /// <param name="appId">App ID to add or update</param> /// <param name="appName">Name of app to add, or update to</param> /// <param name="overwriteName">If true, will overwrite any existing games. If false, will fail if the game already exists.</param> /// <param name="ignore">Set of games to ignore. Can be null. If the game is in this list, no action will be taken.</param> /// <param name="forceInclude">If true, include the game even if it is of an ignored type.</param> /// <param name="src">The listing source that this request came from.</param> /// <param name="isNew">If true, a new game was added. If false, an existing game was updated, or the operation failed.</param> /// <returns>True if the game was integrated, false otherwise.</returns> private GameInfo IntegrateGame( int appId, string appName, bool overwriteName, SortedSet<int> ignore, AppTypes includedTypes, GameListingSource src, out bool isNew ) { isNew = false; if( ( ignore != null && ignore.Contains( appId ) ) || !Program.GameDB.IncludeItemInGameList( appId, includedTypes ) ) { Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_SkippedIntegratingGame, appId, appName ); return null; } GameInfo result = null; if( !Games.ContainsKey( appId ) ) { result = new GameInfo( appId, appName, this ); Games.Add( appId, result ); isNew = true; } else { result = Games[appId]; if( overwriteName ) { result.Name = appName; } } result.ApplySource( src ); Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_IntegratedGameIntoGameList, appId, appName, isNew ); return result; }
private void ShowStockChart(string stockCode,AppTypes.TimeRanges timeRange, AppTypes.TimeScale timeScale) { DateTime frDate = common.Consts.constNullDate, toDate = common.Consts.constNullDate; if (!AppTypes.GetDate(timeRange, out frDate, out toDate)) return; //string formName = constFormNameStock + stockCode.Trim(); //TUAN- enable open new form with a same stock code string formName = CreateNewStockFormName(); //TUAN- enable open new form with a same stock code Tools.Forms.tradeAnalysis myForm = (Tools.Forms.tradeAnalysis)cachedForms.Find(formName); if (myForm == null || myForm.IsDisposed) { myForm = new Tools.Forms.tradeAnalysis(); myForm.Name = formName; myForm.ChartTimeRange = AppTypes.TimeRanges.None; // timeRange; myForm.ChartTimeScale = timeScale; myForm.ChartPriceType = this.ChartType; myForm.UseStock(DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode)); myForm.Activated += new System.EventHandler(this.tradeAnalysisActivatedHandler); //Cache it if no error occured cachedForms.Add(formName, myForm); } myForm.myContextMenuStrip = CreateContextMenu_TradeAnalysis(); myForm.myContextMenuStrip.Font = Settings.sysFontMenu; myForm.Show(dockPanel); UpdateActiveForm(FormOptions.ChartType); }
/// <summary> /// Loads in games from a VDF node containing a list of games. /// Any games in the node not found in the game list will be added to the gamelist. /// If a game in the node has a tags subnode, the "favorite" field will be overwritten. /// If a game in the node has a category set, it will overwrite any categories in the gamelist. /// If a game in the node does NOT have a category set, the category in the gamelist will NOT be cleared. /// </summary> /// <param name="appsNode">Node containing the game nodes</param> /// <param name="ignore">Set of games to ignore</param> /// <param name="forceInclude">Include games even if their type is not an included type</param> /// <returns>Number of games loaded</returns> private int IntegrateGamesFromVdf( VdfFileNode appsNode, SortedSet<int> ignore, AppTypes includedTypes ) { int loadedGames = 0; Dictionary<string, VdfFileNode> gameNodeArray = appsNode.NodeArray; if( gameNodeArray != null ) { foreach( KeyValuePair<string, VdfFileNode> gameNodePair in gameNodeArray ) { int gameId; if( int.TryParse( gameNodePair.Key, out gameId ) ) { if( ( ignore != null && ignore.Contains( gameId ) ) || !Program.GameDB.IncludeItemInGameList( gameId, includedTypes ) ) { Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_SkippedProcessingGame, gameId ); } else if( gameNodePair.Value != null && gameNodePair.Value.NodeType == ValueType.Array ) { GameInfo game = null; // Add the game to the list if it doesn't exist already if( !Games.ContainsKey( gameId ) ) { game = new GameInfo( gameId, Program.GameDB.GetName( gameId ), this ); Games.Add( gameId, game ); Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_AddedNewGame, gameId, game.Name ); } else { game = Games[gameId]; } loadedGames++; game.ApplySource( GameListingSource.SteamConfig ); game.Hidden = ( gameNodePair.Value.ContainsKey( "hidden" ) && gameNodePair.Value["hidden"].NodeInt != 0 ); VdfFileNode tagsNode = gameNodePair.Value["tags"]; if( tagsNode != null ) { Dictionary<string, VdfFileNode> tagArray = tagsNode.NodeArray; if( tagArray != null ) { List<Category> cats = new List<Category>( tagArray.Count ); foreach( VdfFileNode tag in tagArray.Values ) { string tagName = tag.NodeString; if( tagName != null ) { Category c = GetCategory( tagName ); if( c != null ) cats.Add( c ); } } if( cats.Count > 0 ) { SetGameCategories( gameId, cats, false ); } } } Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_ProcessedGame, gameId, string.Join( ",", game.Categories ) ); } } } } return loadedGames; }
protected void ShowStock(string stockCode, AppTypes.TimeRanges timeRange, AppTypes.TimeScale timeScale) { if (myShowStock == null) return; myShowStock(stockCode, timeRange, timeScale); }
/// <summary> /// Loads category info from the given steam config file. /// </summary> /// <param name="filePath">The path of the file to open</param> /// <param name="ignore">Set of game IDs to ignore</param> /// <param name="forceInclude">If true, include games even if they are not of an included type</param> /// <returns>The number of game entries found</returns> public int ImportSteamConfigFile( string filePath, SortedSet<int> ignore, AppTypes includedTypes ) { Program.Logger.Write( LoggerLevel.Info, GlobalStrings.GameData_OpeningSteamConfigFile, filePath ); VdfFileNode dataRoot; try { using( StreamReader reader = new StreamReader( filePath, false ) ) { dataRoot = VdfFileNode.LoadFromText( reader, true ); } } catch( ParseException e ) { Program.Logger.Write( LoggerLevel.Error, GlobalStrings.GameData_ErrorParsingConfigFileParam, e.Message ); throw new ApplicationException( GlobalStrings.GameData_ErrorParsingSteamConfigFile + e.Message, e ); } catch( IOException e ) { Program.Logger.Write( LoggerLevel.Error, GlobalStrings.GameData_ErrorOpeningConfigFileParam, e.Message ); throw new ApplicationException( GlobalStrings.GameData_ErrorOpeningSteamConfigFile + e.Message, e ); } VdfFileNode appsNode = dataRoot.GetNodeAt( new string[] { "Software", "Valve", "Steam", "apps" }, true ); int count = IntegrateGamesFromVdf( appsNode, ignore, includedTypes ); Program.Logger.Write( LoggerLevel.Info, GlobalStrings.GameData_SteamConfigFileLoaded, count ); return count; }
public void SetTrend(AppTypes.MarketTrend shortTerm, AppTypes.MarketTrend mediumTerm, AppTypes.MarketTrend longTerm) { this.ShortTermTrend = shortTerm; this.MediumTermTrend = mediumTerm; this.LongTermTrend = longTerm; }
public static databases.baseDS.portfolioDetailDataTable GetPortfolioDetail_ByType(AppTypes.PortfolioTypes[] types) { try { lock (myClient) { return myClient.GetPortfolioDetail_ByType(types); } } catch (Exception er) { if (OnError != null) OnError(er); } return null; }
/// <summary> /// Integrates list of games from an HTML page into the loaded game list. /// </summary> /// <param name="page">The full text of the page to load</param> /// <param name="overWrite">If true, overwrite the names of games already in the list.</param> /// <param name="ignore">A set of item IDs to ignore. Can be null.</param> /// <param name="ignoreDlc">Ignore any items classified as DLC in the database.</param> /// <param name="newItems">The number of new items actually added</param> /// <returns>Returns the number of games successfully processed and not ignored.</returns> public int IntegrateHtmlGameList( string page, bool overWrite, SortedSet<int> ignore, AppTypes includedTypes, out int newItems ) { newItems = 0; int totalItems = 0; Regex srch = new Regex( "\"appid\":([0-9]+),\"name\":\"([^\"]+)\"" ); MatchCollection matches = srch.Matches( page ); foreach( Match m in matches ) { if( m.Groups.Count < 3 ) continue; string appIdString = m.Groups[1].Value; string appName = m.Groups[2].Value; int appId; if( appName != null && appIdString != null && int.TryParse( appIdString, out appId ) ) { appName = ProcessUnicode( appName ); bool isNew; GameInfo integratedGame = IntegrateGame( appId, appName, overWrite, ignore, includedTypes, GameListingSource.WebProfile, out isNew ); if( integratedGame != null ) { totalItems++; if( isNew ) { newItems++; } } } } Program.Logger.Write( LoggerLevel.Info, GlobalStrings.GameData_IntegratedHTMLDataIntoGameList, totalItems, newItems ); return totalItems; }
public BaseAnalysisData(string stockCode, AppTypes.TimeScale timeScale, AppTypes.TimeRanges timeRange,int dataMaxCount) { this.DataStockCode = stockCode; this.DataTimeScale = timeScale; this.DataTimeRange = timeRange; this.DataMaxCount = dataMaxCount; ClearCache(); LoadData(); }
public TradePointInfo(AppTypes.TradeActions action, int dataIdx, DateTime dt) { this.TradeAction = action; this.DataIdx = dataIdx; this.date_time = dt; }
/// <summary> /// Private helper function to perform scraping work. Downloads the given store page and updates the entry with all information found. /// </summary> /// <param name="id">The id of the store page to scrape</param> /// <returns>The type determined during the scrape</returns> private AppTypes ScrapeStoreHelper(int id) { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_InitiatingStoreScrapeForGame, id); string page = ""; int redirectTarget = -1; int oldTime = LastStoreScrape; try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(string.Format(Properties.Resources.UrlSteamStore, id)); // Cookie bypasses the age gate req.CookieContainer = new CookieContainer(1); req.CookieContainer.Add(new Cookie("birthtime", "-2208959999", "/", "store.steampowered.com")); using (WebResponse resp = req.GetResponse()) { LastStoreScrape = Utility.GetCurrentUTime(); if (resp.ResponseUri.Segments.Length < 2) // If we were redirected to the store front page { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingRedirectedToMainStorePage, id); SetTypeFromStoreScrape(AppTypes.Unknown); return(AppTypes.Unknown); } else if (resp.ResponseUri.Segments[1] == "agecheck/") // If we encountered an age gate (cookies should bypass this, but sometimes they don't seem to) { if (resp.ResponseUri.Segments.Length >= 4 && resp.ResponseUri.Segments[3].TrimEnd('/') != id.ToString()) // Age check + redirect { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingHitAgeCheck, id, resp.ResponseUri.Segments[3].TrimEnd('/')); if (int.TryParse(resp.ResponseUri.Segments[3].TrimEnd('/'), out redirectTarget)) { } else // If we got an age check without numeric id (shouldn't happen) { return(AppTypes.Unknown); } } else // If we got an age check with no redirect { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingAgeCheckNoRedirect, id); return(AppTypes.Unknown); } } else if (resp.ResponseUri.Segments[1] != "app/") // Redirected outside of the app path { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingRedirectedToNonApp, id); return(AppTypes.Other); } else if (resp.ResponseUri.Segments.Length < 3) // The URI ends with "/app/" ? { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_Log_ScrapingNoAppId, id); return(AppTypes.Unknown); } else if (resp.ResponseUri.Segments[2].TrimEnd('/') != id.ToString()) // Redirected to a different app id { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingRedirectedToOtherApp, id, resp.ResponseUri.Segments[2].TrimEnd('/')); if (!int.TryParse(resp.ResponseUri.Segments[2].TrimEnd('/'), out redirectTarget)) // if new app id is an actual number { return(AppTypes.Unknown); } } StreamReader sr = new StreamReader(resp.GetResponseStream()); page = sr.ReadToEnd(); Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingPageRead, id); } } catch (Exception e) { // Something went wrong with the download. Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingPageReadFailed, id, e.Message); LastStoreScrape = oldTime; return(AppTypes.Unknown); } AppTypes result = AppTypes.Unknown; if (page.Contains("<title>Site Error</title>")) { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingReceivedSiteError, id); result = AppTypes.Unknown; } else if (regGamecheck.IsMatch(page)) // Here we should have an app, but make sure. { GetAllDataFromPage(page); // Check whether it's DLC and return appropriately if (Flags.Contains("Downloadable Content")) { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingParsedDLC, id, string.Join(",", Genres)); result = AppTypes.DLC; } else { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingParsed, id, string.Join(",", Genres)); result = AppTypes.Game; } } else // The URI is right, but it didn't pass the regex check { Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameDB_ScrapingCouldNotParse, id); result = AppTypes.Unknown; } if (redirectTarget != -1) { this.ParentId = redirectTarget; result = AppTypes.Unknown; } return(result); }
public static void WriteLog(AppTypes.SyslogTypes logType, string investorCode, string desc, string source, string msg) { try { lock (myClient) { myClient.WriteLog((byte)logType, investorCode, desc, source, msg); } } catch (Exception er) { if (OnError != null) OnError(er); } }