-
Notifications
You must be signed in to change notification settings - Fork 8
Feature/launcher provider create db #694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
J0shlerB0y
wants to merge
13
commits into
develop
Choose a base branch
from
feature/LauncherProviderCreateDb
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
37fdc8c
Сделал создание базы из лаунчера входа
J0shlerB0y 9d5f2cf
решил конфликты с изменениями по ревью
J0shlerB0y c5593f6
сделал клиент создание базы для облака
J0shlerB0y 2266c4b
универсальное наполнение базы данных из скриптов
J0shlerB0y a43ac62
починил маппинг страниц + скрипты наполнения баз
J0shlerB0y 0e82442
поменял получения крейтора базы в типе подключения
J0shlerB0y ab2ff0d
починил проблему передачи зависимостей
J0shlerB0y 80ebe2c
добавление title при создании базы
J0shlerB0y a771542
реализация IDbCreatorModel для QSCloud и правки
J0shlerB0y 8229cb5
Создание базы через облако
J0shlerB0y 3f9ae8e
убрал лишние элементы
J0shlerB0y 024eeda
настроил клиент создания базы через облако
J0shlerB0y 0dc4147
сделал адаптер для строго кода и перерабтал под новый интерфейс взаим…
J0shlerB0y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using Grpc.Core; | ||
| using QS.Cloud.Core; | ||
| using QS.Project.Versioning; | ||
| using System.Threading; | ||
|
|
||
| namespace QS.Cloud.Client.Clients { | ||
| public class DataBaseManagementCloudClient : CloudClientByBasicAuth { | ||
| private IApplicationInfo applicationInfo { get; set; } | ||
| public DataBaseManagementCloudClient(IBasicAuthInfoProvider basicAuthInfoProvider) | ||
| : base(basicAuthInfoProvider, "core.cloud.qsolution.ru", 443) | ||
| { | ||
| this.applicationInfo = applicationInfo; | ||
| } | ||
|
|
||
| public CreateDataBaseResponse CreateDataBase(string dbName, string dbTitle, IApplicationInfo applicationInfo) { | ||
| var client = new DataBaseManagement.DataBaseManagementClient(Channel); | ||
| var request = new CreateDataBaseRequest { Name = dbName, Title = dbTitle, ProductId = applicationInfo.ProductCode }; | ||
| return client.CreateDataBase(request, headers); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| using QS.Cloud.Core; | ||
| using QS.DBScripts; | ||
| using QS.DBScripts.Controllers; | ||
| using QS.DBScripts.Models; | ||
| using QS.Dialog; | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace QS.Cloud.Client.DataBase | ||
| { | ||
| public class QsCloudDbCreator : IDbCreatorModel | ||
| { | ||
| static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); | ||
|
|
||
| private readonly int baseId; | ||
|
|
||
| private readonly IProgressBarDisplayable progress; | ||
| private readonly IDbCreatorInteraction interaction; | ||
| private readonly IDbScriptsConfiguration configuration; | ||
| private readonly CancellationToken cancellationToken; | ||
|
|
||
| private LoginManagementCloudClient loginClient; | ||
|
|
||
| public QsCloudDbCreator( | ||
| int baseId, | ||
| BasicAuthInfoProvider AuthInfo, | ||
| IDbScriptsConfiguration configuration, | ||
| IProgressBarDisplayable progress, | ||
| IDbCreatorInteraction interaction, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| this.baseId = baseId; | ||
|
|
||
| loginClient = new LoginManagementCloudClient(AuthInfo); | ||
|
|
||
| this.configuration = configuration ?? throw new ArgumentNullException(nameof(progress)); | ||
| this.progress = progress ?? throw new ArgumentNullException(nameof(progress)); | ||
| this.interaction = interaction ?? throw new ArgumentNullException(nameof(interaction)); | ||
| this.cancellationToken = cancellationToken; | ||
| } | ||
|
|
||
|
|
||
| public async Task<bool> RunCreationAsync(string dbName, string dbTitle) { | ||
| try { | ||
| StartSessionResponse session = loginClient.StartSession(baseId); | ||
|
|
||
| if(!session.Success) { | ||
| await interaction.ReportErrorAsync("Ошибка в создании сесии", "Запрос в облако"); | ||
| throw new InvalidOperationException("Ошибка в создании сесии"); | ||
| } | ||
| else if(!session.IsAdmin) { | ||
| await interaction.ReportErrorAsync("Вы не имеете прав Администратора", "Запрос в облако"); | ||
| } | ||
|
|
||
| var infoProvider = new SessionInfoProvider(sessionId: session.SessionId); | ||
| var sessionLife = new AliveCloudClient(infoProvider); | ||
| sessionLife.NewMessage += (mes) => { | ||
| progress.Update("Сессия: " + mes + " в статусе " + sessionLife.LastStatus.ToString()); | ||
| }; | ||
| sessionLife.KeepAlive(); | ||
|
|
||
| var creator = new MySqlDbCreateModel(session.Db.Server, session.Db.Port, session.Db.Login, session.Db.Password, configuration, progress, interaction, cancellationToken); | ||
| creator.FillBaseGuid = false; | ||
| bool success = await creator.RunCreationAsync(session.Db.BaseName, dbTitle); | ||
|
|
||
| sessionLife.Dispose(); | ||
|
|
||
| return success; | ||
| } | ||
| catch(OperationCanceledException) { | ||
| logger.Info("Создание базы в облаке отменено пользователем."); | ||
| return false; | ||
| } | ||
| catch(Exception ex) { | ||
| logger.Error(ex, "Ошибка при создании базы в облаке."); | ||
| await interaction.ReportErrorAsync(ex.Message, null); | ||
| throw; | ||
| } | ||
| finally { | ||
| if(progress.IsStarted) | ||
| progress.Close(); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using QS.DBScripts; | ||
| using QS.DBScripts.Models; | ||
| using QS.Updater.DB; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using System.Text; | ||
|
|
||
| namespace QS.Cloud.Client.DataBase { | ||
| public class QsCloudScriptsConfiguration : IDbScriptsConfiguration { | ||
| private string ResourceName = "QS.Cloud.Client.Scripts.new_empty.sql"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Как в библиотеках может быть такой ресурс? |
||
| public bool HasCreationScript() { | ||
| return Assembly.GetAssembly(typeof(QsCloudScriptsConfiguration)) | ||
| .GetReferencedAssemblies().Select(x => x.FullName) | ||
| .Contains(ResourceName); | ||
| } | ||
|
|
||
| public CreationScript MakeCreationScript() { | ||
| return new CreationScript( | ||
| Assembly.GetAssembly(typeof(QsCloudScriptsConfiguration)), | ||
| ResourceName, | ||
| new Version(1, 7) | ||
| ); | ||
| } | ||
|
|
||
| public UpdateConfiguration MakeUpdateConfiguration() { | ||
| var configuration = new UpdateConfiguration(); | ||
|
|
||
| configuration.AddUpdate( | ||
| new Version(1, 7), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. То же самое, что это вообще может делать в библиотеках? |
||
| new Version(1, 7, 1), | ||
| "QS.Cloud.Client.Scripts.1.7.sql"); | ||
|
|
||
| return configuration; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package QS.Cloud.Core; | ||
|
|
||
| service DataBaseManagement{ | ||
| // Создать пустую базу | ||
| rpc CreateDataBase (CreateDataBaseRequest) returns (CreateDataBaseResponse); | ||
| } | ||
|
|
||
| message CreateDataBaseRequest{ | ||
| string name = 1; | ||
| string title = 2; | ||
| uint32 product_id = 3; | ||
| } | ||
|
|
||
| message CreateDataBaseResponse{ | ||
| int32 base_id = 1; | ||
| string base_guid = 2; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не согласен, с решением, по сути ты смешиваешь зачем то 2 различные функциональности, вход в саму админку сервера и вход в базу. Просто в моем представлении у IDbProvider не может быть базы в принцепе. Или я не понял задумки.