Skip to content

Commit

Permalink
Added new features / Bug fixed
Browse files Browse the repository at this point in the history
・カレンダーにFullCalendarを使用する機能を追加。
・システムログにClientIDを書き込む機能を追加。
・PostgreSQLの環境でCodeDefineによるDBのマイグレートが失敗する問題を解消。
・URLにサブディレクトリを含む環境でログイン後のURL及びトップ画面のURLが正しく生成されない問題を解消。
・サーバスクリプトitems.NewSiteで作成したapiModelオブジェクトにサイトの各種設定内容を登録できない問題を解消。
・x86環境以外でDockerによるビルドが行えない問題を解消。
  • Loading branch information
uchi-ta committed Sep 3, 2023
1 parent fef4b03 commit 1be7c56
Show file tree
Hide file tree
Showing 51 changed files with 1,271 additions and 437 deletions.
6 changes: 2 additions & 4 deletions Implem.CodeDefiner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
RUN apt-get update && apt-get install -y curl

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Implem.CodeDefiner/Implem.CodeDefiner.csproj", "Implem.CodeDefiner/"]
Expand All @@ -21,10 +19,10 @@ RUN dotnet build "Implem.CodeDefiner/Implem.CodeDefiner.csproj" -c Release -o /a
RUN dotnet build "Implem.Pleasanter/Implem.Pleasanter.csproj" -c Release -o /app/build/Implem.Pleasanter

FROM build AS publish
RUN apt-get update && apt-get install -y jq
RUN dotnet publish "Implem.CodeDefiner/Implem.CodeDefiner.csproj" -c Release -o /app/publish/Implem.CodeDefiner
RUN dotnet publish "Implem.Pleasanter/Implem.Pleasanter.csproj" -c Release -o /app/publish/Implem.Pleasanter
RUN curl -o /usr/bin/jq -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && chmod +x /usr/bin/jq && \
cat Implem.Pleasanter/App_Data/Parameters/Rds.json \
RUN cat Implem.Pleasanter/App_Data/Parameters/Rds.json \
| jq '.Dbms|="PostgreSQL" | .SaConnectionString|=null | .OwnerConnectionString|=null | .UserConnectionString|=null' \
> /app/publish/Implem.Pleasanter/App_Data/Parameters/Rds.json

Expand Down
28 changes: 28 additions & 0 deletions Implem.CodeDefiner/Functions/Rds/RdsConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ internal static void Configure(ISqlObjectFactory factory)
{
CreateDatabase(factory: factory, databaseName: Environments.ServiceName);
}
else
{
UpdateDatabase(factory: factory, databaseName: Environments.ServiceName);
}
}

private static void CreateDatabase(ISqlObjectFactory factory, string databaseName)
Expand Down Expand Up @@ -44,6 +48,30 @@ private static void CreateDatabase(ISqlObjectFactory factory, string databaseNam
.Replace("#Uid_Owner#", ocn["uid"]));
}

private static void UpdateDatabase(ISqlObjectFactory factory, string databaseName)
{
Consoles.Write(Environments.ServiceName, Consoles.Types.Info);
var ocn = new TextData(Parameters.Rds.OwnerConnectionString, ';', '=');
var ucn = new TextData(Parameters.Rds.UserConnectionString, ';', '=');
Def.SqlIoBySa(factory).ExecuteNonQuery(
factory: factory,
dbTransaction: null,
dbConnection: null,
commandText: Def.Sql.CreateUserForPostgres
.Replace("#Uid_Owner#", ocn["uid"])
.Replace("#Pwd_Owner#", ocn["pwd"])
.Replace("#Uid_User#", ucn["uid"])
.Replace("#Pwd_User#", ucn["pwd"])
.Replace("#SchemaName#", factory.SqlDefinitionSetting.SchemaName));
Def.SqlIoBySa(factory).ExecuteNonQuery(
factory: factory,
dbTransaction: null,
dbConnection: null,
commandText: Def.Sql.ChangeDatabaseOwnerForPostgres
.Replace("#InitialCatalog#", databaseName)
.Replace("#Uid_Owner#", ocn["uid"]));
}

