BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Request progress
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi WebServices SOAP
View previous topic :: View next topic  
Author Message
Peter Morris [Droopy eyes
Guest





PostPosted: Tue Oct 17, 2006 8:09 pm    Post subject: Request progress Reply with quote



Hi all

This is actually a dotnet question, but those people in the MS newsgroups
are useless, despite the fact that there are 10 times more of them!

I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

Thanks


--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====
Back to top
Bob Swart
Guest





PostPosted: Tue Oct 17, 2006 9:26 pm    Post subject: Re: Request progress Reply with quote



Hi Pete,

Quote:
I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

So you are writing a client, which makes a request, and you want the
client to show the progress, right?

Well, using a .NET client, you have the option of making the
asynchronous request, which means you have a callback function that is
called for every intermediate piece of result which is sent to you. It
would mean that the server sends you partial updates before everything
is done (so the client is notified of the next progress step), and it
might help if the client knows how much more work is expected...

Do you have any control over that kind of information (like the
filesize, which might be determined on beforehand), or do you want a
real generic solution?

Quote:
If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

It's actually easier in Delphi for .NET ;-)

Groetjes,
Bob Swart

--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
Blog: http://www.drbob42.com/blog - RSS: http://drbob42.com/weblog.xml
New Delphi 2006 Courseware e-books at http://www.eBob42.com/courseware
Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Tue Oct 17, 2006 11:04 pm    Post subject: Re: Request progress Reply with quote



Hi Bob

Quote:
So you are writing a client, which makes a request, and you want the
client to show the progress, right?

Yes. Basically I am uploading a file and then downloading a file, at the
moment this is done via FTP but the customer wants to close down all ports
except 80 (strangely the only port which they have been successfully
attacked with). I will know the upload file size but not the download file
size. Something like this

[WebMethod]
public void PutFile(string fileName, byte[] data);

[WebMethod]
public byte[] GetFile(string fileName);


Any info greatly appreciated, thanks.



--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====
Back to top
Jean-Marie Babet
Guest





PostPosted: Tue Oct 17, 2006 11:34 pm    Post subject: Re: Request progress Reply with quote

Hello Peter,

I don't know how relevant this article is anymore (and maybe you've seen it
already) but here's something that might be helpful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service11052002.asp

"Adding a ProgressBar to your Web Service Client Application".

Cheers,

Bruneau.
Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Wed Oct 18, 2006 4:15 pm    Post subject: Re: Request progress Reply with quote

Hi

I will read through that as soon as I get a chance, thankyou very much!



--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====
Back to top
Deepak Shenoy (TeamB)
Guest





PostPosted: Wed Oct 18, 2006 6:26 pm    Post subject: Re: Request progress Reply with quote

Jean-Marie Babet wrote:

Quote:
Hello Peter,

I don't know how relevant this article is anymore (and maybe you've
seen it already) but here's something that might be helpful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnser
vice/html/service11052002.asp

"Adding a ProgressBar to your Web Service Client Application".


