Exemplo n.º 1
0
        private void buildConnStr()
        {
            ConfigManipulator c = new ConfigManipulator();

            SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();

            try
            {
                sb.DataSource     = c.GetValue("Server");
                sb.InitialCatalog = c.GetValue("Database");
                if (String.Equals(c.GetValue("ConnectionMethod"), Resources.SSPIConnection))
                {
                    sb.IntegratedSecurity = true;
                }
                else
                {
                    sb.IntegratedSecurity = false;
                    sb.UserID             = c.GetValue("ConnectionUsername");
                    sb.Password           = c.GetValue("ConnectionPassword");
                }
            }
            catch
            {
                MessageBox.Show(Resources.AppconfigBroken);
            }

            connStr = sb.ConnectionString;
        }
Exemplo n.º 2
0
        internal FormOptions()
        {
            InitializeComponent();

            tabControl1.Visible = false;

            foreach (TreeNode n in treeView1.Nodes)
            {
                n.Expand();
            }

            // populate login method opts
            comboBox1.Items.Add(Resources.SSPIConnection);
            comboBox1.Items.Add(Resources.UsernamePasswordConnection);

            foreach (DataGridViewColumn c1 in resultSetNamesGrid.Columns)
            {
                c1.HeaderCell.ToolTipText = Resources.TooltipResultNames;
            }

            toolStripStatusLabel1.Text = string.Empty;

            toolTip1.SetToolTip(label9, Resources.MaxSize);
            toolTip1.SetToolTip(textBox7, Resources.MaxSize);

            toolTip2.SetToolTip(label10, Resources.DupeKeyColumnsToolTip);
            toolTip2.AutoPopDelay = Settings1.Default.toolTipDelayBeforeFade;
            toolTip2.SetToolTip(textBox8, Resources.DupeKeyColumnsToolTip);

            ConfigManipulator c = new ConfigManipulator();

            try
            {
                p = LoadOpts();

                textBox1.Text = c.GetValue("Server");
                textBox2.Text = c.GetValue("Database");
                textBox3.Text = c.GetValue("ConnectionUsername");
                textBox4.Text = c.GetValue("ConnectionPassword");

                checkBox1.Checked = p.WriteEmptyResultSetColumns;
                checkBox2.Checked = p.AutoRewriteOverpunch;

                textBox5.Text = p.QueryTimeout.ToString();
                textBox6.Text = p.MaxRowsPerSheet.ToString();
                textBox9.Text = p.MaximumResultSetsPerWorkbook.ToString();

                var p1    = p.ResultNames;
                int count = 0;
                foreach (object o in p1.Keys)
                {
                    DataGridViewRow r = new DataGridViewRow();
                    resultSetNamesGrid.Rows.Add();
                    resultSetNamesGrid.Rows[count].Cells[0].Value = o;
                    resultSetNamesGrid.Rows[count].Cells[1].Value = p1[(int)o];
                    count++;
                }

                if (String.Equals(c.GetValue("ExcelFileType"), Resources.FileTypeXml))
                {
                    comboBox3.SelectedIndex = 1;
                }
                else
                {
                    comboBox3.SelectedIndex = 0;
                }

                if (String.Equals(c.GetValue("ConnectionMethod"), Resources.SSPIConnection))
                {
                    comboBox1.SelectedItem = Resources.SSPIConnection;
                }
                else
                {
                    comboBox1.SelectedItem = Resources.UsernamePasswordConnection;
                }

                if (String.Equals(c.GetValue("NewResultSet"), Resources.NewResultSetWorksheet))
                {
                    radioButton1.Checked = true;
                    radioButton2.Checked = false;
                }
                else
                {
                    radioButton1.Checked = false;
                    radioButton2.Checked = true;
                }

                textBox7.Text = Math.Round((double)p.MaxWorkBookSize / 1024 / 1024 / 1024, 3, MidpointRounding.AwayFromZero).ToString();

                if (p.DupeKeysToDelayStartingNewWorksheet != null && p.DupeKeysToDelayStartingNewWorksheet.Length > 0)
                {
                    textBox8.Text = string.Join(",", p.DupeKeysToDelayStartingNewWorksheet);
                }
            }
            catch (Exceptions.ConfigFileBroken e)
            {
                MessageBox.Show(e.Message);
                if (e.Data.Contains("key"))
                {
                    toolStripStatusLabel1.Text = Resources.AppconfigBroken + " Missing key: " + (string)e.Data["key"];
                }
                else
                {
                    toolStripStatusLabel1.Text = Resources.AppconfigBroken;
                }
                panel7.Enabled = false;
                c1             = e;
            }
        }
Exemplo n.º 3
0
        internal static WorkBookParams LoadOpts()
        {
            ConfigManipulator c = new ConfigManipulator();
            WorkBookParams    a = new WorkBookParams();


            a.WriteEmptyResultSetColumns = Convert.ToBoolean(c.GetValue("WriteEmptyResultColumnHeaders"));
            a.AutoRewriteOverpunch       = Convert.ToBoolean(c.GetValue("AutoRewriteOverpunch"));
            a.BackendMethod = Enum.GetValues(typeof(ExcelBackend))
                              .Cast <ExcelBackend>()
                              .Where(x => String.Equals(x.ToString(), c.GetValue("ExcelFileType"))).First();

            int res = 0;

            if (!Int32.TryParse(c.GetValue("MaxRowsPerSheet"), out res))
            {
                a.MaxRowsPerSheet = Convert.ToInt32(Resources.DefaultMaxRowsPerSheet);
            }
            else
            {
                a.MaxRowsPerSheet = Convert.ToInt32(c.GetValue("MaxRowsPerSheet"));
            }
            if (Int32.TryParse(c.GetValue("QueryTimeout"), out res))
            {
                a.QueryTimeout = Convert.ToInt32(c.GetValue("QueryTimeout"));
            }

            var p1 = c.GetDictionary("ResultNames", typeof(int), typeof(string));

            foreach (object o in p1.Keys)
            {
                a.ResultNames.Add(Convert.ToInt32(o)
                                  , p1[o].ToString());
            }

            var p2 = c.GetDictionary("ColumnsThatPreventNewWorksheets", typeof(string), typeof(string));

            string[] aa = null;
            if (p2.Values.Count > 0)
            {
                aa = new string[p2.Values.Count];
                a.DupeKeysToDelayStartingNewWorksheet = new string[aa.Length];
                for (int i = 0; i < aa.Length; i++)
                {
                    a.DupeKeysToDelayStartingNewWorksheet[i] = p2.Values.ElementAt(i).ToString();
                }
            }

            long res2 = 0;

            if (long.TryParse(c.GetValue("MaximumWorkbookSizeInBytes"), out res2))
            {
                a.MaxWorkBookSize = res2;
            }

            int res3 = 0;

            if (Int32.TryParse(c.GetValue("MaximumResultSetsPerWorkbook"), out res3))
            {
                a.MaximumResultSetsPerWorkbook = res3;
            }

            return(a);
        }