Ejemplo n.º 1
0
        public void Can_Update_Project()
        {
            //Arrange
            var mockRepository = new Mock <IProjectRepository>();

            mockRepository.Setup(m => m.GetById(It.IsAny <int>())).Returns(new Project
            {
                Id          = 1,
                Name        = "pierwszy",
                ProjectGuid = Guid.Parse("e3491b73-1f7b-4afb-b031-28b84c5ea4e2"),
                Information = new ClientInformation {
                    ContactData = "contactData1"
                },
                Status = ProjectStatus.Active
            });
            IUpdateProject service = new UpdateProject(mockRepository.Object);

            //Act

            service.Invoke(1, "newName1");
            var afterUpdate = mockRepository.Object.GetById(4);

            //Assert

            Assert.True(afterUpdate.Name == "newName1");
            Assert.True(afterUpdate.ProjectGuid != Guid.Parse("e3491b73-1f7b-4afb-b031-28b84c5ea4e2"));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            UpdateProject ViewModel = new UpdateProject();

            string url = "ProjectData/FindProject/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Can catch the status code (200 OK, 301 REDIRECT), etc.
            Debug.WriteLine(response.StatusCode);
            if (response.IsSuccessStatusCode)
            {
                ProjectDto SelectedProject = response.Content.ReadAsAsync <ProjectDto>().Result;
                ViewModel.Project = SelectedProject;

                url      = "CategoryData/GetCategories";
                response = client.GetAsync(url).Result;
                IEnumerable <CategoryDto> ProjectsCategory = response.Content.ReadAsAsync <IEnumerable <CategoryDto> >().Result;
                ViewModel.Allcategories = ProjectsCategory;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Ejemplo n.º 3
0
        private void ftpImportButton_Click(object sender, EventArgs e)
        {
            using (var fileDialog = new OpenFileDialog())
            {
                fileDialog.Filter      = "nUpdate Project Files (*.nupdproj)|*.nupdproj";
                fileDialog.Multiselect = false;
                if (fileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    var importProject = UpdateProject.LoadProject(fileDialog.FileName);
                    ftpHostTextBox.Text = importProject.FtpHost;
                    ftpPortTextBox.Text = importProject.FtpPort.ToString(CultureInfo.InvariantCulture);
                    ftpUserTextBox.Text = importProject.FtpUsername;
                    ftpProtocolComboBox.SelectedIndex = importProject.FtpProtocol;
                    ftpModeComboBox.SelectedIndex     = importProject.FtpUsePassiveMode ? 0 : 1;
                    ftpDirectoryTextBox.Text          = importProject.FtpDirectory;
                    ftpPasswordTextBox.Focus();
                }
                catch (Exception ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Error while importing project data.", ex,
                                    PopupButtons.Ok);
                }
            }
        }
Ejemplo n.º 4
0
 public void Put(Guid id, [FromBody] UpdateProject command)
 {
     Apply(id, new ProjectUpdated
     {
         Id   = command.Id = id,
         Name = command.Name,
         NationalSocietyId = command.NationalSocietyId,
         DataOwnerId       = command.DataOwnerId,
     });
 }
Ejemplo n.º 5
0
        public ActionResult Create()
        {
            UpdateProject ViewModel = new UpdateProject();
            //get information about Categories this Project is in.
            string url = "CategoryData/GetCategories";
            HttpResponseMessage       response            = client.GetAsync(url).Result;
            IEnumerable <CategoryDto> PotetnialCategories = response.Content.ReadAsAsync <IEnumerable <CategoryDto> >().Result;

            ViewModel.Allcategories = PotetnialCategories;
            return(View(ViewModel));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> UpdateProject(
            [FromServices] UpdateProject updateProject,
            ProjectViewModel vm)
        {
            var request = new UpdateProject.Request
            {
                Id           = vm.Id,
                Title        = vm.Title,
                Description  = vm.Description,
                Tags         = vm.Tags,
                PrimaryImage = vm.PrimaryImage,
                Images       = vm.Images
            };

            // TODO: refactor
            if (vm.PrimaryImageFile != null)
            {
                if (vm.PrimaryImage != null || vm.PrimaryImage != "")
                {
                    _fileManager.DeleteImage(rootPath, vm.PrimaryImage);
                }

                var imgPath = await _fileManager.SaveImage(rootPath, vm.PrimaryImageFile);

                request.PrimaryImage = imgPath;
            }
            ;

            if (vm.ImageFiles != null)
            {
                if (vm.Images != null)
                {
                    foreach (var image in vm.Images)
                    {
                        _fileManager.DeleteImage(rootPath, image);
                    }
                }

                List <string> images = new List <string>();

                foreach (var image in vm.ImageFiles)
                {
                    var imgPath = await _fileManager.SaveImage(rootPath, vm.PrimaryImageFile);

                    images.Add(imgPath);
                }

                request.Images = images;
            }
            ;

            return(Ok(await updateProject.Do(request)));
        }
        public async Task Project_Should_not_Be_Updated()
        {
            var updateProjectCommand = new UpdateProject
            {
                Id          = Guid.Empty,
                Name        = "Name updated",
                Description = "Description updated"
            };

            var putResponse = await PutAsync(_apiEndpoint, updateProjectCommand);

            putResponse.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
Ejemplo n.º 8
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (!Path.IsPathRooted(programPathTextBox.Text))
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Invalid path set.",
                                "The current path for the program data is not valid.", PopupButtons.Ok);
                return;
            }

            if (programPathTextBox.Text != Settings.Default.ProgramPath)
            {
                try
                {
                    var projectConfiguration = ProjectConfiguration.Load();
                    if (projectConfiguration != null)
                    {
                        foreach (
                            var project in
                            projectConfiguration.Select(config => UpdateProject.LoadProject(config.Path))
                            .Where(project => project.Packages != null))
                        {
                            foreach (var package in project.Packages)
                            {
                                package.LocalPackagePath = Path.Combine(programPathTextBox.Text, "Projects",
                                                                        project.Name,
                                                                        Directory.GetParent(package.LocalPackagePath).Name,
                                                                        Path.GetFileName(package.LocalPackagePath));
                            }

                            UpdateProject.SaveProject(project.Path, project);
                        }

                        CopyFilesRecursively(Settings.Default.ProgramPath, programPathTextBox.Text);
                    }
                }
                catch (Exception ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Error while moving the program data.", ex,
                                    PopupButtons.Ok);
                    return;
                }
            }

            Settings.Default.Language =
                new CultureInfo(
                    languagesComboBox.GetItemText(languagesComboBox.SelectedItem).Split('-')[1].Trim());
            Settings.Default.ProgramPath = programPathTextBox.Text;
            Settings.Default.Save();
            Settings.Default.Reload();
            Close();
        }
