private async Task <int> NextGameChoiceAsync(AppDbContext ltctx, mMember member, dChoice choice) { var _no_choice = 0; try { var _counter = ltctx.tb_lion_choice .Where(x => x.SequenceNo == choice.sequence_no && x.LoginId == choice.login_id) .Count(); // 할당량 만큼 choice(선택) 되었으면 더이상 추가 하지 않음 if (member.MaxSelectNumber > _counter) { _no_choice = _winnerMember.WinnerChoice(ltctx, member, choice, _counter); _winnerScoring.PutJackpot(ltctx, member, choice.sequence_no, (short)_no_choice); await ltctx.SaveChangesAsync(); } } catch (Exception ex) { ltctx.Database.RollbackTransaction(); _logger.LogError(ex, "receiver.choicer"); } return(_no_choice); }
private (bool success, string message) SendMailRecoveryId(mMember member, string mail_address, string login_id) { var _result = (success : false, message : "ok"); var _generator = new Random(); var _password = _generator.Next(0, 99999999).ToString("D8"); member.LoginPassword = Convert.ToBase64String(__cryptor.ComputeHash(_password)); __db_context.SaveChanges(); var _html_body = $"<div>" + $"<h3>안녕하세요 </h3>" + $"<p> </p>" + $"<h2>로그인 ID와 임시 비번을 보내 드립니다.</h2>" + $"<p> </p>" + $"<h3>로그인-ID: '{login_id}'</h3>" + $"<h3>임시 비번: '{_password}'</h3>" + $"<p> </p>" + $"<p> </p>" + $"<p>회사명: {ServiceProviderName}</p>" + $"<p>연락처: {ServiceProviderPhone}</p>" + $"<p>사이트: <a href=\"{ServiceProviderHomePage}\">{ ServiceProviderHomePage}</a></p>" + $"<p> </p>" + "</div>" ; SendMail(mail_address, $"[LottoLion] 임시 인증 정보", _html_body); _result.message = $"'{mail_address}'로 [아이디], [임시비번]이 발송 되었습니다"; _result.success = true; return(_result); }
public mJackpot GetJackpot(AppDbContext ltctx, mMember member, int sequence_no, short no_choice) { var _jackpot = ltctx.tb_lion_jackpot .Where(j => j.SequenceNo == sequence_no && j.LoginId == member.LoginId) .FirstOrDefault(); if (_jackpot == null) { _jackpot = new mJackpot() { SequenceNo = sequence_no, LoginId = member.LoginId, Digit1 = member.Digit1, Digit2 = member.Digit2, Digit3 = member.Digit3, NoChoice = no_choice, NoJackpot = 0, WinningAmount = 0 }; ltctx.tb_lion_jackpot.Add(_jackpot); } return(_jackpot); }
// GET: Members/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } mMember mMember = db.mMembers.Where(mem => mem.nationalid == id).FirstOrDefault(); if (mMember == null) { return(HttpNotFound()); } return(View(mMember)); }
/// <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(AppDbContext ltctx, ApplicationUser app_user) { var _result = false; if (CheckDevice(app_user.device_type, app_user.device_id) == true) { var _new_member = new mMember { 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, UpdateTime = DateTime.Now, Remark = "" }; ltctx.tb_lion_member.Add(_new_member); ltctx.SaveChanges(); _result = true; } return(_result); }
public async Task <(bool success, string message)> PushNotification(AppDbContext ltctx, mMember 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); }
private async Task <(bool success, string message)> SendNotification(AppDbContext ltctx, mMember member, string title, string message) { var _result = (success : false, message : "ok"); try { var _notify_count = ltctx.tb_lion_notify .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 async Task <(bool success, string message)> SaveNotification(AppDbContext ltctx, mMember member, string message) { var _result = (success : false, message : "ok"); try { var _notify = new mNotify() { LoginId = member.LoginId, NotifyTime = DateTime.Now, Message = message, IsRead = false }; ltctx.tb_lion_notify.Add(_notify); _result.success = await ltctx.SaveChangesAsync() > 0; } catch (Exception ex) { _result.message = ex.Message; } return(_result); }
private async Task <int> NextGameSenderAsync(AppDbContext ltctx, mWinner winner, mMember member, dChoice choice) { var _result = 0; try { ltctx.Database.BeginTransaction(); if (member.MailError == false) { var _choices = ltctx.tb_lion_choice .Where(c => c.SequenceNo == choice.sequence_no && c.LoginId == choice.login_id && (c.IsMailSent == false || choice.resend == true)) .OrderBy(c => c.Digit1).ThenBy(c => c.Digit2).ThenBy(c => c.Digit3) .ThenBy(c => c.Digit4).ThenBy(c => c.Digit5).ThenBy(c => c.Digit6) .ToArray(); choice.no_choice = _choices.Length; // 해당 회차에 처리하고자 하는 회원에게 메일 발송이 안된 entity만을 처리 합니다. if (choice.no_choice > 0) { var _verify = await _mailSender.TestMailServerConnectionAsync(member); if (_verify.error_code == SmtpError.GENERIC_SUCCESS) { var _curr_factor = _winnerSelector.GetFactor(ltctx, choice.sequence_no - 0); var _last_factor = _winnerSelector.GetFactor(ltctx, choice.sequence_no - 1); // 선택 번호들을 이미지 처리 함, 최종 zip(압축) 파일로 생성 합니다. var _zip_file = _printOut.SaveLottoSheet(_choices, choice); var _last_jackpot = _winnerScoring.GetJackpot(ltctx, member, choice.sequence_no - 1, member.MaxSelectNumber); // zip 파일을 첨부 하여 메일 발송 합니다. await _mailSender.SendLottoZipFile(_zip_file, choice, winner, member, _curr_factor, _last_factor, _last_jackpot); // 메일 발송 했음을 표기 함 _choices .ToList() .ForEach(c => c.IsMailSent = true); _result = choice.no_choice; } else { WriteMember(choice.sequence_no, choice.login_id, $"mail error '{member.EmailAddress}', {_verify.error_code}, {_verify.error_message}"); } await ltctx.SaveChangesAsync(); } } ltctx.Database.CommitTransaction(); } catch (Exception ex) { ltctx.Database.RollbackTransaction(); _logger.LogError(ex, "receiver.choicer"); } return(_result); }
private async Task <bool> PushChoiceNotification(AppDbContext ltctx, dChoice choice, mMember member, int no_sending) { var _result = false; var _message = $"{choice.sequence_no}회 예측번호가 {member.EmailAddress}로 {no_sending}게임 발송 되었습니다."; { var _push = await _notifyPush.PushNotification(ltctx, member, "예측번호발송", _message); if (_push.success == true) { WriteMember(choice.sequence_no, choice.login_id, $"push choice"); } _result = _push.success; } return(_result); }
public async Task <(SmtpError error_code, string error_message)> TestMailServerConnectionAsync(mMember member) { var _result = (error_code : SmtpError.GENERIC_SUCCESS, error_message : ""); try { var _verify = await __smtp_direct.VerifyMailServerConnection2Async(MailSenderAddress, member.EmailAddress); if (_verify.error_code != SmtpError.GENERIC_SUCCESS) { member.MailError = true; _result = _verify; } } catch { member.MailError = true; _result.error_code = SmtpError.CONNECT_ERROR; } return(_result); }
public async Task SendLottoZipFile(string zip_file_path, dChoice choice, mWinner winner, mMember member, mFactor curr_factor, mFactor last_factor, mJackpot last_jackpot) { var _message = new MimeMessage(); { _message.From.Add(new MailboxAddress(MailSenderName, MailSenderAddress)); _message.To.Add(new MailboxAddress(member.LoginName, member.EmailAddress)); _message.Subject = $"[로또번호] {member.LoginName} 님을 위한 [{choice.sequence_no}]회차 로또645 예측 번호 제공 {(member.IsDirectSend ? "D" : "I")}"; } var _curr_no_combination = curr_factor.LNoCombination + curr_factor.RNoCombination; var _curr_no_extraction = curr_factor.LNoExtraction + curr_factor.RNoExtraction; var _last_no_extraction = last_factor.LNoExtraction + last_factor.RNoExtraction; var _builder = new BodyBuilder(); { _builder.HtmlBody = $"<div>" + $"<h4>안녕하세요 '{member.LoginName}'님, '로또645 예측 번호 제공 서비스' 입니다.</h4>" + $"<p></p>" + $"<h4>A. [{last_jackpot.SequenceNo}]회 추첨 결과</h4>" + $"<p>당첨번호: <strong>{winner.Digit1}, {winner.Digit2}, {winner.Digit3}, {winner.Digit4}, {winner.Digit5}, {winner.Digit6} ({winner.Digit7})</strong></p>" + $"<p>예측결과: {_last_no_extraction:#,##0} 게임</p>" + $"<ul>" + $"<li>1등: {last_factor.NoJackpot1,10:#,##0} 게임, {last_factor.WinningAmount1,15:#,##0} 원</li>" + $"<li>2등: {last_factor.NoJackpot2,10:#,##0} 게임, {last_factor.WinningAmount2,15:#,##0} 원</li>" + $"<li>3등: {last_factor.NoJackpot3,10:#,##0} 게임, {last_factor.WinningAmount3,15:#,##0} 원</li>" + $"<li>4등: {last_factor.NoJackpot4,10:#,##0} 게임, {last_factor.WinningAmount4,15:#,##0} 원</li>" + $"<li>5등: {last_factor.NoJackpot5,10:#,##0} 게임, {last_factor.WinningAmount5,15:#,##0} 원</li>" + $"</ul>" + $"<p>회원결과: {last_jackpot.NoChoice} 게임</p>" + $"<ul>" + $"<li>지난 주 발송 된 번호 중 {last_jackpot.NoJackpot} 게임, <strong>{last_jackpot.WinningAmount:#,##0}원</strong>이 당첨 되었습니다.</li>" + $"</ul>" + $"<h4>B. [{choice.sequence_no}]회 예측 번호</h4>" + $"<ul>" + $"<li>전체 45개의 번호 중 <strong>{_curr_no_combination:#,##0}개의 게임</strong>을 조합 했습니다.</li>" + $"<li>그 중 확률적으로 의미 있는 <strong>{_curr_no_extraction:#,##0}개의 게임</strong>이 추출 되었습니다.</li>" + $"<li>'{member.LoginName}'님에게 추출 된 {_curr_no_extraction:#,##0}개의 게임 중, 엄선해서 <strong>{choice.no_choice:#,##0}개의 게임</strong>을 보내 드립니다.</li>" + $"<li>특별히 원하시는 번호(3개 까지)를 아래 [운영자] 메일로 알려 주시면, 해당 번호가 포함 되어 있는 게임만 받을 수 있습니다.</li>" + $"<li> <a href='https://play.google.com/store/apps/details?id=kr.co.odinsoftware.LION'>로또사자(Android)</a>, " + $"<a href='https://itunes.apple.com/us/app/%EB%A1%9C%EB%98%90%EC%82%AC%EC%9E%90-lottolion/id1236106275?l=ko&ls=1&mt=8'>로또사자(iOS)</a> " + $"앱을 설치 하시면, 당첨내역과 이력 조회 및 게임 수 변경, 번호 지정이 가능 합니다.</li>" + $"</ul>" + $"<h4>C. 출력 방법</h4>" + $"<ul>" + $"<li>이미지 파일을 A4 프린터로 출력 후 로또 용지 크기와 동일하게 절단 합니다.</li>" + $"<li>A4 한장 당 최대 로또 용지 3장이 출력 됩니다.</li>" + $"<li>절취선에 맞춰 절단 후 로또 판매점에서 별도로 작성 하지 않고, 출력하신 용지로 바로 구매 가능 합니다.</li>" + $"<li>절취시 잘못 절단 하면 로또 판매점의 리더기에서 오류가 발생 할 수 있습니다.</li>" + $"<li>실제 로또 용지와 크기가 동일하게 절단하는 것이 중요 합니다.</li>" + $"<li>길이(19cm) 및 높이(8.2cm)는 같거나 조금 작아야 오류가 없습니다.</li>" + $"</ul>" + $"<h4>D. 회원 가입</h4>" + $"<ul>" + $"<li>매주 무료 예측 번호를 원하시는 주변 분이 있는 경우 '메일주소'와 '닉네임'을 아래 [운영자] 메일로 보내 주세요.</li>" + $"<li>메일 수신을 원하지 않는 경우에도 [운영자]에게 제목을 '수신거부'로 메일 보내 주시면 바로 중단 해 드립니다.</li>" + $"</ul>" + $"<h4>E. 연락처</h4>" + $"<ul>" + $"<li>회사명: {ServiceProvider}</li>" + $"<li>연락처: {ServiceProviderPhone}</li>" + $"<li>사이트: <a href='{ServiceProviderHomePage}'>{ServiceProviderHomePage}</a></li>" + $"<li>운영자: <a href='mailto:{ServiceProviderMailTo}'>{ServiceProviderMailTo}</a></li>" + $"</ul>" + "</div>" ; _builder.Attachments.Add(zip_file_path); } _message.Body = _builder.ToMessageBody(); if (member.IsDirectSend == false) { using (var _client = new SmtpClient()) { _client.ServerCertificateValidationCallback = (s, c, h, e) => true; _client.Connect(MailDeliveryServer, MailDeliveryPort, false); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. _client.AuthenticationMechanisms.Remove("XOAUTH2"); // Note: only needed if the SMTP server requires authentication _client.Authenticate(MailDeliveryUserName, MailDeliveryUserPassword); _client.Send(_message); _client.Disconnect(true); } } else { await __smtp_direct.SendMailAsync(_message); } }