You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.5 KiB
115 lines
3.5 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using System.Data; |
|
using System.Data.SqlClient; |
|
using System.Linq; |
|
using TradingLib; |
|
|
|
namespace iMonitorApp.Classes |
|
{ |
|
// Token: 0x02000027 RID: 39 |
|
public class Fixings |
|
{ |
|
// Token: 0x060001A8 RID: 424 RVA: 0x0000D198 File Offset: 0x0000B398 |
|
public Fixings() |
|
{ |
|
bool flag = this.commodityNames == null || this.commodityNames.Keys.Count == 0; |
|
if (flag) |
|
{ |
|
this.commodityNames = this.GetFullNames(); |
|
} |
|
this.fixings = new Dictionary<DateTime, List<string>>(); |
|
} |
|
|
|
// Token: 0x060001A9 RID: 425 RVA: 0x0000D1E8 File Offset: 0x0000B3E8 |
|
public void GetFixings(string account = "EE02") |
|
{ |
|
string selectCommandText = string.Concat(new string[] |
|
{ |
|
"SELECT * FROM iTools_commodity_fixings_", |
|
account, |
|
" WHERE tablerownames IN (SELECT researchTicker FROM tradingRef..CommodityMappingStrategies WHERE tradingRef.dbo.CommodityMappingStrategies.initAlloc<>0 AND tradingRef.dbo.CommodityMappingStrategies.strategy = (SELECT strategy from tradingRef..tblStrategyAccountMapping WHERE tradingRef..tblStrategyAccountMapping.account='", |
|
account, |
|
"'))" |
|
}); |
|
SqlConnection sqlConnection = new SqlConnection("server=4ecapsvsg1\\;Initial Catalog=customRef;User ID=dbuser;Password=dbuser;"); |
|
sqlConnection.Open(); |
|
DataTable dataTable = new DataTable(); |
|
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommandText, sqlConnection); |
|
sqlDataAdapter.Fill(dataTable); |
|
foreach (object obj in dataTable.Rows) |
|
{ |
|
DataRow dataRow = (DataRow)obj; |
|
DateTime key = Convert.ToDateTime(dataRow["timeFixing"]); |
|
List<string> list = new List<string>(); |
|
List<string> list2 = new List<string>(); |
|
for (int i = 0; i < 5; i++) |
|
{ |
|
bool flag = dataRow.Table.Columns.Contains("Contract" + (i + 1).ToString()); |
|
if (!flag) |
|
{ |
|
break; |
|
} |
|
bool flag2 = dataRow["Contract" + (i + 1).ToString()].ToString() != ""; |
|
if (!flag2) |
|
{ |
|
break; |
|
} |
|
list.Add(dataRow["Contract" + (i + 1).ToString()].ToString()); |
|
} |
|
foreach (string ins in list) |
|
{ |
|
Contract contract = new Contract(ins); |
|
try |
|
{ |
|
bool flag3 = !list2.Contains(this.commodityNames[contract.Commodity].ToString()); |
|
if (flag3) |
|
{ |
|
list2.Add(this.commodityNames[contract.Commodity].ToString()); |
|
} |
|
} |
|
catch |
|
{ |
|
} |
|
} |
|
bool flag4 = this.fixings.ContainsKey(key); |
|
if (flag4) |
|
{ |
|
this.fixings[key].AddRange(list2); |
|
this.fixings[key] = this.fixings[key].Distinct<string>().ToList<string>(); |
|
} |
|
else |
|
{ |
|
this.fixings.Add(key, list2); |
|
} |
|
} |
|
sqlConnection.Close(); |
|
} |
|
|
|
// Token: 0x060001AA RID: 426 RVA: 0x0000D4A8 File Offset: 0x0000B6A8 |
|
public Hashtable GetFullNames() |
|
{ |
|
SqlConnection sqlConnection = new SqlConnection("server=4ecapsvsg1\\;Initial Catalog=tradingRef;User ID=dbuser;Password=dbuser;"); |
|
sqlConnection.Open(); |
|
DataTable dataTable = new DataTable(); |
|
string selectCommandText = "SELECT commodity,name from commodityRef"; |
|
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommandText, sqlConnection); |
|
sqlDataAdapter.Fill(dataTable); |
|
Hashtable hashtable = new Hashtable(); |
|
foreach (object obj in dataTable.Rows) |
|
{ |
|
DataRow dataRow = (DataRow)obj; |
|
hashtable.Add(dataRow["commodity"], dataRow["name"]); |
|
} |
|
sqlConnection.Close(); |
|
return hashtable; |
|
} |
|
|
|
// Token: 0x040000E6 RID: 230 |
|
public Dictionary<DateTime, List<string>> fixings; |
|
|
|
// Token: 0x040000E7 RID: 231 |
|
public Hashtable commodityNames; |
|
} |
|
}
|
|
|