コード例 #1
0
 public void nextOrCreateCommand()
 {
     AlertViewViewModel.Button button = new AlertViewViewModel.Button {
         name = "Okay"
     };
     if (string.IsNullOrWhiteSpace(_project_model_i.ProjectName) || string.IsNullOrWhiteSpace(_project_model_i.ProjectLocation) || _project_model_i.ProjectModel == null || _project_model_i.ProjectDate == DateTime.MinValue)
     {
         AlertView alertView = new AlertView("Not enough informations", "The informations you have provided to create a new project is not sufficient. Please fill essential fields.", AlertViewType.WARNING, button);
         alertView.ShowDialog();
     }
     else
     {
         DateTime current_date_time = DateTime.Now;
         _project_model_i.ProjectCreationDate = current_date_time;
         if (_project_model_i.ProjectModel.client_id.value == _project_model_i.ClientModels[0].id.value)
         {
             try {
                 this.nextButtonClicked();
             }
             catch (AlreadyExistsError) {
                 AlertView alertView = new AlertView("Project already exist", "The project you are trying to create is already exist, try a different project name.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (DirectoryNotFoundException) {
                 AlertView alertView = new AlertView("Invalid path", "The path you are trying to create the project is invalid, insert a correct path or explore a path.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (Exception err) {
                 Core.Reference.logger.logError(err);
                 AlertView alertView = new AlertView("Unknown error", "Unknown error has occured while creating a project. Please try again.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
         }
         else
         {
             try {
                 ProjectModelI.ProjectModelApi.model.client_id.value = ProjectModelI.SelectedClient.id.value;
                 CoreApp.getSingleton().createNewProject(ProjectModelI.ProjectModelApi, FolderBrowseCommand.FolderPath);
                 CoreApp.getSingleton().setDefaultProjectPath(FolderBrowseCommand.FolderPath);
                 NewProject.ProjectManager.closeWindow();
             }
             catch (AlreadyExistsError) {
                 AlertView alertView = new AlertView("Project already exist", "The project you are trying to create is already exist, try a different project name.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (DirectoryNotFoundException) {
                 AlertView alertView = new AlertView("Invalid path", "The path you are trying to create the project is invalid, insert a correct path or explore a path.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (Exception err) {
                 Core.Reference.logger.logError(err);
                 AlertView alertView = new AlertView("Unknown error", "Unknown error has occured while creating a project. Please try again.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
         }
     }
 }
コード例 #2
0
        public void createNewProjectWithClient()
        {
            _client_model_i.api.model.id.value = DateTime.Now.Ticks; // TODO: consider change the pk
            _client_model_i.api.update();
            NewProjectViewModel new_project_view_model = NewClient.ProjectManager.NewProject.NewProjectViewModel;

            new_project_view_model.ProjectModelI.SelectedClient = _client_model_i.ClientModel;

            AlertViewViewModel.Button button = new AlertViewViewModel.Button {
                name = "Okay"
            };
            try {
                CoreApp.getSingleton().createNewProject(new_project_view_model.ProjectModelI.ProjectModelApi, new_project_view_model.FolderBrowseCommand.FolderPath);
                CoreApp.getSingleton().setDefaultProjectPath(new_project_view_model.FolderBrowseCommand.FolderPath);
                NewClient.ProjectManager.closeWindow();
            }
            catch (Exception err) {
                Core.Reference.logger.logError(err);
                AlertView alertView = new AlertView("Unknown error", "Unknown error has occured while creating a project. Please try again.", AlertViewType.ERROR, button);
                alertView.ShowDialog();
            }
        }