예제 #1
0
        public Project GetProjectByKey(string key)
        {
            using (var cnn = GetConnection())
            using (var cmd = cnn.CreateCommand())
            {
                cmd.CommandText = @"SELECT * FROM Projects
                                    WHERE Key = @key COLLATE NOCASE";

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@key", key);

                using (var reader = cmd.ExecuteReader())
                {
                    if (!reader.Read()) return null;

                    var project = new Project
                    {
                        Id = reader.Get<string>("Id"),
                        Name = reader.Get<string>("Name"),
                        Key = reader.Get<string>("Key"),
                    };

                    project.AssociatedRemoteRepository = GetAssociatedRemoteRepository(project.Id);

                    return project;
                }
            }
        }
예제 #2
0
        public int Add(string title, string description, DateTime start, DateTime? deadline, string creator)
        {
            var currentUser = this.data.Users
              .All()
              .FirstOrDefault(u => u.UserName == creator);

            if (currentUser == null)
            {
                throw new ArgumentException("Current user cannot be found!");
            }

            var project = new Project
            {
                Title = title,
                Description = description,
                StartDate = start,
                Deadline = deadline,
                Creator = creator
            };

            project.Users.Add(currentUser);
            this.data.Projects.Add(project);
            this.data.Projects.SaveChanges();

            return project.Id;
        }
        public int AddNew(
            string title,
            string description,
            int category,
            decimal price,
            string employerId,
            DateTime startDate,
            DateTime endDate)
        {
            var newProject = new Project()
            {
                Title = title,
                Description = description,
                CategoryId = category,
                Price = price,
                CreatedOn = DateTime.UtcNow,
                StartOn = startDate,
                FinishOn = endDate,
                EmployerID = employerId
            };

            this.projects.Add(newProject);
            this.projects.SaveChanges();

            return newProject.ID;
        }
예제 #4
0
        public IEnumerable <Task> GetTasks(Project project)
        {
            // https://www.example.com/rest/api/latest/search?jql=project%3D%22ProjectName%22%20order%20by%20id&fields=summary
            var request = new RestRequest
            {
                Resource   = "search",
                Parameters =
                {
                    new Parameter
                    {
                        Name  = "jql",
                        Type  = ParameterType.QueryString,
                        Value = $"project=\"{project.Name}\" order by id"
                    },
                    new Parameter {
                        Name = "fields", Type = ParameterType.QueryString, Value = "summary"
                    }
                }
            };

            var apiResult = Api.Execute <TaskResult>(request);

            return(apiResult?.issues?.Select(x => new Task
            {
                Id = x.id,
                Name = x.key,
                Description = (x.fields == null) ? "" : x.fields.summary,
                Project = project,
                Parent = (x.fields?.parent == null) ? null : new Task {
                    Id = x.fields.parent.id
                }
            }));
        }
        public IRemoteTimeRepository GetAssociatedRemoteTimeRepository(Project project)
        {
            if (project.AssociatedRemoteRepository == null) return null;

            var remoteRepository = _remoteTimeRepositories[project.AssociatedRemoteRepository.Value];
            remoteRepository.InitializeForProject(project);
            return remoteRepository;
        }
 private static Guid GetCurrentCloudGuid(Project project)
 {
     var cloudGuid = Guid.Empty;
     var cloudId = project.GetGlobalVariable("CloudId");
     if (!Guid.TryParse(cloudId, out cloudGuid))
         cloudGuid = Guid.Empty;
     return cloudGuid;
 }
예제 #7
0
        public ActionResult AddProject(Project model)
        {
            if (ModelState.IsValid) {
                Business.AddProject (model);

                return RedirectToAction ("Projects");
            }

            return View (model);
        }
예제 #8
0
        public Task GetAssociatedTaskByName(string name, Project project)
        {
            var task = _localTaskRepository.GetTaskByName(name);
            if (task != null) return task;

            var remoteTaskRepository = _associatedRemoteRepositoryService.GetAssociatedRemoteTaskRepository(project);
            if (remoteTaskRepository == null) return null;

            //TODO: we need to make sure the id stored is uniqe. We could do this by specifying that this is the remoteId and then internally tracking via auto-incremeneting key.
            task = remoteTaskRepository.GetTaskByName(name);
            if (task != null) StoreTask(task);
            return task;
        }
