|
Hi, all!
Here is the problem:
I'm writting some code that gets HTML page, and then grabs it's content. The content of the page is organized in multiple pages, and navigation between them is done by clicking on the page's number below the records (For example, there are 150 records, displayed in 10 pages * 15 records/page. Therefore, the web page contains 10 hyperlinks to other pages with records). Obviously, in order to get all the information needed, I need to loop through all the pages' links, download their HTML and afterwards parse the information.
The problem is, that I can only download 2 pages from the list. For some unknown reason, my code freeses after it downloads 2 pages. The order of the pages does not matter, for example if I start from page #5, I can only get pages 5 and 6.
According to common sense and VS debugger the problem lies in the method, that downloads HTML code
public delegate byte[] getHTTPdelegate(Uri address);
public void downloadPage(string URL)
{
client = new WebClient();
getHTTPdelegate dl = client.DownloadData;
IAsyncResult ar = dl.BeginInvoke(new Uri(URL), null, null);
while (!ar.IsCompleted)
{
Thread.Sleep(10);
}
rawPage = dl.EndInvoke(ar);
}
After downloading page #2, the application stops, and in a minute ar two throws an unhandled exception stating that operation has timed out.
Please note, that the problem is not "why isn't it working?", but "why does it work only 2 times?", when it should be downloading all the pages.
Any ideas will be highly appreciated.
|
|
|
|
|
The sleep loop is a bad idea and the downloading is not really asynchronous (because you're just waiting for it)
Did you know WebClient has a method called DownloadDataAsync?
I don't know why it's working twice.
|
|
|
|
|
Thanks for a reply, Harlod.
I know about DownloadDataAsync, but I didn't try that. Now, I will try that, and post the result.
UPDATE: I've implemented downloading via DownloadDataAsync, but still the problem of 2 pages remained Also, the same exception was thrown.
modified on Saturday, June 26, 2010 10:11 AM
|
|
|
|
|
im tring to UnSerialize that string:
="1.0"="UTF-8"
<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" method="auth.createToken" status="ok">
<error code="21" text="One of the parameter values is invalid" info="api_key"/>
</result>
But when i acess the properties it crash program with a null exception
wheres my class:
[XmlRoot("result")]
public class ResultMessage
{
[XmlIgnore]
public const string StatusOk = "ok";
[XmlIgnore]
public const string StatusFail = "fail";
[XmlAttribute("method")]
public string _method;
public string Method
{
get { return _method; }
}
[XmlAttribute("status")]
public string _status;
public string Status
{
get { return _status; }
}
[XmlElement("error")]
[XmlAttribute("status")]
public int _errorcode;
public ErrorCode ErrorCode
{
get { return (ErrorCode)_errorcode; }
}
[XmlElement("error")]
[XmlAttribute("text")]
public string _errortext;
public string ErrorText
{
get { return _errortext; }
}
[XmlElement("error")]
[XmlAttribute("info")]
public string _errorinfo;
public string ErrorInfo
{
get { return _errorinfo; }
}
public ResultMessage()
{
_errorcode = 0;
}
Thanks
|
|
|
|
|
Hello,
I want to concatenate RTF texts from database and show them in a rich textbox as a single document without loosing formating.
I have one record like this
{\rtf1\ansi\ansicpg1252\uc1\deff0{\fonttbl
{\f0\fswiss\fcharset0\fprq2 Arial;}
{\f1\froman\fcharset2\fprq2 Symbol;}}
{\colortbl;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue0;}
{\stylesheet{\s0\itap0\nowidctlpar\f0\fs24 [Normal];}{\*\cs10\additive Default Paragraph Font;}}
{\*\generator TX_RTF32 14.0.520.503;}
\deftab1134\paperw12240\paperh15840\margl1138\margt1138\margr1138\margb1138\widowctrl\formshade\sectd
\headery720\footery720\pgwsxn12240\pghsxn15840\marglsxn1138\margtsxn1138\margrsxn1138\margbsxn1138\pard\itap0\nowidctlpar\plain\f0\fs18\cf3 hello\par }
and another record like
{\rtf1\ansi\ansicpg1252\uc1\deff0{\fonttbl
{\f0\fswiss\fcharset0\fprq2 Arial;}
{\f1\froman\fcharset2\fprq2 Symbol;}}
{\colortbl;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue0;}
{\stylesheet{\s0\itap0\nowidctlpar\f0\fs24 [Normal];}{\*\cs10\additive Default Paragraph Font;}}
{\*\generator TX_RTF32 14.0.520.503;}
\deftab1134\paperw12240\paperh15840\margl1138\margt1138\margr1138\margb1138\widowctrl\formshade\sectd
\headery720\footery720\pgwsxn12240\pghsxn15840\marglsxn1138\margtsxn1138\margrsxn1138\margbsxn1138\pard\itap0\nowidctlpar\plain\f0\fs18\cf3 world\par }
The output of first string is Hello & second is World
I want to display this in a RTF Editor as follows
Hello
World
how can I do that? Any help would be appreciated.....
Thanks
Sebastian
|
|
|
|
|
I found a neat little workaround that you could try -
1. Create two instances of RichTextBox in the application.
2. Load the first RTF file into the first RichTextBox control.
3. Select and copy the content in the first RichTextBox control to
Clipboard by calling the SelectAll and Copy methods of the RichTextBox
class.
4. Paste the content (from Clipboard) to the second RichTextBox control by
calling the RichTextBox.Paste method.
That should give you merged rtf text...
|
|
|
|
|
Thanks abhinav...I was thinking this way, & most probably I will fllow this, unless I find a better solution...
thanks for your thoughts
Sebastian
|
|
|
|
|
NRTFTree - A class library for RTF processing in C#[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi All,
I have asked this question twice already in the last hour but for what ever reason I was not able to locate my posts so here I go again. I would like to create a windows app in C# that will insert data from a text file into a table. What can I use to create my table if I'm not creating a web doc? Is it possible to read text file into a record set using C#? I did some research on this topic and only found solutions created in VB5 an VB6. Thank you in advance for your reply.
modified on Saturday, June 26, 2010 1:26 AM
|
|
|
|
|
You might find some clues here[^]. The article addresses the problem of reading text (in csv form) into a recordset. You could then use your recordset to populate a datagrid. If your text file isn't in csv format, look into parsing functions to separate the text into whatever format you need.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
ASPnoob wrote: I was not able to locate my posts
Just go to your home page (see the link at the top of the page with your user name) and click on messages.
It's time for a new signature.
|
|
|
|
|
I checked for him - they weren't there. I suspect he may have posted at the time the site changed over.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
OK thanks. It's just that I've seen this question more than once recently so I assumed (from his userid) that he really was new to the site.
It's time for a new signature.
|
|
|
|
|
i need a very simple chat application can any one help me
to get the basic idea i dont want a complex code
must be simple to understand
|
|
|
|
|
Google!
Try just three words from your question: "simple chat application" and you will get more than 2,000,000 links. Lazy, lazy, lazy...
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
OriginalGriff wrote: Lazy, lazy, lazy...
That doesn't seem fair. Would you read 2,000,000 web pages? Besides, he already started, see the next thread.
|
|
|
|
|
Sorry.
I must remember that nobody wants to read these days.
When I got started, we would have killed for access to 2 web pages worth of info, never mind 2,000,000. We had to go to a bookshop and pay for info! And then read 2,000,000 pages to find the bit we wanted.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
OriginalGriff wrote: We had to go to a bookshop and pay for info!
And that worked rather well. Of course the universe was a bit smaller then; all of VAX/VMS fitted on a single book shelf, and all of Mac OS in 7 volumes. Nowadays one gets millions of references, all overlapping and contradicting each other.
|
|
|
|
|
This must be one of the most common questions in these forums; all asked by people who never seem to have heard of this[^].
It's time for a new signature.
|
|
|
|
|
|
Here are two general points:
1. Create one database installed on server
2. Develop application / chat form which you will get last inserted message from users
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
public Boolean valid()
{
for (int i=0; i < cmbSampleName.Items.Count; i++)
{
if (txtSampleName.Text == cmbSampleName.Items[i].ToString())
{
return true;
break;
}
else
{
return false;
}
}
}
i want to check weather the current text in textbox is present in combobox or not
plz help
|
|
|
|
|
Your code makes no sense, you're only checking the first item.
Also, you're not returning anything if there are no items in the combobox, which is why you have a compile error.
Maybe this is what you wanted? (warning: untested!)
public bool IsValid()
{
for (int i = 0; i < cmbSampleName.Items.Count; i++)
{
if (txtSampleName.Text == cmbSampleName.Items[i].ToString())
return true;
}
return false;
}
|
|
|
|
|
I suggest stepping through it with the debugger and paying attention to what it does.
If you cannot do that, then trace through the code manually setting i to 0 and considering both cases where if is true and where it is false. Then ask what happens if i is 1 - can it get there?.
Here's a clue - it will not reach the break line.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
He won't be able to step through it as the code won't compile.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|