Exemplo n.º 1
0
        public Task(string priority, List <string> projects, List <string> contexts,
                    string body, DateTime?createdDate, string dueDate, bool completed, DateTime?completedDate)
        {
            Priority = priority.Replace("(", String.Empty).Replace(")", String.Empty).ToUpperInvariant();

            if (projects != null)
            {
                _projects = projects;
            }

            if (contexts != null)
            {
                _contexts = contexts;
            }

            CreatedDate = createdDate;
            DueDate     = dueDate;

            Body = body + (Contexts.Count() > 0 ? " " : String.Empty)
                   + String.Join(" ", _contexts.ToArray())
                   + (Projects.Count() > 0 ? " " : String.Empty)
                   + String.Join(" ", Projects.ToArray())
                   + (String.IsNullOrEmpty(dueDate) ? String.Empty : " due:" + dueDate);

            Completed     = completed;
            CompletedDate = completedDate;

            Raw = (_completed ? "x " : String.Empty)
                  + (!String.IsNullOrEmpty(Priority) ? "(" + Priority + ") " : String.Empty)
                  + (CreatedDate.HasValue ? (CreatedDate.Value.ToString("yyyy-MM-dd") + " ") : String.Empty)
                  + Body;
        }
        private void UpdateSelectCheckbox()
        {
            if (Projects == null)
            {
                return;
            }

            _updatingCheckbox = true;
            var countTotal = Projects.Count(p => p.Enabled);

            SelectCheckboxText = string.Format(
                CultureInfo.CurrentCulture,
                Resources.Checkbox_ProjectSelection,
                countTotal);

            var countSelected = Projects.Count(p => p.Selected);

            if (countSelected == 0)
            {
                CheckboxState = false;
            }
            else if (countSelected == countTotal)
            {
                CheckboxState = true;
            }
            else
            {
                CheckboxState = null;
            }
            _updatingCheckbox = false;
        }
        public IActionResult All(int start, int limit, string createdat, string contributors, string bugs, string name, string search)
        {
            IQueryable <Project> Projects;

            Projects = (String.IsNullOrEmpty(search)) ? context.Projects : context.Projects.Where(p => p.Name.ToLower().Contains(search.ToLower()));
            Projects = Projects
                       .Include(p => p.Creator)
                       .Include(p => p.Bugs)
                       .Include(p => p.Contributors)
                       .ThenInclude(c => c.User);
            int Count = Projects.Count();

            if (createdat != "null")
            {
                Projects = (createdat == "asc") ? Projects.OrderBy(p => p.CreatedAt).ThenBy(p => p.Name) : Projects.OrderByDescending(p => p.CreatedAt).ThenBy(p => p.Name);
            }
            else if (contributors != "null")
            {
                Projects = (contributors == "asc") ? Projects.OrderBy(p => p.Contributors.Count).ThenBy(p => p.CreatedAt) : Projects.OrderByDescending(p => p.Contributors.Count).ThenBy(p => p.CreatedAt);
            }
            else if (bugs != "null")
            {
                Projects = (bugs == "asc") ? Projects.OrderBy(p => p.Bugs.Count).ThenBy(p => p.CreatedAt) : Projects.OrderByDescending(p => p.Bugs.Count).ThenBy(p => p.CreatedAt);
            }
            else if (name != "null")
            {
                Projects = (name == "asc") ? Projects.OrderBy(p => p.Name).ThenBy(p => p.CreatedAt) : Projects.OrderByDescending(p => p.Name).ThenBy(p => p.CreatedAt);
            }
            Projects = Projects.Skip(start).Take(limit);
            return(OkJson(new { Projects = Projects.ToList(), Count = Count }));
        }
Exemplo n.º 4
0
        public async Task ReturnsAllProjectsWhenThereAreNoWordsToFilter()
        {
            var interactor = new GetProjectsAutocompleteSuggestions(dataSource, new string[0]);

            var suggestions = await interactor.Execute();

            suggestions.Should().HaveCount(Projects.Count(p => p.Active))
            .And.AllBeOfType <ProjectSuggestion>();
        }
Exemplo n.º 5
0
 public ProjectViewMoodel(int userid)
 {
     CurrentUserId  = userid;
     Projects       = ProjectModel.GetProjects(currentUserId);
     ProjectsNumber = Projects.Count();
     ResultProjects = new ObservableCollection <Project>();
     foreach (var p in Projects)
     {
         ResultProjects.Add(p);
     }
 }
