コード例 #1
0
ファイル: MainForm.cs プロジェクト: combit/RedmineReports
        private void Form1_Load(object sender, EventArgs e)
        {
            this.BackColor = System.Drawing.Color.FromArgb(245, 246, 247);
            this.GetMainWindowsPos();
            try
            {
                if (RedmineReportsConfigDataHelper.ConnectionStringEncrypted(connString))
                {
                    _dataAccess = new RedmineMySqlDataAccess();
                }
                else
                {
                    if (RedmineReportsConfigDataHelper.ConnectionStringIsPlain(connString))
                    {
                        _dataAccess = new RedmineMySqlDataAccess(null, RedmineReportsConfigDataHelper.ConnectionStringIsPlain(connString));
                    }
                    else
                    {
                        //open config form for sql data
                        ConfigureMySqlDataBaseConnection();
                    }
                }

                _lL = new ListLabel();
                // Add your License Key
                _lL.LicensingInfo = "Insert license key here";

                // fill project listbox
                if (_dataAccess != null)
                {
                    lstbProjects.DataSource = _dataAccess.GetRedmineProjects(Convert.ToBoolean(ConfigurationManager.AppSettings["UseAllProjects"]));
                }
                lstbProjects.DisplayMember = "display_name";
                lstbProjects.ValueMember   = "id";

                // check or uncheck checkbox for subprojects
                cbAllProjects.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UseAllProjects"]);

                DesignerFunction fct = new DesignerFunction();
                fct.FunctionName      = "GetStatusNameFromId";
                fct.GroupName         = "RedmineFunctions";
                fct.ResultType        = LlParamType.String;
                fct.MinimalParameters = 1;
                fct.MaximumParameters = 1;
                fct.Parameter1.Type   = LlParamType.Double;
                fct.EvaluateFunction += new EvaluateFunctionHandler(fct_EvaluateFunction);
                _lL.DesignerFunctions.Add(fct);

                lstbTrackers.Enabled        = !AllLstBoxItemsSelected(lstbTrackers);
                chkBox_All_Trackers.Checked = AllLstBoxItemsSelected(lstbTrackers);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void CompleteBoxes()
        {
            ConfigurationManager.RefreshSection("combit.RedmineReports.Properties.Settings.RedmineConnectionString");
            string convertString = ConfigurationManager.ConnectionStrings["combit.RedmineReports.Properties.Settings.RedmineConnectionString"].ConnectionString;

            if (RedmineReportsConfigDataHelper.ConnectionStringEncrypted(convertString))
            {
                //decrypt connectionstring
                convertString = RedmineReportsConfigDataHelper.DecryptData(convertString);
            }

            Match m = Regex.Match(convertString, "server=([^;]*);uid=([^;]*);pwd=([^;]*);database=([^;]*);port=([^;]*);");

            ipAddressTextBox.Text  = m.Groups[1].Value;
            mySQLLogTextBox.Text   = m.Groups[2].Value;
            mySQLPasssTextBox.Text = m.Groups[3].Value;
            dbNameTextBox.Text     = m.Groups[4].Value;
            mySqlPortTextBox.Text  = m.Groups[5].Value;
        }
コード例 #3
0
        public RedmineMySqlDataAccess(string ConnectionString)
        {
            // create connection
            _connection = new MySqlConnection();
            if (String.IsNullOrEmpty(ConnectionString))
            {
                string convertString = ConfigurationManager.ConnectionStrings["combit.RedmineReports.Properties.Settings.RedmineConnectionString"].ConnectionString;
                //decrypt connectionstring
                _connection.ConnectionString = RedmineReportsConfigDataHelper.DecryptData(convertString);
            }
            else
            {
                _connection.ConnectionString = ConnectionString;
            }

            try
            {
                _connection.Open();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            Configuration            config = ConfigurationManager.OpenExeConfiguration("RedmineReports.exe");
            ConnectionStringsSection connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
            string convertString = connectionStringsSection.ConnectionStrings["combit.RedmineReports.Properties.Settings.RedmineConnectionString"].ConnectionString =
                string.Format("server={0};uid={1};pwd={2};database={3};port={4};",
                              ipAddressTextBox.Text, mySQLLogTextBox.Text, mySQLPasssTextBox.Text,
                              dbNameTextBox.Text, mySqlPortTextBox.Text);

            if (encryptData.Checked)
            {
                //encrpyt connectionstring
                connectionStringsSection.ConnectionStrings["combit.RedmineReports.Properties.Settings.RedmineConnectionString"].ConnectionString = RedmineReportsConfigDataHelper.EncryptData(convertString);
            }
            else
            {
                connectionStringsSection.ConnectionStrings["combit.RedmineReports.Properties.Settings.RedmineConnectionString"].ConnectionString = convertString;
            }

            config.Save();
            ConfigurationManager.RefreshSection("connectionStrings");
            saveButton.Enabled = false;
            redmineReportsForm.reloadCmb(string.Format("server={0};uid={1};pwd={2};database={3};port={4};",
                                                       ipAddressTextBox.Text, mySQLLogTextBox.Text, mySQLPasssTextBox.Text,
                                                       dbNameTextBox.Text, mySqlPortTextBox.Text));
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }