Beispiel #1
0
        public static Object[] returnLicence()
        {
            string      chemin = Chemins.getCheminInformation();
            RegistryKey Nkey   = Registry.CurrentUser;

            try
            {
                Object[]    lic    = new Object[3];
                RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
                if (valKey != null)
                {
                    lic[0] = (valKey.GetValue("authentify") != null ? valKey.GetValue("authentify") : false);
                    lic[1] = (valKey.GetValue("licence") != null ? valKey.GetValue("licence") : "");
                    lic[2] = (valKey.GetValue("date_load") != null ? valKey.GetValue("date_load") : DateTime.Now);
                }
                return(lic);
            }
            catch (Exception e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Nkey.Close();
            }
        }
Beispiel #2
0
        public static void Return()
        {
            string      chemin = Chemins.getCheminConfiguration();
            RegistryKey Nkey   = Registry.CurrentUser;

            try
            {
                Object[]    lic    = new Object[3];
                RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
                if (valKey != null)
                {
                    langue           = (string)(valKey.GetValue("langue") != null ? valKey.GetValue("langue") : Constantes.LANGUE_ANGLAIS);
                    template         = (string)(valKey.GetValue("nom_template") != null ? valKey.GetValue("nom_template") : "Basique");
                    back_color_Form  = (string)(valKey.GetValue("back_color_form") != null ? valKey.GetValue("back_color_form") : "GradientInactiveCaption");
                    fore_color_Label = (string)(valKey.GetValue("fore_color_label") != null ? valKey.GetValue("fore_color_label") : "ControlText");
                    back_color_Text  = (string)(valKey.GetValue("back_color_text") != null ? valKey.GetValue("back_color_text") : "Control");
                    fore_color_Text  = (string)(valKey.GetValue("fore_color_text") != null ? valKey.GetValue("fore_color_text") : "WindowText");
                    police_Label     = (string)(valKey.GetValue("police_label") != null ? valKey.GetValue("police_label") : "Microsoft Sans Serif");
                    police_Text      = (string)(valKey.GetValue("police_text") != null ? valKey.GetValue("police_text") : "Microsoft Sans Serif");
                    taille_Label     = float.Parse((string)(valKey.GetValue("taille_label") != null ? valKey.GetValue("taille_label") : "8,25"));
                    taille_Text      = float.Parse((string)(valKey.GetValue("taille_text") != null ? valKey.GetValue("taille_text") : "8,25"));
                }
            }
            catch (Exception e)
            {
                Messages.Exception(e);
            }
            finally
            {
                Nkey.Close();
            }
        }
Beispiel #3
0
        public static void Save()
        {
            string      chemin = Chemins.getCheminConfiguration();
            RegistryKey Nkey   = Registry.CurrentUser;

            try
            {
                RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
                if (valKey == null)
                {
                    Nkey.CreateSubKey(@chemin);
                    valKey = Nkey.OpenSubKey(@chemin, true);
                }
                valKey.SetValue("langue", langue);
                valKey.SetValue("nom_template", template);
                valKey.SetValue("back_color_form", back_color_Form);
                valKey.SetValue("fore_color_label", fore_color_Label);
                valKey.SetValue("back_color_text", back_color_Text);
                valKey.SetValue("fore_color_text", fore_color_Text);
                valKey.SetValue("police_label", police_Label);
                valKey.SetValue("police_text", police_Text);
                valKey.SetValue("taille_label", taille_Label);
                valKey.SetValue("taille_text", taille_Text);
            }
            catch (Exception e)
            {
                Messages.Exception(e);
            }
            finally
            {
                Nkey.Close();
            }
        }
Beispiel #4
0
        public static void Log(string logMessage)
        {
            string file = Chemins.getCheminParametre() + "Log.txt";

            if (!File.Exists(file))
            {
                File.Create(file);
            }
            using (StreamWriter log = File.AppendText(file))
            {
                WriteLog(logMessage, log);
            }
        }
