Beispiel #1
0
        public bool sendDataToServer(string tableName = "", string PKField = "", string keyword = "")
        {
            bool result = false;

            Data_Access DS_HQ     = new Data_Access();
            string      localDate = "";
            string      fileName  = "";

            localDate = String.Format(culture, "{0:ddMMyyyy}", DateTime.Now);
            fileName  = "EXPORT_LOCAL_DATA_" + tableName + "_" + localDate + ".sql";

            // EXPORT LOCAL DATA
            exportData(fileName, tableName, PKField, keyword);

            if (DS_HQ.HQ_mySQLConnect(true))
            {
                gUtil.saveSystemDebugLog(0, "[SYNC] CONNECTION TO SERVER CREATED");

                result = syncLocalDataToServer(DS_HQ, fileName, Data_Access.HQ_SERVER);

                try
                {
                    File.Delete(fileName);
                }
                catch (Exception ex)
                {
                    gUtil.saveSystemDebugLog(0, "[SYNC] FAILED TO DELETE EXPORT FILE [" + ex.Message + "]");
                }
            }
            else
            {
                MessageBox.Show("KONEKSI KE PUSAT GAGAL");
                gUtil.saveSystemDebugLog(0, "[SYNC] FAILED TO CONNECT TO SERVER");

                result = false;
            }

            return(result);
        }
        private bool syncToCentralHQ()
        {
            bool        result = false;
            Data_Access DS_HQ  = new Data_Access();

            // CREATE CONNECTION TO CENTRAL HQ DATABASE SERVER
            gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "TRY TO CREATE CONNECTION TO CENTRAL HQ");
            if (DS_HQ.HQ_mySQLConnect(true))
            {
                gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "CONNECTION TO CENTRAL HQ CREATED");

                // DUMP NECESSARY DATA TO LOCAL COPY
                exportData(syncFileName, DS_HQ, true);
                gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "CENTRAL HQ DATA EXPORTED");

                // CLOSE CONNECTION TO CENTRAL HQ DATABASE SERVER
                DS_HQ.mySqlClose();
                gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "CLOSE CONNECTION TO CENTRAL HQ");

                // INSERT TO LOCAL DATA
                gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "SYNC LOCAL INFORMATION WITH DATA FROM CENTRAL HQ [" + syncFileName + "]");
                syncInformation(syncFileName);
                gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "SYNC LOCAL INFORMATION FINISHED");

                result = true;
            }
            else
            {
                MessageBox.Show("KONEKSI KE PUSAT GAGAL");
                gutil.saveSystemDebugLog(globalConstants.MENU_SINKRONISASI_INFORMASI, "FAILED TO CONNECT TO CENTRAL HQ");

                result = false;
            }

            return(result);
        }