Exemplo n.º 6
0
 private void GetProjectInformation(Project2 project)
 {
     project.ProcessStatus = "Processing";
     GetDirectoryInfo(project, project.ProjectPath);
     GetDirectorySize(project, project.ProjectPath);
     if (token.IsCancellationRequested)
     {
         project.ProcessStatus = "Cancelled";
     }
     else
     {
         project.ProcessStatus = "Done";
     }
     ProgressPercent += 100.0 / Projects.Count();
 }
Exemplo n.º 7
0
        public async Task OnGetAsync()
        {
            Projects = await _context.Projects.ToListAsync();

            Scope = await _context.Scope.ToListAsync();

            Revenue = new List <Revenue>();

            for (int i = 0; i < Projects.Count(); i++)
            {
                Revenue.Add(new Revenue
                {
                    LEAD_NUMBER  = " ",
                    PROJECT_NAME = " ",
                    CUSTOMER     = " ",
                    PART_NUMBER  = " ",
                    PRIORITY     = " ",
                    DELIVERABLE  = " ",
                    COMMIT_DATE  = DateTime.Now,
                    EE_LEAD      = " ",
                    ME_LEAD      = " ",
                    SALESMAN     = " ",
                    EAR          = 0
                });
                Revenue[i].LEAD_NUMBER  = Projects[i].LEAD_NUMBER;
                Revenue[i].PROJECT_NAME = Projects[i].PROJECT_NAME;
                Revenue[i].CUSTOMER     = Projects[i].CUSTOMER;
                Revenue[i].PART_NUMBER  = Projects[i].PART_NUMBER;
                Revenue[i].PRIORITY     = Projects[i].PRIORITY;
                Revenue[i].DELIVERABLE  = Projects[i].DELIVERABLE;
                Revenue[i].COMMIT_DATE  = Projects[i].COMMIT_DATE;
                Revenue[i].EE_LEAD      = Projects[i].EE_LEAD;
                Revenue[i].ME_LEAD      = Projects[i].ME_LEAD;
                Revenue[i].SALESMAN     = Projects[i].SALESMAN;
                for (int j = 0; j < Scope.Count(); j++)
                {
                    if (Revenue[i].LEAD_NUMBER == Scope[j].LEAD_NUMBER)
                    {
                        Revenue[i].EAR = Scope[j].EAU * Scope[j].TARGET_PRICE;
                    }
                }
            }
            RevenueIQ = Revenue.AsQueryable();
            // RevenueIQ = RevenueIQ.Where(s => s.EAR != 0);
            RevenueIQ = RevenueIQ.OrderByDescending(s => s.EAR);
            // Revenue = await RevenueIQ.ToListAsync();
        }
Exemplo n.º 8
0
        public void UpdateState()
        {
            if (Projects.Count(item => item.IsDone) == 0)
            {
                State = PracticalStateEnum.Default;
            }
            else if (Projects.Count(item => item.IsDone) < Projects.Count)
            {
                State = PracticalStateEnum.OnWorking;
            }
            else
            {
                State = PracticalStateEnum.HasDone;
            }

            RaisePropertyChanged("Projects");
        }
Exemplo n.º 9
0
 public void DevSeedDatabase()
 {
     if (Statuses.Count() == 0)
     {
         DevSeedStatuses();
     }
     if (Users.Count() == 0)
     {
         DevSeedUser();
     }
     if (Projects.Count() == 0)
     {
         DevSeedProject();
     }
     if (TodoItems.Count() == 0 || true)
     {
         DevSeedTodoItem();
     }
 }
        private void UpdateSelectCheckBoxState()
        {
            _updatingSelectCheckBoxState = true;
            int countSelected = Projects.Count(project => project.IsSelected);

            if (countSelected == 0)
            {
                SelectCheckBoxState = false;
            }
            else if (countSelected == Projects.Count)
            {
                SelectCheckBoxState = true;
            }
            else
            {
                SelectCheckBoxState = null;
            }

            _updatingSelectCheckBoxState = false;
        }
            /// <summary>
            /// 自定义序列化过程
            /// </summary>
            /// <param name="info"></param>
            /// <param name="context"></param>
            public void GetObjectData(SerializationInfo info, StreamingContext context)
            {
                info.AddValue(NameItem, Name);
                if ((Projects != null) && (Projects.Count() > 0))
                {
                    var items = Projects.Where
                                (
                        x =>
                        (DateTime.Now.Year - x.EndYear <= 2) &&
                        x.Scale > 3000
                                );
                    if (items != null)
                    {
                        info.AddValue(ProjectsItem, items.ToArray());
                    }
                }
                if (Staff != null)
                {
                    var items =
                        from employee in Staff
                        where
                        (employee.Certificates != null) &&
                        (employee.Certificates.Count() > 0) &&
                        (employee.Certificates.Where(x =>
                                                     string.Equals(x.Name, ProjectManagerItem) &&
                                                     x.CompareTo(ProfessionalPm) >= 0).Count() > 0)


                        select new Employee()
                    {
                        Name         = employee.Name,
                        Certificates = employee.Certificates.Where(x => x.CompareTo(ProfessionalPm) > 0).ToArray()
                    };
                    if ((items != null) && (items.Count() > 0))
                    {
                        info.AddValue(StaffItem, items.ToArray());
                    }
                }
            }
