| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using Common;
- using Common.Logic;
- using Common.Singleton;
- using Database.Database;
- namespace MyKungKangWorker.Utils
- {
- public class TestMt
- {
- private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
- public static async Task<bool> TestMtHandler(
- IConfiguration configuration,
- ModelContext dbContext
- )
- {
- log.Debug("START WEEKLY term drawer");
- try
- {
- // get all mts
- // get message
- string contentLuckyCode = "";
- string contentTurn = "";
- string langGet = "";
- //List<Config> configs = dbContext.Configs.Where(x =>
- // // x.ParamName == "ADD_RENEW_LUCKYCODE" ||
- // x.ParamName == "ADD_WEEKLY_OVER_PRIZE_LUCKYCODE" ||
- // x.ParamName == "ADD_WEEKLY_OVER_PRIZE_TURN" ||
- // x.ParamName == "SMS_LANG"
- // ).ToList();
- CommonConfig commonConfig = CommonConfig.Instance;
- List<Config>? configs = commonConfig.GetConfig(
- new List<string>
- {
- "ADD_RENEW_LUCKYCODE",
- "ADD_WEEKLY_OVER_PRIZE_LUCKYCODE",
- "ADD_WEEKLY_OVER_PRIZE_TURN",
- "SMS_LANG"
- }
- );
- if (configs != null && configs.Count > 0)
- {
- var lang = configs.Find(x => x.ParamName == "SMS_LANG");
- var luckyCodeMessage = configs.Find(
- x => x.ParamName == "ADD_WEEKLY_OVER_PRIZE_LUCKYCODE"
- );
- var turnMessage = configs.Find(
- x => x.ParamName == "ADD_WEEKLY_OVER_PRIZE_TURN"
- );
- if (lang != null && lang.ParamValue == "MY")
- {
- langGet = "MY";
- if (luckyCodeMessage != null)
- {
- contentLuckyCode = luckyCodeMessage.ParamValueFr!;
- }
- if (turnMessage != null)
- {
- contentTurn = turnMessage.ParamValueFr!;
- }
- }
- else
- {
- langGet = "EN";
- if (luckyCodeMessage != null)
- {
- contentLuckyCode = luckyCodeMessage.ParamValue!;
- }
- if (turnMessage != null)
- {
- contentTurn = turnMessage.ParamValue!;
- }
- }
- }
- // for one lucky code user prize lately
- string code = CommonLogic.GenerateUniqueNumber();
- string content = contentLuckyCode.Replace("%code%", code).Replace("%number%", "1");
- log.Debug("Send mt adding 1 lucky code for 2 person more to test");
- _ = Connector.SentMtAsync(dbContext, "", content);
- string codes =
- CommonLogic.GenerateUniqueNumber()
- + (langGet == "EN" ? ", " : " နှင့် ")
- + CommonLogic.GenerateUniqueNumber();
- content = contentLuckyCode.Replace("%code%", codes).Replace("%number%", "2");
- log.Debug("Send mt adding 2 lucky code for 2 person more to test");
- _ = Connector.SentMtAsync(dbContext, "", content);
- }
- catch (Exception ex)
- {
- log.Error("Exception: ", ex);
- }
- return false;
- }
- }
- }
|