Example #1
0
        public void syncDataCabang(string tableName, string PKField = "", string keyword = "")
        {
            string          sqlCommand   = "";
            List <int>      branchIDList = new List <int>();
            MySqlDataReader rdr;

            // EXPORT DATA TO FILE
            string localDate = "";
            string fileName  = "";

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

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

            sqlCommand = "SELECT BRANCH_ID FROM MASTER_BRANCH WHERE BRANCH_ACTIVE = 1";

            using (rdr = DS.getData(sqlCommand))
            {
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        branchIDList.Add(rdr.GetInt32("BRANCH_ID"));
                    }
                }
            }
            rdr.Close();

            string HQ_IP_ADDRESS = DS.getHQ_IPServer();

            // START CONNECTION TO PABRIK
            clearDataCabang(tableName, 0, HQ_IP_ADDRESS);
            sendDataToCabang(fileName, 0, HQ_IP_ADDRESS);

            // START CONNECTION TO EACH BRANCH
            for (int i = 0; i < branchIDList.Count; i++)
            {
                clearDataCabang(tableName, branchIDList[i]);
                sendDataToCabang(fileName, branchIDList[i]);
            }
        }