Beispiel #1
0
        private async Task <DirectoryInfo> CopySourceProject()
        {
            ErrorText = null;

            // Can't create a project with no name
            if (string.IsNullOrWhiteSpace(NewProjectName))
            {
                ErrorText = "Can't create project without a project name.";
                return(null);
            }

            await GetCaseSensitiveSourceName();

            // Can't continue without a case-sensitive filter name
            if (string.IsNullOrEmpty(caseSensitiveSourceName))
            {
                ErrorText = $"{SourceProjectDirectory.Name} solution file could not be found.";
                return(null);
            }

            // Photoshop convention: lower-cased folder
            var targetPath = $"{ParentPath}\\{NewProjectName.ToLower()}";
            var targetDir  = Directory.CreateDirectory(targetPath);

            // Don't try to replace the contents of a folder
            if (targetDir.GetDirectories().Length > 0 ||
                targetDir.GetFiles().Length > 0)
            {
                ErrorText = "Can't create project. Target directory is not empty.";
                return(null);
            }

            await IOUtility.CopyFilesRecursivelyAsync(SourceProjectDirectory, targetDir, getNameCallback : (string name) =>
            {
                var newName = name.ReplaceVariations(caseSensitiveSourceName, NewProjectName, HandleRenameConflictResolution);
                return(Task.FromResult(newName));
            });

            return(targetDir);
        }
        private void AddProject(object obj)
        {
            if (ConfigProjectsCollection.Where(e => e.ProjectName.ToLower().Equals(NewProjectName.ToLower())).Any())
            {
                MessageBox.Show("Provided project already exists!");
                return;
            }

            var newConfigProjectsLibId = configProjectsLibRepository.AddNewConfigProjectsLib(NewProjectName);
            //nweConfigAreaid configArearepositoer.where.name==notAssigned
            var newConfigProjectId = configProjectRepository.AddNewConfigProjects(newConfigProjectsLibId, ConfigAreasCollection.Where(e => e.AreaName.Equals("Not assigned")).FirstOrDefault().ID);

            //ad new configprojectid (newConfigProjectsLibId, nweConfigAreaid)
            ConfigProjectsCollection.Add
            (
                new ConfigProject()
            {
                ID = newConfigProjectId,

                AreaName           = "Not assigned",
                ConfigAreaID       = ConfigAreasCollection.Where(e => e.AreaName.Equals("Not assigned")).FirstOrDefault().ID,
                ConfigProjectLibID = newConfigProjectsLibId,
                ProjectName        = NewProjectName,
                JdUploaded         = false,
                Selected           = true
            }
            );
            ConfigProjectsCollection = ConfigProjectsCollection.OrderBy(e => e.ProjectName).ToObservableCollection();

            ConfigProjectsLib configProjectsLib = new ConfigProjectsLib()
            {
                Id = newConfigProjectsLibId, ProjectName = NewProjectName, Selected = true
            };

            ///send congifdPorjecr
            configProjectMessenger.RaiseConfigProjectChanged(ConfigProjectsCollection.Where(e => e.ID == newConfigProjectId).FirstOrDefault());
        }