示例#1
0
        // this method uses Tags defined in UI for some controls!!!
        private void MainForm_Load(object sender, EventArgs e)
        {
            label1.Text  = "";
            label12.Text = ResGUIStr.LABEL_CONFIG_FILE;

            // set UI elements from Tags
            cbCaseFixingValidation.Checked       = cbCaseFixingValidation.Tag.ToString().Contains(":true");
            cbCreateProcedureInOutput.Checked    = cbCreateProcedureInOutput.Tag.ToString().Contains(":true");
            cbFormatOutput.Checked               = cbFormatOutput.Tag.ToString().Contains(":true");
            cbGenerateConversionComments.Checked = cbGenerateConversionComments.Tag.ToString().Contains(":false");

            configFileControl.OpenDialogFilter = "Text Files|*.txt|All Files|*.*";
            configFileControl.OpenDialogTitle  = ResGUIStr.TITLE_SELECT_CONFIG_FILE;
            inputFileControl.OpenDialogFilter  = "Sql Files|*.sql|All Files|*.*";
            inputFileControl.OpenDialogTitle   = ResGUIStr.TITLE_SELECT_INPUT_FILE;
            outputFileControl.OpenDialogFilter = "Sql Files|*.sql|All Files|*.*";
            outputFileControl.OpenDialogTitle  = ResGUIStr.TITLE_SELECT_OUTPUT_FILE;

            controlsList = new List <Control>();
            controlsList.Add(cbCaseFixingValidation);
            controlsList.Add(cbCreateProcedureInOutput);
            controlsList.Add(cbFormatOutput);
            controlsList.Add(cbGenerateConversionComments);
            controlsList.Add(tbHANAHostname);
            controlsList.Add(tbHANAPassword);
            controlsList.Add(tbHANASchema);
            controlsList.Add(tbHANAUser);

            /*controlsList.Add(tbMSDatabase);
             * controlsList.Add(tbMSHostname);
             * controlsList.Add(tbMSPassword);
             * controlsList.Add(tbMSUser);
             */
            controlsList.Add(tbHANAPort);
            controlsList.Add(tbMSPort);
            controlsList.Add(inputFileControl);
            controlsList.Add(outputFileControl);

            TranslatorTool tool = new TranslatorTool();

            Config.Initialize(null);
            PrepareForm();
            if (Config.InputFile.Length == 0)
            {
                outputFileControl.FileName = "";
            }
            if (Config.isInitialized)
            {
                configFileControl.FileName = Config.configFileName;
            }
            tool.Close();
        }
示例#2
0
        // this method uses Tags defined in UI for some controls!!!
        private void Run()
        {
            string input  = "";
            string output = "";

            // this runs on the UI thread, otherwise it would be not thread safe
            // and we would get errors while debugging btnRun... and label1...
            this.Invoke((MethodInvoker) delegate
            {
                btnRun.Enabled = false;
                label1.Text    = ResStr.INF_TRANSLATOR_RUNNING;
                input          = sourceLeft.Text;
            });

            tool = new TranslatorTool();

            StringBuilder stringBuilder = GenerateCommandLine();

            string[] strings = stringBuilder.ToString().TrimEnd(' ').Split(' ');

            int numOfStatements;
            int numOfErrors;

            try
            {
                tool.ApplyLocalSettings();
                output = tool.RunConversion(strings, input, out lastResult, out numOfStatements, out numOfErrors);
            }
            catch
            {
                output = ResStr.ERR_CRITICAL_SYNTAX_ERROR;
            }

            //MessageBox.Show(lastResult);

            tool.Close();

            this.Invoke((MethodInvoker) delegate
            {
                btnRun.Enabled = true;
                label1.Text    = "";
                sourceRight.Clear();
                sourceRight.AppendText(output, Color.Black);
                HighlightText(sourceLeft);
                HighlightText(sourceRight);
                ShowResults();
            });
        }
示例#3
0
        public static int Main(string[] args)
        {
            int  result  = 0;
            bool startUI = false;

#if !DEBUG
            try
            {
#endif // !DEBUG
            if (!args.Contains("-g"))
            {
                // console version
                IntPtr ptr = GetForegroundWindow();
                int    u;
                GetWindowThreadProcessId(ptr, out u);
                Process process        = Process.GetProcessById(u);
                bool    attachToWindow = process.ProcessName == "cmd";

                if (attachToWindow)
                {
                    //Is the uppermost window a cmd process?
                    // attach to existing cmd
                    AttachConsole(process.Id);
                }
                else
                {
                    // this is explorer or not cmd console, e.g. NC, FarManager, etc.
                    // create new console window
                    AllocConsole();
                }

                TranslatorTool program = new TranslatorTool();

                try
                {
                    program.Run(args, out startUI);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

#if DEBUG
                Console.WriteLine();
                Console.WriteLine(ResStr.MSG_PRESS_ANY_KEY_TO_CONTINUE);

                if (!attachToWindow && !startUI)
                {
                    Console.ReadKey();
                }
#endif

                FreeConsole();
            }

            if (startUI || args.Contains("-g"))
            {
                // UI version
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
#if !DEBUG
        }

        catch (Exception e)
        {
            if (startUI || args.Contains("-g"))
            {
                MessageBox.Show(String.Format(ResStr.WARN_INTERNAL_ERROR, "\n" + e.Message + "\n"));
            }
            Console.WriteLine(ResStr.MSG_INTERNAL_ERROR, e.Message);

            result = -1;
        }
#endif // !DEBUG

            return(result);
        }
示例#4
0
 private void configFileControl_OpenButtonClicked()
 {
     tool = new TranslatorTool(configFileControl.OpenDialogFileName);
     PrepareForm();
     tool.Close();
 }