Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Autorizacion autorizacion = new Autorizacion();
                autorizacion.nombre      = Constantes.cadena0004;
                autorizacion.CodigoUnico = Serial().ToString().ToUpper() + "-" + Guid.NewGuid().ToString().ToUpper();
                autorizacion.fecha       = DateTime.Now;

                string json = JsonConvert.SerializeObject(autorizacion);

                // Create a new file
                FileInfo fi = new FileInfo(Path.Combine(Ruta, Archivo));
                using (StreamWriter sw = fi.CreateText())
                {
                    sw.WriteLine(json);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #2
0
        private void CargarInformacion()
        {
            FileInfo fi = new FileInfo(Path.Combine(Ruta, Archivo));

            try
            {
                if (fi.Exists)
                {
                    using (StreamReader sr = File.OpenText(Path.Combine(Ruta, Archivo)))
                    {
                        Autorizacion m = JsonConvert.DeserializeObject <Autorizacion>(sr.ReadLine());

                        string[] words = m.CodigoUnico.Split('-');


                        if (words[0].Equals(Serial().ToUpper()))
                        {
                            label1.Text     = Constantes.Day.activo.ToString();
                            button1.Enabled = false;
                        }
                        else
                        {
                            label1.Text = Constantes.Day.duplicado.ToString();
                        }
                    }
                }
                else
                {
                    label1.Text = Constantes.Day.prueba.ToString();
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.ToString());
            }
        }