public void CreatPassiveSPScript(XCollection <SQLInboundChanel> channelSet) { string interfaceName = Program.DeviceMgt.DeviceDirInfor.Header.Name; string fnameInstall = Application.StartupPath + "\\" + RuleScript.InstallSP.FileName; string fnameUninstall = Application.StartupPath + "\\" + RuleScript.UninstallSP.FileName; //Install //using (StreamWriter sw = File.CreateText(fnameInstall)) // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE { StringBuilder sb = new StringBuilder(); sb.AppendLine(GWDataDB.GetUseDataBaseSql()); foreach (SQLInboundChanel channel in channelSet) { sb.AppendLine(channel.SPStatement); } //sw.Write(sb.ToString()); File.WriteAllText(fnameInstall, sb.ToString(), Encoding.Unicode); } //UnInstall using (StreamWriter sw = File.CreateText(fnameUninstall)) { StringBuilder sb = new StringBuilder(); sb.AppendLine(GWDataDB.GetUseDataBaseSql()); foreach (SQLInboundChanel channel in channelSet) { string strSql = RuleControl.GetInboundSPUninstall(interfaceName, channel.Rule); sb.AppendLine(strSql); } sw.Write(sb.ToString()); } }
private void CreateInboundSPScript(IInboundRule[] ruleList) { string interfaceName = Program.DeviceMgt.DeviceDirInfor.Header.Name; string fnameInstall = Application.StartupPath + "\\" + RuleScript.InstallSP.FileName; string fnameUninstall = Application.StartupPath + "\\" + RuleScript.UninstallSP.FileName; Program.Log.Write("Creating install storage procedure script..."); //using (StreamWriter sw = File.CreateText(fnameInstall)) // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE { StringBuilder sb = new StringBuilder(); sb.AppendLine(GWDataDB.GetUseDataBaseSql()); foreach (IInboundRule rule in ruleList) { string strSql = RuleControl.GetInboundSP(interfaceName, rule); sb.AppendLine(strSql); IRuleSupplier supplier = rule as IRuleSupplier; if (supplier != null) { string strSqlSupplied = supplier.GetInstallDBScript(); if (strSqlSupplied != null) { sb.AppendLine(strSqlSupplied); } } } //sw.Write(sb.ToString()); File.WriteAllText(fnameInstall, sb.ToString(), Encoding.Unicode); } Program.Log.Write("Create install storage procedure script succeeded. " + fnameInstall); Program.Log.Write("Creating uninstall storage procedure script..."); using (StreamWriter sw = File.CreateText(fnameUninstall)) { StringBuilder sb = new StringBuilder(); sb.AppendLine(GWDataDB.GetUseDataBaseSql()); foreach (IInboundRule rule in ruleList) { string strSql = RuleControl.GetInboundSPUninstall(interfaceName, rule); sb.AppendLine(strSql); IRuleSupplier supplier = rule as IRuleSupplier; if (supplier != null) { string strSqlSupplied = supplier.GetUninstallDBScript(); if (strSqlSupplied != null) { sb.AppendLine(strSqlSupplied); } } } sw.Write(sb.ToString()); } Program.Log.Write("Create uninstall storage procedure script succeeded. " + fnameUninstall); }