Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 20 of 22 total
Thread New User Feedback
Wed, Apr 23 2014 1:41 PMPermanent Link

Chris Clark

Thanks for that uli

Thats pretty similar to where I am headed, yet to dabble in replication though. I'll be using datasnap for firemonkey and probably https access for EWB rather than STunnel.
Wed, Apr 23 2014 2:32 PMPermanent Link

Raul

Team Elevate Team Elevate

On 4/23/2014 11:28 AM, Chris Clark wrote:
> Thanks for that, just had a quick wander through the web server, now I know how it works and the TEWBdatabase and TEWBdataset components work in delphi what do I miss by not using the built in webserver?

Nothing really - Tim has made it really simple to get the data in/out
using the EWB web server (whether with modules or just direct to
supported databases). Not using it simply means more work for you but
all the specs are published (like json and update etc) etc so it's just
your work.

We already had a web server in our app so we just extended it to support
the EWB JSON as it was easier than to add EWB web server to the mix. And
we already had SSL support in the web server so it applies to ewb apps.
However on flip side we did not fully implement the EWB JSON for updates
but rather just use the TServerRequest to post data to our web server
and then do a refesh of the dataset in ewb app to see changes.

Raul

Wed, Apr 23 2014 3:09 PMPermanent Link

Chris Clark

Hi Raul

Thanks for that, out of interest, how do you find maintaining your own webserver, I've pretty much made all design choices except for whether I should roll my own webserver or use iis. On the one hand iis is there and already had all the ui for admin of virtual hosts, DSL certs etc and performance and scalability is there without much thought.. But on the other hand it could be a deployment headache with virtual directories isapi extensions, application pools and 32 vs 64 bitness et al.
Wed, Apr 23 2014 5:29 PMPermanent Link

Walter Matte

Tactical Business Corporation


Chris

I rolled my own server too, using Real Thin Client (RTC) components.  Out of the box RTC has as a demo of full blown HTTP Server which could be extended.

I just built my own but "borrowed" all the file serving code from the demo web server.  So all HTML, JS, Graphics etc.

I had never worked with JSON before, but lots with XML... I just went and found a good JSON library.

I have posted my routine DataSetToJSON here...   http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=3624#3624

I haven't implemented Blob Graphics yet, but have observed how Tim's framework does it.  
http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=4093#4093

Here is my routine that takes the EWB Commit JSON and does the Inserts, Updates or Deletes from the tables - I make sure all of the tables used have a unique primary key.  I was surprised how little code it took.


function TdmDBISAM.EWBCommit(sJSON: string): string;
var
 json: TJSONObject;
 jbefore: TJSONObject;
 jafter: TJSONObject;                                  
 sTable, sOperation, sKey : string;
 i,j : integer;