private static bool Exists(ISqlObjectFactory factory, string databaseName)
{
var isExists = Def.SqlIoBySa(factory).ExecuteTable(
Expand Down
15 changes: 13 additions & 2 deletions Implem.CodeDefiner/Functions/Rds/SchemaConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ internal static class SchemaConfigurator
internal static void Configure(ISqlObjectFactory factory)
{
Consoles.Write(factory.SqlDefinitionSetting.SchemaName, Consoles.Types.Info);
var ocn = new TextData(Parameters.Rds.OwnerConnectionString, ';', '=');
var ucn = new TextData(Parameters.Rds.UserConnectionString, ';', '=');
if (factory.SqlDefinitionSetting.IsCreatingDb)
{
var ocn = new TextData(Parameters.Rds.OwnerConnectionString, ';', '=');
var ucn = new TextData(Parameters.Rds.UserConnectionString, ';', '=');
Def.SqlIoByAdmin(factory).ExecuteNonQuery(
factory: factory,
dbTransaction: null,
Expand All @@ -22,6 +22,17 @@ internal static void Configure(ISqlObjectFactory factory)
.Replace("#Uid_User#", ucn["uid"])
.Replace("#SchemaName#", factory.SqlDefinitionSetting.SchemaName));
}
else
{
Def.SqlIoByAdmin(factory).ExecuteNonQuery(
factory: factory,
dbTransaction: null,
dbConnection: null,
commandText: Def.Sql.GrantDatabaseForPostgres
.Replace("#Uid_Owner#", ocn["uid"])
.Replace("#Uid_User#", ucn["uid"])
.Replace("#SchemaName#", factory.SqlDefinitionSetting.SchemaName));
}
}
}
}
6 changes: 3 additions & 3 deletions Implem.CodeDefiner/Implem.CodeDefiner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<Description>This program does the automatic code creation and merging of existing code based on the definition. Also it will make the configuration change of sql server database.</Description>
<AssemblyVersion>1.3.45.0</AssemblyVersion>
<FileVersion>1.3.45.0</FileVersion>
<Version>1.3.45.0</Version>
<AssemblyVersion>1.3.46.0</AssemblyVersion>
<FileVersion>1.3.46.0</FileVersion>
<Version>1.3.46.0</Version>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

Expand Down
4 changes: 4 additions & 0 deletions Implem.DefinitionAccessor/Def.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13434,6 +13434,8 @@ public class SqlColumn2nd
public string CreateSchema;
public string CreateDatabaseForPostgres;
public string CreateUserForPostgres;
public string ChangeDatabaseOwnerForPostgres;
public string GrantDatabaseForPostgres;
}

