-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
・サーバスクリプトにUpsertメソッドを追加。 ・サイト統合されたテーブルのデータをサーバスクリプトで取得する機能を追加。 ・サイト統合されたテーブルのデータをAPIで取得する機能を追加。
- Loading branch information
Showing
24 changed files
with
538 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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
8 changes: 8 additions & 0 deletions
8
Implem.Pleasanter/App_Data/Definitions/Definition_Code/Model_UpsertByServerScriptCases.json
This file contains 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,8 @@ | ||
{ | ||
"Id": "Model_UpsertByServerScriptCases", | ||
"RepeatType": "Table", | ||
"Indent": "4", | ||
"Separator": "\\r\\n", | ||
"ItemOnly": "1", | ||
"Exclude": "Sites,Wikis" | ||
} |
23 changes: 23 additions & 0 deletions
23
....Pleasanter/App_Data/Definitions/Definition_Code/Model_UpsertByServerScriptCases_Body.txt
This file contains 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,23 @@ | ||
case "#TableName#": | ||
var #modelName#Ss = Site.#TableName#SiteSettings( | ||
context: context, | ||
referenceId: ReferenceId); | ||
if (model is string #modelName#RequestString) | ||
{ | ||
context.ApiRequestBody = #modelName#RequestString; | ||
} | ||
else if (model is ServerScriptModelApiModel #modelName#ApiModel) | ||
{ | ||
context.ApiRequestBody = #modelName#ApiModel.ToJsonString( | ||
context: context, | ||
ss: #modelName#Ss); | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
return #ModelName#Utilities.UpsertByServerScript( | ||
context: context, | ||
ss: #modelName#Ss, | ||
previousTitle: Title, | ||
model: model); |
This file contains 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
6 changes: 6 additions & 0 deletions
6
...Pleasanter/App_Data/Definitions/Definition_Code/Model_Utilities_UpsertByServerScript.json
This file contains 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,6 @@ | ||
{ | ||
"Id": "Model_Utilities_UpsertByServerScript", | ||
"Indent": "2", | ||
"ItemOnly": "1", | ||
"Include": "Results,Issues" | ||
} |
92 changes: 92 additions & 0 deletions
92
...santer/App_Data/Definitions/Definition_Code/Model_Utilities_UpsertByServerScript_Body.txt
This file contains 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,92 @@ | ||
public static bool UpsertByServerScript( | ||
Context context, | ||
SiteSettings ss, | ||
string previousTitle, | ||
object model) | ||
{ | ||
var api = context.RequestDataString.Deserialize<Api>(); | ||
var #modelName#ApiModel = context.RequestDataString.Deserialize<#ModelName#ApiModel>(); | ||
if (api?.Keys?.Any() != true || #modelName#ApiModel == null) | ||
{ | ||
context.InvalidJsonData = !context.RequestDataString.IsNullOrEmpty(); | ||
return false; | ||
} | ||
api.View = api.View ?? new View(); | ||
api.Keys.ForEach(columnName => | ||
{ | ||
var objectValue = #modelName#ApiModel.ObjectValue(columnName: columnName); | ||
if (objectValue != null) | ||
{ | ||
api.View.AddColumnFilterHash( | ||
context: context, | ||
ss: ss, | ||
column: ss.GetColumn( | ||
context: context, | ||
columnName: columnName), | ||
objectValue: objectValue); | ||
api.View.AddColumnFilterSearchTypes( | ||
columnName: columnName, | ||
searchType: Column.SearchTypes.ExactMatch); | ||
} | ||
}); | ||
var #modelName#Model = new #ModelName#Model( | ||
context: context, | ||
ss: ss, | ||
#modelName#Id: 0, | ||
view: api.View, | ||
#modelName#ApiModel: #modelName#ApiModel); | ||
switch (#modelName#Model.AccessStatus) | ||
{ | ||
case Databases.AccessStatuses.Selected: | ||
break; | ||
case Databases.AccessStatuses.NotFound: | ||
return CreateByServerScript( | ||
context: context, | ||
ss: ss, | ||
model: model); | ||
default: | ||
return false; | ||
} | ||
var invalid = #ModelName#Validators.OnUpdating( | ||
context: context, | ||
ss: ss, | ||
#modelName#Model: #modelName#Model, | ||
api: true, | ||
serverScript: true); | ||
switch (invalid.Type) | ||
{ | ||
case Error.Types.None: | ||
break; | ||
default: | ||
return false; | ||
} | ||
#modelName#Model.SiteId = ss.SiteId; | ||
#modelName#Model.SetTitle( | ||
context: context, | ||
ss: ss); | ||
#modelName#Model.VerUp = Versions.MustVerUp( | ||
context: context, | ||
ss: ss, | ||
baseModel: #modelName#Model); | ||
var errorData = #modelName#Model.Update( | ||
context: context, | ||
ss: ss, | ||
notice: true, | ||
previousTitle: previousTitle); | ||
switch (errorData.Type) | ||
{ | ||
case Error.Types.None: | ||
if (model is Libraries.ServerScripts.ServerScriptModelApiModel serverScriptModelApiModel) | ||
{ | ||
if (serverScriptModelApiModel.Model is #ModelName#Model data) | ||
{ | ||
data.SetByModel(#modelName#Model: #modelName#Model); | ||
} | ||
} | ||
return true; | ||
case Error.Types.Duplicated: | ||
return false; | ||
default: | ||
return false; | ||
} | ||
} |
Oops, something went wrong.