Exemplo n.º 12
0
        public async Task <MonitorStatus> DoUpdate(IEnumerable <MonitoredProjectSettings> monitoredProjects)
        {
            var projectSyncOutcome = await SyncMonitoredProjects(monitoredProjects);

            if (projectSyncOutcome != MonitorStatus.UpdateSuccessful)
            {
                return(projectSyncOutcome);
            }

            if (!Projects.Any())
            {
                return(MonitorStatus.NoProjects);
            }

            Task[] taskArray = new Task[Projects.Count()];
            for (int i = 0; i < Projects.Count(); i++)
            {
                taskArray[i] = Projects.ElementAt(i).RetrievePullRequests();
            }
            Task.WaitAll(taskArray);

            if (Projects.Any(proj => proj.PullRequestRetrievalStatus == RetrievalStatus.FailedDueToConnection))
            {
                return(MonitorStatus.CouldNotReachServer);
            }

            if (Projects.Any(proj => proj.PullRequestRetrievalStatus == RetrievalStatus.FailedDueToAuth))
            {
                return(MonitorStatus.AuthorisationError);
            }

            if (Projects.Any(proj => proj.PullRequestRetrievalStatus == RetrievalStatus.FailedReasonUnknown) ||
                Projects.Any(proj => proj.PullRequestRetrievalStatus == RetrievalStatus.Unstarted))
            {
                return(MonitorStatus.UnrecognisedError);
            }

            return(MonitorStatus.UpdateSuccessful);
        }
Exemplo n.º 13
0
        public ActionResult Add(ProjectModel model)
        {
            ViewBag.Organizations    = Organizations;
            ViewBag.HasOrganizations = Organizations.Any();
            ViewBag.TimeZones        = TimeZoneInfo.GetSystemTimeZones();

            #region Validation

            Organization organization = null;

            if (!String.IsNullOrEmpty(model.OrganizationName))
            {
                Organization existing = Organizations.FirstOrDefault(o => o.Name == model.OrganizationName);
                organization = existing ?? new Organization {
                    Name = model.OrganizationName.Trim()
                };
            }
            else if (!String.IsNullOrEmpty(model.OrganizationId))
            {
                organization = Organizations.FirstOrDefault(o => o.Id == model.OrganizationId);
                ModelState state = ModelState["OrganizationName"];
                if (state != null)
                {
                    state.Errors.Clear();
                }
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (organization == null)
            {
                ModelState.AddModelError("OrganizationName", "Organization Name is required.");
                return(View(model));
            }

            if (!String.IsNullOrEmpty(organization.Id) && Projects.Count(p => p.OrganizationId == organization.Id && String.Equals(p.Name, model.Name, StringComparison.OrdinalIgnoreCase)) > 0)
            {
                ModelState.AddModelError("Name", "A project with this name already exists.");
                return(View(model));
            }

            #endregion

            var user = GetUser();
            if (String.IsNullOrEmpty(organization.Id))
            {
                if (!_billingManager.CanAddOrganization(user))
                {
                    ModelState.AddModelError(String.Empty, "Please upgrade your plan to add an additional organization.");
                    return(View(model));
                }

                _billingManager.ApplyBillingPlan(organization, Settings.Current.EnableBilling ? BillingManager.FreePlan : BillingManager.UnlimitedPlan, user);
                organization = _organizationRepository.Add(organization, true);

                user.OrganizationIds.Add(organization.Id);
                _userRepository.Save(user);
            }

            var project = new Project {
                Name = model.Name, TimeZone = model.TimeZone, OrganizationId = organization.Id
            };
            project.NextSummaryEndOfDayTicks = TimeZoneInfo.ConvertTime(DateTime.Today.AddDays(1), project.DefaultTimeZone()).ToUniversalTime().Ticks;
            project.ApiKeys.Add(Guid.NewGuid().ToString("N").ToLower());
            project.AddDefaultOwnerNotificationSettings(user.Id);

            if (!_billingManager.CanAddProject(project))
            {
                ModelState.AddModelError(String.Empty, "Please upgrade your plan to add an additional project.");
                return(View(model));
            }

            project = _projectRepository.Add(project);
            _organizationRepository.IncrementStats(project.OrganizationId, projectCount: 1);

            return(RedirectToAction("Configure", "Project", new { id = project.Id }));
        }
Exemplo n.º 14
0
        private bool IsShortNameIsUnique()
        {
            int count = Projects.Count(p => p.ShortName == Entity.ShortName && p.ID != Entity.ID);

            return(count == 0);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Method to load all projects found on the base path
        /// </summary>
        public void LoadProjects()
        {
            GlobalResult.LogGeneralMessage(Constants.IMG_SEARCH_MSG_START_APP);
            GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_BASE_DIR, BasePath));
            GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_BASE_IMAGE_DIR, ImagePath));
            GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_IMAGE_NAME, ImageName));
            GlobalResult.LogGeneralMessage(Constants.IMG_SEARCH_MSG_START_LOADING_PROJECT);
            IEnumerable <string> m_lstProjects;

            try
            {
                m_lstProjects = Directory.EnumerateFileSystemEntries(BasePath, Constants.IMG_SEARCH_PROJECT_EXTENSION, SearchOption.AllDirectories);
                if (m_lstProjects.Count() > 0)
                {
                    foreach (string m_strProject in m_lstProjects)
                    {
                        Project m_prjProject = new Project(m_strProject);
                        if (m_prjProject.CheckSearchFolder(ImagePath))
                        {
                            Projects.Add(m_prjProject);
                        }
                    }
                    GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_PROJECT_FOUND, m_lstProjects.Count(), Projects.Count()));
                }
                else
                {
                    GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_NO_PROJECT, BasePath));
                }
            }
            catch (ArgumentException m_exArg)
            {
                GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_ARG_EXCEPTION, BasePath, m_exArg.Message));
            }
            catch (DirectoryNotFoundException m_exDirNotFound)
            {
                GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_DIR_EXCEPTION, BasePath, m_exDirNotFound.Message));
            }
            catch (IOException m_exIO)
            {
                GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_IO_EXCEPTION, BasePath, m_exIO.Message));
            }
        }
