public void ShareActivity(ShareActivity model, Controller ctrl) { List <PlayerDailyActivityCSV> ListOfActivitiesCSV = CreateListOfActivities(model, ctrl); //Get Player Details PlayersRepository playerRepo = new PlayersRepository(); var player = playerRepo.ReadOne(model.PlayerID); var leagueName = (string.IsNullOrEmpty(player.SelectedLeagueName) == false ? player.SelectedLeagueName : "No League Selected"); string FileName = "DailyActivity_" + player.FullName.Replace(" ", string.Empty) + "_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".csv"; //Now Create CSV string fullFilePath = CreateCSV(ListOfActivitiesCSV, FileName, player.FullName, player.EmailAddress, leagueName, ctrl); //Now Send Email SystemSettingsRepository sysRepo = new SystemSettingsRepository(); var sys = sysRepo.GetSystemSettings(); PlayerDashboardRepository pdRepo = new PlayerDashboardRepository(); var playerDashboard = pdRepo.ReadOne(model.PlayerID); EmailsRepository emailRepo = new EmailsRepository(); string Body = "Hi," + "<br/><br/> I would like to share my Daily Activity Data with you " + "<br/><br/> Personal Message: " + model.MsgBody; Guid guid = Guid.NewGuid(); EmailThread = new Thread(() => emailRepo.SendEmailWithAttachment(playerDashboard.PlayerEmailAddress, model.EmailAddress, "Daily Activity Data - " + playerDashboard.PlayerFullName, Body, fullFilePath, EmailThread, ctrl, sys.SupportEmailAddress, null, false)); EmailThread.Name = "DailyActivityData_" + guid.ToString(); EmailThread.Start(); }
//public void UpdateDashboardURLs() //{ // var playerDashboard = db.PlayerDashboard.Include("Players").ToList(); // List<PlayerDashboardExt> ListOfPlayerDashboardExt = new List<PlayerDashboardExt>(); // foreach (var item in playerDashboard) // { // PlayerDashboardExt model = Map(item); // List<char> invalidURLChar = SecurityUtils.GetInvalidURLCharacters(); // if (item.DashboardURL.Contains(" ") || invalidURLChar.Any(m => item.DashboardURL.Contains(m))) // { // string _DashboardURL = item.DashboardURL; // SecurityUtils.Check_RemoveInvalidURLChar(ref _DashboardURL); // item.DashboardURL = _DashboardURL; // db.SaveChanges(); // model.DashboardURL = _DashboardURL; // ListOfPlayerDashboardExt.Add(model); // } // } // //Now Re-Send Email to Each Player, the Standalone Email // MandrillRepository mandrillRepo = new MandrillRepository(); // foreach (var item in ListOfPlayerDashboardExt) // { // mandrillRepo.ProgressDashboard_Standalone(item); // } //} //Create Progress Dashboard for All Player of a League if Enable Progress Dashboard checkbox is ticked for this League public void CreateProgressDashboardForSinglePlayer(PlayersExt model) { try { PlayerDashboardRepository pdRepo = new PlayerDashboardRepository(); //Create Premium Dashboard Default Setting for User string _DashboardURL = SecurityUtils.EncryptText(model.EmailAddress); SecurityUtils.Check_RemoveInvalidURLChar(ref _DashboardURL); PlayerDashboardExt modelDashExt = new PlayerDashboardExt() { PlayerID = model.PlayerID, DashboardURL = _DashboardURL, IsFirstLogin = true, PlayerFullName = model.FullName, PlayerEmailAddress = model.EmailAddress, DashboardCreatedDate = DateTime.Now.Date, DashboardExpiryDate = DateTime.Now.Date.AddDays(98), //14 Weeks => 14 x 7 = 98 Days ReminderTime = 19 //By Default 19:00 when Creating new Player's Dashboard }; string RandomPassword = System.Web.Security.Membership.GeneratePassword(6, 1); modelDashExt.DashboardPassword = SecurityUtils.EncryptText(RandomPassword); //TODO: Map to DB Object var dbmodel = Map(modelDashExt); //Save to DB db.PlayerDashboard.Add(dbmodel); db.SaveChanges(); //Now Send Email to Each Player, the Standalone Email MandrillRepository mandrillRepo = new MandrillRepository(); mandrillRepo.ProgressDashboard_Standalone(modelDashExt); SecurityUtils.AddAuditLog("The Progress Dashboard For Player when Player Added to Team. Success", "For Player Email " + model.EmailAddress); } catch (Exception ex) { ErrorHandling.HandleException(ex); string ErrorMsg = ex.Message + " - " + ex.InnerException != null ? ex.InnerException.Message : ""; SecurityUtils.AddAuditLog("The Progress Dashboard For Player when Player Added to Team. Error Occurred", "For Player Email " + model.EmailAddress + " But Error Occurred: " + ErrorMsg); } }