예제 #9
0
 public async Task RunAsync(object dataContext)
 {
     var settings = dataContext as Settings;
     var project = new Project();
     project.ConnectionString.Value = settings.ConnectionString;
     project.MaximumRowsInTable.Value = settings.MaximumRowsInTable;
     project.OutputFolder.Value = settings.OutputDirectory;
     project.Tables = settings.Tables;
     Importer.ProcessProject(project);
     if (File.Exists(settings.ProjectFile))
     {
         _configurationService.SetRoamingValue("LastProjectPath", settings.ProjectFile);
     }
 }
        public void NewProjectTest()
        {
            string projectName = "testProjectName";
            Uri location = new Uri(@"C:\projects\");

            Member creator = new Member("memTest1", "testName");
            Project testProject = new Project("projectA", creator, projectName, location);

            controller.NewProject(testProject);

            Project[] projects = controller.GetProjects();
            int index = -2;
            Assert.IsTrue(ContainsProject(projects, testProject, out index), "Project Controller evidently not containing newly generated project");
            Assert.AreEqual(controller.GetProjects()[index].Creator, creator);
        }
예제 #11
0
        bool AdjustJiraEstimate(Project project = null)
        {
            var settingKey = _baseJiraRepository.GetSettingKey(AdjustEstimateKey);

            if (!_settingsService.GetSetting <string>(settingKey).IsNullOrWhitespace())
            {
                return(_settingsService.GetSetting <bool>(settingKey));
            }

            var projectString      = (project != null) ? " for {0} ".FormatWith(project.Name) : "";
            var adjustJiraEstimate = _inputService.AskForBoolean("Would you like JIRA to automatically adjust estimates {0}when you log your time?".FormatWith(projectString));

            _settingsService.SaveSetting(settingKey, adjustJiraEstimate.ToString());
            return(adjustJiraEstimate);
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            //TODO validate fields
            string creatorName = cbCreator.SelectedText;
            string projectName = txtProjectName.Text;

            Uri projectUri = new Uri(txtProjectUri.Text);

            Project res = new Project("UItest_project", new Member("UItest_member", creatorName), projectName, projectUri);

            Controllers.ProjectController.GetInstance().NewProject(res);

            callback(true, res);
            //TODO add try catch with a callback(false, null);
            this.Dispose();
        }
        public Project GetProject()
        {
            var project = new Project
            {
                Name = this.GetCompany().Name + "'s " + this.GetStringItem(this.projectNames),
                Description = "The project's detailed description.",
                Status = ProjectStatus.EarlyStage,
                DevelopersNeeded = this.random.Next(1, 10),
                KnowledgeRequired = this.GetStringItem(this.knowledge) + ", " +
                                    this.GetStringItem(this.knowledge) + ", " +
                                    this.GetStringItem(this.knowledge),
                SkillsRequired = this.GetStringItem(this.skills) + ", " +
                                    this.GetStringItem(this.skills) + ", " +
                                    this.GetStringItem(this.skills),
                AverageMonetaryAwardPerDeveloper = this.random.Next(500, 50000)
            };

            return project;
        }
예제 #14
0
        /// <summary>
        /// 更新项目
        /// </summary>
        /// <param name="projectModel"></param>
        /// <returns></returns>
        public CommonResult Update(Models.Project projectModel)
        {
            if (IsRepeatProjectName(projectModel.ProjectNo, projectModel.ProjectName))
            {
                return(CommonResult.Instance("已存在此项目名,请换一个再试"));
            }
            db.Project.Where(project => project.ProjectNo == projectModel.ProjectNo).Update(u => new Models.Project()
            {
                ProjectName = projectModel.ProjectName,
                Creater     = projectModel.Creater,
                CreateTime  = projectModel.CreateTime,
                Editor      = projectModel.Editor,
                EditTime    = DateTime.Now,
                Remark      = projectModel.Remark,
                State       = projectModel.State
            });

            //AllServices.ActionLogService.AddLog("更新项目信息",model.ToJson(),Enums.ActionCategory.Update);
            return(CommonResult.Instance());
        }
        private bool ContainsProject(Project[] haystack, Project needle, out int index)
        {
            bool found = false;
            index = 0;

            while (!found && index < haystack.Length)
            {
                found = haystack[index].Equals(needle);
                if (!found)
                {
                    index++;
                }
            }

            if (!found)
            {
                index = -1;
            }

            return found;
        }
예제 #16
0
        /// <summary>
        /// 新增项目
        /// </summary>
        /// <param name="projectModel"></param>
        /// <returns></returns>
        public CommonResult Add(Models.Project projectModel)
        {
            if (IsRepeatProjectName(projectModel.ProjectNo, projectModel.ProjectName))
            {
                return(CommonResult.Instance("已存在此任务名,请换一个再试"));
            }

            projectModel.ProjectNo   = db.Database.SqlQuery <string>("select ([dbo].[GetNextTN]('Project')) ").FirstOrDefault();
            projectModel.ProjectName = projectModel.ProjectName;
            projectModel.Creater     = projectModel.Creater;
            projectModel.Editor      = projectModel.Editor;
            projectModel.CreateTime  = projectModel.CreateTime;
            projectModel.EditTime    = projectModel.EditTime;
            projectModel.Remark      = projectModel.Remark;
            projectModel.State       = Convert.ToInt32(ItemState.Enable);

            db.Project.Add(projectModel);
            if (db.SaveChanges() < 0)
            {
                return(CommonResult.Instance(0, "新建失败", projectModel.ProjectName));
            }
            return(CommonResult.Instance());
            //AllServices.ActionLogService.AddLog("新增文件",folderModel.ToJson(),Enums.ActionCategory.Add);
        }
예제 #17
0
 public void InitializeForProject(Project project)
 {
 }
예제 #18
0
 public IEnumerable<Task> GetTasks(Project project)
 {
     return GetTasks();
 }
예제 #19
0
 public void InitializeForProject(Project project)
 {
     _baseJiraRepository.KeyModifier = project.Id;
     _api = new JiraApi(_baseJiraRepository.JiraUser, _baseJiraRepository.ApiBaseUrl);
 }
 public void InitializeAssociatedRepositories(Project project)
 {
     GetAssociatedRemoteTaskRepository(project);
     GetAssociatedRemoteTimeRepository(project);
 }
예제 #21
0
 public IEnumerable<Task> GetTasksByProject(Project project)
 {
     return project == null ? Enumerable.Empty<Task>() : GetTasksByProjectId(project.Id);
 }
 private static ProjectDirectories GetProjectDirectories(Project project)
 {
     var projectProperties = project.DTE.Properties["Environment", "ProjectsAndSolution"];
     var defaultProjectLocation = projectProperties.Item("ProjectsLocation").Value as string;
     var stagingPath = Path.Combine(defaultProjectLocation, "CloudFoundry_Staging");
     var projectDirectory = Path.GetDirectoryName(project.FullName);
     var projectName = Path.GetFileNameWithoutExtension(projectDirectory).ToLower();
     var precompiledSitePath = Path.Combine(stagingPath, projectName);
     return new ProjectDirectories()
     {
         StagingPath = stagingPath,
         ProjectDirectory = projectDirectory,
         DeployFromPath = precompiledSitePath
     };
 }
        private void PerformAction(string actionName, Project project, Cloud cloud, ProjectDirectories dir,
            Action<IVcapClient, DirectoryInfo> action)
        {
            var worker = new BackgroundWorker();

            Messenger.Default.Register<NotificationMessageAction<string>>(this,
                message =>
                {
                    if (message.Notification.Equals(Messages.SetProgressData))
                        message.Execute(actionName);
                });

            var window = new ProgressDialog();
            var dispatcher = window.Dispatcher;
            var helper = new WindowInteropHelper(window);
            helper.Owner = (IntPtr)(dte.MainWindow.HWnd);
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += (s, args) =>
            {
                if (worker.CancellationPending) { args.Cancel = true; return; }

                Messenger.Default.Send(new ProgressMessage(0, "Starting " + actionName));

                if (worker.CancellationPending) { args.Cancel = true; return; }

                if (!Directory.Exists(dir.StagingPath))
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(10, "Creating Staging Path"))));
                    Directory.CreateDirectory(dir.StagingPath);
                }

                if (worker.CancellationPending) { args.Cancel = true; return; }

                if (Directory.Exists(dir.DeployFromPath))
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(10, "Creating Precompiled Site Path"))));
                    Directory.Delete(dir.DeployFromPath, true);
                }

                if (worker.CancellationPending) { args.Cancel = true; return; }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(30, "Preparing Compiler"))));

                VsWebSite.VSWebSite site = project.Object as VsWebSite.VSWebSite;
                if (site != null)
                {
                    site.PreCompileWeb(dir.DeployFromPath, true);
                }
                else
                {
                    string frameworkPath = (site == null) ? project.GetFrameworkPath() : String.Empty;

                    if (worker.CancellationPending) { args.Cancel = true; return; }
                    string objDir = Path.Combine(dir.ProjectDirectory, "obj");
                    if (Directory.Exists(objDir))
                    {
                        Directory.Delete(objDir, true); // NB: this can cause precompile errors
                    }

                    var process = new System.Diagnostics.Process()
                    {
                        StartInfo = new ProcessStartInfo()
                        {
                            FileName = Path.Combine(frameworkPath, "aspnet_compiler.exe"),
                            Arguments = String.Format("-nologo -v / -p \"{0}\" -f -u -c \"{1}\"", dir.ProjectDirectory, dir.DeployFromPath),
                            CreateNoWindow = true,
                            ErrorDialog = false,
                            UseShellExecute = false,
                            RedirectStandardOutput = true
                        }
                    };

                    if (worker.CancellationPending) { args.Cancel = true; return; }
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(40, "Precompiling Site"))));
                    process.Start();
                    string output = process.StandardOutput.ReadToEnd();
                    process.WaitForExit();
                    if (process.ExitCode != 0)
                    {
                        string message = "Asp Compile Error";
                        if (false == String.IsNullOrEmpty(output))
                        {
                            message += ": " + output;
                        }
                        dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError(message))));
                        return;
                    }
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(50, "Logging in to Cloud Foundry"))));

                if (worker.CancellationPending) { args.Cancel = true; return; }

                var client = new VcapClient(cloud);
                try
                {
                    client.Login();
                }
                catch (Exception e)
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Failure: " + e.Message))));
                    return;
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(75, "Sending to " + cloud.Url))));
                if (worker.CancellationPending) { args.Cancel = true; return; }

                try
                {
                    action(client, new DirectoryInfo(dir.DeployFromPath));
                }
                catch (Exception e)
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Failure: " + e.Message))));
                    return;
                }
                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(100, actionName + " complete."))));
            };

            worker.RunWorkerAsync();
            if (!window.ShowDialog().GetValueOrDefault())
            {
                worker.CancelAsync();
            }
        }
