Skip to content

Commit

Permalink
Bug fixed:
Browse files Browse the repository at this point in the history
・履歴に存在するファイルは削除しない設定が正しく動作しない問題を解消。
  • Loading branch information
uchi-ta committed Apr 27, 2023
1 parent 0d40b96 commit 5acae46
Show file tree
Hide file tree
Showing 42 changed files with 317 additions and 203 deletions.
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.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</Version>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

Expand Down
6 changes: 6 additions & 0 deletions Implem.DefinitionAccessor/Def.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ public static void SetCodeDefinition()
case "Model_Update": Code.Model_Update = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Update, definitionRow, CodeXls); break;
case "Model_Update_ExecuteAutomaticNumberingExec": Code.Model_Update_ExecuteAutomaticNumberingExec = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_Update_ExecuteAutomaticNumberingExec, definitionRow, CodeXls); break;
case "Model_UpdateAttachmentsStatements": Code.Model_UpdateAttachmentsStatements = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateAttachmentsStatements, definitionRow, CodeXls); break;
case "Model_UpdateAttachmentsStatements_Create": Code.Model_UpdateAttachmentsStatements_Create = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateAttachmentsStatements_Create, definitionRow, CodeXls); break;
case "Model_UpdateAttachmentsStatementsMethod": Code.Model_UpdateAttachmentsStatementsMethod = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateAttachmentsStatementsMethod, definitionRow, CodeXls); break;
case "Model_UpdateByApiCases": Code.Model_UpdateByApiCases = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateByApiCases, definitionRow, CodeXls); break;
case "Model_UpdateByCalendarCases": Code.Model_UpdateByCalendarCases = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_UpdateByCalendarCases, definitionRow, CodeXls); break;
Expand Down Expand Up @@ -916,6 +917,7 @@ public static void SetCodeDefinition()
case "Model_WhereDefault": Code.Model_WhereDefault = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_WhereDefault, definitionRow, CodeXls); break;
case "Model_WhereSiteIdOrDefault": Code.Model_WhereSiteIdOrDefault = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_WhereSiteIdOrDefault, definitionRow, CodeXls); break;
case "Model_WriteAttachmentsExecute": Code.Model_WriteAttachmentsExecute = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_WriteAttachmentsExecute, definitionRow, CodeXls); break;
case "Model_WriteAttachmentsExecute_Update": Code.Model_WriteAttachmentsExecute_Update = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Model_WriteAttachmentsExecute_Update, definitionRow, CodeXls); break;
case "Rds": Code.Rds = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Rds, definitionRow, CodeXls); break;
case "Rds_AggregationAverageCases": Code.Rds_AggregationAverageCases = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Rds_AggregationAverageCases, definitionRow, CodeXls); break;
case "Rds_AggregationGroupByCases": Code.Rds_AggregationGroupByCases = definitionRow[1].ToString().NoSpace(definitionRow["NoSpace"].ToBool()); SetCodeTable(CodeTable.Rds_AggregationGroupByCases, definitionRow, CodeXls); break;
Expand Down Expand Up @@ -7081,6 +7083,7 @@ public class CodeColumn2nd
public string Model_Update;
public string Model_Update_ExecuteAutomaticNumberingExec;
public string Model_UpdateAttachmentsStatements;
public string Model_UpdateAttachmentsStatements_Create;
public string Model_UpdateAttachmentsStatementsMethod;
public string Model_UpdateByApiCases;
public string Model_UpdateByCalendarCases;
Expand Down Expand Up @@ -7311,6 +7314,7 @@ public class CodeColumn2nd
public string Model_WhereDefault;
public string Model_WhereSiteIdOrDefault;
public string Model_WriteAttachmentsExecute;
public string Model_WriteAttachmentsExecute_Update;
public string Rds;
public string Rds_AggregationAverageCases;
public string Rds_AggregationGroupByCases;
Expand Down Expand Up @@ -7857,6 +7861,7 @@ public class CodeTable
public CodeDefinition Model_Update = new CodeDefinition();
public CodeDefinition Model_Update_ExecuteAutomaticNumberingExec = new CodeDefinition();
public CodeDefinition Model_UpdateAttachmentsStatements = new CodeDefinition();
public CodeDefinition Model_UpdateAttachmentsStatements_Create = new CodeDefinition();
public CodeDefinition Model_UpdateAttachmentsStatementsMethod = new CodeDefinition();
public CodeDefinition Model_UpdateByApiCases = new CodeDefinition();
public CodeDefinition Model_UpdateByCalendarCases = new CodeDefinition();
Expand Down Expand Up @@ -8087,6 +8092,7 @@ public class CodeTable
public CodeDefinition Model_WhereDefault = new CodeDefinition();
public CodeDefinition Model_WhereSiteIdOrDefault = new CodeDefinition();
public CodeDefinition Model_WriteAttachmentsExecute = new CodeDefinition();
public CodeDefinition Model_WriteAttachmentsExecute_Update = new CodeDefinition();
public CodeDefinition Rds = new CodeDefinition();
public CodeDefinition Rds_AggregationAverageCases = new CodeDefinition();
public CodeDefinition Rds_AggregationGroupByCases = new CodeDefinition();
Expand Down
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.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</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.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions Implem.Factory/Implem.Factory.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.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

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.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</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.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</Version>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public List<SqlStatement> CreateStatements(
<!--Model_UpdateStatus-->

});
<!--Model_UpdateAttachmentsStatements--->

