public async Task DoSaveProjectPlanFileAsync(string projectTitle) { if (string.IsNullOrWhiteSpace(projectTitle)) { throw new ArgumentNullException(nameof(projectTitle)); } try { IsBusy = true; string directory = m_ProjectSettingService.PlanDirectory; string filename = Path.Combine(directory, projectTitle); filename = Path.ChangeExtension(filename, Properties.Resources.Filter_SaveProjectPlanFileExtension); ProjectPlanDto projectPlan = await BuildProjectPlanDtoAsync(); await SaveProjectPlanDtoAsync(projectPlan, filename); IsProjectUpdated = false; m_ProjectSettingService.SetFilePath(filename); } catch (Exception ex) { DispatchNotification( Properties.Resources.Title_Error, ex.Message); } finally { IsBusy = false; RaiseCanExecuteChangedAllCommands(); } }
private static Task SaveProjectPlanDtoAsync(ProjectPlanDto projectPlanDto, string filename) { if (projectPlanDto == null) { throw new ArgumentNullException(nameof(projectPlanDto)); } if (string.IsNullOrWhiteSpace(filename)) { throw new ArgumentException(nameof(filename)); } return(Task.Run(() => OpenSave.SaveJson(projectPlanDto, filename))); }
private void ProcessProjectPlanDto(ProjectPlanDto projectPlanDto) { if (projectPlanDto == null) { throw new ArgumentNullException(nameof(projectPlanDto)); } lock (m_Lock) { ResetProject(); // Project Start Date. ProjectStartWithoutPublishing = projectPlanDto.ProjectStart; // Resources. ResourceSettingsDto = projectPlanDto.ResourceSettings; // Compilation. GraphCompilation = DtoConverter.FromDto(projectPlanDto.GraphCompilation); CyclomaticComplexity = projectPlanDto.GraphCompilation.CyclomaticComplexity; Duration = projectPlanDto.GraphCompilation.Duration; // Activities. // Be sure to do this after the resources and project start date have been added. foreach (DependentActivityDto dependentActivityDto in projectPlanDto.DependentActivities) { m_CoreViewModel.AddManagedActivity(DtoConverter.FromDto(dependentActivityDto)); } m_CoreViewModel.UpdateActivitiesAllocatedToResources(); m_CoreViewModel.SetCompilationOutput(); m_CoreViewModel.CalculateCosts(); // Arrow Graph. ArrowGraphSettingsDto = projectPlanDto.ArrowGraphSettings; ArrowGraphDto = projectPlanDto.ArrowGraph; HasStaleOutputs = projectPlanDto.HasStaleOutputs; } PublishGraphCompilationUpdatedPayload(); PublishArrowGraphDtoUpdatedPayload(); //PublishGanttChartDtoUpdatedPayload(); }
public async Task DoSaveProjectPlanFileAsync() { try { IsBusy = true; string directory = m_AppSettingService.ProjectPlanFolder; if (m_FileDialogService.ShowSaveDialog( directory, Properties.Resources.Filter_SaveProjectPlanFileType, Properties.Resources.Filter_SaveProjectPlanFileExtension) == DialogResult.OK) { string filename = m_FileDialogService.Filename; if (string.IsNullOrWhiteSpace(filename)) { DispatchNotification( Properties.Resources.Title_Error, Properties.Resources.Message_EmptyFilename); } else { ProjectPlanDto projectPlan = await BuildProjectPlanDtoAsync(); await SaveProjectPlanDtoAsync(projectPlan, filename); IsProjectUpdated = false; ProjectTitle = Path.GetFileNameWithoutExtension(filename); m_AppSettingService.ProjectPlanFolder = Path.GetDirectoryName(filename); } } } catch (Exception ex) { DispatchNotification( Properties.Resources.Title_Error, ex.Message); } finally { IsBusy = false; RaiseCanExecuteChangedAllCommands(); } }
public async Task DoOpenProjectPlanFileAsync(string fileName) { try { IsBusy = true; if (IsProjectUpdated) { var confirmation = new Confirmation { Title = Properties.Resources.Title_UnsavedChanges, Content = Properties.Resources.Message_UnsavedChanges }; m_ConfirmationInteractionRequest.Raise(confirmation); if (!confirmation.Confirmed) { return; } } string filename = fileName; if (string.IsNullOrWhiteSpace(filename)) { string directory = m_ProjectSettingService.PlanDirectory; if (m_FileDialogService.ShowOpenDialog( directory, Properties.Resources.Filter_OpenProjectPlanFileType, Properties.Resources.Filter_OpenProjectPlanFileExtension) == DialogResult.OK) { filename = m_FileDialogService.Filename; } else { return; } } if (string.IsNullOrWhiteSpace(filename)) { DispatchNotification( Properties.Resources.Title_Error, Properties.Resources.Message_EmptyFilename); } else { ProjectPlanDto projectPlan = await OpenProjectPlanDtoAsync(filename); ProcessProjectPlanDto(projectPlan); IsProjectUpdated = false; m_ProjectSettingService.SetFilePath(filename); } } catch (Exception ex) { DispatchNotification( Properties.Resources.Title_Error, ex.Message); ResetProject(); } finally { IsBusy = false; RaiseCanExecuteChangedAllCommands(); } }