Ejemplo n.º 1
0
        public Database()
        {
            Init.Init init = new Init.Init();
            if (init.isSettings())
            {
                init.Load();
                directory_db     = init.connecteurInfo.installation_dir + @"\" + DB_DOSSIER;
                connectionString = "Data Source=" + directory_db + @"\" + DB_NAME + "; Version=" + DB_VERSION;
            }

            if (!Directory.Exists(directory_db))
            {
                Directory.CreateDirectory(directory_db);
            }
            if (!File.Exists(directory_db + @"\" + DB_NAME))
            {
                SQLiteConnection.CreateFile(directory_db + @"\" + DB_NAME);
            }
            this.reprocessManager    = new ReprocessManager();
            this.alertMailLogManager = new AlertMailLogManager();
            this.settingsManager     = new SettingsManager();
            this.connexionManager    = new ConnexionManager();
            this.emailManager        = new EmailManager();
            this.reliquatManager     = new ReliquatManager();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            int Height = Console.LargestWindowHeight - 10;
            int Width  = Console.LargestWindowWidth - 10;

            Console.SetWindowSize(Width, Height);
            Console.SetWindowPosition(0, 0);

            //////////////////////////////////////////////////////////////////////////////////////
            ///// Check if the app is running
            ///

            Init.Init init   = new Init.Init();
            int       result = init.checkRunningApp();

            if (result != 99)
            {
                // hide or show the running software window
                var handle = GetConsoleWindow();
                ShowWindow(handle, result);
            }
            else
            {
                return;
            }
            ///////////////////////////////////////////

            // Some biolerplate to react to close window event, CTRL-C, kill, etc
            _handler += new EventHandler(Handler);
            SetConsoleCtrlHandler(_handler, true);

            //start your multi threaded program here
            Program p = new Program();

            p.Start();

            //hold the console so it doesn’t run off the end

            /*
             * while (!exitSystem)
             * {
             *  Thread.Sleep(500);
             * }
             */
        }
Ejemplo n.º 3
0
        private static bool Handler(CtrlType sig)
        {
            newThread.Abort();

            Connecteur_Info.Custom.Batch_Interrup interrup = new Connecteur_Info.Custom.Batch_Interrup();
            interrup.interruption();

            //do your cleanup here
            Thread.Sleep(5000); //simulate some cleanup delay
            Console.WriteLine("");

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            /////////////// Fichier_De_Nettoyage.dll ///////////////
            ///
            string logDirectoryName_general = Directory.GetCurrentDirectory() + @"\" + "LOG";
            string logDirectoryName_import  = Directory.GetCurrentDirectory() + @"\" + "LOG" + @"\" + "LOG_Import";

            Fichier_De_Nettoyage.FichierDeNettoyage clean = new Fichier_De_Nettoyage.FichierDeNettoyage();
            string[,] paths = new string[4, 2] {
                { "general_logs", logDirectoryName_general },                                   //log files
                { "import_logs", logDirectoryName_import },                                     //log files
                { "import_files_success", Directory.GetCurrentDirectory() + @"\Success File" }, //fichier import success
                { "import_files_error", Directory.GetCurrentDirectory() + @"\Error File" } //fichier import erreur
            };

            clean.startClean(paths);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ///
            Console.WriteLine("Cleanup complete !");

            Init.Init init = new Init.Init();
            init.setDisplay(false);

            Console.WriteLine("General Config reseted!");

            //allow main to run off
            exitSystem = true;

            //shutdown right away so there are no lingering threads
            Environment.Exit(-1);

            return(true);
        }
Ejemplo n.º 4
0
        public Database(StreamWriter writer)
        {
            Init.Init init = new Init.Init();
            if (init.isSettings())
            {
                init.Load_w_logs(writer);
                directory_db     = init.connecteurInfo.installation_dir + @"\" + DB_DOSSIER;
                connectionString = "Data Source=" + directory_db + @"\" + DB_NAME + "; Version=" + DB_VERSION;
            }
            else
            {
                writer.WriteLine("");
                writer.WriteLine(DateTime.Now + " :: Database.dll => Database() | Creation d'une instance");
                writer.WriteLine(DateTime.Now + " :: Database.dll => Database() | ");
                writer.WriteLine(DateTime.Now + " :: Database.dll => Database() | Creation d'une instance");
            }

            writer.WriteLine("");
            writer.WriteLine(DateTime.Now + " :: Database.dll => Database() | Creation d'une instance");
            if (!Directory.Exists(directory_db))
            {
                Directory.CreateDirectory(directory_db);
                writer.WriteLine(DateTime.Now + " :: Database.dll => Database() | Creation du repertoire => " + directory_db);
            }
            if (!File.Exists(directory_db + @"\" + DB_NAME))
            {
                SQLiteConnection.CreateFile(directory_db + @"\" + DB_NAME);
                writer.WriteLine(DateTime.Now + " :: Database.dll => Database() | Creation de la base de donnee => " + directory_db + @"\" + DB_NAME);
            }
            this.reprocessManager    = new ReprocessManager();
            this.alertMailLogManager = new AlertMailLogManager();
            this.settingsManager     = new SettingsManager();
            this.connexionManager    = new ConnexionManager();
            this.emailManager        = new EmailManager();
            this.reliquatManager     = new ReliquatManager();

            writer.WriteLine("");
            writer.Flush();
        }
Ejemplo n.º 5
0
        public GeneralConfig()
        {
            InitializeComponent();

            // Init Connecteur Info, Version and Database path in a file
            Init.Init init = new Init.Init();
            if (init.isSettings())
            {
                init.Load();
                init.connecteurInfo.installation_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                init.saveInfo();
            }
            else
            {
                init.connecteurInfo = new Connecteur_Info.ConnecteurInfo();
                init.connecteurInfo.installation_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                init.saveInfo();
            }

            // Init database
            Database.Database       db        = new Database.Database();
            Database.Model.Settings settings_ = db.settingsManager.get(db.connectionString, 1);

            if (settings_ != null)
            {
                if (settings_.showWindow == 5)
                {
                    // visible Software while running
                    debugMode_checkBox.Checked = true;
                }
                else if (settings_.showWindow == 0)
                {
                    // Hide Software while running
                    debugMode_checkBox.Checked = false;
                }


                /*
                 * if (settings_.isAppOpen)
                 * {
                 *  label3.Text = "Planificateur en Cour...";
                 * }
                 * else
                 * {
                 *  label3.Text = "Planificateur est fermet.";
                 * }
                 */

                if (settings_.isACP_ComptaCPT_CompteG == 1 ? true : false)
                {
                    checkBox_activate_compt_g_taxe.Text    = "Activer";
                    checkBox_activate_compt_g_taxe.Checked = true;
                    textBox1.Enabled = true;
                    textBox1.Text    = "" + settings_.ACP_ComptaCPT_CompteG;
                }
                else
                {
                    checkBox_activate_compt_g_taxe.Text    = "Désactiver";
                    checkBox_activate_compt_g_taxe.Checked = false;
                    textBox1.Enabled = false;
                    textBox1.Text    = "" + settings_.ACP_ComptaCPT_CompteG;
                }

                textBox2.Text = settings_.EDI_Folder;

                ////////////////////////////////////////////////////////////////////////////////////
                /// Tarifaire
                ///
                if (settings_.priceType_active == 1 ? true : false)
                {
                    checkBox_activer_tarif.Text    = "Activer";
                    checkBox_activer_tarif.Checked = true;

                    radioButton_tarif_cmd_EDI.Enabled   = true;
                    radioButton_tarif_cmd_EDI.Checked   = settings_.priceType_cmdEDIPrice == 1 ? true : false;
                    radioButton_tarif_produit.Enabled   = true;
                    radioButton_tarif_produit.Checked   = settings_.priceType_productPrice == 1 ? true : false;
                    radioButton_tarif_categorie.Enabled = true;
                    radioButton_tarif_categorie.Checked = settings_.priceType_categoryPrice == 1 ? true : false;
                    radioButton_tarif_client.Enabled    = true;
                    radioButton_tarif_client.Checked    = settings_.priceType_clientPrice == 1 ? true : false;
                }
                else
                {
                    checkBox_activer_tarif.Text    = "Désactiver";
                    checkBox_activer_tarif.Checked = false;

                    radioButton_tarif_cmd_EDI.Enabled   = false;
                    radioButton_tarif_cmd_EDI.Checked   = settings_.priceType_cmdEDIPrice == 1 ? true : false;
                    radioButton_tarif_produit.Enabled   = false;
                    radioButton_tarif_produit.Checked   = settings_.priceType_productPrice == 1 ? true : false;
                    radioButton_tarif_categorie.Enabled = false;
                    radioButton_tarif_categorie.Checked = settings_.priceType_categoryPrice == 1 ? true : false;
                    radioButton_tarif_client.Enabled    = false;
                    radioButton_tarif_client.Checked    = settings_.priceType_clientPrice == 1 ? true : false;
                }

                ////////////////////////////////////////////////////////////////////////////////////
                /// Reprocess
                ///
                if (settings_.reprocess_active == 1 ? true : false)
                {
                    checkBox_reprocess_activate.Text    = "Activer";
                    checkBox_reprocess_activate.Checked = true;
                }
                else
                {
                    checkBox_reprocess_activate.Text    = "Désactiver";
                    checkBox_reprocess_activate.Checked = false;
                }

                numericUpDown_hour.Value          = settings_.reprocess_hour;
                numericUpDown1_reprocess_cd.Value = settings_.reprocess_countDown;
            }
        }
Ejemplo n.º 6
0
        public Main()
        {
            InitializeComponent();
            string version = new Connecteur_Info.ConnecteurInfo().Version;

            label3.Text         = "Connecteur Sage v" + version + " \nImport et export de documents commerciaux.";
            labelVersion.Text   = "Version : " + version;
            labelCopyright.Text = "Copyright © 2013 - 2022";


            // Init Connecteur Info, Version and Database path in a file
            Init.Init init = new Init.Init();
            if (init.isSettings())
            {
                init.Load();
                init.connecteurInfo.installation_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                init.saveInfo();
            }
            else
            {
                init.connecteurInfo = new Connecteur_Info.ConnecteurInfo();
                init.connecteurInfo.installation_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                init.saveInfo();
            }

            Forms.ProgressDialog progressDialog = new Forms.ProgressDialog();

            // Initialize the thread that will handle the background process
            Thread backgroundThread = new Thread(
                new ThreadStart(() =>
            {
                //Loading General Settings
                if (progressDialog.InvokeRequired)
                {
                    progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading General Settings...."));
                }
                for (int n = 0; n < 10; n++)
                {
                    Thread.Sleep(1);
                    progressDialog.UpdateProgress(n);
                }

                // Init database && tables
                Database.Database db = new Database.Database();
                db.initTables();


                Database.Model.Settings settings_ = db.settingsManager.get(db.connectionString, 1);
                if (settings_ != null)
                {
                    //settings.configurationGeneral.general.showWindow == 5  ---> show software
                    label_debugMode.Text    = ((settings_.showWindow == 5) ? "Mode Débugage : Activé" : "Mode Débugage : Désactivé");
                    label_tarifaire.Text    = ((settings_.priceType_active == 1 ? true : false) ? "Configuration Tarifaire : Activé" : "Config Tarifaire : Désactivé");
                    label_retraitement.Text = ((settings_.reprocess_active == 1 ? true : false) ? "Retraitement : Activé" : "Retraitement : Désactivé");
                }
                else
                {
                    try
                    {
                        using (Forms.GeneralConfig form = new Forms.GeneralConfig())
                        {
                            form.ShowDialog();
                        }
                    }
                    // Récupération d'une possible SDKException
                    catch (SDKException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }



                //Loading Connexion Settings
                if (progressDialog.InvokeRequired)
                {
                    progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Connexion Settings...."));
                }
                for (int n = 10; n < 20; n++)
                {
                    Thread.Sleep(1);
                    progressDialog.UpdateProgress(n);
                }

                Connexion.ConnexionSaveLoad conn_Settings = new ConnexionSaveLoad();

                if (conn_Settings.isSettings())
                {
                    conn_Settings.Load();

                    label1.Text = "DSN ODBC : " + conn_Settings.configurationConnexion.ODBC.DNS;
                    label2.Text = "DSN ODBC Nom : " + conn_Settings.configurationConnexion.ODBC.USER;
                    label5.Text = "DSN SQL : " + conn_Settings.configurationConnexion.SQL.DNS;
                    label9.Text = "DSN SQL Nom : " + conn_Settings.configurationConnexion.SQL.USER;
                }
                else
                {
                    try
                    {
                        using (Forms.ConfigConnexion form = new Forms.ConfigConnexion())
                        {
                            form.ShowDialog();
                        }
                    }
                    // Récupération d'une possible SDKException
                    catch (SDKException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                //Loading Import Settings
                if (progressDialog.InvokeRequired)
                {
                    progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Import Settings...."));
                }
                for (int n = 20; n < 40; n++)
                {
                    Thread.Sleep(1);
                    progressDialog.UpdateProgress(n);
                }

                Config_Import.ConfigurationSaveLoad import_Settings = new Config_Import.ConfigurationSaveLoad();


                if (import_Settings.isSettings())
                {
                    import_Settings.Load();

                    int cpt   = 0;
                    int count = -1;

                    //Doc Export Achat
                    //no config yet, so show désactivated only
                    cpt   = 0;
                    count = 3;
                    cpt  += ((import_Settings.configurationImport.Doc_Achat.Commande.Activate == "true") ? 1 : 0);
                    isDocAchatCommande = ((import_Settings.configurationImport.Doc_Achat.Commande.Activate == "true") ? true : false);
                    cpt += ((import_Settings.configurationImport.Doc_Achat.DSADV.Activate == "true") ? 1 : 0);
                    isDocAchatDESADV = ((import_Settings.configurationImport.Doc_Achat.DSADV.Activate == "true") ? true : false);
                    cpt += ((import_Settings.configurationImport.Doc_Achat.Facture.Activate == "true") ? 1 : 0);
                    isDocAchatFacture = ((import_Settings.configurationImport.Doc_Achat.Facture.Activate == "true") ? true : false);
                    label2.Text       = ((cpt == 0) ? "Document Achat d'import : désactivé" : "Document Achat d'import : " + cpt + "/" + count + " activé");

                    //Doc Export Vente
                    cpt   = 0;
                    count = 3;
                    cpt  += ((import_Settings.configurationImport.Doc_Ventes.Commande.Activate == "true") ? 1 : 0);
                    isDocVenteCommande = ((import_Settings.configurationImport.Doc_Ventes.Commande.Activate == "true") ? true : false);
                    cpt += ((import_Settings.configurationImport.Doc_Ventes.DSADV.Activate == "true") ? 1 : 0);
                    isDocVenteDESADV = ((import_Settings.configurationImport.Doc_Ventes.DSADV.Activate == "true") ? true : false);
                    cpt += ((import_Settings.configurationImport.Doc_Ventes.Facture.Activate == "true") ? 1 : 0);
                    isDocVenteFacture = ((import_Settings.configurationImport.Doc_Ventes.Facture.Activate == "true") ? true : false);
                    label9.Text       = ((cpt == 0) ? "Document Vente d'import : désactivé" : "Document Vente d'import : " + cpt + "/" + count + " activé");

                    // Stock
                    cpt          = 0;
                    count        = 1;
                    cpt         += ((import_Settings.configurationImport.Doc_Stock.Stock.Activate == "true") ? 1 : 0);
                    isDocStock   = ((import_Settings.configurationImport.Doc_Stock.Stock.Activate == "true") ? true : false);
                    label11.Text = ((cpt == 0) ? "Document de stock import : désactivé" : "Document de stock import : " + cpt + "/" + count + " activé");
                }
                else
                {
                    try
                    {
                        using (ConfigImport form = new ConfigImport())
                        {
                            form.ShowDialog();
                        }
                    }
                    // Récupération d'une possible SDKException
                    catch (SDKException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }


                // Loading Export Settings
                if (progressDialog.InvokeRequired)
                {
                    progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Export Settings...."));
                }
                for (int n = 40; n < 60; n++)
                {
                    Thread.Sleep(1);
                    progressDialog.UpdateProgress(n);
                }

                Config_Export.ConfigurationSaveLoad export_Settings = new Config_Export.ConfigurationSaveLoad();

                if (export_Settings.isSettings())
                {
                    export_Settings.Load();

                    int cpt   = 0;
                    int count = -1;

                    //Doc Export Achat
                    //no config yet, so show désactivated only
                    cpt         = 0;
                    count       = 3;
                    label7.Text = ((cpt == 0) ? "Document Achat d'Export : désactivé" : "Document Achat d'Export : " + cpt + "/" + count + " activé");
                    groupBox_export_doc_achat.Enabled = ((cpt == 0) ? false : true);
                    label_export_doc_achat.Text       = ((cpt == 0) ? "Ces fonctionnalité ne sont pas accessible..." : ".....");

                    //Doc Export Vente
                    cpt         = 0;
                    count       = 3;
                    cpt        += ((export_Settings.configurationExport.Commande.Activate) ? 1 : 0);
                    cpt        += ((export_Settings.configurationExport.DSADV.Activate) ? 1 : 0);
                    cpt        += ((export_Settings.configurationExport.Facture.Activate) ? 1 : 0);
                    label8.Text = ((cpt == 0) ? "Document Vente d'Export : désactivé" : "Document Vente d'Export : " + cpt + "/" + count + " activé");
                    groupBox_export_doc_vente.Enabled    = ((cpt == 0) ? false : true);
                    label_groupBox_export_doc_vente.Text = ((cpt == 0) ? "la configuration est nécessaire. Veuillez vous rendre dans la configuration d'export et la remplir, merci..." : "");

                    // Stock
                    cpt          = 0;
                    count        = 1;
                    cpt         += ((export_Settings.configurationExport.Stock.Activate) ? 1 : 0);
                    label10.Text = ((cpt == 0) ? "Document stock d'Export : désactivé" : "Document stock d'Export : " + cpt + "/" + count + " activé");
                    groupBox_export_doc_stock.Enabled = ((cpt == 0) ? false : true);
                    label_export_doc_stock.Text       = ((cpt == 0) ? "Veuillez vous rendre dans la configuration d'export et la remplir, merci..." : "");
                }
                else
                {
                    try
                    {
                        using (ConfExport form = new ConfExport())
                        {
                            form.ShowDialog();
                        }
                    }
                    // Récupération d'une possible SDKException
                    catch (SDKException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                //Loading Backup Settings
                if (progressDialog.InvokeRequired)
                {
                    progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Backup Settings...."));
                }
                for (int n = 60; n < 80; n++)
                {
                    Thread.Sleep(1);
                    progressDialog.UpdateProgress(n);
                }

                if (File.Exists(pathModule + @"\SettingBackup.xml"))
                {
                    ConfigurationBackup backup = new ConfigurationBackup();
                    backup.Load();
                    label_backup_activation.Text     = ((backup.activate) ? "Activation : Oui" : "Activation : Non");
                    label_backup_generalLog.Text     = ((backup.general_Log != 0) ? "Log général : " + backup.general_Log + " jours" : "Log général : désactiver");
                    label_backup_importLog.Text      = ((backup.import_Log != 0) ? "Log d'import : " + backup.import_Log + " jours" : "Log d'import : désactiver");
                    label_backup_exportLog.Text      = ((backup.export_Log != 0) ? "Log d'export : " + backup.export_Log + " jours" : "Log d'export : désactiver");
                    label_backup_import_success.Text = ((backup.import_files_success != 0) ? "Fichier EDI import (Success) : " + backup.import_files_success + " jours" : "Fichier EDI import (Success) : désactiver");
                    label_backup_import_error.Text   = ((backup.import_files_error != 0) ? "Fichier EDI import (Erreur) : " + backup.import_files_error + " jours" : "Fichier EDI import (Erreur) : désactiver");
                    label_fichier_backup.Text        = ((backup.backup_files != 0) ? "Fichier EDI backup :  " + backup.backup_files + " jours" : "Fichier EDI backup : désactiver");
                }
                else
                {
                    try
                    {
                        using (Forms.ConfigBackup form = new Forms.ConfigBackup())
                        {
                            form.ShowDialog();
                        }
                    }
                    // Récupération d'une possible SDKException
                    catch (SDKException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }


                bool ok = false;
                for (int n = 80; n < 100; n++)
                {
                    Thread.Sleep(1);
                    progressDialog.UpdateProgress(n);
                    if (n == 99)
                    {
                        ok = true;
                    }
                    ;
                }

                // Close the dialog if it hasn't been already
                if (ok && progressDialog.InvokeRequired)
                {
                    progressDialog.BeginInvoke(new System.Action(() => progressDialog.Close()));
                    string msg = "Vous pouvez réaliser l'import des documents commerciaux suivantes :\n\n";
                    msg       += "Import des bons de commandes d'achat : " + ((isDocAchatCommande) ? "activé" : "désactivé") + "\n";
                    msg       += "Import des bons de livraison d'achat : " + ((isDocAchatDESADV) ? "activé" : "désactivé") + "\n";
                    msg       += "Import des factures d'achat : " + ((isDocAchatFacture) ? "activé" : "désactivé") + "\n\n";
                    msg       += "Import des bons de commandes vente : " + ((isDocVenteCommande) ? "activé" : "désactivé") + "\n";
                    msg       += "Import des bons de livraison vente : " + ((isDocVenteDESADV) ? "activé" : "désactivé") + "\n";
                    msg       += "Import des factures vente : " + ((isDocVenteFacture) ? "activé" : "désactivé") + "\n\n";
                    msg       += "Import des stock : " + ((isDocStock) ? "activé" : "désactivé") + "\n";

                    label4.Text = msg;
                }
            }
                                ));

            // Start the background process thread
            backgroundThread.Start();

            // Open the dialog
            progressDialog.ShowDialog();
        }