/// <summary> /// Affiche la liste des scénarios impactés à l'utilisateur. /// </summary> /// <param name="currentScenario">The current scenario.</param> /// <param name="allScenarios">All scenarios.</param> /// <param name="delete"><c>true</c> si l'action est une suppression.</param> /// <param name="actionsToDelete">Les actions à supprimer.</param> /// <param name="whenNoScenarioImpacted">Action à exécuter lorsqu'aucun scénario n'est impacté.</param> /// <param name="actionsWithUpdatedWBS">The actions with updated WBS.</param> protected async Task <bool> ShowImpactedScenarios( Scenario currentScenario, Scenario[] allScenarios, bool delete, KAction[] actionsToDelete, Action whenNoScenarioImpacted, KAction[] actionsWithUpdatedWBS = null) { Scenario[] scenarios = await ServiceBus.Get <IAnalyzeService>().PredictImpactedScenarios(currentScenario, allScenarios, actionsToDelete, actionsWithUpdatedWBS); bool ok = true; // Informer des scénarios impactés if (scenarios != null && scenarios.Any()) { string messageKey = delete ? "VM_AnalyzeCommon_DeleteImpactedScenarios" : "VM_AnalyzeCommon_ImpactedScenarios"; string scenariosJoint = string.Join(Environment.NewLine, scenarios.Select(s => s.Label)); string message = string.Format( LocalizationManager.GetString(messageKey), scenariosJoint); MessageDialogResult res = DialogFactory.GetDialogView <IMessageDialog>() .Show(message, null, MessageDialogButton.YesNoCancel, MessageDialogImage.Warning); ok = res == MessageDialogResult.Yes; } else { whenNoScenarioImpacted?.Invoke(); } return(ok); }
static void Main(string[] args) { //服务发现 string serviceKey = "Foo.Services"; ServiceInformation service = ServiceBus.Get(serviceKey).Result.FeelingLucky(); //service = new ServiceInformation() //{ // Host = "localhost", // Port = 50051, //}; while (true) { string target = $"{service.Host}:{service.Port}"; Channel channel = new Channel(target, ChannelCredentials.Insecure); var client = new Greeter.GreeterClient(channel); Console.Write("Input your name: "); String user = Console.ReadLine(); var request = new HelloRequest { Name = user }; Console.WriteLine($"request: \n{JsonConvert.SerializeObject(request)}"); var reply = client.SayHello(request); Console.WriteLine($"reply: \n{JsonConvert.SerializeObject(reply)}"); channel.ShutdownAsync().Wait(); } }
/// <summary> /// Enregistre les actions modifiées. /// </summary> /// <param name="refreshSelectionWhenDone"><c>true</c> pour rafraichir la sélection une fois la sauvegarde effectuée.</param> private async Task <bool> SaveActions(bool refreshSelectionWhenDone) { ShowSpinner(); try { await ServiceBus.Get <IValidateService>().SaveSimulateData(SelectedTargetScenario); if (refreshSelectionWhenDone) { await OnLoading(); } foreach (var action in SelectedTargetScenario.Actions) { action.StartTracking(); } HideSpinner(); return(true); } catch (Exception e) { base.OnError(e); } return(false); }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override async Task OnLoading() { Users.Clear(); try { var(users, roles, languages, teams) = await ServiceBus.Get <IApplicationUsersService>().GetUsersAndRolesAndLanguages(); Users.AddRange(users); foreach (var user in Users) { if (user.Username == Security.SecurityContext.CurrentUser.Username) { user.IsUsernameReadOnly = true; } user.StartTracking(); } var presRoles = roles.Select(r => new PresentationRole(this, r)).ToArray(); Array.Sort(presRoles); Roles = presRoles; Languages = languages; } catch (Exception e) { base.OnError(e); } }
/// <summary> /// Modifie le message du spinner. /// </summary> /// <param name="message">Le message à afficher.</param> protected void SetMessageSpinner(string message = null) { if (!DesignMode.IsInDesignMode) { ServiceBus.Get <ISpinnerService>().SetMessage(message); } }
private async Task <string> BackupBeforeRestoreAsync() { this.TraceDebug("nettoyage du dossier SqlDir..."); SqlMessages.Add(new SqlOutput("Cleaning up the buffer directory...")); foreach (string file in Directory.GetFiles(ServiceBus.Get <IDataBaseService>().GeBackupDir())) { try { this.TraceDebug(file); SqlMessages.Add(new SqlOutput(file)); File.Delete(file); } catch (Exception e) { this.TraceError(e, file); SqlMessages.Add(new SqlOutput(e)); SqlMessages.Add(new SqlOutput("This error has no consequence for next restore steps. Continuing...")); } } this.TraceDebug("Fin du nettoyage"); string backupFilePath = await DoBackup(); SqlMessages.Add(new SqlOutput("The backup before restore process has succeded. Backup file is store at location:")); SqlMessages.Add(new SqlOutput(backupFilePath, SqlOutputKind.Path)); return(backupFilePath); }
/// <summary> /// Affiche le spinner. /// </summary> /// <param name="message">Le message à afficher.</param> protected void ShowSpinner(string message = null) { if (!DesignMode.IsInDesignMode) { ServiceBus.Get <ISpinnerService>().ShowIncrement(message); } }
/// <summary> /// Met à jour l'état de la synthèse. /// </summary> /// <typeparam name="TReferential">Le type de référentiel.</typeparam> /// <param name="vm">Le viewModel.</param> public void UpdateRestitutionState <TReferential>(IRestitutionViewByResourceViewModel <TReferential> vm) where TReferential : IActionReferential { ProcessReferentialIdentifier id = ReferentialsHelper.GetIdentifier <TReferential>(); _restitutionState.Referential = id; _restitutionState.Solutions = false; _restitutionState.RestitutionValueMode = (int)vm.SelectedValueMode; switch (vm.SelectedViewIndex) { case 0: // Vue Globale _restitutionState.ViewMode = RestitutionStateViewMode.Global; _restitutionState.ResourceId = null; break; case 1: // Vue par opérateur _restitutionState.ViewMode = RestitutionStateViewMode.PerOperator; _restitutionState.ResourceId = vm.SelectedResource != null ? (int?)vm.SelectedResource.Id : null; break; case 2: // Vue par équipement _restitutionState.ViewMode = RestitutionStateViewMode.PerEquipment; _restitutionState.ResourceId = vm.SelectedResource != null ? (int?)vm.SelectedResource.Id : null; break; default: throw new ArgumentOutOfRangeException(nameof(vm)); } ServiceBus.Get <IProjectManagerService>().RestitutionState[_currentProjectId] = _restitutionState; }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override Task OnLoading() { _timeService = ServiceBus.Get <ITimeTicksFormatService>(); IProjectManagerService pms = ServiceBus.Get <IProjectManagerService>(); RestitutionState restitutionState = pms.RestitutionState[pms.CurrentProject.ProjectId]; switch (restitutionState.ViewMode.Value) { case RestitutionStateViewMode.Global: SelectedViewIndex = 0; break; case RestitutionStateViewMode.PerOperator: SelectedViewIndex = 1; break; case RestitutionStateViewMode.PerEquipment: SelectedViewIndex = 2; break; } SelectedValueMode = (RestitutionValueMode)restitutionState.RestitutionValueMode.Value; return(Task.CompletedTask); }
public async Task GreeterServiceTest() { //服务信息 var serviceInfo = new ServiceInformation() { Host = "127.0.0.1", Port = 1234, Description = "我的小服务, 老火了", Key = "Foo.Services", Name = "我的小服务", ServiceType = ServiceType.Grpc, }; //启动服务 Server server = new Server { Services = { Greeter.BindService(new GreeterImpl()) }, Ports = { new ServerPort(serviceInfo.Host, serviceInfo.Port, ServerCredentials.Insecure) } }; server.Start(); //注册服务 using (var zon = await ServiceBus.Register(serviceInfo)) { //发现服务 string serviceKey = serviceInfo.Key; ServiceInformation service = ServiceBus.Get(serviceKey).Result.FeelingLucky(); //使用服务 string target = $"{service.Host}:{service.Port}"; Channel channel = new Channel(target, ChannelCredentials.Insecure); Greeter.GreeterClient client = new Greeter.GreeterClient(channel); HelloRequest request = new HelloRequest() { Name = "徐云金", SecretSignal = "天王盖地虎", }; request.Gifts.AddRange(new List <Gift>() { new Gift { Name = "兔子" }, new Gift { Name = "橘猫" }, }); Console.WriteLine($"request: \n{JsonConvert.SerializeObject(request)}"); HelloReply reply = client.SayHello(request); Console.WriteLine($"reply: \n{JsonConvert.SerializeObject(reply)}"); Assert.AreEqual(request.Name, reply.Name); channel.ShutdownAsync().Wait(); } }
/// <summary> /// Cache le spinner. /// </summary> protected void HideSpinner() { if (!DesignMode.IsInDesignMode) { ServiceBus.Get <ISpinnerService>().HideDecrement(); } CommandManager.InvalidateRequerySuggested(); }
/// <summary> /// Met à jour l'état de la synthèse. /// </summary> /// <param name="solutionsVm">Le viewModel</param> public void UpdateRestitutionState(IRestitutionSolutionsViewModel solutionsVm) { _restitutionState.Referential = null; _restitutionState.Solutions = true; _restitutionState.ViewMode = null; _restitutionState.ResourceId = null; ServiceBus.Get <IProjectManagerService>().RestitutionState[_currentProjectId] = _restitutionState; }
/// <summary> /// Charge les données. /// </summary> /// <param name="projectId">L'identifiant du projet.</param> protected override async Task LoadData(int projectId) { ShowSpinner(); try { AcquireData data = await ServiceBus.Get <IValidateService>().GetAcquireData(projectId); await LoadDataInternal(data); } catch (Exception e) { base.OnError(e); } }
/// <summary> /// Initialise les extensions. /// </summary> void InitializeExtensions() { // Charger les extensions var extensionsManager = ServiceBus.Get <IExtensionsManager>(); var extensions = Container.GetExports <IExtension>().Select(e => e.Value); var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; var descriptions = extensions.Select(e => new ExtensionDescription(e, currentVersion >= e.MinimumApplicationVersion, extensionsManager.IsExtensionEnabled(e.ExtensionId))); extensionsManager.SetExtensions(descriptions); }
/// <summary> /// Charge les données. /// </summary> /// <param name="projectId">L'identifiant du projet.</param> protected override async Task LoadData(int projectId) { ShowSpinner(); try { SimulateData data = await ServiceBus.Get <IAnalyzeService>().GetSimulateData(projectId); LoadDataInternal(data); } catch (Exception e) { base.OnError(e); } }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override async Task OnLoading() { await base.OnLoading(); NavigationService = ServiceBus.Get <INavigationService>(); if (NavigationService.Preferences.GanttGridView.HasValue) { ChangeView(NavigationService.Preferences.GanttGridView.Value); } else { ChangeView(GanttGridView.WBS); } }
private bool TryPrepareRestore(string source, out string sqlDirSourceFile) { this.TraceDebug("Préparation de la restauration"); IDataBaseService dataBaseService = ServiceBus.Get <IDataBaseService>(); string finalSourcePath = Path.Combine(dataBaseService.GeBackupDir(), "tempRestorationFile"); try { if (File.Exists(source)) { SqlMessages.Add(new SqlOutput("Importing backup file...")); File.Copy(source, finalSourcePath, true); } else { SqlMessages.Add(new SqlOutput("Restore process has failed: The specified file has not been found", SqlOutputKind.Error)); } } catch (UnauthorizedAccessException e) { this.TraceError(e, "Une erreur s'est produite durant le processus de restauration de base de donnée (import du fichier de backup)"); SqlMessages.Add(new SqlOutput(e)); SqlMessages.Add(new SqlOutput("Backup file copy has failed. Check files authorization.", SqlOutputKind.Error)); SqlMessages.Add(new SqlOutput("Restore process is rolled backed and aborted now.")); sqlDirSourceFile = null; return(false); } catch (Exception e) { this.TraceError(e, "Une erreur non gérée s'est produite durant le processus de restauration de base de donnée (import du fichier de backup)"); SqlMessages.Add(new SqlOutput(e)); SqlMessages.Add(new SqlOutput("A not handled error occured during the importation.", SqlOutputKind.Error)); SqlMessages.Add(new SqlOutput("Restore process is aborted now.")); if (File.Exists(finalSourcePath)) { File.Delete(finalSourcePath); } sqlDirSourceFile = null; return(false); } sqlDirSourceFile = finalSourcePath; return(true); }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override async Task OnLoading() { _navigationService = ServiceBus.Get <INavigationService>(); EventBus.Subscribe <ScenarioChangedEvent>(e => { if (e.Scenario != null) { TryLoadScenario(e.Scenario.Id); } }); var projectId = ServiceBus.Get <IProjectManagerService>().CurrentProject.ProjectId; await LoadData(projectId); EventBus?.Publish(new GanttAutoScaleEvent(this)); }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override Task OnLoading() { _extensionsManager = ServiceBus.Get <IExtensionsManager>(); // Récupérer toutes les extensions CompositionContainer container = IoC.Resolve <CompositionContainer>(); IEnumerable <ExtensionDescription> extensions = _extensionsManager.GetExtensions(); Extensions = extensions.Select(ext => new ExtensionViewModel(ext.Extension, ext.IsEnabled, this) { IsVersionValid = ext.IsVersionValid, }).ToArray(); return(Task.CompletedTask); }
private async Task DoRestore(string source, int version = 3) { SqlExecutionResult <string> sqlResult = ServiceBus.Get <IDataBaseService>().Restore(source, version, true); sqlResult.SqlMessageSent += SqlResultSqlMessageSent; try { await sqlResult.Start(); sqlResult.SqlMessageSent -= SqlResultSqlMessageSent; this.TraceInfo("Le processus de restauration de la base de données s'est déroulé avec succés"); SqlMessages.Add(new SqlOutput("restore process of the backup file has succeeded.", SqlOutputKind.Success)); try { if (File.Exists(source)) { File.Delete(source); } } catch (Exception ex) { SqlMessages.Add(new SqlOutput("An error occured while trying to remove the imported backup file.", SqlOutputKind.Error)); this.TraceError("Suppression du fichier temporaire importé pour le processus de restauration", ex); } RestartApplication(); } catch (Exception e) { sqlResult.SqlMessageSent -= SqlResultSqlMessageSent; this.TraceError(e, "Une erreur s'est produite durant le processus de restauration de base de donnée"); SqlMessages.Add(new SqlOutput(e.InnerException ?? e)); SqlMessages.Add(new SqlOutput("Restoration failed and rolled back.", SqlOutputKind.Error)); try { if (File.Exists(source)) { File.Delete(source); } } catch (Exception ex) { SqlMessages.Add(new SqlOutput("An error occured while trying to remove the imported backup file.", SqlOutputKind.Error)); this.TraceError("Suppression du fichier temporaire importé pour le processus de restauration", ex); } RestartApplicationWithError(); } }
/// <summary> /// Appelé lorsque l'affichage dans la synthèse d'un scénario a changé. /// </summary> /// <param name="scenario">Le scénario.</param> /// <param name="isShownInSummary"><c>true</c> pour l'afficher dans la synthèse.</param> async void OnScenarioIsShownInSummaryChanged(ScenarioSelection scenario, bool isShownInSummary) { UdpateScenariosToShow(); ShowSpinner(); try { var updatedScenario = await ServiceBus.Get <IAnalyzeService>().UpdateScenarioIsShownInSummary(scenario.Scenario.ScenarioId, isShownInSummary); Scenarios.Single(_ => _.Scenario.ScenarioId == updatedScenario.ScenarioId).Scenario.AcceptChanges(); HideSpinner(); } catch (Exception e) { base.OnError(e); } }
private async Task Load(int processId) { var(users, roles) = await ServiceBus.Get <IPrepareService>().GetMembers(processId); Users = users.ToArray(); ActivatedUsers = new List <User>(await FilterByActivatedUser(Users.Where(u => !u.IsDeleted && u.Roles.Any(r => r.RoleCode == KnownRoles.Administrator || r.RoleCode == KnownRoles.Analyst)), u => u.UserId)); var owner = Users.Single(_ => _.UserId == CurrentProcess.OwnerId); ActivatedUsersAndOwner = new List <User>(ActivatedUsers); if (!ActivatedUsersAndOwner.Any(_ => _.UserId == owner.UserId)) { ActivatedUsersAndOwner.Add(owner); ActivatedUsersAndOwner = ActivatedUsersAndOwner.OrderBy(_ => _.FullName).ToList(); } OnPropertyChanged(nameof(Owner)); OnPropertyChanged(nameof(CanUpdateRights)); }
/// <summary> /// Sauvegarde les actions. /// </summary> /// <param name="scenarios">Les scénarios à sauvegarder.</param> /// <param name="scenario">Le scénario à sauvegarder.</param> protected override Task <Scenario> SaveActionsServiceCall(Scenario[] scenarios, Scenario scenario) { //// Dans le cas ou il n'y a pas de video associée, le start et finish de l'action suit celui du build start et build finish dans un contexte de validation. //// Cela permet lorsqu'on associe une nouvelle video qu'elle ait le bon emplacement //if (scenario != null) //{ // foreach (var action in scenario.Actions) // { // if (action.VideoId == null) // { // action.Start = action.BuildStart; // action.Finish = action.BuildFinish; // } // } //} return(ServiceBus.Get <IAnalyzeService>().SaveBuildScenario(scenarios, scenario)); }
/// <summary> /// Arrête le contrôleur /// </summary> protected override async Task OnStop() { SaveSettings(); SignalRFactory.Dispose(); if (!_shutdown) { await ServiceBus.Get <ISharedDatabasePresentationService>().ReleaseLock(); } await base.OnStop(); if (Application.Current != null) { Application.Current.Shutdown(); } }
/// <summary> /// Charge les données en interne. /// </summary> /// <param name="data">les données.</param> protected void LoadDataInternal(Business.Dtos.SimulateData data) { _allScenarios = data.Scenarios; CustomFieldsLabels = new CustomFieldsLabels(data.CustomFieldsLabels); var projectService = ServiceBus.Get <IProjectManagerService>(); if (projectService.CurrentScenario == null || !ScenarioNaturesFilter.Contains(projectService.CurrentScenario.NatureCode)) { projectService.SelectScenario(_allScenarios.First(s => ScenarioNaturesFilter.Contains(s.NatureCode))); } else { TryLoadScenario(projectService.CurrentScenario.Id); } HideSpinner(); }
/// <summary> /// Charge les données. /// </summary> async Task LoadData(bool firstLoad) { int projectId = ServiceBus.Get <IProjectManagerService>().CurrentProject.ProjectId; ScenarioDescription currentScenario = ServiceBus.Get <IProjectManagerService>().CurrentScenario; ShowSpinner(); try { RestitutionData data = await OnLoadData(projectId); _allScenarios = data.Scenarios; Scenarios = data.Scenarios .Where(s => !s.IsDeleted) .Select(s => new ScenarioSelection(s, s.IsShownInSummary, OnScenarioIsShownInSummaryChanged)).ToArray(); UdpateScenariosToShow(); if (SelectedView == null) { if (_restitutionState.Solutions) { SelectedView = _solutionsViewKey; } else { string key = ReferentialsUse.GetLabel(_restitutionState.Referential.Value); SelectedView = key; } } else { await _currentViewModel?.Refresh(); } HideSpinner(); } catch (Exception e) { base.OnError(e); } }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override Task OnLoading() { IProjectManagerService pms = ServiceBus.Get <IProjectManagerService>(); _currentProjectId = pms.CurrentProject.ProjectId; if (!pms.RestitutionState.TryGetValue(_currentProjectId, out _restitutionState)) { _restitutionState = new RestitutionState { Referential = ProcessReferentialIdentifier.Category, RestitutionValueMode = (int)Core.Behaviors.RestitutionValueMode.Absolute, ViewMode = RestitutionStateViewMode.Global, }; pms.RestitutionState[_currentProjectId] = _restitutionState; } return(LoadData(true)); }
/// <summary> /// Appelé lorsqu'une erreur a lieu. /// </summary> /// <param name="ex">L'exception.</param> private void OnError(Exception ex) { ServiceBus.Get <ISpinnerService>().HideDecrement(); this.TraceError(ex, ex.Message); if (ex is OperationCanceledException || ex?.InnerException is OperationCanceledException || (ex is AggregateException && ((AggregateException)ex).InnerExceptions .Union(((AggregateException)ex).InnerExceptions.SelectMany(_ => (_ as AggregateException)?.InnerExceptions)) .OfType <OperationCanceledException>().Any())) { DialogFactory.GetDialogView <IMessageDialog>().Show(LocalizationManager.GetString("ExtKp_Dlg_ExportCanceled"), string.Empty); } else { DialogFactory.GetDialogView <IErrorDialog>().Show(LocalizationManager.GetString("Common_Error_GenericMessage"), LocalizationManager.GetString("Common_Error"), ex); } }
public async Task RegisterTest() { //服务信息 var serviceInfo = new ServiceInformation() { Host = "127.0.0.1", Port = 1234, Description = "我的小服务, 老火了", Key = "Foo.Services", Name = "我的小服务", ServiceType = ServiceType.Grpc, }; using (var zon = await ServiceBus.Register(serviceInfo)) { var serviceLoaded = (await ServiceBus.Get(serviceInfo.Key)).FeelingLucky(); Assert.AreEqual(serviceInfo.Key, serviceLoaded.Key); } }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override async Task OnLoading() { ShowSpinner(); var projectInfo = ServiceBus.Get <IProjectManagerService>().CurrentProject; var prepareService = ServiceBus.Get <IPrepareService>(); CurrentProcess = await prepareService.GetProcess(projectInfo.ProcessId, false); CurrentProject = prepareService.GetProjectSync(projectInfo.ProjectId); try { await Load(CurrentProcess.ProcessId); HideSpinner(); } catch (Exception e) { base.OnError(e); } }