예제 #1
0
        public void GetNewActivationCode(Client client, int value)
        {
            ActivationCode code  = Generate(value);
            string         email = client.Email;

            new Mailer().Send(code, email);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public void Send(ActivationCode code, string email)
 {
     send(code.Code, email, "Activation code");
 }