Exemple #1
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            loginProgressBar.Visible = true;
            var  trr = new TestRailReader(serverTxt.Text, loginTxt.Text, passwordTxt.Text);
            bool accessGranted;

            var domain = "@neopost.com";

            if (loginTxt.Text.Substring(loginTxt.Text.Length - domain.Length, domain.Length).Equals(domain))
            {
                accessGranted = trr.TryLogin(domain);
            }
            else
            {
                accessGranted = trr.TryLogin();
            }

            if (accessGranted)
            {
                this.DialogResult = DialogResult.OK;

                var administrator = _dbs.GetAdmin();
                if (administrator != null)
                {
                    administrator.SetProperties(1, serverTxt.Text, loginTxt.Text, administrator.ProjectId);
                }
                else
                {
                    administrator = new Administrator();
                    administrator.SetProperties(1, serverTxt.Text, loginTxt.Text, -1);
                }

                try
                {
                    if (_dbs.DocumentExists(AdminCollectionName, 1))
                    {
                        _dbs.UpdateDocument(administrator);
                    }
                    else
                    {
                        _dbs.InsertDocument(administrator);
                    }
                }
                catch (Exception ex)
                {
                    Program.LogException(ex);
                }
            }
            else
            {
                loginProgressBar.Visible = false;
                MessageBox.Show(@"Cannot login, try again.");
                serverTxt.Focus();
            }
        }
Exemple #2
0
        private void TestRailSearcher_Load(object sender, EventArgs e)
        {
            LoginForm loginForm = new LoginForm();

            if (loginForm.ShowDialog() != DialogResult.OK)
            {
                this.Close();
            }

            // Set window location
            if (Settings.Default.WindowLocation != null)
            {
                this.Location = Settings.Default.WindowLocation;
            }

            // Set window size
            if (Settings.Default.WindowSize != null)
            {
                this.Size = Settings.Default.WindowSize;
            }

            this._server   = loginForm.serverTxt.Text;
            this._user     = loginForm.loginTxt.Text;
            this._password = loginForm.passwordTxt.Text;

            loginLabel.Text = this._user;
            searchTxt.Text  = "";
            SetLoading(false);

            _trr        = new TestRailReader(this._server, this._user, this._password);
            _caseFields = _trr.GetCaseFields();
            GetAssignees();

            var projects = _trr.GetProjects();

            foreach (var project in projects)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = (string)project["name"];
                item.Value = project["id"];
                projectsCmb.Items.Add(item);
            }

            var dbs   = new DatabaseServer(DatabaseFilePath, AdminCollectionName);
            var admin = dbs.GetAdmin();
            var index = 0;

            foreach (var projectsCmbItem in projectsCmb.Items)
            {
                if (((ComboboxItem)projectsCmbItem).Value.ToString().Equals(admin.ProjectId.ToString()))
                {
                    projectsCmb.SelectedIndex = index;
                    SetLoading(true);
                    FillSuites();
                    GetSections();
                    GetStatusesAndTestTypesAndTags();
                    SetLoading(false);
                    break;
                }
                index++;
            }

            testCasesDataGridView.Columns.Add("Suite", "Suite");
            testCasesDataGridView.Columns.Add("ID", "ID");
            testCasesDataGridView.Columns.Add("Category", "Category");
            testCasesDataGridView.Columns.Add("Title", "Title");
            testCasesDataGridView.Columns.Add("Original ID", "Original ID");
            testCasesDataGridView.Columns.Add("Test Type", "Test Type");
            testCasesDataGridView.Columns.Add("Tags", "Tags");
            testCasesDataGridView.Columns.Add("Status", "Status");
            testCasesDataGridView.Columns.Add("Assignee", "Assignee");

            this.Text = Program.VersionLabel;
            loginForm.Close();
        }