begin

 json := TJSONObject.Create(sJson);
 try
    if json['operations'].AsArray.Count > 0 then
    begin
      for i := 0 to json['operations'].AsArray.Count - 1 do
      begin
        sTable     := json['operations'].AsArray[i].AsObject['dataset'].AsString;       
        sOperation := json['operations'].AsArray[i].AsObject['operation'].AsString;       
        if not json['operations'].AsArray[i].AsObject['beforerow'].IsNull then
        begin  
          jbefore     := json['operations'].AsArray[i].AsObject['beforerow'].AsObject;    
        end;
        if not json['operations'].AsArray[i].AsObject['afterrow'].IsNull then
        begin
          jafter    := json['operations'].AsArray[i].AsObject['afterrow'].AsObject;    
        end;

        if sOperation = '1' then
        begin
          tbX.TableName := sTable;
          tbX.Open;
          tbX.Insert;
        
          for j := 0 to jafter.ValueCount - 1 do
          begin
            if not jafter.ValueByIndex[j].IsNull then
            begin
              if (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftDateTime) or
                 (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftTime) or
                 (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftDate) or
                 (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftTimeStamp) then
              begin   
                tbX.FieldByName(jafter.ValueByIndex[j].Name).AsDateTime := UNIXTimeToDateTimeFAST(jafter.ValueByIndex[j].AsInt64);
              end
              else
              begin
                tbX.FieldByName(jafter.ValueByIndex[j].Name).AsString := jafter.ValueByIndex[j].AsString;
              end;
            end;                    
          end;
          
          tbX.Post;
          tbX.Close;
        end;

        if sOperation = '2' then
        begin
          tbX.TableName := sTable;
          tbX.Open;
          for j := 0 to tbX.IndexDefs.Count - 1 do
          begin
            //if (ixUnique in tbX.IndexDefs[j].Options) then   
            if (ixPrimary in tbX.IndexDefs[j].Options) then   
            begin
              sKey := tbX.IndexDefs[j].Fields;
              Break;
            end;
          end;
          
          if tbX.Locate(sKey, jbefore.Values[sKey].AsString, []) then
          begin
            tbX.Edit;
            for j := 0 to jafter.ValueCount - 1 do
            begin
              if ((jbefore.ValueByIndex[j].IsNull) and (not jafter.ValueByIndex[j].IsNull)) or
                 ((not jbefore.ValueByIndex[j].IsNull) and (jafter.ValueByIndex[j].IsNull)) or
                 (
                  ((not jbefore.ValueByIndex[j].IsNull) and (not jafter.ValueByIndex[j].IsNull)) and
                   (jbefore.ValueByIndex[j].AsString <> jafter.ValueByIndex[j].AsString)
                 ) then
              begin
                if (jafter.ValueByIndex[j].IsNull) then
                begin
                  tbX.FieldByName(jafter.ValueByIndex[j].Name).Clear;
                end
                else if (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftDateTime) or
                        (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftTime) or
                        (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftDate) or
                        (tbX.FieldByName(jafter.ValueByIndex[j].Name).DataType = ftTimeStamp) then
                begin   
                  tbX.FieldByName(jafter.ValueByIndex[j].Name).AsDateTime := UNIXTimeToDateTimeFAST(jafter.ValueByIndex[j].AsInt64);
                end
                else
                begin
                  tbX.FieldByName(jafter.ValueByIndex[j].Name).AsString := jafter.ValueByIndex[j].AsString;
                end;
              end;
            end;
            tbX.Post;
          end;
          tbX.Close;
        end;

        if sOperation = '3' then
        begin
          tbX.TableName := sTable;
          tbX.Open;
          for j := 0 to tbX.IndexDefs.Count - 1 do
          begin
            //if (ixUnique in tbX.IndexDefs[j].Options) then   
            if (ixPrimary in tbX.IndexDefs[j].Options) then   
            begin
              sKey := tbX.IndexDefs[j].Fields;
              Break;
            end;
          end;
          
          if tbX.Locate(sKey, jbefore.Values[sKey].AsString, []) then
            tbX.Delete;
          tbX.Close;
        end;        
      end;
    end;
 finally
   json.Free;
 end;

end;


Walter
Wed, Apr 23 2014 7:29 PMPermanent Link

Raul

Team Elevate Team Elevate

On 4/23/2014 3:09 PM, Chris Clark wrote:
> Thanks for that, out of interest, how do you find maintaining your own webserver, I've pretty much made all design choices except for whether I should roll my own webserver or use iis. On the one hand iis is there and already had all the ui for admin of virtual hosts, DSL certs etc and performance and scalability is there without much thought.. But on the other hand it could be a deployment headache with virtual directories isapi extensions, application pools and 32 vs 64 bitness et al.

In our case we needed the flexibility over scalability so built-in web
server was the way to go. The again we don't use it for general purpose
internet facing file hosting much. Looked briefly at IIS and it would
have been difficult to manage for our business logic side and likely a
nightmare to support.

Current one we have Indy based though customized for us and works very
well.

Longer term (when we have some free time) i'd like to switch over to
http.sys based one. That would include almost all the IIS benefits (OS
level certs, scalability, etc) and yet retain all the flexibility.
Synopse/Mormot has published a version (gpl though i think) and TMS
shipped a component (Sparkle) so i might just look into one of those at
some point.


Raul
Wed, Apr 23 2014 9:40 PMPermanent Link

Robert Horbury-Smith

Raul wrote:

> Longer term (when we have some free time) i'd like to switch over to
> http.sys based one. That would include almost all the IIS benefits
> (OS level certs, scalability, etc) and yet retain all the
> flexibility.  Synopse/Mormot has published a version (gpl though i
> think) and TMS shipped a component (Sparkle) so i might just look
> into one of those at some point.

That's really interesting Rual.

