public Dictionary<string, object> GetMergedMap() { Dictionary<string, object> finalPurchase = new Dictionary<string, object>(); IEnumerator<KeyValuePair<Part, Dictionary<string, object>>> enumerator = purchase.GetEnumerator (); while(enumerator.MoveNext()) { Logger.Log(enumerator.Current.ToString()); finalPurchase = finalPurchase.Concat(enumerator.Current.Value) .ToDictionary (d => d.Key, d => d.Value); // .GroupBy(d => d.Key) // .ToDictionary (d => d.Key, d => d.First().Value); } return finalPurchase; }
static Dictionary<Type, uint> s_Type_caseIDtypeIDMap; // Type => (typeID | (caseID << 16)) #endif #if GENERATE_DEBUGGING_ASSEMBLY static void GenerateAssembly(Type[] types, Dictionary<Type, TypeData> typeMap) { Dictionary<Type, TypeData> _map = GenerateTypeData(types); Dictionary<Type, TypeData> map = typeMap.Concat(_map).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); var nonStaticTypes = map.Where(kvp => kvp.Value.IsDynamic).Select(kvp => kvp.Key); var ab = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("NetSerializerDebug"), AssemblyBuilderAccess.RunAndSave); var modb = ab.DefineDynamicModule("NetSerializerDebug.dll"); var tb = modb.DefineType("NetSerializer", TypeAttributes.Public); /* generate stubs */ foreach (var type in nonStaticTypes) { var mb = SerializerCodegen.GenerateStaticSerializerStub(tb, type); map[type].WriterMethodInfo = mb; map[type].WriterILGen = mb.GetILGenerator(); } foreach (var type in nonStaticTypes) { var dm = DeserializerCodegen.GenerateStaticDeserializerStub(tb, type); map[type].ReaderMethodInfo = dm; map[type].ReaderILGen = dm.GetILGenerator(); } #if GENERATE_SWITCH var serializerSwitchMethod = tb.DefineMethod("SerializerSwitch", MethodAttributes.Public | MethodAttributes.Static, null, new Type[] { typeof(Stream), typeof(object), typeof(ObjectList) }); serializerSwitchMethod.DefineParameter(1, ParameterAttributes.None, "stream"); serializerSwitchMethod.DefineParameter(2, ParameterAttributes.None, "value"); serializerSwitchMethod.DefineParameter(3, ParameterAttributes.None, "objList"); var serializerSwitchMethodInfo = serializerSwitchMethod; var deserializerSwitchMethod = tb.DefineMethod("DeserializerSwitch", MethodAttributes.Public | MethodAttributes.Static, null, new Type[] { typeof(Stream), typeof(object).MakeByRefType(), typeof(ObjectList) }); deserializerSwitchMethod.DefineParameter(1, ParameterAttributes.None, "stream"); deserializerSwitchMethod.DefineParameter(2, ParameterAttributes.Out, "value"); deserializerSwitchMethod.DefineParameter(3, ParameterAttributes.None, "objList"); var deserializerSwitchMethodInfo = deserializerSwitchMethod; var ctx = new CodeGenContext(map, serializerSwitchMethodInfo, deserializerSwitchMethodInfo); #else var ctx = new CodeGenContext(map); #endif /* generate bodies */ foreach (var type in nonStaticTypes) { SerializerCodegen.GenerateSerializerBody(ctx, type, map[type].WriterILGen); DeserializerCodegen.GenerateDeserializerBody(ctx, type, map[type].ReaderILGen); } #if GENERATE_SWITCH var ilGen = serializerSwitchMethod.GetILGenerator(); SerializerCodegen.GenerateSerializerSwitch(ctx, ilGen, map); ilGen = deserializerSwitchMethod.GetILGenerator(); DeserializerCodegen.GenerateDeserializerSwitch(ctx, ilGen, map); #else foreach (var kvp in map) { GetSerializationInvoker(tb, kvp.Value.WriterMethodInfo, kvp.Key, (int)kvp.Value.TypeID); GetDeserializationInvoker(tb, kvp.Value.ReaderMethodInfo, kvp.Key, (int)kvp.Value.TypeID); } #endif tb.CreateType(); ab.Save("NetSerializerDebug.dll"); SerializationID.userID = SerializationID.userIDstart; }
private IEnumerable<Pair<String, Object>> SafeExploreProps(Object obj) { var scope = BindingFlags.Instance; if ((Explore & Explore.Private) != 0) scope |= BindingFlags.NonPublic; if ((Explore & Explore.Public) != 0) scope |= BindingFlags.Public; var outFields = new Dictionary<String, Object>(); foreach (var f in obj.GetType().GetExplorableFields(scope)) { if (AcceptFieldCriterion(obj, f)) { outFields.Add(f.Name.NormalizeFieldName(), SafeGet(() => f.GetValue(obj))); } } var outProps = new Dictionary<String, Object>(); var props = obj.GetType().GetExplorableProperties(scope); foreach (var p in props) { var sameCase = p.Name; var camelCase = Char.ToLower(p.Name[0]) + p.Name.Substring(1); var _camelCase = "_" + camelCase; var m_undercase = "m" + _camelCase; Object sfval = null, cfval = null, ufval = null, mufval = null; var dupeName = outFields.TryGetValue(sameCase, out sfval); dupeName |= outFields.TryGetValue(camelCase, out cfval); dupeName |= outFields.TryGetValue(_camelCase, out ufval); dupeName |= outFields.TryGetValue(m_undercase, out mufval); // todo. not 100% correct since it doesn't take into account diff names avail at once var fval = sfval ?? cfval ?? ufval ?? mufval; var pval = SafeGet(() => p.GetValue(obj, null)); if (dupeName) { if (fval == null || pval == null) { if (fval == null && pval == null) { outFields.Remove(sameCase); outFields.Remove(camelCase); outFields.Remove(_camelCase); outFields.Remove(m_undercase); } } else { var ftype = fval.GetType(); var ptype = pval.GetType(); if (!(ftype.IsClass ^ ptype.IsClass)) { if (ftype.IsClass && ptype.IsClass) { if (ReferenceEquals(fval, pval)) { outFields.Remove(sameCase); outFields.Remove(camelCase); outFields.Remove(_camelCase); outFields.Remove(m_undercase); } } else { if (Equals(fval, pval)) { outFields.Remove(sameCase); outFields.Remove(camelCase); outFields.Remove(_camelCase); outFields.Remove(m_undercase); } } } } } if (AcceptPropCriterion(obj, p)) { outProps.Add(p.Name, pval); } } return outFields.Concat(outProps).Select(kvp => new Pair<String, Object>(kvp.Key, kvp.Value)); }
static Dictionary<Type, TypeData> GenerateDynamic(Type[] types, Dictionary<Type, TypeData> typeMap) { Dictionary<Type, TypeData> _map = GenerateTypeData(types); Dictionary<Type, TypeData> map = typeMap.Concat(_map).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); var nonStaticTypes = map.Where(kvp => kvp.Value.IsDynamic).Select(kvp => kvp.Key); /* generate stubs */ foreach (var type in nonStaticTypes) { var s_dm = SerializerCodegen.GenerateDynamicSerializerStub(type); var typeData = map[type]; typeData.WriterMethodInfo = s_dm; typeData.WriterILGen = s_dm.GetILGenerator(); var d_dm = DeserializerCodegen.GenerateDynamicDeserializerStub(type); typeData.ReaderMethodInfo = d_dm; typeData.ReaderILGen = d_dm.GetILGenerator(); } #if GENERATE_SWITCH var serializerSwitchMethod = new DynamicMethod("SerializerSwitch", null, new Type[] { typeof(Stream), typeof(object), typeof(ObjectList) }, typeof(Serializer), true); serializerSwitchMethod.DefineParameter(1, ParameterAttributes.None, "stream"); serializerSwitchMethod.DefineParameter(2, ParameterAttributes.None, "value"); serializerSwitchMethod.DefineParameter(3, ParameterAttributes.None, "objList"); var serializerSwitchMethodInfo = serializerSwitchMethod; var deserializerSwitchMethod = new DynamicMethod("DeserializerSwitch", null, new Type[] { typeof(Stream), typeof(object).MakeByRefType(), typeof(ObjectList) }, typeof(Serializer), true); deserializerSwitchMethod.DefineParameter(1, ParameterAttributes.None, "stream"); deserializerSwitchMethod.DefineParameter(2, ParameterAttributes.Out, "value"); deserializerSwitchMethod.DefineParameter(3, ParameterAttributes.Out, "objList"); var deserializerSwitchMethodInfo = deserializerSwitchMethod; var ctx = new CodeGenContext(map, serializerSwitchMethodInfo, deserializerSwitchMethodInfo); #else var ctx = new CodeGenContext(map); #endif /* generate bodies */ foreach (var type in nonStaticTypes) { SerializerCodegen.GenerateSerializerBody(ctx, type, map[type].WriterILGen); DeserializerCodegen.GenerateDeserializerBody(ctx, type, map[type].ReaderILGen); } #if GENERATE_SWITCH var ilGen = serializerSwitchMethod.GetILGenerator(); SerializerCodegen.GenerateSerializerSwitch(ctx, ilGen, map); s_serializerSwitch = (SerializerSwitch)serializerSwitchMethod.CreateDelegate(typeof(SerializerSwitch)); ilGen = deserializerSwitchMethod.GetILGenerator(); DeserializerCodegen.GenerateDeserializerSwitch(ctx, ilGen, map); s_deserializerSwitch = (DeserializerSwitch)deserializerSwitchMethod.CreateDelegate(typeof(DeserializerSwitch)); #else foreach (var kvp in map) { kvp.Value.serializer = GetSerializationInvoker(null, kvp.Value.WriterMethodInfo, kvp.Key, (int)kvp.Value.TypeID); kvp.Value.deserializer = GetDeserializationInvoker(null, kvp.Value.ReaderMethodInfo, kvp.Key, (int)kvp.Value.TypeID); } #endif return map; }
private void CompareSameMatch() { this._comparing = true; lock (this._listSameMatch) { System.Collections.Generic.List<MatchDTO> listIBETMatch = this._listIBETMatch; System.Collections.Generic.List<MatchDTO> listSbobetMatch = this._listSbobetMatch; if (this._listSameMatch != null) { this._listSameMatch.Clear(); } else { this._listSameMatch = new System.Collections.Generic.List<MatchDTO>(); } if (scantype == ScanningType.both) { #region BuonComIBETSBO Dictionary<string, IbetMatch> iMatchs = this._ibetEngine.ibetAgent.parser.LdicMatches[0]; Dictionary<string, SboMatch> sMatchs = this._sbobetEngine.sboAgent.parserLive.LdicMatches[0]; //var i = iMatchs.Values. foreach (KeyValuePair<string, IbetMatch> iM in iMatchs) { foreach (KeyValuePair<string, SboMatch> sM in sMatchs) { if ((iM.Value.Home == sM.Value.home) || (iM.Value.Away == sM.Value.away)) { MatchDTO matchDTO = new MatchDTO(); matchDTO.ID = iM.Value.MatchId; matchDTO.AwayTeamName = iM.Value.Away + " / " + sM.Value.away; matchDTO.HomeTeamName = iM.Value.Home + " / " + sM.Value.home; matchDTO.Minute = iM.Value.Minute; matchDTO.HomeScore = iM.Value.ScoreH.ToString(); matchDTO.AwayScore = iM.Value.ScoreA.ToString(); if (iM.Value.Period == 0) matchDTO.IsHalfTime = true; else if (iM.Value.Period == 1) matchDTO.Half = 1; else if (iM.Value.Period == 2) matchDTO.Half = 2; LeagueDTO leagueDTO = new LeagueDTO(); leagueDTO.Name = iM.Value.LeagueName + " / " + sM.Value.leagueName; leagueDTO.ID = iM.Value.LeagueId; matchDTO.League = leagueDTO; foreach (KeyValuePair<string, SboOdd> sO in sM.Value.dicOdds) { foreach (KeyValuePair<string, IbetOdd> iO in iM.Value.dicOdds) { if (sO.Value.oddType == iO.Value.oddType) { if (sO.Value.home + iO.Value.away == -0.01m || sO.Value.home + iO.Value.away == 0) { //iBet.Utilities.WriteLog.Write("Odd Found:iH sA: " + iM.Value.Home + "/" + sM.Value.home + "-" + iM.Value.Away + "/" + sM.Value.away + // " >> ibet Odd: " + iO.Value.home + "/" + iO.Value.away + " >> sbo Odd:" + sO.Value.home + "/" + sO.Value.away + // " >> " + iO.Value.oddType + ":" + sO.Value.oddType); //BetObject betObject = new BetObject(); //betObject.ibet = new Bet(); //this._ibetEngine.ibetAgent.CheckOdds TransactionDTO transactionDTO = new TransactionDTO(); } if (sO.Value.away + iO.Value.home == -0.01m || sO.Value.away + iO.Value.home == 0) { //iBet.Utilities.WriteLog.Write("Odd Found:iA sH: " + iM.Value.Home + "/" + sM.Value.home + "-" + iM.Value.Away + "/" + sM.Value.away + // " >> ibet Odd: " + iO.Value.home + "/" + iO.Value.away + " >> sbo Odd:" + sO.Value.home + "/" + sO.Value.away + // " >> " + iO.Value.oddType + ":" + sO.Value.oddType); } } } } this._listSameMatch.Add(matchDTO); } } } System.DateTime now = System.DateTime.Now; System.TimeSpan timeSpan; System.DateTime now2 = System.DateTime.Now; timeSpan = now2 - now; double totalMilliseconds = timeSpan.TotalMilliseconds; BarItem arg_648_0 = this.lblSbobetTotalMatch; int count = sMatchs.Count; arg_648_0.Caption = count.ToString(); BarItem arg_663_0 = this.lblIbetTotalMatch; count = iMatchs.Count; arg_663_0.Caption = count.ToString(); this.lblSameMatch.Caption = "Total Same Match: " + this._listSameMatch.Count; this.lblLastUpdate.Caption = System.DateTime.Now.ToString(); #endregion } else if (scantype == ScanningType.ibet || scantype == ScanningType.ibetVSibet) { Dictionary<string, IbetMatch> iMatchs1 = new Dictionary<string, IbetMatch>(); Dictionary<string, IbetMatch> iMatchs0 = new Dictionary<string, IbetMatch>(); if (checkEdit5.Checked)//live iMatchs0 = this._ibetEngine.ibetAgent.parser.LdicMatches[0]; if (checkEdit6.Checked)//non live iMatchs1 = this._ibetEngine.ibetAgent.parser.LdicMatches[1]; this._ibetMatchs = iMatchs1.Concat(iMatchs0).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value); lock (this._ibetMatchs) { foreach (KeyValuePair<string, IbetMatch> iM in _ibetMatchs) { #region SAMEWORD_PREPARE_MATCHLIST MatchDTO matchDTO = new MatchDTO(); matchDTO.ID = iM.Value.MatchId; matchDTO.AwayTeamName = iM.Value.Away; matchDTO.HomeTeamName = iM.Value.Home; //matchDTO.KickOffTime = iM.Value.KickOffTime; string formatString = "yyyyMMddHHmm"; //string sample = "201006112219"; DateTime dt = DateTime.ParseExact(iM.Value.KickOffTime, formatString, null); matchDTO.KickOffTime = dt.ToString("dd/MM HH:mm"); DateTime ct = DateTime.Parse(this._ibetEngine.ibetAgent.CT); TimeSpan ts = dt.Subtract(ct);//kick off time - current time double tic = ts.TotalSeconds; if (tic <= 300 && tic > 0) { matchDTO.KickOffTime += " - " + ts.Minutes.ToString() + " mins to start"; } else if (tic < 0) { matchDTO.KickOffTime += " !Live"; } matchDTO.Minute = iM.Value.Minute; matchDTO.HomeScore = iM.Value.ScoreH.ToString(); matchDTO.AwayScore = iM.Value.ScoreA.ToString(); if (iM.Value.Period == 0) matchDTO.IsHalfTime = true; else if (iM.Value.Period == 1) matchDTO.Half = 1; else if (iM.Value.Period == 2) matchDTO.Half = 2; LeagueDTO leagueDTO = new LeagueDTO(); leagueDTO.Name = iM.Value.LeagueName; leagueDTO.ID = iM.Value.LeagueId; matchDTO.League = leagueDTO; this._listSameMatch.Add(matchDTO); int num = 0; if (this.chbRandomStake.Checked) { while (num == 0) { string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)]; int.TryParse(strNum, out num); } } #endregion if (scantype == ScanningType.ibetVSibet) { #region IBET_vs_IBET if (leagueDTO.Name.Contains("SPECIFIC 15 MINS OVER/UNDER")) { if (((System.DateTime.Now - this._lastTransactionTime).Seconds > 8) && !this._betting) { if (matchDTO.HomeTeamName.Contains("30:01-45:00") || matchDTO.HomeTeamName.Contains("75:01-90:00")) { if (!matchDTO.KickOffTime.Contains("Live")) { foreach (KeyValuePair<string, IbetOdd> iO in iM.Value.dicOdds) { if (iO.Value.oddType == 3)//keo OU { TransactionDTO transactionDTO; string strOU = "a"; if (checkEdit2.Checked) { strOU = "h"; } if (matchDTO.HomeTeamName.Contains("30:01-45:00")) { if (checkEdit17.Checked)//allow Half 1 { transactionDTO = PlaceSingleIBET("Over15_Fang", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, strOU, num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } else { if (checkEdit18.Checked) //allow half 2 { transactionDTO = PlaceSingleIBET("Over15_Fang", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, strOU, num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } } } } } } } #endregion } else if (scantype == ScanningType.ibet) { #region IBET_Strategies foreach (KeyValuePair<string, IbetOdd> iO in iM.Value.dicOdds) { if (((System.DateTime.Now - this._lastTransactionTime).Seconds > 8) && !this._betting) { if (checkEdit12.Checked) // under strategy { if (iO.Value.oddType == 3 && iO.Value.home == iO.Value.away) { if (checkEdit9.Checked) { if (!matchDTO.KickOffTime.Contains("Live")) { TransactionDTO transactionDTO = PlaceSingleIBET("Under", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "a", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } else { TransactionDTO transactionDTO = PlaceSingleIBET("Under", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "a", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } } if (checkEdit8.Checked) //over strategy { if (iO.Value.oddType == 3 && iO.Value.home == iO.Value.away) { TransactionDTO transactionDTO = PlaceSingleIBET("Over", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "h", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } if (checkEdit7.Checked) // Over 92/90 { if (matchDTO.KickOffTime.Contains("Live")) { if (iO.Value.oddType == 3 || iO.Value.oddType == 8) { if (iO.Value.hdp - ((decimal)iM.Value.ScoreH + (decimal)iM.Value.ScoreA) == (decimal)0.5) { if (iM.Value.Home.Contains("No. of Corners") && iO.Value.home == (decimal)0.90 && iO.Value.away == (decimal)0.92) { TransactionDTO transactionDTO = PlaceSingleIBET("Over9290", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "h", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } } } } if (checkEdit9.Checked) // Odd down: Sap keo { if (matchDTO.KickOffTime.Contains("mins to start")) { if (iO.Value.oddType == 3) { List<Bet> bl = this._ibetEngine.ibetAgent.betList; lock (bl) { foreach (Bet bet in bl) { if (bet.Home == matchDTO.HomeTeamName && bet.Away == matchDTO.AwayTeamName) { iBet.Utilities.WriteLog.Write("Sap Keo:: Tim thay keo trong bet list trong tran : " + bet.Home + " - " + bet.Away); if (bet.Handicap == iO.Value.hdp) { if (iO.Value.away < 0 || iO.Value.away - bet.OddsValue >= (decimal)0.05) { iBet.Utilities.WriteLog.Write("Sap Keo:: Keo bi sap " + (iO.Value.away - bet.OddsValue).ToString() + " gia. Go to bet over"); //keo under sap xuo^'ng an cao hon TransactionDTO transactionDTO = PlaceSingleIBET("SapKeo", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "h", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } } } } } } } if (chbHighRevenueBoost.Checked) // Best analysed strategy { if (!leagueDTO.Name.Contains("Cup") && !leagueDTO.Name.Contains("CUP")) { if (iO.Value.oddType == 3 && iO.Value.home == iO.Value.away) { OddDTO oddDTO = new OddDTO(); oddDTO.Odd = iO.Value.hdp.ToString(); string s = CheckBestStrategyValidation(matchDTO, oddDTO); if (s == "nguoc") { TransactionDTO transactionDTO = PlaceSingleIBET("nguoc", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.home.ToString(), eOddType.FulltimeOverUnder, "h", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); //Console.Write("nguoc"); } else if (s == "xuoi") { TransactionDTO transactionDTO = PlaceSingleIBET("xuoi", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.home.ToString(), eOddType.FulltimeOverUnder, "h", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); //Console.Write("xuoi"); } } } } if (checkEdit11.Checked)//fair odd { if (!leagueDTO.Name.Contains("Cup") && !leagueDTO.Name.Contains("CUP")) { if (iM.Value.Minute >= 35 && iM.Value.Period == 1 && iM.Value.ScoreA == iM.Value.ScoreH) { iBet.Utilities.WriteLog.Write("01:Found fair odd: " + iM.Value.Home + "-" + iM.Value.Away + ":" + iM.Value.Minute + "m"); if ((iO.Value.home > (decimal)0.9) && iO.Value.oddType == 3 && (iO.Value.hdp - (decimal)(iM.Value.ScoreH + iM.Value.ScoreA) == (decimal)1.75)) { iBet.Utilities.WriteLog.Write("02:Found fair odd correct"); foreach (KeyValuePair<string, IbetMatch> snapshotMacht in _ibetMatchsSnapShot) { if (snapshotMacht.Value.Home == iM.Value.Home && snapshotMacht.Value.Away == iM.Value.Away) { iBet.Utilities.WriteLog.Write("03:Found match in Snapshot"); foreach (KeyValuePair<string, IbetOdd> snapshotOdd in snapshotMacht.Value.dicOdds) { if (snapshotOdd.Value.oddType == 3 && snapshotOdd.Value.hdp >= (decimal)2.5 && (snapshotOdd.Value.home >= (decimal)0.92 || snapshotOdd.Value.home < (decimal)0)) { iBet.Utilities.WriteLog.Write("04:Found odd over 2.5 correct in Snapshot"); if (snapshotOdd.Value.oddType == 1 && snapshotOdd.Value.hdp <= (decimal)0.75) { iBet.Utilities.WriteLog.Write("05:Found handicap correct in Snapshot, go to Bet"); TransactionDTO transactionDTO = PlaceSingleIBET("Over1.75", iO.Value.home.ToString(), matchDTO, iO.Value.oddsId, iO.Value.home.ToString(), eOddType.FulltimeOverUnder, "h", num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account); this.AddTransaction(transactionDTO); } } } } } } } } } } } #endregion } } } if (scantype == ScanningType.ibetVSibet) { #region IBET_vs_IBET_continue Dictionary<string, IbetMatch> iMatchs2 = new Dictionary<string, IbetMatch>(); iMatchs2 = this._ibetEngine.ibetAgent.parser.LdicMatches[0]; //this._ibetEngine.ibetAgent.RefreshBetList(); lock (iMatchs2) { foreach (KeyValuePair<string, IbetMatch> iM2 in _ibetMatchs) { if ((iM2.Value.Period == 1 && iM2.Value.Minute >= (int)spinEdit1.Value) || (iM2.Value.Period == 2 && iM2.Value.Minute >= (int)spinEdit2.Value)) // chi chon nhung tran p31 cua hiep 1 { foreach (KeyValuePair<string, IbetOdd> iO2 in iM2.Value.dicOdds) { if (((System.DateTime.Now - this._lastTransactionTime).Seconds > 8) && !this._betting) { if (iO2.Value.oddType == 8 || iO2.Value.oddType == 3) { if (iO2.Value.hdp - ((decimal)iM2.Value.ScoreH + (decimal)iM2.Value.ScoreA) == (decimal)0.5) { bl = this._ibetEngine.ibetAgent.betList; foreach (Bet bet in bl) { if (bet.Home.Contains("30:01-45:00") || bet.Home.Contains("75:01-90:00")) { string HomeTeam = ""; if (iO2.Value.oddType == 8) { HomeTeam = bet.Home.Replace(" 30:01-45:00", ""); } else { HomeTeam = bet.Home.Replace(" 75:01-90:00", ""); } if (HomeTeam == iM2.Value.Home.Replace("(N)", "").TrimEnd()) { MatchDTO matchDTO = new MatchDTO(); matchDTO.HomeTeamName = iM2.Value.Home.Replace("(N)", "").TrimEnd(); matchDTO.AwayTeamName = iM2.Value.Away.Replace("(N)","").TrimEnd(); matchDTO.Minute = iM2.Value.Minute; matchDTO.HomeScore = iM2.Value.ScoreH.ToString(); matchDTO.AwayScore = iM2.Value.ScoreA.ToString(); matchDTO.Half = iM2.Value.Period; int num = (int)bet.Stake; int ExRate1 = (int)config.Ibet.ExchangeRate; int ExRate2 = (int)config.Ibet2.ExchangeRate; float stake2 = num * ExRate1 / ExRate2; decimal giatri1; string OU = "h"; if (bet.Choice == Choice.H) { giatri1 = iO2.Value.away; OU = "a"; } else { giatri1 = iO2.Value.home; } //iBet.Utilities.WriteLog.Write("Tim thay tran :" + bet.Home + " -vs- " + bet.Away + // ", o phut thu:" + matchDTO.Minute.ToString() + ", hiep " + matchDTO.Half.ToString() + // "chuan bi xa.."); eOddType oddtype; if ((giatri1 > 0 && bet.OddsValue + giatri1 >= spinEdit4.Value) || giatri1 < 0) { if (checkEdit1.Checked) { string textx = ""; if (bet.Home.Contains("30:01-45:00")) { textx = "Over15_XA > 30-45 > Xa loi gia > Min:" + matchDTO.Minute + "half " + matchDTO.Half.ToString() + " > " + bet.OddsValue.ToString() + "/" + giatri1.ToString() + " > Ref ID:" + bet.Id; oddtype = eOddType.FirstHalfOverUnder; } else { textx = "Over15_XA > 75-90 > Xa loi gia > Min:" + matchDTO.Minute + "half " + matchDTO.Half.ToString() + " > " + bet.OddsValue.ToString() + "/" + giatri1.ToString() + " > Ref ID:" + bet.Id; oddtype = eOddType.FulltimeOverUnder; } TransactionDTO transactionDTO = PlaceSingleIBET(textx, giatri1.ToString(), matchDTO, iO2.Value.oddsId, iO2.Value.hdp.ToString(), oddtype, OU, stake2.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent2.Config.Account); this.AddTransaction(transactionDTO); iBet.Utilities.WriteLog.Write(textx); } } else { string textx = ""; if (bet.Choice == Choice.H && matchDTO.Minute >= 30) { if (bet.Home.Contains("30:01-45:00")) { textx = "Over15_XA > 30-45 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id; oddtype = eOddType.FirstHalfOverUnder; } else { textx = "Over15_XA > 75-90 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id; oddtype = eOddType.FulltimeOverUnder; } TransactionDTO transactionDTO = PlaceSingleIBET(textx, iO2.Value.away.ToString(), matchDTO, iO2.Value.oddsId, iO2.Value.hdp.ToString(), oddtype, OU, stake2.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent2.Config.Account); this.AddTransaction(transactionDTO); //iBet.Utilities.WriteLog.Write(textx); } else if (bet.Choice == Choice.A && matchDTO.Minute >= 34) { if (bet.Home.Contains("30:01-45:00")) { textx = "Over15_XA > 30-45 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id; oddtype = eOddType.FirstHalfOverUnder; } else { textx = "Over15_XA > 75-90 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id; oddtype = eOddType.FulltimeOverUnder; } TransactionDTO transactionDTO = PlaceSingleIBET(textx, iO2.Value.away.ToString(), matchDTO, iO2.Value.oddsId, iO2.Value.hdp.ToString(), oddtype, OU, stake2.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent2.Config.Account); this.AddTransaction(transactionDTO); } } } } } } } } } } } } #endregion } BarItem arg_663_0 = this.lblIbetTotalMatch; int count = _ibetMatchs.Count; arg_663_0.Caption = count.ToString() + " (" + iMatchs0.Count.ToString() + " live)"; this.lblLastUpdate.Caption = System.DateTime.Now.ToString(); this.rpgIbet.Text = "IBET - " + this._ibetEngine.ibetAgent.Config.Account + " " + this._ibetEngine.ibetAgent.CT; } else if (scantype == ScanningType.sbo) { #region SBO_Strategies Dictionary<string, SboMatch> sMatchs0 = this._sbobetEngine.sboAgent.parserLive.dicMatches; Dictionary<string, SboMatch> sMatchs1 = this._sbobetEngine.sboAgent.parserNonlive.dicMatches; Dictionary<string, SboMatch> sMatchs = sMatchs1.Concat(sMatchs0).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value); foreach (KeyValuePair<string, SboMatch> sM in sMatchs) { MatchDTO matchDTO = new MatchDTO(); matchDTO.ID = sM.Value.matchId; matchDTO.AwayTeamName = sM.Value.away; matchDTO.HomeTeamName = sM.Value.home; matchDTO.AwayScore = sM.Value.awayscore.ToString(); matchDTO.HomeScore = sM.Value.homescore.ToString(); matchDTO.Minute = sM.Value.minute; matchDTO.Half = sM.Value.half; if (matchDTO.Half == 0) matchDTO.IsHalfTime = true; LeagueDTO leagueDTO = new LeagueDTO(); leagueDTO.Name = sM.Value.leagueName; leagueDTO.ID = sM.Value.leagueId; matchDTO.League = leagueDTO; this._listSameMatch.Add(matchDTO); } BarItem arg_648_0 = this.lblSbobetTotalMatch; int count = sMatchs.Count; arg_648_0.Caption = count.ToString() + " (" + sMatchs0.Count.ToString() + " live)"; #endregion } else if (scantype == ScanningType.ibetVSibet) { } lock (this.grdSameMatch) { this.grdSameMatch.RefreshDataSource(); } lock (girdBetList1) { this.girdBetList1.RefreshDataSource(); } } this._comparing = false; if (this._compareAgain && !this._comparing) { this._compareAgain = false; this.CompareSameMatch(); } }
/// <summary> /// Process is used to return a JSON object containing a variety of information about the host system /// which is running the WaveBox server /// </summary> public void Process(UriWrapper uri, IHttpProcessor processor, User user) { try { // Allocate an array of various statistics about the running process IDictionary<string, object> status = new Dictionary<string, object>(); // Gather data about WaveBox process global::System.Diagnostics.Process proc = global::System.Diagnostics.Process.GetCurrentProcess(); // Get current UNIX time long unixTime = DateTime.UtcNow.ToUnixTime(); // Get current query log ID long queryLogId = Injection.Kernel.Get<IDatabase>().LastQueryLogId; // Get process ID status["pid"] = proc.Id; // Get uptime of WaveBox instance status["uptime"] = unixTime - WaveBoxService.StartTime.ToUnixTime(); // Get last update time in UNIX format for status status["updated"] = unixTime; // Get hostname of machine status["hostname"] = System.Environment.MachineName; // Get WaveBox version status["version"] = WaveBoxService.BuildVersion; // Get build date status["buildDate"] = WaveBoxService.BuildDate.ToString("MMMM dd, yyyy"); // Get host platform status["platform"] = WaveBoxService.OS.ToDescription(); // Get current CPU usage status["cpuPercent"] = CpuUsage(); // Get current memory usage in MB status["memoryMb"] = (float)proc.WorkingSet64 / 1024f / 1024f; // Get peak memory usage in MB status["peakMemoryMb"] = (float)proc.PeakWorkingSet64 / 1024f / 1024f; // Get list of media types WaveBox can index and serve (removing "Unknown") status["mediaTypes"] = Enum.GetNames(typeof(FileType)).Where(x => x != "Unknown").ToList(); // Get list of transcoders available status["transcoders"] = Enum.GetNames(typeof(TranscodeType)).ToList(); // Get list of services status["services"] = ServiceManager.GetServices(); // Get last query log ID status["lastQueryLogId"] = queryLogId; // Call for extended status, which uses some database intensive calls if (uri.Parameters.ContainsKey("extended")) { if (uri.Parameters["extended"].IsTrue()) { // Check if any destructive queries have been performed since the last cache if ((statusCache.LastQueryId == null) || (queryLogId > statusCache.LastQueryId)) { // Update to the latest query log ID statusCache.LastQueryId = queryLogId; logger.IfInfo("Gathering extended status metrics from database"); // Get count of artists statusCache.Cache["artistCount"] = Injection.Kernel.Get<IArtistRepository>().CountArtists(); // Get count of album artists statusCache.Cache["albumArtistCount"] = Injection.Kernel.Get<IAlbumArtistRepository>().CountAlbumArtists(); // Get count of albums statusCache.Cache["albumCount"] = Injection.Kernel.Get<IAlbumRepository>().CountAlbums(); // Get count of songs statusCache.Cache["songCount"] = Injection.Kernel.Get<ISongRepository>().CountSongs(); // Get count of videos statusCache.Cache["videoCount"] = Injection.Kernel.Get<IVideoRepository>().CountVideos(); // Get total file size of songs (bytes) statusCache.Cache["songFileSize"] = Injection.Kernel.Get<ISongRepository>().TotalSongSize(); // Get total file size of videos (bytes) statusCache.Cache["videoFileSize"] = Injection.Kernel.Get<IVideoRepository>().TotalVideoSize(); // Get total song duration statusCache.Cache["songDuration"] = Injection.Kernel.Get<ISongRepository>().TotalSongDuration(); // Get total video duration statusCache.Cache["videoDuration"] = Injection.Kernel.Get<IVideoRepository>().TotalVideoDuration(); logger.IfInfo("Metric gathering complete, cached results!"); } // Append cached status dictionary to status status = status.Concat(statusCache.Cache).ToDictionary(x => x.Key, x => x.Value); } } // Return all status processor.WriteJson(new StatusResponse(null, status)); return; } catch (Exception e) { logger.Error(e); } // Return error processor.WriteJson(new StatusResponse("Could not retrieve server status", null)); return; }
/// <summary> /// Calculates an intercept course for all pirates /// </summary> /// <param name="currentItem"></param> /// <param name="dmID"></param> public override void Generate(T_Item currentItem, String dmID) { Dictionary<T_Move, T_Reveal> dict = GetActionsAsDictionary(currentItem.Action); //Make new dictionaries; they will be copies containing either merchants or pirates Dictionary<T_Move, T_Reveal> merchantsDict = new Dictionary<T_Move,T_Reveal>(); Dictionary<T_Move, T_Reveal> piratesDict = new Dictionary<T_Move, T_Reveal>(); //Copy pirates and merchants into dictionaries foreach (T_Move key in dict.Keys) { if (GetOwner(key, dict[key]) == "Pirate DM") piratesDict.Add(key, dict[key]); else merchantsDict.Add(key, dict[key]); } if (piratesDict.Keys.Count == 0) return; //This dictionary of pirates is the one we'll use to save intercept courses. Dictionary<T_Move, T_Reveal> piratesWithInterceptCourse = new Dictionary<T_Move, T_Reveal>(); //Set each pirate on the shortest intercept course to a newly revealed or existing merchant. foreach (T_Move pirateMove in piratesDict.Keys) { Vec2D pirateLocation = new Vec2D(GetLocation(pirateMove, piratesDict[pirateMove])); //=========Check newly revealed merchants created in this item to find closest ===========================// double timeToIntercept = 1000000000000000; Vec2D closestInterceptPoint = null; T_Move closestNewMerchant = null; foreach (T_Move merchantMove in merchantsDict.Keys) { double merchantSpeed = merchantMove.Throttle * GetMaxSpeed(merchantMove); Vec2D merchantStart = new Vec2D(GetLocation(merchantMove, merchantsDict[merchantMove])); Vec2D merchantDestination = new Vec2D((LocationValue)merchantMove.Location.Item); Vec2D interceptPoint = GetInterceptPoint(merchantStart, merchantDestination, merchantSpeed, pirateLocation, GetMaxSpeed(pirateMove)); double merchantTimeToIntercept = merchantStart.ScalerDistanceTo(interceptPoint) / merchantSpeed; if (merchantTimeToIntercept < timeToIntercept) { closestNewMerchant = merchantMove; closestInterceptPoint = interceptPoint; timeToIntercept = merchantTimeToIntercept; } } //============Check merchants already revealed, see if one is closer ======================== //TODO: make sure any merchants we will move in this round are not being compared DDDAdapter.SeamateObject closestRevealedMerchant = null; foreach (DDDAdapter.SeamateObject vessel in revealedSeaVessels) { //Compare all the existing merchants' positions to see if they are closer. //if (vessel.ID == closestNewMerchant.ID) continue; if (vessel.Owner == "Merchant DM") { double merchantSpeed = vessel.Throttle * vessel.MaximumSpeed; Vec2D merchantStart = new Vec2D(vessel.Location); Vec2D merchantDestination = new Vec2D(vessel.DestinationLocation); Vec2D interceptPoint = GetInterceptPoint(merchantStart, merchantDestination, merchantSpeed, pirateLocation, GetMaxSpeed(pirateMove)); double merchantTimeToIntercept = merchantStart.ScalerDistanceTo(interceptPoint) / merchantSpeed; if (merchantTimeToIntercept < timeToIntercept) { closestNewMerchant = null; closestRevealedMerchant = vessel; closestInterceptPoint = interceptPoint; timeToIntercept = merchantTimeToIntercept; } } else continue; //ignore pirates or fleet ships } if (closestInterceptPoint == null) { return; } //Make a new move for the pirate, containing the pirate's intercept course. T_Move moveWithInterceptCourse = new T_Move(); moveWithInterceptCourse.ID = pirateMove.ID; moveWithInterceptCourse.Throttle = 1.0; moveWithInterceptCourse.Location = new T_Location(); moveWithInterceptCourse.Location.Item = closestInterceptPoint.ToLocationValue(); //Set the pirate and merchant's "Intent" relating to the intercept in their SimObjects if (closestNewMerchant != null) { ddd.UpdateObjectAttribute(closestNewMerchant.ID, "Intent", "Being intercepted:" + pirateMove.ID + ":" + timeToIntercept, "AGENT"); //Merchant ddd.UpdateObjectAttribute(pirateMove.ID, "Intent", "Intercepting:" + closestNewMerchant.ID + ":" + timeToIntercept, "AGENT"); //Pirate } else if (closestRevealedMerchant != null) { ddd.UpdateObjectAttribute(closestRevealedMerchant.ID, "Intent", "Being intercepted:" + pirateMove.ID + ":" + timeToIntercept, "AGENT"); //Merchant ddd.UpdateObjectAttribute(pirateMove.ID, "Intent", "Intercepting:" + closestRevealedMerchant.ID + ":" + timeToIntercept, "AGENT"); //Pirate } else Console.Error.WriteLine("Fix intercept generator"); //Add the pirate's updated move and reveal to pirate dictionary. piratesWithInterceptCourse[moveWithInterceptCourse] = piratesDict[pirateMove]; } //Add altered pirates back to merchants, and reset the action array. currentItem.Action = GetActionsFromDictionary(merchantsDict.Concat(piratesWithInterceptCourse).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)); }
private void ReadDataFromRouteData() { if (RouteData.Values["clientId"].GetType() == typeof(System.Int32)) { clientId = (int)RouteData.Values["clientId"]; } else { clientId = int.Parse((string)RouteData.Values["clientId"]); } if (RouteData.Values["portalId"].GetType() == typeof(System.Int32)) { portalId = (int)RouteData.Values["portalId"]; } else { portalId = int.Parse((string)RouteData.Values["portalId"]); } _portal = Session.GetPortalSessions().GetPortalSession(portalId, clientId).Portal; _user = HttpContext.Session.GetUser(portalId); SolutionFinderModule SFModule = (SolutionFinderModule)_portal.Configuration.SolutionFinderModule; if (SFModule == null) { KBCustomException kbCustExp = KBCustomException.ProcessException(null, KBOp.LoadSolutionFinderPage, KBErrorHandler.GetMethodName(), GeneralResources.SolutionFinderModuleNotFoundError, LogEnabled.False); throw kbCustExp; } //Assign portal and user object to artilceManger this._solFinderManager.Portal = _portal; this._solFinderManager.User = HttpContext.Session.GetUser(portalId); //Assign portal and user object to artilceManger this._articleManager.Portal = _portal; this._articleManager.User = HttpContext.Session.GetUser(portalId); //resource object ViewData["CommonViewModel"] = Utilities.CreateCommonViewModel(clientId, portalId, this._portal.PortalType, this._portal.Configuration, "solutionFinder"); headerVM = ((CommonViewModel)ViewData["CommonViewModel"]).HeaderViewModel; Resources = Session.Resource(portalId, clientId, "solutionFinder", _portal.Language.Name); ResourcesArticle = Session.Resource(portalId, clientId, "ARTICLE", _portal.Language.Name); Resources = Resources.Concat(ResourcesArticle).ToDictionary(x => x.Key, x => x.Value); CommonResources = Session.Resource(portalId, clientId, "common", _portal.Language.Name); //get Module name and create navigation homeText = Utilities.getModuleText(headerVM, "home"); SFText = Utilities.getModuleText(headerVM, "solutionFinder"); }