Beispiel #5
0
        public static List <List <string> > DumpLog()
        {
            List <List <string> > list = new List <List <string> >();
            string file = Chemins.getCheminParametre() + "Log.txt";

            if (File.Exists(file))
            {
                using (StreamReader r = File.OpenText(file))
                {
                    list.Add(ReadLog(r));
                }
            }
            return(list);
        }
Beispiel #6
0
 public static bool verifyKeyLicence(string key)
 {
     try
     {
         Object[] lic = returnLicence();
         if (lic != null)
         {
             string valeur = Convert.ToString(lic[1]);
             var    t      = valeur + " = " + key;
             if (valeur.Trim().Equals(key.Trim()))
             {
                 Constantes.ACTIVE = true;
                 string      chemin = Chemins.getCheminInformation();
                 RegistryKey Nkey   = Registry.CurrentUser;
                 try
                 {
                     RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
                     if (valKey == null)
                     {
                         Nkey.CreateSubKey(@chemin);
                         valKey = Nkey.OpenSubKey(@chemin, true);
                     }
                     valKey.SetValue("authentify", true);
                     return(true);
                 }
                 catch (Exception e)
                 {
                     Messages.Exception(e);
                     return(false);
                 }
                 finally
                 {
                     Nkey.Close();
                 }
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         Messages.Exception(e);
         return(false);
     }
 }
Beispiel #7
0
 public static bool createDb_()
 {
     try
     {
         if (Connexion.isConnection_())
         {
             //AddCheminServeur();
             string chemin = Chemins.getCheminScript() + Constantes.FILE_SEPARATOR;
             if (File.Exists(chemin + "create_db.bat"))
             {
                 System.Diagnostics.Process proc = new System.Diagnostics.Process();
                 proc.StartInfo.WorkingDirectory       = chemin;
                 proc.StartInfo.FileName               = chemin + "create_db.bat";
                 proc.StartInfo.Arguments              = chemin;
                 proc.StartInfo.RedirectStandardError  = false;
                 proc.StartInfo.RedirectStandardOutput = false;
                 proc.StartInfo.UseShellExecute        = false;
                 proc.Start();
                 proc.WaitForExit();
                 return(true);
             }
             else
             {
                 Messages.ShowErreur("Fichier bat inexistant");
             }
         }
         else
         {
             if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible ! Entrer de nouveaux parametres"))
             {
                 new IHM.Form_Serveur().Show();
                 Application.Run();
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         Messages.Exception(e);
         return(false);
     }
 }
Beispiel #8
0
        public static void deleteLicence()
        {
            string      chemin = Chemins.getCheminInformation();
            RegistryKey Nkey   = Registry.CurrentUser;

            try
            {
                RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
                if (valKey != null)
                {
                    Nkey.DeleteSubKey(@chemin);
                }
            }
            catch (Exception e)
            {
                Messages.Exception(e);
            }
            finally
            {
                Nkey.Close();
            }
        }
Beispiel #9
0
        public static void createLicence()
        {
            string      chemin = Chemins.getCheminInformation();
            RegistryKey Nkey   = Registry.CurrentUser;

            try
            {
                RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
                if (valKey == null)
                {
                    Nkey.CreateSubKey(@chemin);
                    valKey = Nkey.OpenSubKey(@chemin, true);

                    valKey.SetValue("authentify", false);
                    valKey.SetValue("licence", "696-668-969-694-234-044");
                    valKey.SetValue("date_load", DateTime.Now);
                }
                else
                {
                    if ((valKey.GetValue("authentify") == null || valKey.GetValue("authentify").Equals("")) &&
                        (valKey.GetValue("licence") == null || valKey.GetValue("licence").Equals("")) &&
                        (valKey.GetValue("date_load") == null || valKey.GetValue("date_load").Equals("")))
                    {
                        valKey.SetValue("authentify", false);
                        valKey.SetValue("licence", "696-668-969-694-234-044");
                        valKey.SetValue("date_load", DateTime.Now);
                    }
                }
            }
            catch (Exception e)
            {
                Messages.Exception(e);
            }
            finally
            {
                Nkey.Close();
            }
        }