[Long message]
Wow. That was cool. I managed to finally get it to twist and turn and
actually work with my Delphi (Win32) download progress bar code
(http://www.agnisoft.com/white_papers/dlprogress/dlprogress.asp)

(Note: that project has one file referenced wrong in the server DPR
file, which btw is a Web App Debugger app. You can correct it by
editing the dpr - I no longer work there and have no access)

The Microsoft article expects you to already know the transfer size,
which honestly is silly. But then you don't get any knowledge of the
transfer size in your SoapExtension (which gets you a non-seekable
stream meaning you can't get Stream.Length() from it)

So how do you get to the length then? Response.ContentLength is your
answer, except where can you see Response? Answer: NOWHERE. I had to
use Reflector to back up the call stack a little bit and find a
reasonable place, and that's another overridden method. Heck, let me
not bore you with all of this. Here's the Extension code:

namespace DotNetProgress
{
internal class ProgressClient :
DotNetProgress.localhost.IIDownloaderservice
{
public ProgressBar Progress;
public int TransferSize;
public Form1.UpdateDelegate ProgressDelegate;
public WebResponse _Response = null;

protected override WebResponse GetWebResponse(WebRequest
request)
{
_Response = base.GetWebResponse(request);
return _Response;
}
}

public class ProgressExtension : SoapExtension
{
// Holds the original stream
private Stream m_oldStream;
// The new stream
private Stream m_newStream;
// The buffer for reading from the old stream
// and writing to the new stream
private byte[] m_bufferIn;
// The progress bar we will be incrementing
private ProgressBar m_Progress;
// The size of each read
private int m_readSize;
private int m_totalSize;
// The delegate we will invoke for updating the
// progress bar.
private Form1.UpdateDelegate m_progressDelegate;
// Used to keep track of which stream we are trying
// to chain into
private bool m_isAfterSerialization;
public override void ProcessMessage(SoapMessage message)
{
switch (message.Stage)
{
case SoapMessageStage.AfterSerialize:
// To let us know that the next ChainStream call
// will let us hook in where we want.
m_isAfterSerialization = true;
break;
case SoapMessageStage.BeforeDeserialize:
// This is where we stream through the data
SoapClientMessage clientMessage
= (SoapClientMessage)message;
if (clientMessage.Client is ProgressClient)
{
ProgressClient proxy
= (ProgressClient)clientMessage.Client;
m_Progress = proxy.Progress;
// Read 1/100th of the request at a time.
// This will give the progress bar 100
// notifications.
//m_readSize = proxy.TransferSize / 100;
m_readSize = 8192;
m_totalSize = ((int)
proxy._Response.ContentLength) / 100;
m_progressDelegate = proxy.ProgressDelegate;
}
int CurRead = 0;
while (true)
{
try
{
int bytesRead
= m_oldStream.Read(m_bufferIn,
0,
m_readSize);
if (bytesRead == 0)
{
// end of message...rewind the
// memory stream so it is ready
// to be read during deserial.
m_newStream.Seek(0,
System.IO.SeekOrigin.Begin);
return;
}

m_newStream.Write(m_bufferIn,
0,
bytesRead);


// Update the progress bar
CurRead += bytesRead;
m_Progress.Invoke(m_progressDelegate, new
object[] { CurRead, m_totalSize });
}
catch
{
// rewind the memory stream
m_newStream.Seek(0,
System.IO.SeekOrigin.Begin);
return;
}
}
}
}

public override Stream ChainStream(Stream stream)
{
if (m_isAfterSerialization)
{
m_oldStream = stream;
m_newStream = new MemoryStream();
m_bufferIn = new Byte[8192];
return m_newStream;
}
return stream;
}
// We don't have an initializer to be shared across streams
public override object GetInitializer(Type serviceType)
{
return null;
}

public override object GetInitializer(
LogicalMethodInfo methodInfo,
SoapExtensionAttribute attribute)
{
return null;
}

public override void Initialize(object initializer)
{ m_isAfterSerialization = false; }
}
}

and in the Main Form:
private void btnDownload_Click(object sender, EventArgs e)
{
ProgressClient srv = new ProgressClient();
srv.Progress = this.progressBar1;
srv.TransferSize = 8192 * 100;
srv.ProgressDelegate = new
UpdateDelegate(ProgressBarUpdate);
srv.DownloadFile(edtFileName.Text);
}

public delegate void UpdateDelegate( int CurRead, int
TotalSize);

private void ProgressBarUpdate( int CurRead, int TotalSize)
{
progressBar1.Value = CurRead / TotalSize;
Application.DoEvents();
}

If this is still confusing, let me know and I'll bundle it all up and
email. It's a wonder you're still reading this, really.

--
Deepak Shenoy (TeamB)
http://shenoyatwork.blogspot.com
Back to top
Bob Swart
Guest





PostPosted: Wed Oct 18, 2006 6:33 pm    Post subject: Re: Request progress Reply with quote

Hi Deepak,

Quote:
So how do you get to the length then? Response.ContentLength is your
answer, except where can you see Response? Answer: NOWHERE. I had to
use Reflector to back up the call stack a little bit and find a
reasonable place, and that's another overridden method. Heck, let me
not bore you with all of this. Here's the Extension code:

Thanks for sharing. One little comment:

Quote:
while (true)

I would probably code this as a "repeat ... until butesRead = 0" in
Delphi ;-)

Quote:
If this is still confusing, let me know and I'll bundle it all up and
email. It's a wonder you're still reading this, really.

I read all the way until the end ;-)

Groetjes,
Bob Swart