예제 #24
0
        public IEnumerable<Task> GetTasks(Project project)
        {
            // https://www.example.com/rest/api/latest/search?jql=project%3D%22ProjectName%22%20order%20by%20id&fields=summary
            var request = new RestRequest
            {
                Resource = "search",
                Parameters =
                {
                    new Parameter
                    {
                        Name = "jql",
                        Type = ParameterType.QueryString,
                        Value = $"project=\"{project.Name}\" order by id"
                    },
                    new Parameter {Name = "fields", Type = ParameterType.QueryString, Value = "summary"}
                }
            };

            var apiResult = Api.Execute<TaskResult>(request);

            return apiResult?.issues?.Select(x => new Task
            {
                Id = x.id,
                Name = x.key,
                Description = (x.fields == null) ? "" : x.fields.summary,
                Project = project,
                Parent = (x.fields?.parent == null) ? null : new Task {Id = x.fields.parent.id}
            });
        }
예제 #25
0
        public IEnumerable<Project> GetProjects()
        {
            var projects = new List<Project>();

            using (var cnn = GetConnection())
            using (var cmd = cnn.CreateCommand())
            {
                cmd.CommandText = @"SELECT * FROM Projects";

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var project = new Project
                        {
                            Id = reader.Get<string>("Id"),
                            Name = reader.Get<string>("Name"),
                            Key = reader.Get<string>("Key"),
                        };

                        project.AssociatedRemoteRepository = GetAssociatedRemoteRepository(project.Id);

                        projects.Add(project);
                    }
                }
            }

            return projects;
        }
 private void MergeModel(FormCollection fields, Project model)
 {
     TryUpdateModel(model, new[] { "Name" }, fields.ToValueProvider());
 }
