private int WinnerWrite(LottoLionContext ltctx, TFilter filter) { var _result = 0; foreach (var _d in filter.elects) { var _select = new TbLionSelect() { SequenceNo = filter.sequence_no, SelectNo = _d.select_no, Digit1 = _d.digits[0], Digit2 = _d.digits[1], Digit3 = _d.digits[2], Digit4 = _d.digits[3], Digit5 = _d.digits[4], Digit6 = _d.digits[5], IsLeft = _d.is_left }; ltctx.TbLionSelect.Add(_select); _result++; } return(_result); }
public TbLionJackpot GetJackpot(LottoLionContext ltctx, TbLionMember member, int sequence_no, short no_choice) { var _jackpot = ltctx.TbLionJackpot .Where(j => j.SequenceNo == sequence_no && j.LoginId == member.LoginId) .FirstOrDefault(); if (_jackpot == null) { _jackpot = new TbLionJackpot() { SequenceNo = sequence_no, LoginId = member.LoginId, Digit1 = member.Digit1, Digit2 = member.Digit2, Digit3 = member.Digit3, NoChoice = no_choice, NoJackpot = 0, WinningAmount = 0 }; ltctx.TbLionJackpot.Add(_jackpot); } return(_jackpot); }
public NotifyController(IOptions <JwtIssuerOptions> jwtOptions, IConfigurationRoot config_root, LottoLionContext db_context) { __usermgr = new UserManager(jwtOptions.Value); __cconfig.SetConfigRoot(config_root); __db_context = db_context; }
/// <summary> /// 메일 주소와 암호가 일치 하는지 확인 합니다. /// </summary> /// <param name="ltctx"></param> /// <param name="app_user"></param> /// <returns></returns> public (Claim identity, string mail_address) GetClaimsIdentityByLoginId(LottoLionContext ltctx, ApplicationUser app_user) { var _result = (identity : (Claim)null, mail_address : ""); if (CheckDevice(app_user.device_type, app_user.device_id) == true) { var _member = ltctx.TbLionMember .Where(m => m.LoginId == app_user.login_id && m.IsAlive == true) .SingleOrDefault(); if (_member != null) { if (_member.DeviceType != app_user.device_type || _member.DeviceId != app_user.device_id) { _member.DeviceType = app_user.device_type; _member.DeviceId = app_user.device_id; ltctx.SaveChanges(); } var _hash_value = Convert.FromBase64String(_member.LoginPassword); var _pass_hash = __cryptor.VerifyHash(app_user.password, hash_value: _hash_value); if (_pass_hash == true) { _result.identity = new Claim("UserType", "Member"); _result.mail_address = _member.EmailAddress; } } } return(_result); }
private async Task<(bool success, string message)> SaveNotification(LottoLionContext ltctx, TbLionMember member, string message) { var _result = (success: false, message: "ok"); try { var _notify = new TbLionNotify() { LoginId = member.LoginId, NotifyTime = DateTime.Now, Message = message, IsRead = false }; ltctx.TbLionNotify.Add(_notify); _result.success = await ltctx.SaveChangesAsync() > 0; } catch (Exception ex) { _result.message = ex.Message; } return _result; }
public TbLionAnalysis AnalysisWinner(LottoLionContext ltctx, TbLionWinner[] winners, TbLionAnalysis[] analysies, int analysis_no) { var _winner = winners[analysis_no - 1]; var _analysis = new TbLionAnalysis() { SequenceNo = analysis_no, Digit1 = _winner.Digit1, Digit2 = _winner.Digit2, Digit3 = _winner.Digit3, Digit4 = _winner.Digit4, Digit5 = _winner.Digit5, Digit6 = _winner.Digit6, Digit7 = _winner.Digit7 }; var _digits = new short[6]; { _digits[0] = _analysis.Digit1; _digits[1] = _analysis.Digit2; _digits[2] = _analysis.Digit3; _digits[3] = _analysis.Digit4; _digits[4] = _analysis.Digit5; _digits[5] = _analysis.Digit6; } // 1.홀짝 치우침 EvenOddBalance(analysies, _analysis, analysis_no); // 2.고저 치우침 HighLowBalance(analysies, _analysis, analysis_no); // 3.합계 치우침 SumBalance(_analysis); // 4.숫자 집단 치우침 GroupBalance(_analysis, _digits); // 5.HotCold 치우침 HotColdCalc(analysies, _analysis, _digits, analysis_no); // 6.퍼센티지 계산 PercentageCalc(analysies, _analysis, _digits, analysis_no); // 7.당첨 차트 계산 WinerChart(analysies, _analysis, _digits, analysis_no); // 8.합계빈도 확인 ReviewFrequency(analysies, _analysis, _digits, analysis_no); return(_analysis); }
public async Task<(bool success, string message)> PushNotification(LottoLionContext ltctx, TbLionMember member, string title, string message) { var _result = (success: false, message: "ok"); if ( String.IsNullOrEmpty(member.DeviceId) == false && (member.DeviceType == "I" || member.DeviceType == "A" || member.DeviceType == "W") ) { _result = await SaveNotification(ltctx, member, message); if (_result.success == true) await SendNotification(ltctx, member, title, message); } return _result; }
/// <summary> /// /// </summary> /// <param name="login_id">로그인 사용자 아이디</param> /// <param name="login_name">로그인 사용자 명</param> /// <param name="password">암호</param> /// <param name="device_type">장치구분("I"phone, "A"ndroid, "W"indowsPhone</param> /// <param name="device_id">장치 식별자</param> /// <param name="mail_address">메일 주소</param> public bool AddNewMember(LottoLionContext ltctx, ApplicationUser app_user) { var _result = false; if (CheckDevice(app_user.device_type, app_user.device_id) == true) { var _new_member = new TbLionMember { LoginId = app_user.login_id, LoginName = app_user.login_name, LoginPassword = Convert.ToBase64String(__cryptor.ComputeHash(app_user.password)), DeviceType = app_user.device_type, DeviceId = app_user.device_id, AccessToken = "", IsAlive = true, PhoneNumber = "", EmailAddress = app_user.mail_address, MailError = false, IsMailSend = true, IsDirectSend = false, IsNumberChoice = true, MaxSelectNumber = 30, Digit1 = 0, Digit2 = 0, Digit3 = 0, CreateTime = DateTime.Now, Remark = "" }; ltctx.TbLionMember.Add(_new_member); ltctx.SaveChanges(); _result = true; } return(_result); }
private async Task<(bool success, string message)> SendNotification(LottoLionContext ltctx, TbLionMember member, string title, string message) { var _result = (success: false, message: "ok"); try { var _notify_count = ltctx.TbLionNotify .Where(n => n.LoginId == member.LoginId && n.IsRead == false) .Count(); _notify_count++; if (member.DeviceType == "I") { _result = await IosPushNotifyAPNs .JwtAPNsPush(member.DeviceId, message, _notify_count, IosApnsSound); } else if (member.DeviceType == "A") { _result = await DroidPushNotifyFCM .SendNotification(member.DeviceId, "high", title, "PUSH_EVENT_ALARM", message, _notify_count, "alarm", "#d32121"); } else if (member.DeviceType == "W") { } if (_result.success == false) { member.DeviceType = "U"; member.DeviceId = ""; await ltctx.SaveChangesAsync(); } } catch (Exception ex) { _result.message = ex.Message; } return _result; }
private (int no_select, int no_combine) WinnerElect(LottoLionContext ltctx, TFilter filter) { var _result = (no_select : 0, no_combine : 0); // 완전 조합으로 번호를 생성 후 filtering 하여 확률적으로 당첨이 낮은 set을 제외 시킵니다. var _combinations = GetCombinations(filter.sampling_digits, 6); foreach (var _numbers in _combinations) { _result.no_combine++; if (Filtering(filter, _numbers) == false) { continue; } _result.no_select++; var _tdigits = new TDigits() { select_no = _result.no_select + filter.start_select_no, digits = _numbers.OrderBy(n => n).ToArray(), is_used = false, is_left = filter.is_left_selection }; filter.elects.Add(_tdigits); } var _digits_compare = new TDigitsComparer(); { filter.elects = filter.elects .Distinct(_digits_compare) .ToList(); } return(_result); }
private ConcurrentDictionary <int, TDigits> GetChoicePool(LottoLionContext ltctx, int sequence_no) { lock (__choice_pool) { if (__sequence_no != sequence_no) { var _select = ltctx.TbLionSelect .Where(x => x.SequenceNo == sequence_no && x.IsUsed == false) .Select(x => new TDigits { select_no = x.SelectNo, digits = new short[] { x.Digit1, x.Digit2, x.Digit3, x.Digit4, x.Digit5, x.Digit6 }, is_used = x.IsUsed, is_left = x.IsLeft }) .OrderBy(x => x.select_no) .ToList(); __choice_pool.Clear(); var _sequence_key = 0; foreach (var _s in _select) { _sequence_key++; __choice_pool.TryAdd(_sequence_key, _s); } __sequence_no = sequence_no; } return(__choice_pool); } }
public TbLionPercent AnalysisPercentage(LottoLionContext ltctx, TbLionWinner[] winners, int sequence_no) { var _p = GetWinnerPercentage(winners, sequence_no); var _percent = new TbLionPercent() { SequenceNo = sequence_no, LJackpot01 = _p.lj[0], LSelect01 = _p.ls[0], LJackpot02 = _p.lj[1], LSelect02 = _p.ls[1], LJackpot03 = _p.lj[2], LSelect03 = _p.ls[2], LJackpot04 = _p.lj[3], LSelect04 = _p.ls[3], LJackpot05 = _p.lj[4], LSelect05 = _p.ls[4], LJackpot06 = _p.lj[5], LSelect06 = _p.ls[5], LJackpot07 = _p.lj[6], LSelect07 = _p.ls[6], LJackpot08 = _p.lj[7], LSelect08 = _p.ls[7], LJackpot09 = _p.lj[8], LSelect09 = _p.ls[8], LJackpot10 = _p.lj[9], LSelect10 = _p.ls[9], RJackpot01 = (short)(6 - _p.lj[0]), RSelect01 = (short)(45 - _p.ls[0]), RJackpot02 = (short)(6 - _p.lj[1]), RSelect02 = (short)(45 - _p.ls[1]), RJackpot03 = (short)(6 - _p.lj[2]), RSelect03 = (short)(45 - _p.ls[2]), RJackpot04 = (short)(6 - _p.lj[3]), RSelect04 = (short)(45 - _p.ls[3]), RJackpot05 = (short)(6 - _p.lj[4]), RSelect05 = (short)(45 - _p.ls[4]), RJackpot06 = (short)(6 - _p.lj[5]), RSelect06 = (short)(45 - _p.ls[5]), RJackpot07 = (short)(6 - _p.lj[6]), RSelect07 = (short)(45 - _p.ls[6]), RJackpot08 = (short)(6 - _p.lj[7]), RSelect08 = (short)(45 - _p.ls[7]), RJackpot09 = (short)(6 - _p.lj[8]), RSelect09 = (short)(45 - _p.ls[8]), RJackpot10 = (short)(6 - _p.lj[9]), RSelect10 = (short)(45 - _p.ls[9]) }; return(_percent); }
public TbLionFactor GetFactor(LottoLionContext ltctx, int sequence_no) { var _analysis = ltctx.TbLionAnalysis .Where(x => x.SequenceNo < sequence_no) .OrderByDescending(x => x.SequenceNo) .Take(1) .SingleOrDefault(); var _factor = ltctx.TbLionFactor .Where(x => x.SequenceNo <= sequence_no) .OrderByDescending(x => x.SequenceNo) .Take(1) .SingleOrDefault(); if (_factor != null) { if (_factor.SequenceNo != sequence_no) { var _new_factor = new TbLionFactor() { SequenceNo = sequence_no, LNoSampling = _factor.LNoSampling, // 좌측 조합을 위한 번호 모집단 (보통 27개 이하) LNoCombination = 0, // 좌측 완전 조합 갯수 LNoExtraction = 0, // 각 회차 별 필터링을 거쳐 추출 된 게임 갯수 RNoSampling = _factor.RNoSampling, // 우측 조합을 위한 번호 모집단 (보통 27개 이하) RNoCombination = 0, // 우측 완전 조합 갯수 RNoExtraction = 0, // 각 회차 별 필터링을 거쳐 추출 된 게임 갯수 MinOddEven = _factor.MinOddEven, // 홀수 최소 발생 갯수 MaxOddEven = _factor.MaxOddEven, // 홀수 최대 발생 갯수 MinHighLow = _factor.MinHighLow, // 고저 최소 발생 갯수 MaxHighLow = _factor.MaxHighLow, // 고저 최대 발생 갯수 OddSelection = _analysis.SumOdd > _analysis.SumEven, // 홀수 짝수 선택(홀짝 계산 값이 홀수 값 이면 제외 함) HighSelection = _analysis.SumHigh > _analysis.SumLow, // 고저 번호 선택(고저 계산 값이 낮은 값 이면 제외 함) MaxSumFrequence = _factor.MaxSumFrequence, // 합계 발생 빈도(과거 당첨번호 합계가 1번 이하 이면 제외 함) MaxGroupBalance = _factor.MaxGroupBalance, // 최대 집단 빈도(번호가 없는 집단이 3개 이상 이면 제외 함) MaxLastNumber = _factor.MaxLastNumber, // 끝수 동일 갯수(끝자리 숫자가 3개 이상 동일 하면 제외 함) MaxSeriesNumber = _factor.MaxSeriesNumber, // 일련 번호 갯수(3자리 이상 번호가 연번이면 제외 함) MaxSameDigits = _factor.MaxSameDigits, // 과거 당첨 번호 중 같은 번호가 출현한 갯수 MaxSameJackpot = _factor.MaxSameJackpot, // 같은 번호가 3회 이상 발생 한 흔적이 거의 없음 }; ltctx.TbLionFactor.Add(_new_factor); _factor = _new_factor; } else { _factor.OddSelection = _analysis.SumOdd > _analysis.SumEven; _factor.HighSelection = _analysis.SumHigh > _analysis.SumLow; } } else { var _new_factor = new TbLionFactor() { SequenceNo = sequence_no, LNoSampling = 25, // 좌측 조합을 위한 번호 모집단 (보통 27개 이하) LNoCombination = 0, // 좌측 완전 조합 갯수 LNoExtraction = 0, // 각 회차 별 필터링을 거쳐 추출 된 게임 갯수 RNoSampling = 20, // 우측 조합을 위한 번호 모집단 (보통 27개 이하) RNoCombination = 0, // 우측 완전 조합 갯수 RNoExtraction = 0, // 각 회차 별 필터링을 거쳐 추출 된 게임 갯수 MinOddEven = 1, // 홀수 최소 발생 갯수 MaxOddEven = 5, // 홀수 최대 발생 갯수 MinHighLow = 1, // 고저 최소 발생 갯수 MaxHighLow = 5, // 고저 최대 발생 갯수 OddSelection = _analysis.SumOdd > _analysis.SumEven, // 홀수 짝수 선택(홀짝 계산 값이 홀수 값 이면 제외 함) HighSelection = _analysis.SumHigh > _analysis.SumLow, // 고저 번호 선택(고저 계산 값이 낮은 값 이면 제외 함) MaxSumFrequence = 2, // 합계 발생 빈도(과거 당첨번호 합계가 1번 이하 이면 제외 함) MaxGroupBalance = 3, // 최대 집단 빈도(번호가 없는 집단이 3개 이상 이면 제외 함) MaxLastNumber = 3, // 끝수 동일 갯수(끝자리 숫자가 3개 이상 동일 하면 제외 함) MaxSeriesNumber = 3, // 일련 번호 갯수(3자리 이상 번호가 연번이면 제외 함) MaxSameDigits = 4, // 과거 당첨 번호 중 같은 번호가 출현한 갯수 MaxSameJackpot = 3, // 같은 번호가 3회 이상 발생 한 흔적이 거의 없음 }; ltctx.TbLionFactor.Add(_new_factor); _factor = _new_factor; } return(_factor); }
/// <summary> /// 번호를 추출 합니다. 숫자 선택 후 제외 시키는 방법으로 처리 하게 됩니다. /// </summary> /// <param name="ltctx"></param> /// <param name="factor"></param> /// <returns></returns> public int WinnerSelect(LottoLionContext ltctx, TbLionFactor factor) { var _analysies = ltctx.TbLionAnalysis .Where(x => x.SequenceNo < factor.SequenceNo) .OrderBy(x => x.SequenceNo) .ToArray(); var _sum_odd_even = EvenOddBalance(_analysies, factor.SequenceNo); var _sum_high_low = HighLowBalance(_analysies, factor.SequenceNo); var _sum_balances = _analysies .GroupBy(x => x.SumFrequence) .Select( y => new TKeyValue { key = y.Key, value = y.Count() } ) .ToList(); var _filter = new TFilter() { sequence_no = factor.SequenceNo, is_left_selection = false, start_select_no = 0, elects = new List <TDigits>(), sampling_digits = null, analysies = _analysies, factor = factor, sum_balances = _sum_balances, sum_odd = _sum_odd_even.sum_odd, sum_even = _sum_odd_even.sum_even, sum_high = _sum_high_low.sum_high, sum_low = _sum_high_low.sum_low }; // 좌측 { var _sampling_numbers = GetLNumbereByPercent(_analysies, factor.SequenceNo, factor.LNoSampling); _filter.is_left_selection = true; _filter.sampling_digits = _sampling_numbers; var _selection = WinnerElect(ltctx, _filter); { _filter.start_select_no += _selection.no_select; factor.LNoCombination = _selection.no_combine; factor.LNoExtraction = _selection.no_select; } } // 우측 { var _sampling_numbers = GetRNumbereByPercent(_analysies, factor.SequenceNo, factor.RNoSampling); _filter.is_left_selection = false; _filter.sampling_digits = _sampling_numbers; var _selection = WinnerElect(ltctx, _filter); { _filter.start_select_no += _selection.no_select; factor.RNoCombination = _selection.no_combine; factor.RNoExtraction = _selection.no_select; } } // shuffle WinnerShuffle(_filter); // write to db return(WinnerWrite(ltctx, _filter)); }
public int SelectScoring(LottoLionContext ltctx, TbLionWinner winner, TbLionFactor factor, List <short> winner_digits) { var _no_jackpot = 0; // clear { factor.NoJackpot1 = 0; factor.WinningAmount1 = 0; factor.NoJackpot2 = 0; factor.WinningAmount2 = 0; factor.NoJackpot3 = 0; factor.WinningAmount3 = 0; factor.NoJackpot4 = 0; factor.WinningAmount4 = 0; factor.NoJackpot5 = 0; factor.WinningAmount5 = 0; } var _selects = ltctx.TbLionSelect .Where(x => x.SequenceNo == winner.SequenceNo && x.Ranking == 0) .ToList(); foreach (var _s in _selects) { var _select_digits = new List <short>(); { _select_digits.Add(_s.Digit1); _select_digits.Add(_s.Digit2); _select_digits.Add(_s.Digit3); _select_digits.Add(_s.Digit4); _select_digits.Add(_s.Digit5); _select_digits.Add(_s.Digit6); } var _match_count = 0; foreach (var _x in _select_digits) { if (winner_digits.Exists(x => x == _x) == true) { _match_count++; } } _no_jackpot++; if (_match_count >= 6) { _s.Ranking = 1; _s.Amount = winner.Amount1; factor.NoJackpot1++; factor.WinningAmount1 += winner.Amount1; } else if (_match_count >= 5) { if (_select_digits.Exists(x => x == winner.Digit7) == true) { _s.Ranking = 2; _s.Amount = winner.Amount2; factor.NoJackpot2++; factor.WinningAmount2 += winner.Amount2; } else { _s.Ranking = 3; _s.Amount = winner.Amount3; factor.NoJackpot3++; factor.WinningAmount3 += winner.Amount3; } } else if (_match_count >= 4) { _s.Ranking = 4; _s.Amount = winner.Amount4; factor.NoJackpot4++; factor.WinningAmount4 += winner.Amount4; } else if (_match_count >= 3) { _s.Ranking = 5; _s.Amount = winner.Amount5; factor.NoJackpot5++; factor.WinningAmount5 += winner.Amount5; } else { _no_jackpot--; // 낙첨(6위) select(추출) 번호는 삭제 함 ltctx.TbLionSelect.Remove(_s); } } return(_no_jackpot); }
/// <summary> /// /// </summary> /// <param name="ltctx"></param> /// <param name="winner"></param> /// <param name="winner_digits"></param> /// <param name="login_id">로그인 사용자 아이디</param> public int ChoiceScoring(LottoLionContext ltctx, TbLionWinner winner, TbLionJackpot jackpot, List <short> winner_digits, string login_id) { var _no_jackpot = 0; // clear { jackpot.NoJackpot = 0; jackpot.WinningAmount = 0; } var _choices = ltctx.TbLionChoice .Where(x => x.SequenceNo == winner.SequenceNo && x.LoginId == login_id && x.Ranking == 0) .ToList(); foreach (var _c in _choices) { var _choice_digits = new List <short>(); { _choice_digits.Add(_c.Digit1); _choice_digits.Add(_c.Digit2); _choice_digits.Add(_c.Digit3); _choice_digits.Add(_c.Digit4); _choice_digits.Add(_c.Digit5); _choice_digits.Add(_c.Digit6); } var _match_count = 0; foreach (var _x in _choice_digits) { if (winner_digits.Exists(x => x == _x) == true) { _match_count++; } } _no_jackpot++; if (_match_count >= 6) { _c.Ranking = 1; _c.Amount = winner.Amount1; jackpot.NoJackpot++; jackpot.WinningAmount += _c.Amount; } else if (_match_count >= 5) { if (_choice_digits.Exists(x => x == winner.Digit7) == true) { _c.Ranking = 2; _c.Amount = winner.Amount2; } else { _c.Ranking = 3; _c.Amount = winner.Amount3; } jackpot.NoJackpot++; jackpot.WinningAmount += _c.Amount; } else if (_match_count >= 4) { _c.Ranking = 4; _c.Amount = winner.Amount4; jackpot.NoJackpot++; jackpot.WinningAmount += _c.Amount; } else if (_match_count >= 3) { _c.Ranking = 5; _c.Amount = winner.Amount5; jackpot.NoJackpot++; jackpot.WinningAmount += _c.Amount; } else { _no_jackpot--; _c.Ranking = 6; _c.Amount = 0; // 낙첨(6위) select(추출) 번호는 삭제 함 //ltctx.TbLionChoice.Remove(_c); } } return(_no_jackpot); }
/// <summary> /// /// </summary> /// <param name="ltctx"></param> /// <param name="app_user"></param> /// <returns></returns> public async Task <(Claim identity, string mail_address)> GetClaimsIdentityByFacebook(LottoLionContext ltctx, ApplicationUser app_user) { var _result = (identity : (Claim)null, mail_address : ""); if (CheckDevice(app_user.device_type, app_user.device_id) == true) { var _member = ltctx.TbLionMember .Where(m => m.LoginId == app_user.facebook_id && m.IsAlive == true) .SingleOrDefault(); if (_member != null) { if (await VerifyFacebookToken(app_user.facebook_token, app_user.facebook_id) == true) { if (_member.DeviceType != app_user.device_type || _member.DeviceId != app_user.device_id) { _member.DeviceType = app_user.device_type; _member.DeviceId = app_user.device_id; ltctx.SaveChanges(); } _result.identity = new Claim("UserType", "Member"); _result.mail_address = _member.EmailAddress; } } } return(_result); }