private bool SendClimbersListForTeam(string email, int?team_id, string subj, string body) { string fileName; if (team_id == null) { fileName = "LIST"; } else { fileName = "LIST_" + team_id.Value.ToString(); } fileName += "_" + DateTime.UtcNow.ToString("yyyyMMdd_HHmm", CultureInfo.CurrentCulture) + ".csv"; MemoryStream mStr = new MemoryStream(); try { StreamWriter swr = new StreamWriter(mStr, Encoding.Unicode); ONLteam[] teams; if (team_id == null) { teams = (from t in dc.ONLTeamsCompLinks where t.comp_id == compID select t.ONLteam).Distinct().ToArray(); } else { teams = (from tL in dc.ONLteams where tL.iid == team_id select tL).ToArray(); } //teams = (from t in teams // where t.ONLClimberCompLinks.Count(l => l.comp_id == compID) > 0 // select t).ToArray(); bool lead = comp.Lead(), speed = comp.Speed(), boulder = comp.Boulder(); try { var grpLstT = from g in dc.ONLGroups where g.ONLGroupsCompLinks.Count(gl => gl.comp_id == compID) > 0 orderby g.oldYear, g.genderFemale select g; List <ONLGroup> grpList = new List <ONLGroup>(); foreach (var g in grpLstT) { grpList.Add(g); } foreach (var t in teams) { int teamID = t.iid; swr.AutoFlush = true; swr.WriteLine(t.name); if (t.HasClimbers(compID)) { swr.WriteLine("№\tФамилия, Имя\tГ.р.\tРазр." + (lead ? "\tТр." : String.Empty) + (speed ? "\tСк." : String.Empty) + (boulder ? "\tБоулд." : String.Empty) ); foreach (var g in grpList) { var clmLstT = from c in dc.ONLClimberCompLinks where c.group_id == g.iid && c.team_id == teamID && c.state == Constants.CLIMBER_CONFIRMED && c.comp_id == compID orderby c.ONLclimber.surname, c.ONLclimber.name select c; int curClm = 0; swr.WriteLine(g.name + ":"); if (t.HasClimbers(compID, g.iid)) { foreach (var c in clmLstT.Where(w => w.queue_pos < 1)) { swr.WriteLine((++curClm).ToString() + ".\t" + c.ONLclimber.surname + " " + c.ONLclimber.name + "\t" + c.ONLclimber.age.ToString() + "\t" + c.qf + (lead ? ("\t" + getShortValue(c.lead)) : String.Empty) + (speed ? ("\t" + getShortValue(c.speed)) : String.Empty) + (boulder ? ("\t" + getShortValue(c.boulder)) : String.Empty)); } swr.WriteLine(); swr.WriteLine("Очередь:"); foreach (var c in clmLstT.Where(w => w.queue_pos > 0)) { swr.WriteLine(c.queue_pos.ToString() + ".\t" + c.ONLclimber.surname + " " + c.ONLclimber.name + "\t" + c.ONLclimber.age.ToString() + "\t" + c.qf); } swr.WriteLine(); swr.WriteLine("Неподтверждённые:"); curClm = 0; var clmLstU = from c in dc.ONLClimberCompLinks where c.group_id == g.iid && c.team_id == teamID && c.comp_id == compID && c.state != Constants.CLIMBER_CONFIRMED orderby c.ONLclimber.surname, c.ONLclimber.name select c; foreach (var c in clmLstU) { swr.WriteLine((++curClm).ToString() + "\t" + c.ONLclimber.surname + " " + c.ONLclimber.name + "\t" + c.ONLclimber.age.ToString() + "\t" + c.qf + "\t" + (c.state == Constants.CLIMBER_PENDING_DELETE ? "Удаление" : (c.ONLClimberCompLink1.Count == 0 ? "Добавление" : "Правка")) ); } } else { swr.WriteLine("Участники в данную группу не заявлены"); } swr.WriteLine(); swr.WriteLine(); } } else { swr.WriteLine("УЧАСТНИКИ НЕ ЗАЯВЛЕНЫ"); } } string sTmp; MailService ms = new MailService(dc, compID); return(ms.SendMail(email, subj, body, MailPriority.Normal, fileName, mStr, out sTmp)); } finally { swr.Close(); } } finally { mStr.Close(); } }
public MembershipUser CreateUser(string username, string password, string email, int?teamID, string chief, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { ValidatePasswordEventArgs e = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(e); if (e.Cancel) { status = MembershipCreateStatus.InvalidPassword; return(null); } if (RequiresUniqueEmail && !String.IsNullOrEmpty(GetUserNameByEmail(email))) { status = MembershipCreateStatus.DuplicateEmail; return(null); } if (!(providerUserKey is string)) { status = MembershipCreateStatus.InvalidProviderUserKey; return(null); } string newIid = (string)providerUserKey; if (newIid.Length > 3) { newIid = newIid.Substring(0, 3); } if (GetUser(newIid, false) != null) { status = MembershipCreateStatus.DuplicateUserName; return(null); } try { ONLuser u = ONLuser.CreateONLuser(newIid, username, password, String.Empty); u.team_id = teamID; u.email = email; u.chief = chief; u.creationDate = DateTime.UtcNow; dc.ONLusers.AddObject(u); dc.SaveChanges(); status = MembershipCreateStatus.Success; try { if (!String.IsNullOrEmpty(email)) { string str; MailService ms = new MailService(dc, -1); ms.SendMail(email, "Учетная запись", "Создана учётная запись в системе подачи заявок на соревнования по скалолазанию.\r\n" + "Ваш регион: " + username + "\r\n" + "Ваш пароль: " + password + "\r\n\r\n" + "С Уважением, Администратор системы.", System.Net.Mail.MailPriority.Normal, out str); } } catch { } return(GetUser(newIid, false)); } catch (Exception) { status = MembershipCreateStatus.ProviderError; return(null); } }