예제 #27
0
        public void StoreProject(Project project)
        {
            using (var cnn = GetConnection())
            using (var cmd = cnn.CreateCommand())
            {
                cmd.CommandText = @"INSERT OR IGNORE INTO Projects (Id, Name, Key) VALUES (@Id, @Name, @Key)";

                cmd.Prepare();
                cmd.Parameters.AddWithValue("@Id", project.Id);
                cmd.Parameters.AddWithValue("@Name", project.Name);
                cmd.Parameters.AddWithValue("@Key", project.Key);

                cmd.ExecuteNonQuery();
            }

            StoreAssociatedRepository(project.Id, project.AssociatedRemoteRepository.ToString());
        }
 public IEnumerable<Task> GetTasks(Project project)
 {
     throw new NotImplementedException();
 }
예제 #29
0
 public void AssociateProjectWithRepository(Project project, SupportedRemoteRepository repository)
 {
     project.AssociatedRemoteRepository = repository;
     _associatedRemoteRepositoryService.InitializeAssociatedRepositories(project);
     _localProjectRepository.StoreProject(project);
 }
예제 #30
0
 public void InitializeForProject(Project project)
 {
     _baseJiraRepository.KeyModifier = project.Id;
     _api = new JiraApi(_baseJiraRepository.JiraUser, _baseJiraRepository.ApiBaseUrl);
 }
 private static void SetCurrentCloudGuid(Project project, Guid guid)
 {
     project.SetGlobalVariable("CloudId", guid.ToString());
 }
예제 #32
0
 public void InitializeForProject(Project project)
 {
 }
        public IQueryable<Project> Update(Project updatedProject)
        {
            this.projects.Update(updatedProject);
            this.projects.SaveChanges();

            return this.projects
                .All()
                .Where(r => r.ID == updatedProject.ID);
        }
예제 #34
0
 public IEnumerable<Task> GetTasksByProject(Project project)
 {
     return GetTasks(project.Id);
 }
 public void NewProject(Project p)
 {
     projects.Add(p);
 }
 public void InitializeForProject(Project project)
 {
     throw new NotImplementedException();
 }