Exemplo n.º 1
0
        private void FormJobNew_Load(object sender, EventArgs e)
        {
            textSearch.Text = InitialSearchString;
            listBoxUsers.Items.Add("Any");
            _listUsers = Userods.GetDeepCopy(true);
            _listUsers.ForEach(x => listBoxUsers.Items.Add(x.UserName));
            //Statuses
            listBoxStatus.Items.Add("Any");
            _listJobStatuses = Enum.GetValues(typeof(JobPhase)).Cast <JobPhase>().ToList();
            _listJobStatuses.ForEach(x => listBoxStatus.Items.Add(x.ToString()));
            //Categories
            listBoxCategory.Items.Add("Any");
            _listJobCategory = Enum.GetValues(typeof(JobCategory)).Cast <JobCategory>().ToList();
            _listJobCategory.ForEach(x => listBoxCategory.Items.Add(x.ToString()));
            ODThread thread = new ODThread((o) => {
                //We can reduce these calls to DB by passing in more data from calling class. if available.
                if (_listJobsAll == null)
                {
                    _listJobsAll = Jobs.GetAll();
                    Jobs.FillInMemoryLists(_listJobsAll);
                }
                try {
                    _listFeatureRequestsAll = FeatureRequests.GetAll();
                }
                catch (Exception ex) {
                    ex.DoNothing();
                    _listFeatureRequestsAll = new List <FeatureRequest>();
                }
                _listBugsAll = Bugs.GetAll();
                this.Invoke((Action)ReadyForSearch);
            });

            thread.AddExceptionHandler((ex) => { /*todo*/ });
            thread.Start();
        }
Exemplo n.º 2
0
        private void butAuto_Click(object sender, EventArgs e)
        {
            FormVersionPrompt FormVP = new FormVersionPrompt("Please type a version number", false);

            FormVP.VersionText = "XX.XX";
            if (FormVP.ShowDialog() == DialogResult.Cancel)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }
            FeatureRequests.CompleteRequests(_listRequestLinks.Select(x => x.FKey).ToList(), FormVP.VersionText);
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void FormEmailJobs_Load(object sender, System.EventArgs e)
        {
            List <long> frNums = JobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Request).Select(x => x.FKey).ToList();

            _listFeatureReqs = FeatureRequests.GetAll(frNums);
            _listJobEmails   = Jobs.GetCustomerEmails(JobCur)
                               .OrderByDescending(x => x.IsQuote)
                               .ThenByDescending(x => x.IsTask)
                               .ThenByDescending(x => x.IsFeatureReq)
                               .ThenByDescending(x => x.PledgeAmount)
                               .ThenByDescending(x => x.Votes)
                               .ThenBy(x => x.Pat.PatNum).ToList();
            FillComboEmail();
            FillGridRecipients();
            textBodyTextTemplate.Text = PrefC.GetString(PrefName.JobManagerDefaultEmail);
            textPledgeTemplate.Text   = PrefC.GetString(PrefName.JobManagerDefaultBillingMsg);
            textVersions.Text         = JobCur.JobVersion;
            textDescriptions.Text     = JobCur.Title;
            _listFeatureReqs.ForEach(x => textDescriptions.Text += "\r\n\r\nFeature Request #" + x.FeatReqNum + "\r\n" + x.Description);
        }
Exemplo n.º 4
0
        private void FormJobNew_Load(object sender, EventArgs e)
        {
            textSearch.Text = InitialSearchString;
            listBoxUsers.Items.Add("Any");
            _listUsers = Userods.GetDeepCopy(true);
            _listUsers.ForEach(x => listBoxUsers.Items.Add(x.UserName));
            //Statuses
            listBoxStatus.Items.Add("Any");
            _listJobStatuses = Enum.GetValues(typeof(JobPhase)).Cast <JobPhase>().ToList();
            _listJobStatuses.ForEach(x => listBoxStatus.Items.Add(x.ToString()));
            //Categories
            listBoxCategory.Items.Add("Any");
            _listJobCategory = Enum.GetValues(typeof(JobCategory)).Cast <JobCategory>().ToList();
            _listJobCategory.ForEach(x => listBoxCategory.Items.Add(x.ToString()));
            ODThread thread = new ODThread((o) => {
                //We can reduce these calls to DB by passing in more data from calling class. if available.
                _listJobsAll = Jobs.GetAll();
                Jobs.FillInMemoryLists(_listJobsAll);
                _listTasksAll     = Tasks.GetMany(_listJobsAll.SelectMany(x => x.ListJobLinks).Where(x => x.LinkType == JobLinkType.Task).Select(x => x.FKey).Distinct().ToList());
                _listTaskNotesAll = TaskNotes.GetForTasks(_listTasksAll.Select(x => x.TaskNum).ToList());
                _listPatientAll   = Patients.GetMultPats(_listJobsAll.SelectMany(x => x.ListJobQuotes).Select(x => x.PatNum).Distinct().ToList()).ToList();
                _listPatientAll.AddRange(Patients.GetMultPats(_listTasksAll.FindAll(x => x.ObjectType == TaskObjectType.Patient).Select(x => x.KeyNum).ToList()));
                try {
                    _listFeatureRequestsAll = FeatureRequests.GetAll();
                }
                catch (Exception ex) {
                    ex.DoNothing();
                    _listFeatureRequestsAll = new List <FeatureRequest>();
                }
                _listBugsAll = Bugs.GetAll();
                this.Invoke((Action)ReadyForSearch);
            });

            thread.AddExceptionHandler((ex) => { /*todo*/ });
            thread.Start();
        }
