Commit 071af034 by Mac Stephens

Refactor dropdown to use project wide server backed management and reuse the…

Refactor dropdown to use project wide server backed management and reuse the name manager for application/assigned flows. Deployed 0.8.7
parent 8c9083aa
...@@ -20,7 +20,7 @@ type ...@@ -20,7 +20,7 @@ type
FUnauthorizedAccessProc: TUnauthorizedAccessProc; FUnauthorizedAccessProc: TUnauthorizedAccessProc;
public public
const clientVersion = '0.8.6'; const clientVersion = '0.8.7';
procedure InitApp(SuccessProc: TSuccessProc; procedure InitApp(SuccessProc: TSuccessProc;
UnauthorizedAccessProc: TUnauthorizedAccessProc); UnauthorizedAccessProc: TUnauthorizedAccessProc);
procedure SetClientConfig(Callback: TVersionCheckCallback); procedure SetClientConfig(Callback: TVersionCheckCallback);
......
...@@ -94,13 +94,13 @@ ...@@ -94,13 +94,13 @@
<DCC_RemoteDebug>false</DCC_RemoteDebug> <DCC_RemoteDebug>false</DCC_RemoteDebug>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=0.8.6.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.8.0;Comments=;LastCompiledTime=2018/08/27 15:18:29</VerInfo_Keys> <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=0.8.7.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.8.0;Comments=;LastCompiledTime=2018/08/27 15:18:29</VerInfo_Keys>
<AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode> <AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode>
<VerInfo_MajorVer>0</VerInfo_MajorVer> <VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>8</VerInfo_MinorVer> <VerInfo_MinorVer>8</VerInfo_MinorVer>
<VerInfo_Release>6</VerInfo_Release> <VerInfo_Release>7</VerInfo_Release>
<TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebBrowser>1</TMSWebBrowser> <TMSWebBrowser>1</TMSWebBrowser>
<TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebSingleInstance>1</TMSWebSingleInstance> <TMSWebSingleInstance>1</TMSWebSingleInstance>
<TMSWebOutputPath>..\emT3XDataServer\bin\static</TMSWebOutputPath> <TMSWebOutputPath>..\emT3XDataServer\bin\static</TMSWebOutputPath>
</PropertyGroup> </PropertyGroup>
......
...@@ -8,9 +8,9 @@ uses ...@@ -8,9 +8,9 @@ uses
type type
TGetOptionsEvent = reference to function(const AFieldName: string): TJSArray; TGetOptionsEvent = reference to function(const AFieldName: string): TJSArray;
TFocusTriggerEvent = reference to procedure(const ATriggerId: string); TFocusTriggerEvent = reference to procedure(const ATriggerId: string);
TAddAssignedNameEvent = reference to procedure(const ARowIndex: Integer; const ANewName: string); TAddManagedNameEvent = reference to procedure(const AFieldName: string; const ARowIndex: Integer; const ANewName: string);
TRenameAssignedNameEvent = reference to procedure(const AOldName, ANewName: string); TRenameManagedNameEvent = reference to procedure(const AFieldName, AOldName, ANewName: string);
TDeleteAssignedNameEvent = reference to procedure(const AName: string); TDeleteManagedNameEvent = reference to procedure(const AFieldName, AName: string);
TNameManager = class TNameManager = class
private private
...@@ -20,9 +20,9 @@ type ...@@ -20,9 +20,9 @@ type
FCurrentEditName: string; FCurrentEditName: string;
FGetOptions: TGetOptionsEvent; FGetOptions: TGetOptionsEvent;
FFocusTrigger: TFocusTriggerEvent; FFocusTrigger: TFocusTriggerEvent;
FAddAssignedName: TAddAssignedNameEvent; FAddManagedName: TAddManagedNameEvent;
FRenameAssignedName: TRenameAssignedNameEvent; FRenameManagedName: TRenameManagedNameEvent;
FDeleteAssignedName: TDeleteAssignedNameEvent; FDeleteManagedName: TDeleteManagedNameEvent;
procedure AddAnotherClick(Event: TJSEvent); procedure AddAnotherClick(Event: TJSEvent);
procedure SaveClick(Event: TJSEvent); procedure SaveClick(Event: TJSEvent);
procedure NameInputKeyDown(Event: TJSEvent); procedure NameInputKeyDown(Event: TJSEvent);
...@@ -40,9 +40,9 @@ type ...@@ -40,9 +40,9 @@ type
constructor Create( constructor Create(
const AGetOptions: TGetOptionsEvent; const AGetOptions: TGetOptionsEvent;
const AFocusTrigger: TFocusTriggerEvent; const AFocusTrigger: TFocusTriggerEvent;
const AAddAssignedName: TAddAssignedNameEvent; const AAddManagedName: TAddManagedNameEvent;
const ARenameAssignedName: TRenameAssignedNameEvent; const ARenameManagedName: TRenameManagedNameEvent;
const ADeleteAssignedName: TDeleteAssignedNameEvent const ADeleteManagedName: TDeleteManagedNameEvent
); );
procedure BindControls; procedure BindControls;
...@@ -70,17 +70,17 @@ end; ...@@ -70,17 +70,17 @@ end;
constructor TNameManager.Create( constructor TNameManager.Create(
const AGetOptions: TGetOptionsEvent; const AGetOptions: TGetOptionsEvent;
const AFocusTrigger: TFocusTriggerEvent; const AFocusTrigger: TFocusTriggerEvent;
const AAddAssignedName: TAddAssignedNameEvent; const AAddManagedName: TAddManagedNameEvent;
const ARenameAssignedName: TRenameAssignedNameEvent; const ARenameManagedName: TRenameManagedNameEvent;
const ADeleteAssignedName: TDeleteAssignedNameEvent const ADeleteManagedName: TDeleteManagedNameEvent
); );
begin begin
inherited Create; inherited Create;
FGetOptions := AGetOptions; FGetOptions := AGetOptions;
FFocusTrigger := AFocusTrigger; FFocusTrigger := AFocusTrigger;
FAddAssignedName := AAddAssignedName; FAddManagedName := AAddManagedName;
FRenameAssignedName := ARenameAssignedName; FRenameManagedName := ARenameManagedName;
FDeleteAssignedName := ADeleteAssignedName; FDeleteManagedName := ADeleteManagedName;
FCurrentField := ''; FCurrentField := '';
FCurrentRowIndex := -1; FCurrentRowIndex := -1;
FCurrentTriggerId := ''; FCurrentTriggerId := '';
...@@ -257,18 +257,18 @@ begin ...@@ -257,18 +257,18 @@ begin
Exit; Exit;
end; end;
if not SameText(FCurrentField, 'assignedTo') then if not (SameText(FCurrentField, 'assignedTo') or SameText(FCurrentField, 'application')) then
Exit; Exit;
if FCurrentEditName <> '' then if FCurrentEditName <> '' then
begin begin
if Assigned(FRenameAssignedName) then if Assigned(FRenameManagedName) then
FRenameAssignedName(FCurrentEditName, newName); FRenameManagedName(FCurrentField, FCurrentEditName, newName);
end end
else else
begin begin
if Assigned(FAddAssignedName) then if Assigned(FAddManagedName) then
FAddAssignedName(FCurrentRowIndex, newName); FAddManagedName(FCurrentField, FCurrentRowIndex, newName);
end; end;
CloseManager; CloseManager;
...@@ -356,7 +356,7 @@ begin ...@@ -356,7 +356,7 @@ begin
Event.preventDefault; Event.preventDefault;
Event.stopPropagation; Event.stopPropagation;
if not SameText(FCurrentField, 'assignedTo') then if not (SameText(FCurrentField, 'assignedTo') or SameText(FCurrentField, 'application')) then
Exit; Exit;
el := TJSHTMLElement(Event.currentTarget); el := TJSHTMLElement(Event.currentTarget);
...@@ -383,7 +383,7 @@ begin ...@@ -383,7 +383,7 @@ begin
Event.preventDefault; Event.preventDefault;
Event.stopPropagation; Event.stopPropagation;
if not SameText(FCurrentField, 'assignedTo') then if not (SameText(FCurrentField, 'assignedTo') or SameText(FCurrentField, 'application')) then
Exit; Exit;
el := TJSHTMLElement(Event.currentTarget); el := TJSHTMLElement(Event.currentTarget);
...@@ -391,8 +391,8 @@ begin ...@@ -391,8 +391,8 @@ begin
if nameToDelete = '' then if nameToDelete = '' then
Exit; Exit;
if Assigned(FDeleteAssignedName) then if Assigned(FDeleteManagedName) then
FDeleteAssignedName(nameToDelete); FDeleteManagedName(FCurrentField, nameToDelete);
CloseManager; CloseManager;
end; end;
...@@ -401,7 +401,7 @@ procedure TNameManager.OpenManager(const AFieldName: string; const ARowIndex: In ...@@ -401,7 +401,7 @@ procedure TNameManager.OpenManager(const AFieldName: string; const ARowIndex: In
var var
titleEl: TJSHTMLElement; titleEl: TJSHTMLElement;
begin begin
if not SameText(AFieldName, 'assignedTo') then if not (SameText(AFieldName, 'assignedTo') or SameText(AFieldName, 'application')) then
Exit; Exit;
FCurrentField := AFieldName; FCurrentField := AFieldName;
...@@ -411,7 +411,12 @@ begin ...@@ -411,7 +411,12 @@ begin
titleEl := GetElement('nm_title'); titleEl := GetElement('nm_title');
if Assigned(titleEl) then if Assigned(titleEl) then
titleEl.innerHTML := 'Manage Assigned To'; begin
if SameText(AFieldName, 'application') then
titleEl.innerHTML := 'Manage Application'
else
titleEl.innerHTML := 'Manage Assigned To';
end;
ResetInputArea; ResetInputArea;
RenderExistingList; RenderExistingList;
......
object ApiDatabase: TApiDatabase object ApiDatabase: TApiDatabase
OnCreate = DataModuleCreate OnCreate = DataModuleCreate
Height = 453 Height = 475
Width = 641 Width = 803
object ucETaskApi: TUniConnection object ucETaskApi: TUniConnection
AutoCommit = False AutoCommit = False
ProviderName = 'MySQL' ProviderName = 'MySQL'
Database = 'eTask' Database = 'eTask'
LoginPrompt = False LoginPrompt = False
Left = 255 Left = 267
Top = 379 Top = 395
end end
object MySQLUniProvider1: TMySQLUniProvider object MySQLUniProvider1: TMySQLUniProvider
Left = 354 Left = 416
Top = 378 Top = 398
end end
object uqUsers: TUniQuery object uqUsers: TUniQuery
Connection = ucETaskApi Connection = ucETaskApi
...@@ -775,4 +775,160 @@ object ApiDatabase: TApiDatabase ...@@ -775,4 +775,160 @@ object ApiDatabase: TApiDatabase
Value = nil Value = nil
end> end>
end end
object uqProjectApplications: TUniQuery
Connection = ucETaskApi
SQL.Strings = (
'select distinct'
' tia.TASK_ITEM_APPLICATION_ID,'
' tia.PROJECT_ID,'
' tia.NAME'
'from task_item_application tia'
'join tasks target_task'
' on target_task.PROJECT_ID = tia.PROJECT_ID'
'where target_task.TASK_ID = :TASK_ID'
'order by tia.NAME')
Left = 58
Top = 314
ParamData = <
item
DataType = ftUnknown
Name = 'TASK_ID'
Value = nil
end>
object uqProjectApplicationsTASK_ITEM_APPLICATION_ID: TIntegerField
FieldName = 'TASK_ITEM_APPLICATION_ID'
end
object uqProjectApplicationsPROJECT_ID: TStringField
FieldName = 'PROJECT_ID'
Required = True
Size = 7
end
object uqProjectApplicationsNAME: TStringField
FieldName = 'NAME'
Required = True
Size = 255
end
end
object uqApplicationInsert: TUniQuery
Connection = ucETaskApi
SQL.Strings = (
'insert into task_item_application ('
' PROJECT_ID,'
' NAME'
')'
'values ('
' :PROJECT_ID,'
' :NAME'
')')
Left = 700
Top = 28
ParamData = <
item
DataType = ftUnknown
Name = 'PROJECT_ID'
Value = nil
end
item
DataType = ftUnknown
Name = 'NAME'
Value = nil
end>
end
object uqApplicationRename: TUniQuery
Connection = ucETaskApi
SQL.Strings = (
'update task_item_application'
'set NAME = :NEW_NAME'
'where TASK_ITEM_APPLICATION_ID = :TASK_ITEM_APPLICATION_ID'
' and PROJECT_ID = :PROJECT_ID')
Left = 700
Top = 82
ParamData = <
item
DataType = ftUnknown
Name = 'NEW_NAME'
Value = nil
end
item
DataType = ftUnknown
Name = 'TASK_ITEM_APPLICATION_ID'
Value = nil
end
item
DataType = ftUnknown
Name = 'PROJECT_ID'
Value = nil
end>
end
object uqApplicationDelete: TUniQuery
Connection = ucETaskApi
SQL.Strings = (
'delete from task_item_application'
'where TASK_ITEM_APPLICATION_ID = :TASK_ITEM_APPLICATION_ID'
' and PROJECT_ID = :PROJECT_ID')
Left = 700
Top = 136
ParamData = <
item
DataType = ftUnknown
Name = 'TASK_ITEM_APPLICATION_ID'
Value = nil
end
item
DataType = ftUnknown
Name = 'PROJECT_ID'
Value = nil
end>
end
object uqRenameTaskItemApplication: TUniQuery
Connection = ucETaskApi
SQL.Strings = (
'update task_items ti'
'join tasks t'
' on t.TASK_ID = ti.TASK_ID'
'set ti.APPLICATION = :NEW_NAME'
'where t.PROJECT_ID = :PROJECT_ID'
' and lower(ti.APPLICATION) = lower(:OLD_NAME)')
Left = 698
Top = 188
ParamData = <
item
DataType = ftUnknown
Name = 'NEW_NAME'
Value = nil
end
item
DataType = ftUnknown
Name = 'PROJECT_ID'
Value = nil
end
item
DataType = ftUnknown
Name = 'OLD_NAME'
Value = nil
end>
end
object uqBlankTaskItemApplication: TUniQuery
Connection = ucETaskApi
SQL.Strings = (
'update task_items ti'
'join tasks t'
' on t.TASK_ID = ti.TASK_ID'
'set ti.APPLICATION = '#39#39
'where t.PROJECT_ID = :PROJECT_ID'
' and lower(ti.APPLICATION) = lower(:NAME)')
Left = 696
Top = 244
ParamData = <
item
DataType = ftUnknown
Name = 'PROJECT_ID'
Value = nil
end
item
DataType = ftUnknown
Name = 'NAME'
Value = nil
end>
end
end end
...@@ -73,6 +73,15 @@ type ...@@ -73,6 +73,15 @@ type
uqTaskAssignedUsersTASK_ID: TStringField; uqTaskAssignedUsersTASK_ID: TStringField;
uqTaskAssignedUsersUSER_TYPE: TStringField; uqTaskAssignedUsersUSER_TYPE: TStringField;
uqTaskAssignedUsersNAME: TStringField; uqTaskAssignedUsersNAME: TStringField;
uqProjectApplications: TUniQuery;
uqApplicationInsert: TUniQuery;
uqApplicationRename: TUniQuery;
uqApplicationDelete: TUniQuery;
uqRenameTaskItemApplication: TUniQuery;
uqBlankTaskItemApplication: TUniQuery;
uqProjectApplicationsTASK_ITEM_APPLICATION_ID: TIntegerField;
uqProjectApplicationsPROJECT_ID: TStringField;
uqProjectApplicationsNAME: TStringField;
procedure DataModuleCreate(Sender: TObject); procedure DataModuleCreate(Sender: TObject);
procedure uqUsersCalcFields(DataSet: TDataSet); procedure uqUsersCalcFields(DataSet: TDataSet);
private private
......
...@@ -48,7 +48,11 @@ type ...@@ -48,7 +48,11 @@ type
name: string; name: string;
end; end;
type TTaskApplicationOption = class
public
name: string;
end;
TTaskItemCode = class TTaskItemCode = class
public public
code: string; code: string;
...@@ -61,6 +65,7 @@ type ...@@ -61,6 +65,7 @@ type
count: integer; count: integer;
task: TTaskHeader; task: TTaskHeader;
items: TList<TTaskItem>; items: TList<TTaskItem>;
applicationOptions: TList<TTaskApplicationOption>;
reportedByOptions: TList<TTaskUserOption>; reportedByOptions: TList<TTaskUserOption>;
assignedToOptions: TList<TTaskUserOption>; assignedToOptions: TList<TTaskUserOption>;
statusOptions: TList<TTaskItemCode>; statusOptions: TList<TTaskItemCode>;
...@@ -75,6 +80,13 @@ type ...@@ -75,6 +80,13 @@ type
destructor Destroy; override; destructor Destroy; override;
end; end;
TTaskApplicationOptionsResponse = class
public
applicationOptions: TList<TTaskApplicationOption>;
constructor Create;
destructor Destroy; override;
end;
TTaskRowSave = class TTaskRowSave = class
public public
taskItemId: integer; taskItemId: integer;
...@@ -93,9 +105,6 @@ type ...@@ -93,9 +105,6 @@ type
notes: string; notes: string;
end; end;
type type
[ServiceContract, Model(API_MODEL)] [ServiceContract, Model(API_MODEL)]
IApiService = interface(IInvokable) IApiService = interface(IInvokable)
...@@ -106,6 +115,9 @@ type ...@@ -106,6 +115,9 @@ type
[HttpPost] function AddAssignedName(taskId: string; name: string): TTaskUserOptionsResponse; [HttpPost] function AddAssignedName(taskId: string; name: string): TTaskUserOptionsResponse;
[HttpPost] function RenameAssignedName(taskId: string; oldName: string; newName: string): TTaskUserOptionsResponse; [HttpPost] function RenameAssignedName(taskId: string; oldName: string; newName: string): TTaskUserOptionsResponse;
[HttpPost] function DeleteAssignedName(taskId: string; name: string): TTaskUserOptionsResponse; [HttpPost] function DeleteAssignedName(taskId: string; name: string): TTaskUserOptionsResponse;
[HttpPost] function AddApplicationName(taskId: string; name: string): TTaskApplicationOptionsResponse;
[HttpPost] function RenameApplicationName(taskId: string; oldName: string; newName: string): TTaskApplicationOptionsResponse;
[HttpPost] function DeleteApplicationName(taskId: string; name: string): TTaskApplicationOptionsResponse;
procedure MoveTaskRow(const taskId: Integer; const taskItemId: Integer; const newItemNum: Integer); procedure MoveTaskRow(const taskId: Integer; const taskItemId: Integer; const newItemNum: Integer);
function DeleteTaskRow(const taskId: Integer; const taskItemId: Integer): Boolean; function DeleteTaskRow(const taskId: Integer; const taskItemId: Integer): Boolean;
end; end;
...@@ -116,6 +128,7 @@ constructor TTaskItemsResponse.Create; ...@@ -116,6 +128,7 @@ constructor TTaskItemsResponse.Create;
begin begin
inherited; inherited;
items := TList<TTaskItem>.Create; items := TList<TTaskItem>.Create;
applicationOptions := TList<TTaskApplicationOption>.Create;
reportedByOptions := TList<TTaskUserOption>.Create; reportedByOptions := TList<TTaskUserOption>.Create;
assignedToOptions := TList<TTaskUserOption>.Create; assignedToOptions := TList<TTaskUserOption>.Create;
statusOptions := TList<TTaskItemCode>.Create; statusOptions := TList<TTaskItemCode>.Create;
...@@ -124,6 +137,7 @@ end; ...@@ -124,6 +137,7 @@ end;
destructor TTaskItemsResponse.Destroy; destructor TTaskItemsResponse.Destroy;
begin begin
items.Free; items.Free;
applicationOptions.Free;
reportedByOptions.Free; reportedByOptions.Free;
assignedToOptions.Free; assignedToOptions.Free;
statusOptions.Free; statusOptions.Free;
...@@ -142,6 +156,18 @@ begin ...@@ -142,6 +156,18 @@ begin
inherited; inherited;
end; end;
constructor TTaskApplicationOptionsResponse.Create;
begin
inherited;
applicationOptions := TList<TTaskApplicationOption>.Create;
end;
destructor TTaskApplicationOptionsResponse.Destroy;
begin
applicationOptions.Free;
inherited;
end;
initialization initialization
RegisterServiceType(TypeInfo(IApiService)); RegisterServiceType(TypeInfo(IApiService));
......
...@@ -30,6 +30,13 @@ type ...@@ -30,6 +30,13 @@ type
function DeleteAssignedName(taskId: string; name: string): TTaskUserOptionsResponse; function DeleteAssignedName(taskId: string; name: string): TTaskUserOptionsResponse;
procedure MoveTaskRow(const taskId: Integer; const taskItemId: Integer; const newItemNum: Integer); procedure MoveTaskRow(const taskId: Integer; const taskItemId: Integer; const newItemNum: Integer);
function DeleteTaskRow(const taskId, taskItemId: Integer): Boolean; function DeleteTaskRow(const taskId, taskItemId: Integer): Boolean;
function FindProjectId(const taskId: string): string;
function FindApplicationId(const taskId, name: string): Integer;
function FindApplicationName(const taskId, name: string): string;
function BuildApplicationOptionsResponse(const taskId: string): TTaskApplicationOptionsResponse;
function AddApplicationName(taskId: string; name: string): TTaskApplicationOptionsResponse;
function RenameApplicationName(taskId: string; oldName: string; newName: string): TTaskApplicationOptionsResponse;
function DeleteApplicationName(taskId: string; name: string): TTaskApplicationOptionsResponse;
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
procedure BeforeDestruction; override; procedure BeforeDestruction; override;
...@@ -58,6 +65,7 @@ var ...@@ -58,6 +65,7 @@ var
taskHeader: TTaskHeader; taskHeader: TTaskHeader;
taskUserOption: TTaskUserOption; taskUserOption: TTaskUserOption;
taskItemCode: TTaskItemCode; taskItemCode: TTaskItemCode;
taskApplicationOption: TTaskApplicationOption;
item: TTaskItem; item: TTaskItem;
begin begin
Logger.Log(4, Format('ApiService.GetTaskItems - TASK_ID="%s"', [taskId])); Logger.Log(4, Format('ApiService.GetTaskItems - TASK_ID="%s"', [taskId]));
...@@ -93,6 +101,21 @@ begin ...@@ -93,6 +101,21 @@ begin
Result.task := taskHeader; Result.task := taskHeader;
apiDB.uqProjectApplications.Close;
apiDB.uqProjectApplications.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqProjectApplications.Open;
while not apiDB.uqProjectApplications.Eof do
begin
taskApplicationOption := TTaskApplicationOption.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(taskApplicationOption);
taskApplicationOption.name := apiDB.uqProjectApplicationsNAME.AsString;
Result.applicationOptions.Add(taskApplicationOption);
apiDB.uqProjectApplications.Next;
end;
apiDB.uqProjectReportedUsers.Close; apiDB.uqProjectReportedUsers.Close;
apiDB.uqProjectReportedUsers.ParamByName('TASK_ID').AsString := taskId; apiDB.uqProjectReportedUsers.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqProjectReportedUsers.Open; apiDB.uqProjectReportedUsers.Open;
...@@ -687,6 +710,230 @@ begin ...@@ -687,6 +710,230 @@ begin
end; end;
end; end;
function TApiService.FindProjectId(const taskId: string): string;
begin
Result := '';
apiDB.uqTaskHeader.Close;
apiDB.uqTaskHeader.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqTaskHeader.Open;
if not apiDB.uqTaskHeader.IsEmpty then
Result := apiDB.uqTaskHeaderPROJECT_ID.AsString;
end;
function TApiService.FindApplicationId(const taskId, name: string): Integer;
begin
Result := 0;
apiDB.uqProjectApplications.Close;
apiDB.uqProjectApplications.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqProjectApplications.Open;
while not apiDB.uqProjectApplications.Eof do
begin
if SameText(Trim(apiDB.uqProjectApplicationsNAME.AsString), Trim(name)) then
begin
Result := apiDB.uqProjectApplicationsTASK_ITEM_APPLICATION_ID.AsInteger;
Exit;
end;
apiDB.uqProjectApplications.Next;
end;
end;
function TApiService.FindApplicationName(const taskId, name: string): string;
begin
Result := '';
apiDB.uqProjectApplications.Close;
apiDB.uqProjectApplications.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqProjectApplications.Open;
while not apiDB.uqProjectApplications.Eof do
begin
if SameText(Trim(apiDB.uqProjectApplicationsNAME.AsString), Trim(name)) then
begin
Result := apiDB.uqProjectApplicationsNAME.AsString;
Exit;
end;
apiDB.uqProjectApplications.Next;
end;
end;
function TApiService.BuildApplicationOptionsResponse(const taskId: string): TTaskApplicationOptionsResponse;
var
taskApplicationOption: TTaskApplicationOption;
begin
Result := TTaskApplicationOptionsResponse.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
apiDB.uqProjectApplications.Close;
apiDB.uqProjectApplications.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqProjectApplications.Open;
while not apiDB.uqProjectApplications.Eof do
begin
taskApplicationOption := TTaskApplicationOption.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(taskApplicationOption);
taskApplicationOption.name := apiDB.uqProjectApplicationsNAME.AsString;
Result.applicationOptions.Add(taskApplicationOption);
apiDB.uqProjectApplications.Next;
end;
end;
function TApiService.AddApplicationName(taskId: string; name: string): TTaskApplicationOptionsResponse;
var
projectId: string;
newName: string;
existingName: string;
begin
newName := Trim(name);
if newName = '' then
raise Exception.Create('Application name cannot be blank.');
projectId := FindProjectId(taskId);
if projectId = '' then
raise Exception.Create('Project not found for task.');
existingName := FindApplicationName(taskId, newName);
if existingName = '' then
begin
apiDB.uqApplicationInsert.Connection.StartTransaction;
try
apiDB.uqApplicationInsert.Close;
apiDB.uqApplicationInsert.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqApplicationInsert.ParamByName('NAME').AsString := newName;
apiDB.uqApplicationInsert.ExecSQL;
apiDB.uqApplicationInsert.Connection.Commit;
except
on E: Exception do
begin
if apiDB.uqApplicationInsert.Connection.InTransaction then
apiDB.uqApplicationInsert.Connection.Rollback;
raise;
end;
end;
end;
Result := BuildApplicationOptionsResponse(taskId);
end;
function TApiService.RenameApplicationName(taskId: string; oldName: string; newName: string): TTaskApplicationOptionsResponse;
var
projectId: string;
oldApplicationId: Integer;
existingApplicationId: Integer;
trimmedOldName: string;
trimmedNewName: string;
begin
trimmedOldName := Trim(oldName);
trimmedNewName := Trim(newName);
if trimmedOldName = '' then
raise Exception.Create('Old application name cannot be blank.');
if trimmedNewName = '' then
raise Exception.Create('New application name cannot be blank.');
projectId := FindProjectId(taskId);
if projectId = '' then
raise Exception.Create('Project not found for task.');
oldApplicationId := FindApplicationId(taskId, trimmedOldName);
if oldApplicationId = 0 then
raise Exception.Create('Application name not found.');
existingApplicationId := FindApplicationId(taskId, trimmedNewName);
apiDB.uqApplicationRename.Connection.StartTransaction;
try
apiDB.uqRenameTaskItemApplication.Close;
apiDB.uqRenameTaskItemApplication.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqRenameTaskItemApplication.ParamByName('OLD_NAME').AsString := trimmedOldName;
apiDB.uqRenameTaskItemApplication.ParamByName('NEW_NAME').AsString := trimmedNewName;
apiDB.uqRenameTaskItemApplication.ExecSQL;
if (existingApplicationId <> 0) and (existingApplicationId <> oldApplicationId) then
begin
apiDB.uqApplicationDelete.Close;
apiDB.uqApplicationDelete.ParamByName('TASK_ITEM_APPLICATION_ID').AsInteger := oldApplicationId;
apiDB.uqApplicationDelete.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqApplicationDelete.ExecSQL;
end
else
begin
apiDB.uqApplicationRename.Close;
apiDB.uqApplicationRename.ParamByName('TASK_ITEM_APPLICATION_ID').AsInteger := oldApplicationId;
apiDB.uqApplicationRename.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqApplicationRename.ParamByName('NEW_NAME').AsString := trimmedNewName;
apiDB.uqApplicationRename.ExecSQL;
end;
apiDB.uqApplicationRename.Connection.Commit;
except
on E: Exception do
begin
if apiDB.uqApplicationRename.Connection.InTransaction then
apiDB.uqApplicationRename.Connection.Rollback;
raise;
end;
end;
Result := BuildApplicationOptionsResponse(taskId);
end;
function TApiService.DeleteApplicationName(taskId: string; name: string): TTaskApplicationOptionsResponse;
var
projectId: string;
applicationId: Integer;
applicationName: string;
begin
projectId := FindProjectId(taskId);
if projectId = '' then
raise Exception.Create('Project not found for task.');
applicationId := FindApplicationId(taskId, name);
applicationName := FindApplicationName(taskId, name);
if applicationId = 0 then
raise Exception.Create('Application name not found.');
apiDB.uqApplicationDelete.Connection.StartTransaction;
try
apiDB.uqBlankTaskItemApplication.Close;
apiDB.uqBlankTaskItemApplication.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqBlankTaskItemApplication.ParamByName('NAME').AsString := applicationName;
apiDB.uqBlankTaskItemApplication.ExecSQL;
apiDB.uqApplicationDelete.Close;
apiDB.uqApplicationDelete.ParamByName('TASK_ITEM_APPLICATION_ID').AsInteger := applicationId;
apiDB.uqApplicationDelete.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqApplicationDelete.ExecSQL;
apiDB.uqApplicationDelete.Connection.Commit;
except
on E: Exception do
begin
if apiDB.uqApplicationDelete.Connection.InTransaction then
apiDB.uqApplicationDelete.Connection.Rollback;
raise;
end;
end;
Result := BuildApplicationOptionsResponse(taskId);
end;
initialization initialization
RegisterServiceType(TypeInfo(IApiService)); RegisterServiceType(TypeInfo(IApiService));
RegisterServiceType(TApiService); RegisterServiceType(TApiService);
......
[Settings] [Settings]
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=4 FileLogLevel=4
webClientVersion=0.8.6 webClientVersion=0.8.7
LogFileNum=152 LogFileNum=155
[Database] [Database]
Server=192.168.116.131 Server=192.168.102.131
--Server=192.168.116.128 --Server=192.168.116.128
--Server=192.168.102.131 --Server=192.168.102.131
--Server=192.168.159.10 --Server=192.168.159.10
......
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{2A3028D9-BC39-4625-9BA5-0338012E2824}</ProjectGuid> <ProjectGuid>{2A3028D9-BC39-4625-9BA5-0338012E2824}</ProjectGuid>
<ProjectVersion>20.4</ProjectVersion> <ProjectVersion>20.4</ProjectVersion>
...@@ -114,10 +114,10 @@ ...@@ -114,10 +114,10 @@
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
<DCC_ExeOutput>.\bin</DCC_ExeOutput> <DCC_ExeOutput>.\bin</DCC_ExeOutput>
<DCC_UnitSearchPath>C:\RADTOOLS\FastMM4;$(DCC_UnitSearchPath)</DCC_UnitSearchPath> <DCC_UnitSearchPath>C:\RADTOOLS\FastMM4;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.8.6.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys> <VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.8.7.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys>
<VerInfo_MajorVer>0</VerInfo_MajorVer> <VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>8</VerInfo_MinorVer> <VerInfo_MinorVer>8</VerInfo_MinorVer>
<VerInfo_Release>6</VerInfo_Release> <VerInfo_Release>7</VerInfo_Release>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''"> <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode> <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment