Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: where to write code



Permlink Replies: 3 - Last Post: Apr 24, 2018 9:10 AM Last Post By: Markus Humm
filter filter

Posts: 4
Registered: 2/23/07
where to write code
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 12:21 AM
Please help a little with info.
I createt app for uploading files to ftp for android. but people that are using it they forget to open it. so I need to change few things.
I want that not application uploads files to ftp but service it self!!!! is that possible? if yes then where I need to write code!!!!???????
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: where to write code
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 11:20 AM   in response to: filter filter in response to: filter filter
Am 23.04.2018 um 09:21 schrieb filter filter:
Please help a little with info.
I createt app for uploading files to ftp for android. but people that are using it they forget to open it. so I need to change few things.
I want that not application uploads files to ftp but service it self!!!! is that possible? if yes then where I need to write code!!!!???????

Hello,

I'm still uncertain about what you want.
How shall people tell your app/service/whatever which files to upload?

Where is the starting point of these people?

Greetings

Markus
filter filter

Posts: 4
Registered: 2/23/07
Re: where to write code
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 11:19 PM   in response to: Markus Humm in response to: Markus Humm
There is software witch creates jpg files on mobile. After they are created I need to move them to my nas storage via FTP protocol.
So I created software to move them and software is working only when opened but not in background :(. I'm new to programming so this is my code maybe i'm doing it wrong :(

unit Unit2;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP, FMX.Controls.Presentation, FMX.StdCtrls,
FMX.ScrollBox, FMX.Memo, FMX.Objects,
System.IOUtils, DateUtils,System.Android.Service;

type
thread1=class(TThread)
protected
procedure Execute; override;
end;

TForm2 = class(TForm)
ftp: TIdFTP;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FService: TLocalServiceConnection;
public
{ Public declarations }
workerThread: Thread1;

end;

var
Form2: TForm2;

implementation

{$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID}


procedure Thread1.Execute;
var
i:integer;
LFileName,path:string;
LList: TStringDynArray;
LListimg:TStringDynArray;
Present: TDateTime;
Year, Month, Day: Word;
loop:integer;
begin
loop:=1;
while loop=1 do
begin
present:=now;
DecodeDate(Present, Year, Month, Day);
form2.ftp.Host:='x.x.x.x';
form2.ftp.Username:='xxxxx';
form2.ftp.Password:='xxxxx';
form2.ftp.Connect;
sleep(5000);
if form2.ftp.Connected=false then
begin
form2.ftp.Connect;
form2.Label1.Text:='connecting';
end
else

begin
while form2.ftp.Connected=true do
begin
LList := TDirectory.GetFiles('/storage/emulated/0/Packman/images/'+IntToStr(year)+
'/'+IntToStr(Month));
form2.Label1.Text:='connected';
form2.ftp.ChangeDir('/PakMan/BLS/PakMan/PackMan/Images/'+IntTostr(year)+'/'+Inttostr(month));
sleep(2000);
for i:=0 to High(LList) do
begin
sleep(1000);
form2.ftp.put(LList[i],Tpath.GetFileName(LList[i]));
deletefile(LList[i]);
end;
setlength(LList,0);
llist:=nil;


begin
LListimg := TDirectory.GetFiles('/storage/emulated/0/Packman/signatures/'+IntToStr(year)+
'/'+IntToStr(Month));
form2.Label1.Text:='connected';
form2.ftp.ChangeDir('/PakMan/BLS/PakMan/PackMan/Signatures/'+IntTostr(year)+'/'+Inttostr(month));
sleep(2000);
for i:=0 to High(LListimg) do
begin
sleep(1000);
form2.ftp.put(LListimg[i],Tpath.GetFileName(LListimg[i]));
deletefile(LListimg[i]);
end;
setlength(LListimg,0);
llist:=nil;

end;

form2.ftp.Disconnect;
form2.Label4.Text:=TimeToStr(Time);
form2.label1.Text:='disconnected';
sleep(300000);
end;
end;

end;

end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Fservice:=TLocalServiceConnection.Create;
FService.StartService('SyncService');
workerThread:=Thread1.Create(false);

end;

end.

Markus Humm wrote:
Am 23.04.2018 um 09:21 schrieb filter filter:
Please help a little with info.
I createt app for uploading files to ftp for android. but people that are using it they forget to open it. so I need to change few things.
I want that not application uploads files to ftp but service it self!!!! is that possible? if yes then where I need to write code!!!!???????

Hello,

I'm still uncertain about what you want.
How shall people tell your app/service/whatever which files to upload?

Where is the starting point of these people?

Greetings

Markus

Edited by: filter filter on Apr 24, 2018 1:45 AM
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: where to write code [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 24, 2018 9:10 AM   in response to: filter filter in response to: filter filter
Hello,

do I understand you correctly: YOU have written some software which
generates JPG files on an Android device. Afterwards these files need to
be sent to a NAS, but the user shall be able to quit your application
already at that time while the transfer is still running. Correct?

if yes your transfer needs to be putin a Android service which can run
in the background. Delphi basically supports Android services and that
support might be sufficient (I just have not enough knowledge about
writing a service besides that this is a different project type and a
service may never have any GUI).

Now the question would be how the app triggers the service to start its
work.

Maybe it can be done via Android intents?

Greetings

Markus

Am 24.04.2018 um 10:45 schrieb filter filter:
There is software witch creates jpg files on mobile. After they are created I need to move them to my nas storage via FTP protocol.
So I created software to move them and software is working only when opened but not in background :(. I'm new to programming so this is my code maybe i'm doing it wrong :(

unit Unit2;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP, FMX.Controls.Presentation, FMX.StdCtrls,
FMX.ScrollBox, FMX.Memo, FMX.Objects,
System.IOUtils, DateUtils,System.Android.Service;

type
thread1=class(TThread)
protected
procedure Execute; override;
end;

TForm2 = class(TForm)
ftp: TIdFTP;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FService: TLocalServiceConnection;
public
{ Public declarations }
workerThread: Thread1;

end;

var
Form2: TForm2;

implementation

{$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID}


procedure Thread1.Execute;
var
i:integer;
LFileName,path:string;
LList: TStringDynArray;
LListimg:TStringDynArray;
Present: TDateTime;
Year, Month, Day: Word;
loop:integer;
begin
loop:=1;
while loop=1 do
begin
present:=now;
DecodeDate(Present, Year, Month, Day);
form2.ftp.Host:='x.x.x.x';
form2.ftp.Username:='xxxxx';
form2.ftp.Password:='xxxxx';
form2.ftp.Connect;
sleep(5000);
if form2.ftp.Connected=false then
begin
form2.ftp.Connect;
form2.Label1.Text:='connecting';
end
else

begin
while form2.ftp.Connected=true do
begin
LList := TDirectory.GetFiles('/storage/emulated/0/Packman/images/'+IntToStr(year)+
'/'+IntToStr(Month));
form2.Label1.Text:='connected';
form2.ftp.ChangeDir('/PakMan/BLS/PakMan/PackMan/Images/'+IntTostr(year)+'/'+Inttostr(month));
sleep(2000);
for i:=0 to High(LList) do
begin
sleep(1000);
form2.ftp.put(LList[i],Tpath.GetFileName(LList[i]));
deletefile(LList[i]);
end;
setlength(LList,0);
llist:=nil;


begin
LListimg := TDirectory.GetFiles('/storage/emulated/0/Packman/signatures/'+IntToStr(year)+
'/'+IntToStr(Month));
form2.Label1.Text:='connected';
form2.ftp.ChangeDir('/PakMan/BLS/PakMan/PackMan/Signatures/'+IntTostr(year)+'/'+Inttostr(month));
sleep(2000);
for i:=0 to High(LListimg) do
begin
sleep(1000);
form2.ftp.put(LListimg[i],Tpath.GetFileName(LListimg[i]));
deletefile(LListimg[i]);
end;
setlength(LListimg,0);
llist:=nil;

end;

form2.ftp.Disconnect;
form2.Label4.Text:=TimeToStr(Time);
form2.label1.Text:='disconnected';
sleep(300000);
end;
end;

end;

end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Fservice:=TLocalServiceConnection.Create;
FService.StartService('SyncService');
workerThread:=Thread1.Create(false);

end;

end.

Markus Humm wrote:
Am 23.04.2018 um 09:21 schrieb filter filter:
Please help a little with info.
I createt app for uploading files to ftp for android. but people that are using it they forget to open it. so I need to change few things.
I want that not application uploads files to ftp but service it self!!!! is that possible? if yes then where I need to write code!!!!???????

Hello,

I'm still uncertain about what you want.
How shall people tell your app/service/whatever which files to upload?

Where is the starting point of these people?

Greetings

Markus

Edited by: filter filter on Apr 24, 2018 1:45 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02