I've been looking at mORMot for a back end and am deeply impressed
(still haven't digested how to run it with an already implimented
database - it seems to want to impliment it's own).

At the moment I'm debating how to front end it with my peers (peers are
arguing for a rich database grid so I may have a fight on my hands to
front end it with EWB).

It won't be for a few months yet till I can look at it in depth but if
we go the EWB path I'll post back here when some of the research has
been completed.

If you beat me to it, can you let us know how you go?


Robert
Thu, Apr 24 2014 12:53 AMPermanent Link

Gruetzmacher

hello chris,
this is exactly where i got stuck ... ! so i am very thankful for a hands-on backend example!
i ordered ewb but never used it (wanted to wait for the anchors anyway)

i would imagine to have a web application like this:
- frontend sends request to webserver to receive json-data
- webserver (probably tim's webserver - does it run on linux too? (the edb-server nowadays is able to ...)) handles request by calling edb-database and produces json
- i absolutely have no idea in which way i should provide modules to have the webserver logic ... totally newbie
- the traffic should be secure (ssl - i have no idea how to do this)
- the frontend renders the json in a grid
- i would need something like add/edit/post record as well

so if the sample-application you provide could provide these things i would be extremely happy. i am interested in phonegap as well to provide the user a native experience on there handhelds. but web is just as fine (in the beginning)

i guess there are quite some people like me ...

thank you very much!

Chris Clark wrote:

Hi Tim

Just a bit of feedback from a new user to EWB which I thought might be useful. I've been an EDB customer for a while, am a Delphi Developer and need a web portal for our small ERP app.

I've evaluated EWB probably 3 or 4 times, and always been unable to get a proof of concept which I'm happy with. The stumbling block has also been SSL support. I loved the dataset functionality in the built in web server but for a public facing app SSL was a must. I was a little wary of going down the 'roll your own json' approach as in reality I've little experience of json and parsing json to apply the updates seemed like some work, what I was looking for was dataset like functionality. I looked at the PHP dataset provider, but again, a decent learning curve with php.

We were going to go with ASP.NET but in the final evals, the speed of front end development was so quick in EWB I decided to bite the bullet and look at json at the back end.

Now, having looked at actually building json in Delphi with the use of the EWB adapters it is trivial, and you can deploy using webbroker, data snap et al. once you've figured out how it works. The problem is there are no examples and certainly a couple of 'gotchas' particularly with turning off caching in TWebresponse for the browser in the IDE to not cache the data.

Which is kind of my point, for Windows Delphi Developers looking to move to the web with little or no experience of json I think it would be a great idea to put together some simple Delphi server side demos which work out of the box.

I would have expected me to be the perfect target customer for EWB, already having EDB but almost didn't purchase because I couldn't see a working example of how I could easily create the solution I needed.

Anyhow, I'm now a happy customer.

Hope this is in some way helpful.
Thu, Apr 24 2014 2:06 AMPermanent Link

alexza

Chris Clark wrote:
"Which is kind of my point, for Windows Delphi Developers looking to move to the web with little or no experience of json I think it would be a great idea to put together some simple Delphi server side demos which work out of the box."

Thanks a lot Chris,
for expressing my feeling better than I could have done.

Please, anyone who has the chance, post some roll out of the box little example.

Alex
Thu, Apr 24 2014 8:32 AMPermanent Link

Matthew Jones

> 3. Android application built with Firemonkey: no solution till now
> except embedding a browser component and displaying the EWB
> application without browser. But looks nice and is a simple
> solution.

Seems an odd way to do this - you can PhoneGap an EWB application easily (despite
what the Delphi Hater's blog may say!). If you want to use FireMonkey, you can use
the same API's that EWB would - they are just http calls (or whatever you are using
for the server).

/Matthew Jones/
Thu, Apr 24 2014 8:32 AMPermanent Link

Matthew Jones

I think it is also worth stating that if you don't want to talk "directly" to a
database, then you can do it many other ways. I have never used the database
facilities in EWB as I talk to the servers using either REST or the RemObjects SDK
facilities. The database is handled in the Windows Service that acts as the web
server, but the "get me the product info" call doesn't care whether it is from a
database or a donut.

/Matthew Jones/
« Previous PagePage 2 of 3Next Page »
Jump to Page:  1 2 3
Image