Showing posts with label content. Show all posts
Showing posts with label content. Show all posts

Monday, March 26, 2012

Please Help - How to do Content Gathering!

ok...here goes...

I need to be pointed in some direction on how this can be done using C#.

Lets say that there is a link for a tab delimited .txt file, or a excel spreedsheet with information that i want to get from one site and populate my database off of that information. But i want to be able to make my webapp smart enough to be able to go get this information in some kind of intervals I want (i.e. --> weekly, monthly, every 3 months...)

Can someone please point me in the right direction as to where I can find how to do this...

thanks in advance.If this has to happen on a regular basis - thus not request-based - ASP.NET is likely not the platform to use. Well, it's the platform to use when creating the web app, but not the technology to gather the content. Instead, there are quite some ways to do this:
1. Create a Windows application to gather content and schedule it using at.exe or the Windows Scheduling in the Control Panel.
2. Create a background Windows Service that can do the gathering behind the scenes.
3. (Advanced) Create a SQL Server Notification Services app that accepts incoming inputs from various sources and - as a delivery - inserts the new retrieved data in the database.
Aye create a service to query your remote server every (X) [x = your interval].
Then have it bring your stream back and parse through it. What are you writing this in c# or vb. You do know depending on what your doing with spreadsheets you may need a copy of excel on your server?
I got a little code that basically works. my problem is that the site i am gathering the information from has sessions on it. so if i just put in the link to the site's file i'll will tell me that the session has expired or that there was a problem with the page. Here is the code I have.

and yes, excel and all the goodies are on the server already.


private void Page_Load(object sender, System.EventArgs e)
{
// it works when the open read command is pointed to the actual file.
System.Net.WebClient Client = new WebClient();
Stream strm = Client.OpenRead("http://www.whatever.com");
StreamReader sr = new StreamReader(strm);

string line;

if (strm != null)
{
do
{
line = sr.ReadLine();
ListBox1.Items.Add(line);
}
while (line !=null);
strm.Close();
}
else
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = "Something went wrong";
}

Stream strm2 = Client.OpenRead("http://www.whatever.com.aspx?format=excel&prefix=");
StreamReader sr2 = new StreamReader(strm2);
line = string.Empty;

if (strm2 != null)
{
do
{
line = sr2.ReadLine();
ListBox2.Items.Add(line);
lblStatus.Text = line;
}
while (line !=null);
strm2.Close();
}
else
{
lblStatus.ForeColor = Color.Red;
lblStatus.Text = "Something went wrong";
}

}

Saturday, March 24, 2012

Please help DEPERATE page randomly stops loading

Hi

I am getting pretty frustrated here.
I have a simple page architecture that consists of a header web user
control, the main page content and a footer web user control

Every so often that page loads the header content and just stops. If I click
view source, I see that all the content has been pushed to the client. It
just doesn't render!!

This happens at random points often when doing postbacks. I am not using
smartnavigation.

Has anyone else seen anything similar?

Thanks,

SBad HTML is the problem.
You did not close the tag or the quotes.
Sometimes IE can recover sometimes not.

George.

"SamIAm" <samuel@.rubbachicken.com> wrote in message
news:%23ouR1T4$DHA.2348@.TK2MSFTNGP09.phx.gbl...
> Hi
> I am getting pretty frustrated here.
> I have a simple page architecture that consists of a header web user
> control, the main page content and a footer web user control
> Every so often that page loads the header content and just stops. If I
click
> view source, I see that all the content has been pushed to the client. It
> just doesn't render!!
> This happens at random points often when doing postbacks. I am not using
> smartnavigation.
> Has anyone else seen anything similar?
> Thanks,
> S