<!--Model_UpdateAttachmentsStatements_Create--->

<!--Model_CreatePermissions-->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
private List<SqlStatement> UpdateAttachmentsStatements(Context context, SiteSettings ss)
private List<SqlStatement> UpdateAttachmentsStatements(Context context, SiteSettings ss, bool verUp = false)
{
var statements = new List<SqlStatement>();
ColumnNames()
Expand All @@ -12,10 +12,12 @@
context: context,
columnName: columnName),
statements: statements,
referenceId: #ModelName#Id));
referenceId: #ModelName#Id,
verUp: verUp));
return statements;
}
private void WriteAttachments(Context context, SiteSettings ss)

private void WriteAttachments(Context context, SiteSettings ss, bool verUp = false)
{
ColumnNames()
.Where(columnName => columnName.StartsWith("Attachments"))
Expand All @@ -27,5 +29,6 @@ private void WriteAttachments(Context context, SiteSettings ss)
column: ss.GetColumn(
context: context,
columnName: columnName),
referenceId: #ModelName#Id));
referenceId: #ModelName#Id,
verUp: verUp));
}
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
statements.AddRange(UpdateAttachmentsStatements(context: context, ss: ss));
statements.AddRange(UpdateAttachmentsStatements(
context: context,
ss: ss,
verUp: verUp));
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Id": "Model_UpdateAttachmentsStatements_Create",
"Indent": "3",
"Include": "Issues,Results"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
statements.AddRange(UpdateAttachmentsStatements(
context: context,
ss: ss));
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
bool otherInitValue = false,
bool setBySession = true,
bool get = true,
bool checkConflict = true)
bool checkConflict = true)
{
<!--Model_OnUpdating_ServerScript-->
<!--Model_OnApiUpdatingMailAddress_Users-->
Expand All @@ -27,19 +27,24 @@

<!--Model_OnUpdatingExtendedSqls-->

var verUp = Versions.VerUp(
context: context,
ss: ss,
verUp: VerUp);
statements.AddRange(UpdateStatements(
context: context,
ss: ss,
param: param,
otherInitValue: otherInitValue,
additionalStatements: additionalStatements,
checkConflict: checkConflict));
checkConflict: checkConflict,
verUp: verUp));

