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 TestMtHandler( IConfiguration configuration, ModelContext dbContext ) { log.Debug("START WEEKLY term drawer"); try { // get all mts // get message string contentLuckyCode = ""; string contentTurn = ""; string langGet = ""; //List 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? configs = commonConfig.GetConfig( new List { "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; } } }