Example #1
0
        private void CreateLookupTableScript(LookupTable[] tableList)
        {
            if (tableList == null)
            {
                Program.Log.Write(LogType.Warning, "LookupTable array is NULL, do not create any private look up table.");
                return;
            }

            string installTable   = Application.StartupPath + "\\" + RuleScript.InstallLUT.FileName;
            string uninstallTable = Application.StartupPath + "\\" + RuleScript.UninstallLUT.FileName;

            Program.Log.Write("Creating install private look up table script...");
            //using (StreamWriter sw = File.CreateText(installTable))   // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (LookupTable table in tableList)
                {
                    string strSql = RuleControl.GetCreateLUTSQL(table);
                    sb.AppendLine(strSql);
                }
                //sw.Write(sb.ToString());
                File.WriteAllText(installTable, sb.ToString(), Encoding.Unicode);
            }
            Program.Log.Write("Create install private look up table script succeeded. " + installTable);

            Program.Log.Write("Creating uninstall private look up table script...");
            using (StreamWriter sw = File.CreateText(uninstallTable))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (LookupTable table in tableList)
                {
                    string strSql = RuleControl.GetDropLUTSQL(table);
                    sb.AppendLine(strSql);
                }
                sw.Write(sb.ToString());
            }
            Program.Log.Write("Create uninstall private look up table script succeeded. " + uninstallTable);
        }