private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     if (ProjectsGrid.SelectedItems.Count > NotSelected)
     {
         if (ProjectsGrid.SelectedItem is LcsProject)
         {
             LcsProject = ProjectsGrid.SelectedItem as LcsProject;
             UpdateProjectLinks();
         }
     }
     this.Close();
 }
예제 #2
0
파일: MainForm.cs 프로젝트: gerrithb/2LCS
        private void MainForm_Load(object sender, EventArgs e)
        {
            SetInitialGridSettings();

            Instances = JsonConvert.DeserializeObject <List <ProjectInstance> >(Properties.Settings.Default.instances) ??
                        new List <ProjectInstance>();
            Projects = JsonConvert.DeserializeObject <List <LcsProject> >(Properties.Settings.Default.projects) ?? new List <LcsProject>();

            if (!string.IsNullOrEmpty(Properties.Settings.Default.cookie))
            {
                _cookies = new CookieContainer();
                _cookies.SetCookies(new Uri(_lcsUrl), Properties.Settings.Default.cookie);
                _cookies.SetCookies(new Uri(_lcsUpdateUrl), Properties.Settings.Default.cookie);
                _httpClientHelper = new HttpClientHelper(_cookies)
                {
                    LcsUrl       = _lcsUrl,
                    LcsUpdateUrl = _lcsUpdateUrl
                };

                changeProjectMenuItem.Enabled   = true;
                cheInstanceContextMenu.Enabled  = true;
                saasInstanceContextMenu.Enabled = true;
                loginToLcsMenuItem.Enabled      = false;
                logoutToolStripMenuItem.Enabled = true;

                _selectedProject = GetLcsProjectFromCookie();
                if (_selectedProject != null)
                {
                    SetLcsProjectText();
                    refreshMenuItem.Enabled = true;
                    _httpClientHelper.ChangeLcsProjectId(_selectedProject.Id.ToString());
                    var projectInstance = Instances.FirstOrDefault(x => x.LcsProjectId.Equals(_selectedProject.Id));
                    if (projectInstance != null)
                    {
                        if (projectInstance.CheInstances != null)
                        {
                            _cheInstancesSource.DataSource = _cheInstancesList = projectInstance.CheInstances;
                        }
                        if (projectInstance.SaasInstances != null)
                        {
                            _saasInstancesSource.DataSource = _saasInstancesList = projectInstance.SaasInstances;
                        }
                    }
                }
            }
            CreateCustomLinksMenuItems();
        }
예제 #3
0
파일: MainForm.cs 프로젝트: gerrithb/2LCS
        private void ChangeProjectMenuItem_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            using (var form = new ChooseProject())
            {
                form.HttpClientHelper = _httpClientHelper;
                form.ShowDialog();
                if (!form.Cancelled && (form.LcsProject != null))
                {
                    Projects = form.Projects;
                    if (_selectedProject == null || form.LcsProject.Id != _selectedProject.Id)
                    {
                        _cheInstancesSource.DataSource = null;
                        _cheInstancesSource.ResetBindings(false);
                        _saasInstancesSource.DataSource = null;
                        _saasInstancesSource.ResetBindings(false);
                        _selectedProject = form.LcsProject;

                        if (!Instances.Exists(x => x.LcsProjectId == _selectedProject.Id))
                        {
                            var instance = new ProjectInstance()
                            {
                                LcsProjectId = _selectedProject.Id,
                            };
                            Instances.Add(instance);
                        }
                    }
                    refreshMenuItem.Enabled = true;
                    _httpClientHelper.ChangeLcsProjectId(_selectedProject.Id.ToString());
                    _cookies = _httpClientHelper.CookieContainer;
                    GetLcsProjectFromCookie();
                    SetLcsProjectText();
                    RefreshChe(false);
                    RefreshSaas(false);
                }
            }
            Cursor = Cursors.Default;
        }