Exemplo n.º 16
0
 public static int Count()
 {
     return(Projects.Count());
 }
        public DatabaseContext() : base("DbContext")
        {
            if (!Database.Exists())
            {
                Database.Create();
            }

            if (Roles.Where(x => x.Name == "User").FirstOrDefault() == null)
            {
                Roles.Add(new Role()
                {
                    Name        = "User",
                    AccessLevel = 1
                });

                Roles.Add(new Role()
                {
                    Name        = "Admin",
                    AccessLevel = 2
                });
                SaveChanges();
            }

            if (Users.Where(x => x.Login == "admin").FirstOrDefault() == null)
            {
                Users.Add(new User()
                {
                    Login       = "******",
                    Password    = Hash.ComputeSha256Hash("admin"),
                    RoleId      = 2,
                    IsActivated = true,
                    Name        = "UMP",
                    SecondName  = "9",
                    Email       = "*****@*****.**",
                });

                Users.Add(new User()
                {
                    Login       = "******",
                    Password    = Hash.ComputeSha256Hash("1234"),
                    RoleId      = 1,
                    IsActivated = true,
                    Name        = "Ruslan",
                    SecondName  = "Kudrjavtsev",
                    Email       = "*****@*****.**",
                });

                SaveChanges();
            }

            if (Projects.Count() == 0)
            {
                Projects.Add(new Project()
                {
                    Name         = "ProjName",
                    CreatorLogin = "******",
                    StartTime    = DateTime.Now,
                    EndTime      = DateTime.Now.AddYears(1),
                    CreatedTime  = DateTime.Now
                });

                Projects.Add(new Project()
                {
                    Name         = "ProjName1",
                    CreatorLogin = "******",
                    StartTime    = DateTime.Now,
                    EndTime      = DateTime.Now.AddYears(1),
                    CreatedTime  = DateTime.Now
                });

                Projects.Add(new Project()
                {
                    Name         = "ProjName2",
                    CreatorLogin = "******",
                    StartTime    = DateTime.Now,
                    EndTime      = DateTime.Now.AddYears(1),
                    CreatedTime  = DateTime.Now
                });

                Projects.Add(new Project()
                {
                    Name         = "ProjName3",
                    CreatorLogin = "******",
                    StartTime    = DateTime.Now,
                    EndTime      = DateTime.Now.AddYears(1),
                    CreatedTime  = DateTime.Now
                });
                SaveChanges();
            }
        }