Ejemplo n.º 9
0
 private void clearLog_Click(object sender, EventArgs e)
 {
     try
     {
         Project.Log.Clear();
         UpdateProject.SaveProject(Project.Path, Project);
     }
     catch (Exception ex)
     {
         Invoke(new Action(() =>
                           Popup.ShowPopup(this, SystemIcons.Error, "Error while sclearing the log.", ex, PopupButtons.Ok)));
     }
     Close();
 }
Ejemplo n.º 10
0
        //	try
        //	{
        //		deliverables = CABusinessProjectTrackingAPIClient.GetHttpResponse<Deliverables>(devobj, CABPTMethodConstants.DELIVERABLEBYID);
        //		return Json(JsonConvert.SerializeObject(deliverables), JsonRequestBehavior.AllowGet);
        //	}
        //	catch (Exception ex)
        //	{
        //		JsonExceptionResult exception = new JsonExceptionResult();
        //		return Json(JsonConvert.SerializeObject(new CABPTException(ex, out exception)));
        //	}
        //}

        public JsonResult UpdateProjectDetail(UpdateProject obj)
        {
            DTO result = null;

            try
            {
                result = CABusinessProjectTrackingAPIClient.GetHttpResponse <DTO>(obj, CABPTMethodConstants.UPDATEPROJECTDETAIL);
                return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                JsonExceptionResult exception = new JsonExceptionResult();
                return(Json(JsonConvert.SerializeObject(new CABPTException(ex, out exception))));
            }
        }
