public void GetNewActivationCode(Client client, int value) { ActivationCode code = Generate(value); string email = client.Email; new Mailer().Send(code, email); }
public bool Check(ActivationCode code) { Period period = new Period().GetPeriod(code); if (period == null) { return(false); } Client client = new Client().GetCurrent(); #region aktyvacijos kodu duombazes pakoregavimas string line = null; string line_to_delete = code.Code; string programPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\", @"Data\")); using (StreamReader reader = new StreamReader(programPath + "ActivationCodes.txt")) { using (StreamWriter writer = new StreamWriter(programPath + "temp.txt")) { while ((line = reader.ReadLine()) != null) { string[] temp = line.Split(' '); if (String.Compare(temp[0], line_to_delete) == 0) { continue; } writer.WriteLine(line); } } } using (StreamReader reader = new StreamReader(programPath + "temp.txt")) { using (StreamWriter writer = new StreamWriter(programPath + "ActivationCodes.txt")) { while ((line = reader.ReadLine()) != null) { writer.WriteLine(line); } } } #endregion client.UpdatePremiumVersionDate(period); return(true); }
public Period GetPeriod(ActivationCode code) { string programPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\", @"Data\")); using (StreamReader str = new StreamReader(programPath + "ActivationCodes.txt")) { while (!str.EndOfStream) { string[] temp = str.ReadLine().Split(' '); if (temp[0].Equals(code.Code)) { int month; if (int.TryParse(temp[1], out month) && month != 0) { return(new Period(month)); } } } } return(null); }
public void Send(ActivationCode code, string email) { send(code.Code, email, "Activation code"); }