/// <summary>
Expand Down Expand Up @@ -13486,5 +13488,7 @@ public class SqlTable
public SqlDefinition CreateSchema = new SqlDefinition();
public SqlDefinition CreateDatabaseForPostgres = new SqlDefinition();
public SqlDefinition CreateUserForPostgres = new SqlDefinition();
public SqlDefinition ChangeDatabaseOwnerForPostgres = new SqlDefinition();
public SqlDefinition GrantDatabaseForPostgres = new SqlDefinition();
}
}
6 changes: 3 additions & 3 deletions Implem.DefinitionAccessor/Implem.DefinitionAccessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.45.0</AssemblyVersion>
<FileVersion>1.3.45.0</FileVersion>
<Version>1.3.45.0</Version>
<AssemblyVersion>1.3.46.0</AssemblyVersion>
<FileVersion>1.3.46.0</FileVersion>
<Version>1.3.46.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.DisplayAccessor/Implem.DisplayAccessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.45.0</AssemblyVersion>
<FileVersion>1.3.45.0</FileVersion>
<Version>1.3.45.0</Version>
<AssemblyVersion>1.3.46.0</AssemblyVersion>
<FileVersion>1.3.46.0</FileVersion>
<Version>1.3.46.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
7 changes: 4 additions & 3 deletions Implem.Factory/Implem.Factory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.45.0</AssemblyVersion>
<FileVersion>1.3.45.0</FileVersion>
<Version>1.3.45.0</Version>
<AssemblyVersion>1.3.46.0</AssemblyVersion>
<FileVersion>1.3.46.0</FileVersion>
<Version>1.3.46.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Implem.Libraries\Implem.Libraries.csproj" />
<ProjectReference Include="..\Rds\Implem.IRds\Implem.IRds.csproj" />
<ProjectReference Include="..\Rds\Implem.PostgreSql\Implem.PostgreSql.csproj" />
<ProjectReference Include="..\Rds\Implem.SqlServer\Implem.SqlServer.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions Implem.Libraries/Implem.Libraries.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.45.0</AssemblyVersion>
<FileVersion>1.3.45.0</FileVersion>
<Version>1.3.45.0</Version>
<AssemblyVersion>1.3.46.0</AssemblyVersion>
<FileVersion>1.3.46.0</FileVersion>
<Version>1.3.46.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.ParameterAccessor/Implem.ParameterAccessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<AssemblyVersion>1.3.45.0</AssemblyVersion>
<FileVersion>1.3.45.0</FileVersion>
<Version>1.3.45.0</Version>
<AssemblyVersion>1.3.46.0</AssemblyVersion>
<FileVersion>1.3.46.0</FileVersion>
<Version>1.3.46.0</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions Implem.ParameterAccessor/Parts/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class General
public int CalendarEnd;
public int CalendarLimit;
public int CalendarYLimit;
public int DefaultCalendarType;
public int CrosstabBegin;
public int CrosstabEnd;
public int CrosstabXLimit;
Expand Down
1 change: 1 addition & 0 deletions Implem.ParameterAccessor/Parts/SysLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class SysLog
public bool LoginSuccess;
public bool LoginFailure;
public bool SignOut;
public bool ClientId;
public int ExportLimit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@
choices?.Count ?? 0);
var begin = Calendars.BeginDate(
context: context,
ss: ss,
date: date,
timePeriod: timePeriod);
timePeriod: timePeriod,
view: view);
var end = Calendars.EndDate(
context: context,
ss: ss,
date: date,
timePeriod: timePeriod);
timePeriod: timePeriod,
view: view);
var CalendarViewType = !string.IsNullOrEmpty(view.CalendarViewType)
? view.CalendarViewType
: "dayGridMonth";
var dataRows = inRangeY
? CalendarDataRows(
context: context,
Expand Down Expand Up @@ -73,6 +80,8 @@
toColumn: toColumn,
date: date,
begin: begin,
end: end,
CalendarViewType: CalendarViewType,
choices: choices,
dataRows: dataRows,
bodyOnly: false,
Expand Down Expand Up @@ -162,12 +171,19 @@ public static string CalendarJson(
choices?.Count ?? 0);
var begin = Calendars.BeginDate(
context: context,
ss: ss,
date: date,
timePeriod: timePeriod);
timePeriod: timePeriod,
view: view);
var end = Calendars.EndDate(
context: context,
ss: ss,
date: date,
timePeriod: timePeriod);
timePeriod: timePeriod,
view: view);
var CalendarViewType = !string.IsNullOrEmpty(view.CalendarViewType)
? view.CalendarViewType
: "dayGridMonth";
var dataRows = inRangeY
? CalendarDataRows(
context: context,
Expand All @@ -193,12 +209,20 @@ public static string CalendarJson(
toColumn: toColumn,
date: date,
begin: begin,
end: end,
CalendarViewType: CalendarViewType,
choices: choices,
dataRows: dataRows,
bodyOnly: bodyOnly,
showStatus: view.CalendarShowStatus == true,
inRange: inRange,
changedItemId: changedItemId);
var CalendarBodyName = "";
if (ss.CalendarType.ToString() == "Standard"){
CalendarBodyName = "#CalendarBody";
} else {
CalendarBodyName = "#FullCalendarBody";
}
if (inRange)
{
return new ResponseCollection(context: context)
Expand All @@ -210,7 +234,7 @@ public static string CalendarJson(
message: message,
loadScroll: update,
bodyOnly: bodyOnly,
bodySelector: "#CalendarBody",
bodySelector: CalendarBodyName,
body: body)
.Events("on_calendar_load")
.ToJson();
Expand All @@ -230,7 +254,7 @@ public static string CalendarJson(
context: context,
data: Parameters.General.CalendarYLimit.ToString()),
bodyOnly: bodyOnly,
bodySelector: "#CalendarBody",
bodySelector: CalendarBodyName,
body: body)
.Events("on_calendar_load")
.ToJson();
Expand Down Expand Up @@ -317,6 +341,8 @@ private static HtmlBuilder Calendar(
Column toColumn,
DateTime date,
DateTime begin,
DateTime end,
string CalendarViewType,
Dictionary<string, ControlData> choices,
EnumerableRowCollection<DataRow> dataRows,
bool bodyOnly,
Expand All @@ -334,6 +360,8 @@ private static HtmlBuilder Calendar(
toColumn: toColumn,
date: date,
begin: begin,
end: end,
CalendarViewType: CalendarViewType,
choices: choices,
dataRows: dataRows,
showStatus: showStatus,
Expand All @@ -348,6 +376,8 @@ private static HtmlBuilder Calendar(
toColumn: toColumn,
date: date,
begin: begin,
end: end,
CalendarViewType: CalendarViewType,
choices: choices,
dataRows: dataRows,
showStatus: showStatus,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter database "#InitialCatalog#" owner to "#Uid_Owner#";
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE DATABASE "#InitialCatalog#" OWNER "#Uid_Owner#";
create database "#InitialCatalog#" owner "#Uid_Owner#";
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE SCHEMA "#SchemaName#" AUTHORIZATION "#Uid_Owner#";
GRANT USAGE ON SCHEMA "#SchemaName#" TO "#Uid_User#";
CREATE EXTENSION IF NOT EXISTS pg_trgm;
create schema "#SchemaName#" authorization "#Uid_Owner#";
grant usage on schema "#SchemaName#" to "#Uid_User#";
create extension if not exists pg_trgm;
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
CREATE USER "#Uid_Owner#" WITH LOGIN PASSWORD '#Pwd_Owner#' valid until 'infinity';
do $$
begin
if not exists (select * from pg_user where usename = '#Uid_Owner#') then
create user "#Uid_Owner#" with login password '#Pwd_Owner#' valid until 'infinity';
create user "#Uid_User#" with login password '#Pwd_User#' valid until 'infinity';
end if;
end $$
;

ALTER ROLE "#Uid_Owner#";
CREATE USER "#Uid_User#" WITH LOGIN PASSWORD '#Pwd_User#' valid until 'infinity';
alter role "#Uid_Owner#";

alter user "#Uid_Owner#" set search_path to "#SchemaName#";
alter user "#Uid_User#" set search_path to "#SchemaName#";

ALTER USER "#Uid_Owner#" SET search_path TO "#SchemaName#";
ALTER USER "#Uid_User#" SET search_path TO "#SchemaName#";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
grant usage on schema "#SchemaName#" to "#Uid_User#";
create extension if not exists pg_trgm;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 as dummy;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select 1 as dummy;
Loading

0 comments on commit 1be7c56

Please sign in to comment.