Ejemplo n.º 11
0
        public UpdateProject OpenProject(string projectPath)
        {
            UpdateProject project;

            try
            {
                project = UpdateProject.LoadProject(projectPath);
            }
            catch (Exception ex)
            {
                Popup.ShowPopup(this, SystemIcons.Error, "Error while reading the project.", ex,
                                PopupButtons.Ok);
                return(null);
            }

            if (!project.SaveCredentials)
            {
                var credentialsDialog = new CredentialsDialog();
                if (credentialsDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        _ftpPassword =
                            AesManager.Decrypt(Convert.FromBase64String(project.FtpPassword),
                                               credentialsDialog.Password.Trim(), credentialsDialog.Username.Trim());

                        if (project.Proxy != null)
                        {
                            _proxyPassword =
                                AesManager.Decrypt(Convert.FromBase64String(project.ProxyPassword),
                                                   credentialsDialog.Password.Trim(), credentialsDialog.Username.Trim());
                        }

                        if (project.UseStatistics)
                        {
                            _sqlPassword =
                                AesManager.Decrypt(Convert.FromBase64String(project.SqlPassword),
                                                   credentialsDialog.Password.Trim(), credentialsDialog.Username.Trim());
                        }
                    }
                    catch (CryptographicException)
                    {
                        Popup.ShowPopup(this, SystemIcons.Error, "Invalid credentials.",
                                        "The entered credentials are invalid.", PopupButtons.Ok);
                        return(null);
                    }
                }
        public async Task <ActionResult <OutputProject> > Put(Guid projectId, [FromBody] UpdateProject updateProject)
        {
            try
            {
                logger.LogInformation($"Beginning request: /api/projects/{projectId} PUT");
                Project updatedProject = await projectManager.UpdateProjectAsync(projectId, updateProject.Name,
                                                                                 updateProject.Description);

                OutputProject output = projectMapper.MapOutputProject(updatedProject);
                logger.LogInformation($"Request complete: /api/projects/{projectId} PUT");
                return(Ok(output));
            }
            catch (Exception ex)
            {
                return(exceptionManager.Handle(ex));
            }
        }
        public async Task Project_Should_Be_Updated()
        {
            var project = (await GetTop20()).First();
            var updateProjectCommand = new UpdateProject
            {
                Id          = project.Id,
                Name        = "Name updated",
                Description = "Description updated"
            };
            var response = await PutAsync(_apiEndpoint, updateProjectCommand);

            response.EnsureSuccessStatusCode();

            var updatedProject = (await GetTop20()).FirstOrDefault(x => x.Id == project.Id);

            updatedProject.Description.Should().Be(updateProjectCommand.Description);
            updatedProject.Name.Should().Be(updateProjectCommand.Name);
        }
        public async Task <IActionResult> Put(int id, [FromBody] UpdateProject model)
        {
            //TODO: change when automapper
            var updatedProject = new Project()
            {
                Id                         = id,
                ProjectTitle               = model.ProjectTitle,
                ApiAuthenticationToken     = model.ApiAuthenticationToken,
                ApiHostUrl                 = model.ApiHostUrl,
                ApiProjectId               = model.ApiProjectId,
                DataProviderName           = model.DataProviderName,
                CiDataUpdateCronExpression = model.CiDataUpdateCronExpression,
                PipelinesNumber            = model.PipelineNumber
            };

            var r = await _projectService.UpdateProjectAsync(updatedProject);

            return(ApiResponse.FromServiceResult(r));
        }
        public async Task <IActionResult> Put(UpdateProject command)
        {
            _ = await _bus.ExecuteAsync(command);

            return(Updated());
        }
        public async Task <IActionResult> UpdateProject(UpdateProject command)
        {
            await _mediator.Send(command);

            return(Updated());
        }
Ejemplo n.º 17
0
        private void continueButton_Click(object sender, EventArgs e)
        {
            if (_sender == generalTabPage)
            {
                if (!ValidationManager.Validate(generalPanel))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                    "All fields need to have a value.", PopupButtons.Ok);
                    return;
                }

                if (!_generalTabPassed)
                {
                    _projectConfiguration =
                        ProjectConfiguration.Load().ToList();
                    if (_projectConfiguration != null)
                    {
                        if (_projectConfiguration.Any(item => item.Name == nameTextBox.Text))
                        {
                            Popup.ShowPopup(this, SystemIcons.Error, "The project is already existing.",
                                            String.Format(
                                                "The project \"{0}\" is already existing.",
                                                nameTextBox.Text), PopupButtons.Ok);
                            return;
                        }
                    }
                    else
                    {
                        _projectConfiguration = new List <ProjectConfiguration>();
                    }
                }

                if (!Uri.IsWellFormedUriString(updateUrlTextBox.Text, UriKind.Absolute))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Invalid adress.", "The given Update-URL is invalid.",
                                    PopupButtons.Ok);
                    return;
                }

                if (!Path.IsPathRooted(localPathTextBox.Text))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Invalid path.",
                                    "The given local path for the project is invalid.", PopupButtons.Ok);
                    return;
                }

                try
                {
                    Path.GetFullPath(localPathTextBox.Text);
                }
                catch
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Invalid path.",
                                    "The given local path for the project is invalid.", PopupButtons.Ok);
                    return;
                }

                _sender            = ftpTabPage;
                backButton.Enabled = true;
                informationCategoriesTabControl.SelectedTab = ftpTabPage;
            }
            else if (_sender == ftpTabPage)
            {
                if (!ValidationManager.Validate(ftpPanel) || String.IsNullOrEmpty(ftpPasswordTextBox.Text))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                    "All fields need to have a value.", PopupButtons.Ok);
                    return;
                }

                _ftp.Host      = ftpHostTextBox.Text;
                _ftp.Port      = int.Parse(ftpPortTextBox.Text);
                _ftp.Username  = ftpUserTextBox.Text;
                _ftp.Directory = ftpDirectoryTextBox.Text;

                var ftpPassword = new SecureString();
                foreach (var c in ftpPasswordTextBox.Text)
                {
                    ftpPassword.AppendChar(c);
                }
                _ftp.Password = ftpPassword; // Same instance that FtpManager will automatically dispose

                _ftp.UsePassiveMode = ftpModeComboBox.SelectedIndex == 0;
                _ftp.Protocol       = (FtpSecurityProtocol)ftpProtocolComboBox.SelectedIndex;

                if (!backButton.Enabled) // If the back-button was disabled, enabled it again
                {
                    backButton.Enabled = true;
                }

                _sender = statisticsServerTabPage;
                informationCategoriesTabControl.SelectedTab = statisticsServerTabPage;
            }
            else if (_sender == statisticsServerTabPage)
            {
                if (useStatisticsServerRadioButton.Checked)
                {
                    if (SqlDatabaseName == null || String.IsNullOrWhiteSpace(sqlPasswordTextBox.Text))
                    {
                        Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                        "All fields need to have a value.", PopupButtons.Ok);
                        return;
                    }
                }

                _sender = proxyTabPage;
                informationCategoriesTabControl.SelectedTab = proxyTabPage;
            }
            else if (_sender == proxyTabPage)
            {
                if (useProxyRadioButton.Checked)
                {
                    if (!ValidationManager.ValidateTabPage(proxyTabPage) && !String.IsNullOrEmpty(proxyUserTextBox.Text) &&
                        !String.IsNullOrEmpty(proxyPasswordTextBox.Text))
                    {
                        Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                        "All fields need to have a value.", PopupButtons.Ok);
                        return;
                    }
                }

                try
                {
                    using (File.Create(localPathTextBox.Text))
                    {
                    }
                    _projectFileCreated = true;
                }
                catch (IOException ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Failed to create project file.", ex, PopupButtons.Ok);
                    Close();
                }

                var usePassive = ftpModeComboBox.SelectedIndex == 0;

                WebProxy proxy         = null;
                string   proxyUsername = null;
                string   proxyPassword = null;
                if (!String.IsNullOrEmpty(proxyHostTextBox.Text))
                {
                    proxy = new WebProxy(proxyHostTextBox.Text);
                    if (!String.IsNullOrEmpty(proxyUserTextBox.Text) &&
                        !String.IsNullOrEmpty(proxyPasswordTextBox.Text))
                    {
                        proxyUsername = proxyUserTextBox.Text;
                        if (!saveCredentialsCheckBox.Checked)
                        {
                            proxyPassword = Convert.ToBase64String(AesManager.Encrypt(proxyPasswordTextBox.Text,
                                                                                      ftpPasswordTextBox.Text,
                                                                                      ftpUserTextBox.Text));
                        }
                        else
                        {
                            proxyPassword =
                                Convert.ToBase64String(AesManager.Encrypt(proxyPasswordTextBox.Text,
                                                                          Program.AesKeyPassword,
                                                                          Program.AesIvPassword));
                        }
                    }
                }

                string sqlPassword = null;
                if (useStatisticsServerRadioButton.Checked)
                {
                    if (!saveCredentialsCheckBox.Checked)
                    {
                        sqlPassword = Convert.ToBase64String(AesManager.Encrypt(sqlPasswordTextBox.Text,
                                                                                ftpPasswordTextBox.Text,
                                                                                ftpUserTextBox.Text));
                    }
                    else
                    {
                        sqlPassword =
                            Convert.ToBase64String(AesManager.Encrypt(sqlPasswordTextBox.Text, Program.AesKeyPassword,
                                                                      Program.AesIvPassword));
                    }
                }

                Settings.Default.ApplicationID += 1;
                Settings.Default.Save();
                Settings.Default.Reload();

                string ftpPassword;
                if (!saveCredentialsCheckBox.Checked)
                {
                    ftpPassword = Convert.ToBase64String(AesManager.Encrypt(ftpPasswordTextBox.Text,
                                                                            ftpPasswordTextBox.Text,
                                                                            ftpUserTextBox.Text));
                }
                else
                {
                    ftpPassword =
                        Convert.ToBase64String(AesManager.Encrypt(ftpPasswordTextBox.Text, Program.AesKeyPassword,
                                                                  Program.AesIvPassword));
                }

                // Create a new package...
                var project = new UpdateProject
                {
                    Path                        = localPathTextBox.Text,
                    Name                        = nameTextBox.Text,
                    Guid                        = Guid.NewGuid().ToString(),
                    ApplicationId               = Settings.Default.ApplicationID,
                    UpdateUrl                   = updateUrlTextBox.Text,
                    Packages                    = null,
                    SaveCredentials             = saveCredentialsCheckBox.Checked,
                    FtpHost                     = ftpHostTextBox.Text,
                    FtpPort                     = int.Parse(ftpPortTextBox.Text),
                    FtpUsername                 = ftpUserTextBox.Text,
                    FtpPassword                 = ftpPassword,
                    FtpDirectory                = ftpDirectoryTextBox.Text,
                    FtpProtocol                 = ftpProtocolComboBox.SelectedIndex,
                    FtpUsePassiveMode           = usePassive,
                    FtpTransferAssemblyFilePath = _ftpAssemblyPath,
                    Proxy                       = proxy,
                    ProxyUsername               = proxyUsername,
                    ProxyPassword               = proxyPassword,
                    UseStatistics               = useStatisticsServerRadioButton.Checked,
                    SqlDatabaseName             = SqlDatabaseName,
                    SqlWebUrl                   = SqlWebUrl,
                    SqlUsername                 = SqlUsername,
                    SqlPassword                 = sqlPassword,
                    PrivateKey                  = PrivateKey,
                    PublicKey                   = PublicKey,
                    Log = null
                };

                try
                {
                    UpdateProject.SaveProject(localPathTextBox.Text, project); // ... and save it
                }
                catch (IOException ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Error while saving the project file.", ex, PopupButtons.Ok);
                    _mustClose = true;
                    Reset();
                }

                try
                {
                    var projectDirectoryPath = Path.Combine(Program.Path, "Projects", nameTextBox.Text);
                    Directory.CreateDirectory(projectDirectoryPath);
                }
                catch (Exception ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Error while creating the project'S directory.", ex,
                                    PopupButtons.Ok);
                    _mustClose = true;
                    Reset();
                }

                try
                {
                    _projectConfiguration.Add(new ProjectConfiguration(nameTextBox.Text, localPathTextBox.Text));
                    File.WriteAllText(Program.ProjectsConfigFilePath, Serializer.Serialize(_projectConfiguration));
                    _projectConfigurationEdited = true;
                }
                catch (Exception ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error,
                                    "Error while editing the project confiuration file. Please choose another name for the project.",
                                    ex,
                                    PopupButtons.Ok);
                    _mustClose = true;
                    Reset();
                }

                if (useStatisticsServerRadioButton.Checked)
                {
                    var phpFilePath = Path.Combine(Program.Path, "Projects", nameTextBox.Text, "statistics.php");
                    try
                    {
                        File.WriteAllBytes(phpFilePath, Resources.statistics);

                        var phpFileContent = File.ReadAllText(phpFilePath);
                        phpFileContent = phpFileContent.Replace("_DBURL", SqlWebUrl);
                        phpFileContent = phpFileContent.Replace("_DBUSER", SqlUsername);
                        phpFileContent = phpFileContent.Replace("_DBNAME", SqlDatabaseName);
                        phpFileContent = phpFileContent.Replace("_DBPASS", sqlPasswordTextBox.Text);
                        File.WriteAllText(phpFilePath, phpFileContent);
                        _phpFileCreated = true;
                    }
                    catch (Exception ex)
                    {
                        Popup.ShowPopup(this, SystemIcons.Error, "Failed to initialize the project-files.", ex,
                                        PopupButtons.Ok);
                        _mustClose = true;
                        Reset();
                    }
                }

                _generalTabPassed = true;
                InitializeProject();
            }
        }