--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
Blog: http://www.drbob42.com/blog - RSS: http://drbob42.com/weblog.xml
New Delphi 2006 Courseware e-books at http://www.eBob42.com/courseware
Back to top
Deepak Shenoy (TeamB)
Guest





PostPosted: Wed Oct 18, 2006 7:38 pm    Post subject: Re: Request progress Reply with quote

Bob Swart wrote:

Quote:
I would probably code this as a "repeat ... until butesRead = 0" in
Delphi Wink

That's probably a better solution, honestly. I don't like While(true)
at at all, it's a kind of C legacy that refuses to go away. That code
though was not mine - it was the MSDN article code that I tweaked...

Quote:
If this is still confusing, let me know and I'll bundle it all up
and email. It's a wonder you're still reading this, really.

I read all the way until the end Wink

Pretty cool Smile Hope the code works at your end though!


--
Deepak Shenoy (TeamB)
http://shenoyatwork.blogspot.com
Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Wed Oct 18, 2006 8:00 pm    Post subject: Re: Request progress Reply with quote

Quote:
That's probably a better solution, honestly. I don't like While(true)
at at all, it's a kind of C legacy that refuses to go away

You could use

do
{
}
while (bytesRead != 0);




--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====
Back to top
Deepak Shenoy (TeamB)
Guest





PostPosted: Thu Oct 19, 2006 8:13 am    Post subject: Re: Request progress Reply with quote

Peter Morris [Droopy eyes software] wrote:

Quote:
That's probably a better solution, honestly. I don't like
While(true) at at all, it's a kind of C legacy that refuses to go
away

You could use

do
{
}
while (bytesRead != 0);

Ah yes. Good idea. Have mailed the original author of the article as
well.

--
Deepak Shenoy (TeamB)
http://shenoyatwork.blogspot.com
Back to top
Nice design, good graphic
Guest





PostPosted: Sat Mar 10, 2007 2:33 am    Post subject: RE: Request progress Reply with quote

Quote:
Hi all

This is actually a dotnet question, but those people in the MS newsgroups
are useless, despite the fact that there are 10 times more of them!

I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

Thanks


--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====


Nice design, good graphical content. I think I'll come back later again;) http://phentermines.forum-on.de

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Back to top
mmm.. nice design, I must
Guest





PostPosted: Mon Mar 12, 2007 4:15 pm    Post subject: RE: Request progress Reply with quote

Quote:
Hi all

This is actually a dotnet question, but those people in the MS newsgroups
are useless, despite the fact that there are 10 times more of them!

I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

Thanks


--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====


mmm.. nice design, I must say.. http://www.paradistc.org/italia

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Back to top
Du musst ein Fachmann sei
Guest





PostPosted: Thu Mar 15, 2007 7:19 am    Post subject: RE: Request progress Reply with quote

Quote:
Hi all

This is actually a dotnet question, but those people in the MS newsgroups
are useless, despite the fact that there are 10 times more of them!

I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

Thanks


--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====


Du musst ein Fachmann sein - wirklich guter Aufstellungsort, den du hast! http://www.paradistc.org/liberi

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Back to top
i'am really impressed!! h
Guest





PostPosted: Sat Mar 17, 2007 5:14 am    Post subject: RE: Request progress Reply with quote

Quote:
Hi all

This is actually a dotnet question, but those people in the MS newsgroups
are useless, despite the fact that there are 10 times more of them!

I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

Thanks


--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====


i'am really impressed!! http://www.sanzkdni59.org/libera

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Back to top
luogo grande:) nessun oss
Guest





PostPosted: Sun Mar 18, 2007 8:40 pm    Post subject: RE: Request progress Reply with quote

Quote:
Hi all

This is actually a dotnet question, but those people in the MS newsgroups
are useless, despite the fact that there are 10 times more of them!

I was just wondering if there is a way to get the upload/download progress
of a request when that request sends/receives a large binary?

If you know how to do it in C# that would be great, if you know how to do it
in Win32 the info would still be appreciated!

Thanks


--
Pete

Blessed are the geek, for they shall public class GeekEarth : Earth {}
====
Audio compression components, DIB graphics controls, ECO extensions,
FastStrings
http://www.droopyeyes.com
====


luogo grande:) nessun osservazioni! http://www.paradistc.org/sardinia

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi WebServices SOAP All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.