Exemplo n.º 5
0
        private void FillGridMain()
        {
            string[]      searchTokens  = textSearch.Text.ToLower().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            long[]        userNums      = new long[0];
            JobCategory[] jobCats       = new JobCategory[0];
            JobPhase[]    jobPhases     = new JobPhase[0];
            long[]        jobPriorities = new long[0];
            if (listBoxUsers.SelectedIndices.Count > 0 && !listBoxUsers.SelectedIndices.Contains(0))
            {
                userNums = listBoxUsers.SelectedIndices.Cast <int>().Select(x => _listUsers[x - 1].UserNum).ToArray();
            }
            if (listBoxCategory.SelectedIndices.Count > 0 && !listBoxCategory.SelectedIndices.Contains(0))
            {
                jobCats = listBoxCategory.SelectedIndices.Cast <int>().Select(x => (JobCategory)(x - 1)).ToArray();
            }
            if (listBoxPhases.SelectedIndices.Count > 0 && !listBoxPhases.SelectedIndices.Contains(0))
            {
                jobPhases = listBoxPhases.SelectedIndices.Cast <int>().Select(x => (JobPhase)(x - 1)).ToArray();
            }
            if (listBoxPriorities.SelectedIndices.Count > 0 && !listBoxPriorities.SelectedIndices.Contains(0))
            {
                jobPriorities = listBoxPriorities.GetListSelected <Def>().Select(x => x.DefNum).ToArray();
            }
            Action actionCloseProgress = ODProgress.Show(ODEventType.Job, typeof(JobEvent), "Getting job data...");

            #region Get Missing Data
            //This entire section will go out to the database and get any data that is unknown based on some of the filters.
            //The other filters will be applied later via the cached lists.
            try {
                List <Job> listJobs = Jobs.GetForSearch(dateFrom.Value, dateTo.Value, jobPhases.ToList(), jobPriorities.ToList(), _listJobsAll.Select(x => x.JobNum).ToList());
                Jobs.FillInMemoryLists(listJobs, true);
                _listJobsAll.AddRange(listJobs);
            }
            catch (OutOfMemoryException oome) {
                actionCloseProgress();
                oome.DoNothing();
                MsgBox.Show(this, "Not enough memory to complete the search.  Please refine search filters.");
                return;
            }
            //Only get the feature request entries that we care about.
            JobEvent.Fire(ODEventType.Job, "Getting feature request data...");
            List <long> listFeatureRequestNums = _listJobsAll.SelectMany(x => x.ListJobLinks)
                                                 .Where(x => x.LinkType == JobLinkType.Request)
                                                 .Select(x => x.FKey)
                                                 .Distinct()
                                                 .ToList();
            //Don't download any feature requests that we already know about.
            listFeatureRequestNums.RemoveAll(x => x.In(_listFeatureRequestsAll.Select(y => y.FeatReqNum)));
            if (!listFeatureRequestNums.IsNullOrEmpty())
            {
                _listFeatureRequestsAll.AddRange(FeatureRequests.GetAll(listFeatureRequestNums));
            }
            //Only get the bug entries that we care about.
            JobEvent.Fire(ODEventType.Job, "Getting bug data...");
            List <long> listBugIds = _listJobsAll.SelectMany(x => x.ListJobLinks)
                                     .Where(x => x.LinkType == JobLinkType.Bug)
                                     .Select(x => x.FKey)
                                     .Distinct()
                                     .ToList();
            //Don't download any bugs that we already know about.
            listBugIds.RemoveAll(x => x.In(_listBugsAll.Select(y => y.BugId)));
            if (!listBugIds.IsNullOrEmpty())
            {
                _listBugsAll.AddRange(Bugs.GetMany(listBugIds));
            }
            #endregion
            JobEvent.Fire(ODEventType.Job, "Filling grid...");
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn("Job\r\nNum", 50, GridSortingStrategy.AmountParse));
            gridMain.ListGridColumns.Add(new GridColumn("Priority", 50, HorizontalAlignment.Center));
            gridMain.ListGridColumns.Add(new GridColumn("Phase", 85));
            gridMain.ListGridColumns.Add(new GridColumn("Category", 80));
            gridMain.ListGridColumns.Add(new GridColumn("Job Title", -1));
            gridMain.ListGridColumns.Add(new GridColumn("Version", 80));
            gridMain.ListGridColumns.Add(new GridColumn("Est. Version", 80));
            gridMain.ListGridColumns.Add(new GridColumn("Expert", 75));
            gridMain.ListGridColumns.Add(new GridColumn("Engineer", 75));
            gridMain.ListGridColumns.Add(new GridColumn("Est.\r\nHours", 60, GridSortingStrategy.AmountParse));
            gridMain.ListGridColumns.Add(new GridColumn("Act.\r\nHours", 60, GridSortingStrategy.AmountParse));
            gridMain.ListGridColumns.Add(new GridColumn("Job\r\nMatch", 45, HorizontalAlignment.Center));
            gridMain.ListGridColumns.Add(new GridColumn("Bug\r\nMatch", 45, HorizontalAlignment.Center));
            gridMain.ListGridColumns.Add(new GridColumn("FR\r\nMatch", 45, HorizontalAlignment.Center));
            gridMain.ListGridRows.Clear();
            _listJobsFiltered = new List <Job>();
            foreach (Job jobCur in _listJobsAll)
            {
                if (jobCats.Length > 0 && !jobCats.Contains(jobCur.Category))
                {
                    continue;
                }
                if (jobPhases.Length > 0 && !jobPhases.Contains(jobCur.PhaseCur))
                {
                    continue;
                }
                if (jobPriorities.Length > 0 && !jobPriorities.Contains(jobCur.Priority))
                {
                    continue;
                }
                if (userNums.Length > 0 && !userNums.All(x => Jobs.GetUserNums(jobCur).Contains(x)))
                {
                    continue;
                }
                if (!jobCur.DateTimeEntry.Between(dateFrom.Value, dateTo.Value))
                {
                    continue;
                }
                bool isJobMatch        = false;
                bool isBugMatch        = false;
                bool isFeatureReqMatch = false;
                if (searchTokens.Length > 0)
                {
                    bool       addRow   = false;
                    List <Bug> listBugs = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Bug)
                                          .Select(x => _listBugsAll.FirstOrDefault(y => x.FKey == y.BugId))
                                          .Where(x => x != null)
                                          .ToList();
                    List <FeatureRequest> listFeatures = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Request)
                                                         .Select(x => _listFeatureRequestsAll.FirstOrDefault(y => x.FKey == y.FeatReqNum))
                                                         .Where(x => x != null)
                                                         .ToList();
                    foreach (string token in searchTokens.Distinct())
                    {
                        bool isFound = false;
                        //JOB MATCHES
                        if (jobCur.Title.ToLower().Contains(token) ||
                            jobCur.Implementation.ToLower().Contains(token) ||
                            jobCur.Requirements.ToLower().Contains(token) ||
                            jobCur.Documentation.ToLower().Contains(token) ||
                            jobCur.JobNum.ToString().Contains(token))
                        {
                            isFound    = true;
                            isJobMatch = true;
                        }
                        //BUG MATCHES
                        if (!isFound || !isBugMatch)
                        {
                            if (listBugs.Any(x => x.Description.ToLower().Contains(token) || x.Discussion.ToLower().Contains(token)))
                            {
                                isFound    = true;
                                isBugMatch = true;
                            }
                        }
                        //FEATURE REQUEST MATCHES
                        if (!isFound || !isFeatureReqMatch)
                        {
                            if (listFeatures.Any(x => x.Description.Contains(token) || x.FeatReqNum.ToString().ToLower().Contains(token)))
                            {
                                isFound           = true;
                                isFeatureReqMatch = true;
                            }
                        }
                        addRow = isFound;
                        if (!isFound)
                        {
                            break;                            //stop looking for additional tokens, we didn't find this one.
                        }
                    }
                    if (!addRow)
                    {
                        continue;                        //we did not find one of the search terms.
                    }
                }
                _listJobsFiltered.Add(jobCur);
                Def     jobPriority = _listJobPriorities.FirstOrDefault(y => y.DefNum == jobCur.Priority);
                GridRow row         = new GridRow();
                row.Cells.Add(jobCur.JobNum.ToString());
                row.Cells.Add(new GridCell(jobPriority.ItemName)
                {
                    ColorBackG = jobPriority.ItemColor,
                    ColorText  = (jobCur.Priority == _listJobPriorities.FirstOrDefault(y => y.ItemValue.Contains("Urgent")).DefNum) ? Color.White : Color.Black,
                });
                row.Cells.Add(jobCur.PhaseCur.ToString());
                row.Cells.Add(jobCur.Category.ToString());
                row.Cells.Add(jobCur.Title);
                row.Cells.Add(jobCur.JobVersion.ToString());
                row.Cells.Add(jobCur.ProposedVersion.ToString());
                row.Cells.Add(Userods.GetName(jobCur.UserNumExpert));
                row.Cells.Add(Userods.GetName(jobCur.UserNumEngineer));
                row.Cells.Add(jobCur.HoursEstimate.ToString());
                row.Cells.Add(jobCur.HoursActual.ToString());
                row.Cells.Add(isJobMatch ? "X" : "");
                row.Cells.Add(isBugMatch ? "X" : "");
                row.Cells.Add(new GridCell(isFeatureReqMatch ? "X" : "")
                {
                    ColorBackG = _listFeatureRequestsAll.Count == 0 ? Control.DefaultBackColor : Color.Empty
                });
                row.Tag = jobCur;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            actionCloseProgress();
        }