<!--Model_UpdateReminders-->
<!--Model_UpdateExecute-->
<!--Model_Update_ExecuteAutomaticNumberingExec-->
<!--Model_UpdateExecute_User-->
<!--Model_WriteAttachmentsExecute-->
<!--Model_WriteAttachmentsExecute_Update-->
<!--Model_ForceSynchronizeSummaryExecute-->
<!--Model_UpdateWikiTitle-->
<!--Model_OnUpdatedNotice-->
Expand Down Expand Up @@ -68,7 +73,8 @@ public List<SqlStatement> UpdateStatements(
SqlParamCollection param = null,
bool otherInitValue = false,
List<SqlStatement> additionalStatements = null,
bool checkConflict = true)
bool checkConflict = true,
bool verUp = false)
{

<!--Model_SetAttachmentsData-->
Expand All @@ -82,10 +88,7 @@ public List<SqlStatement> UpdateStatements(

<!--Model_IfDuplicated-->

if (Versions.VerUp(
context: context,
ss: ss,
verUp: VerUp))
if (verUp)
{
statements.Add(Rds.#TableName#CopyToStatement(
where: where,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
statements.AddRange(#modelName#Model.UpdateStatements(
context: context,
ss: ss,
dataTableName: formData.Id.ToString()));
dataTableName: formData.Id.ToString(),
verUp: #modelName#Model.VerUp));
}
else if (formData.Id < 0)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Id": "Model_WriteAttachmentsExecute_Update",
"Indent": "3",
"ItemOnly": "1",
"Exclude": "Sites,Wikis"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WriteAttachments(
context: context,
ss: ss,
verUp: verUp);
6 changes: 3 additions & 3 deletions Implem.Pleasanter/Implem.Pleasanter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Copyright>Copyright © Implem Inc 2014 - 2023</Copyright>
<Description>Business application platform</Description>
<AssemblyName>Implem.Pleasanter</AssemblyName>
<AssemblyVersion>1.3.37.1</AssemblyVersion>
<FileVersion>1.3.37.1</FileVersion>
<Version>1.3.37.1</Version>
<AssemblyVersion>1.3.37.2</AssemblyVersion>
<FileVersion>1.3.37.2</FileVersion>
<Version>1.3.37.2</Version>
<Nullable>disable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
Expand Down
43 changes: 24 additions & 19 deletions Implem.Pleasanter/Libraries/DataTypes/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,20 @@ public void DeleteFromLocal(
Context context,
SiteSettings ss,
Column column,
long referenceId)
long referenceId,
bool verUp)
{
var path = Path.Combine(
Directories.BinaryStorage(),
"Attachments",
Guid);
if (ss == null
|| column.NotDeleteExistHistory == false
|| !ExistsHistory(
context: context,
ss: ss,
     column: column,
     referenceId: referenceId))
if (column?.NotDeleteExistHistory != true
|| (verUp == false
&& !ExistsHistory(
context: context,
ss: ss,
column: column,
referenceId: referenceId)))
{
if (System.IO.File.Exists(path))
{
Expand All @@ -117,7 +118,8 @@ public void SqlStatement(
SiteSettings ss,
Column column,
List<SqlStatement> statements,
long referenceId)
long referenceId,
bool verUp)
{
if (Added == true)
{
Expand All @@ -140,12 +142,13 @@ public void SqlStatement(
}
else if (Deleted == true && !Overwritten.HasValue)
{
if (column.NotDeleteExistHistory == false
|| !ExistsHistory(
context: context,
ss: ss,
column: column,
referenceId: referenceId))
if (column?.NotDeleteExistHistory != true
|| (verUp == false
&& !ExistsHistory(
context: context,
ss: ss,
column: column,
referenceId: referenceId)))
{
statements.Add(Rds.DeleteBinaries(
factory: context,
Expand Down Expand Up @@ -174,6 +177,10 @@ private bool ExistsHistory(
Column column,
long referenceId)
{
if (ss == null)
{
return false;
}
switch (ss.ReferenceType)
{
case "Issues":
Expand All @@ -190,8 +197,7 @@ private bool ExistsHistory(
columnBrackets: column.ColumnName.ToSingleArray(),
value: $"%\"Guid\":\"{Guid}\"%",
name: Strings.NewGuid(),
_operator: context.Sqls.LikeWithEscape),
top: 1)) == 1;
_operator: context.Sqls.LikeWithEscape))) >= 1;
case "Results":
return Rds.ExecuteScalar_int(
context: context,
Expand All @@ -206,8 +212,7 @@ private bool ExistsHistory(
columnBrackets: column.ColumnName.ToSingleArray(),
value: $"%\"Guid\":\"{Guid}\"%",
name: Strings.NewGuid(),
_operator: context.Sqls.LikeWithEscape),
top: 1)) == 1;
_operator: context.Sqls.LikeWithEscape))) >= 1;
default:
return false;
}
Expand Down
Loading

0 comments on commit 5acae46

Please sign in to comment.