Пример #1
0
        public void CreatPassiveSPScript(XCollection <SQLOutboundChanel> 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 (SQLOutboundChanel 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 (SQLOutboundChanel channel in channelSet)
                {
                    string strSql = RuleControl.GetOutboundSPUninstall(interfaceName, channel.Rule);
                    sb.AppendLine(strSql);
                }
                sw.Write(sb.ToString());
            }
        }
Пример #2
0
        private void CreateSPScript()
        {
            string dbName         = this.textBoxRISDBName.Text.Trim();
            string interfaceName  = this.textBoxTP.Text.Trim();
            string fnameInstall   = Application.StartupPath + "\\" + RuleScript.InstallSP.FileName;
            string fnameUninstall = Application.StartupPath + "\\" + RuleScript.UninstallSP.FileName;

            using (StreamWriter sw = File.CreateText(fnameInstall))
            {
                StringBuilder sb = new StringBuilder();
                foreach (SQLOutboundChanel chn in SQLOutAdapterConfigMgt.SQLOutAdapterConfig.OutboundChanels)
                {
                    InsertDataId(chn);
                    string strSql = RuleControl.GetOutboundSP(interfaceName, chn.Rule);
                    strSql = strSql.Replace("USE GWDataDB", "");
                    sb.AppendLine(strSql);
                }
                sw.Write("USE " + dbName + "\r\n" + sb.ToString());
            }
            using (StreamWriter sw = File.CreateText(fnameUninstall))
            {
                StringBuilder sb = new StringBuilder();
                foreach (SQLOutboundChanel chn in SQLOutAdapterConfigMgt.SQLOutAdapterConfig.OutboundChanels)
                {
                    string strSql = RuleControl.GetOutboundSPUninstall(interfaceName, chn.Rule);
                    strSql = strSql.Replace("USE GWDataDB", "");
                    sb.AppendLine(strSql);
                }
                sw.Write("USE " + dbName + "\r\n" + sb.ToString());
            }
        }
Пример #3
0
        private void CreateOutboundSPScript(IOutboundRule[] ruleList)
        {
            string interfaceName  = Program.DeviceMgt.DeviceDirInfor.Header.Name;
            string fnameInstall   = Application.StartupPath + "\\" + RuleScript.InstallSP.FileName;
            string fnameUninstall = Application.StartupPath + "\\" + RuleScript.UninstallSP.FileName;

            //using (StreamWriter sw = File.CreateText(fnameInstall))   // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (IOutboundRule rule in ruleList)
                {
                    string strSql = RuleControl.GetOutboundSP(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);
            }
            using (StreamWriter sw = File.CreateText(fnameUninstall))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (IOutboundRule rule in ruleList)
                {
                    string strSql = RuleControl.GetOutboundSPUninstall(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());
            }
        }