delphimvcframework
delphimvcframework copied to clipboard
DMVCFramework Project Wizard Feature request.
Currently when you create a "DelphiMVCFramework Project" the Project Wizard displays:

Would it be possible to add a Radio Group like the uniGUI one ? (see below):

Offering "Standalone Server", "Windows Service App", "Standalone Server / ISAPI Module" and "ISAPI Module" as shown above ??
My thoughts on the "Standalone Server / ISAPI Module" are it would generate code like:
` {$define DMVC_ISAPI} // Comment out this line to turn this project into an STANDALONE CONSOLE
{$ifndef DMVC_ISAPI} program Project1; {$APPTYPE CONSOLE} {$else} library; {$endif}
uses {$ifndef DMVC_ISAPI} System.SysUtils, MVCFramework.Logger, MVCFramework.Commons, MVCFramework.REPLCommandsHandlerU, Web.ReqMulti, Web.WebReq, Web.WebBroker, IdHTTPWebBrokerBridge, {$else} Winapi.ActiveX, System.Win.ComObj, System.SysUtils, MVCFramework.Logger, MVCFramework.Commons, MVCFramework.REPLCommandsHandlerU, Web.ReqMulti, Web.WebReq, Web.WebBroker, Web.Win.ISAPIApp, Web.Win.ISAPIThreadPool, IdHTTPWebBrokerBridge, {$endif} Unit1 in 'Unit1.pas', Unit2 in 'Unit2.pas' {BlogWebModule: TWebModule};
{$ifndef DMVC_ISAPI} {$R *.res}
procedure RunServer(APort: Integer);
var
lServer: TIdHTTPWebBrokerBridge;
lCustomHandler: TMVCCustomREPLCommandsHandler;
lCmd: string;
begin
Writeln('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
if ParamCount >= 1 then
lCmd := ParamStr(1)
else
lCmd := 'start';
lCustomHandler := function(const Value: String; const Server: TIdHTTPWebBrokerBridge; out Handled: Boolean): THandleCommandResult
begin
Handled := False;
Result := THandleCommandResult.Unknown;
// Write here your custom command for the REPL using the following form...
// ***
// Handled := False;
// if (Value = 'apiversion') then
// begin
// REPLEmit('Print my API version number');
// Result := THandleCommandResult.Continue;
// Handled := True;
// end
// else if (Value = 'datetime') then
// begin
// REPLEmit(DateTimeToStr(Now));
// Result := THandleCommandResult.Continue;
// Handled := True;
// end;
end;
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
{ more info about MaxConnections
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_MaxConnections.html }
LServer.MaxConnections := 0;
{ more info about ListenQueue
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_ListenQueue.html }
LServer.ListenQueue := 200;
WriteLn('Write "quit" or "exit" to shutdown the server');
repeat
if lCmd.IsEmpty then
begin
Write('-> ');
ReadLn(lCmd)
end;
try
case HandleCommand(lCmd.ToLower, LServer, lCustomHandler) of
THandleCommandResult.Continue:
begin
Continue;
end;
THandleCommandResult.Break:
begin
Break;
end;
THandleCommandResult.Unknown:
begin
REPLEmit('Unknown command: ' + lCmd);
end;
end;
finally
lCmd := '';
end;
until false;
finally
LServer.Free;
end;
end;
{$else} exports GetExtensionVersion, HttpExtensionProc, TerminateExtension; {$endif} begin {$ifndef DMVC_ISAPI} ReportMemoryLeaksOnShutdown := True; IsMultiThread := True; try if WebRequestHandler <> nil then WebRequestHandler.WebModuleClass := WebModuleClass; WebRequestHandlerProc.MaxConnections := 1024; RunServer(8080); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; {$else} CoInitFlags := COINIT_MULTITHREADED; Application.Initialize; Application.WebModuleClass := WebModuleClass; Application.Run; {$endif} end.
`
Allowing a single project to be tested / run as Standalone.
Then simply comment the top line, change the extension to DLL and deploy for ISAPI.
Thanks Andrew
Yes, it is in the plans. However, we would to make the wizard a bit more general (eg. should be able to generate json-rpc projects too). We are looking for contribtors here.
Cool.. If I get any free time, I'll see what I can submit..