Ejemplo n.º 18
0
 private async Task OpenProject(string filePath)
 {
     curProjectFilePath = filePath;
     General.CurProject = UpdateProject.Load(filePath);
     await LoadManager();
 }
Ejemplo n.º 19
0
        private void continueButton_Click(object sender, EventArgs e)
        {
            backButton.Enabled = true;
            if (_sender == optionTabPage)
            {
                if (importProjectRadioButton.Checked)
                {
                    wizardTabControl.SelectedTab = importTabPage;
                    _sender = importTabPage;
                }
                else if (shareProjectRadioButton.Checked)
                {
                    wizardTabControl.SelectedTab = shareTabPage;
                    _sender = shareTabPage;
                }
            }
            else if (_sender == importTabPage)
            {
                if (!ValidationManager.Validate(importTabPage))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                    "All fields need to have a value.", PopupButtons.Ok);
                    return;
                }

                if (!Path.IsPathRooted(projectToImportTextBox.Text) || !File.Exists(projectToImportTextBox.Text))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Invalid path.",
                                    "The given local path for the project is invalid.", PopupButtons.Ok);
                    return;
                }

                wizardTabControl.SelectedTab = importTabPage1;
                _sender = importTabPage1;
            }
            else if (_sender == importTabPage1)
            {
                if (!ValidationManager.Validate(importTabPage1))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                    "All fields need to have a value.", PopupButtons.Ok);
                    return;
                }

                if (_projectConfigurations.Any(item => item.Name == projectNameTextBox.Text))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Project already existing.",
                                    String.Format("A project with the name \"{0}\" does already exist.", projectNameTextBox.Text), PopupButtons.Ok);
                    return;
                }

                try
                {
                    string folderPath         = Path.Combine(Program.Path, "ImpProj");
                    string statisticsFilePath = Path.Combine(folderPath, "statistics.php");
                    string projectFilePath    = Path.Combine(folderPath,
                                                             String.Format("{0}.nupdproj", projectNameTextBox.Text));
                    Directory.CreateDirectory(folderPath);

                    var updateProject = UpdateProject.LoadProject(projectFilePath);
                    if (updateProject.UseStatistics)
                    {
                        Popup.ShowPopup(this, SystemIcons.Warning, "Incompatible project.", "This project cannot be imported because the support for projects using statistics is currently missing. It will be available in the next version(s) of nUpdate Administration.", PopupButtons.Ok);
                        Directory.Delete(folderPath);
                        return;
                    }

                    //if (updateProject.ConfigVersion != "3b2")
                    //{
                    //    Popup.ShowPopup(this, SystemIcons.Warning, "Incompatible project.", "This project is not compatible to this version of nUpdate Administration. Please download the newest version of nUpdate Administration and then export the project again.", PopupButtons.Ok);
                    //    Directory.Delete(folderPath);
                    //    return;
                    //}

                    updateProject.Path = projectFilePathTextBox.Text;
                    //if (updateProject.UseStatistics)
                    //{
                    //    var statisticsServers = Serializer.Deserialize<List<StatisticsServer>>(Path.Combine(Program.Path, "statservers.json"));
                    //    if (!statisticsServers.Any(item => item.WebUrl == updateProject.SqlWebUrl && item.DatabaseName == updateProject.SqlDatabaseName && item.Username == updateProject.SqlUsername))
                    //    {
                    //        if (Popup.ShowPopup(this, SystemIcons.Information, "New statistics server found.", "This project uses a statistics server that isn't currently available on this computer. Should nUpdate Administration add this server to your list?", PopupButtons.YesNo) == DialogResult.Yes)
                    //        {
                    //            statisticsServers.Add(new StatisticsServer(updateProject.SqlWebUrl, updateProject.SqlDatabaseName, updateProject.SqlUsername));
                    //            File.WriteAllText(Path.Combine(Program.Path, "statservers.json"), Serializer.Serialize(statisticsServers));
                    //        }
                    //    }
                    //}

                    UpdateProject.SaveProject(updateProject.Path, updateProject);

                    string projectPath = Path.Combine(Program.Path, "Projects", projectNameTextBox.Text);
                    if (!Directory.Exists(projectPath))
                    {
                        Directory.CreateDirectory(projectPath);
                    }

                    using (var zip = new ZipFile(projectToImportTextBox.Text))
                    {
                        zip.ExtractAll(folderPath);
                    }

                    if (File.Exists(statisticsFilePath))
                    {
                        File.Move(statisticsFilePath, Path.Combine(projectPath, "statistics.php"));
                    }
                    File.Move(projectFilePath, projectFilePathTextBox.Text);

                    foreach (var versionDirectory in new DirectoryInfo(folderPath).GetDirectories())
                    {
                        Directory.Move(versionDirectory.FullName, Path.Combine(projectPath, versionDirectory.Name));
                    }

                    Directory.Delete(folderPath);
                    _projectConfigurations.Add(new ProjectConfiguration(projectNameTextBox.Text,
                                                                        projectFilePathTextBox.Text));
                    File.WriteAllText(Program.ProjectsConfigFilePath, Serializer.Serialize(_projectConfigurations));
                }
                catch (Exception ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Error while importing the project.", ex, PopupButtons.Ok);
                    return;
                }

                Close();
            }
            else if (_sender == shareTabPage)
            {
                wizardTabControl.SelectedTab = shareTabPage1;
                _sender = shareTabPage1;
            }
            else if (_sender == shareTabPage1)
            {
                if (!ValidationManager.Validate(shareTabPage1))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.",
                                    "All fields need to have a value.", PopupButtons.Ok);
                    return;
                }

                if (!Path.IsPathRooted(projectOutputPathTextBox.Text))
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Invalid path.",
                                    "The given local path for the project is invalid.", PopupButtons.Ok);
                    return;
                }

                try
                {
                    string projectPath = Path.Combine(Program.Path, "Projects", projectsListBox.SelectedItem.ToString());
                    using (var zip = new ZipFile())
                    {
                        string statisticsFilePath = Path.Combine(projectPath, "statistics.php");
                        if (File.Exists(statisticsFilePath))
                        {
                            zip.AddFile(statisticsFilePath, "/");
                        }
                        zip.AddFile(
                            _projectConfigurations.First(item => item.Name == projectsListBox.SelectedItem.ToString())
                            .Path, "/");

                        foreach (
                            var versionDirectory in
                            new DirectoryInfo(projectPath).GetDirectories()
                            .Where(item => UpdateVersion.IsValid(item.Name)))
                        {
                            zip.AddDirectoryByName(versionDirectory.Name);
                            zip.AddDirectory(versionDirectory.FullName, versionDirectory.Name);
                        }

                        zip.Save(projectOutputPathTextBox.Text);
                    }
                }
                catch (Exception ex)
                {
                    Popup.ShowPopup(this, SystemIcons.Error, "Error while sharing the project.", ex, PopupButtons.Ok);
                    return;
                }

                Close();
            }
        }