Get Live updates from Webpage using C# WebClient - c#

I am developing a Windows Phone app in which I am parsing a webpage from my website. Where some games score updated live, like in cricinfo. Anybody tell me how I sync my webpage with my windows phone WebClient request so that I get updated score wihtout request or refershing in my windows phone app. I am using HTML agility pack and Webclient for parsing html page of mine site.

If the webpage is hosted by a third-party which seems to be the case. Except if there is some kind of RSS-Flow you will have to manually refresh regulary your application.
So all you have to do, is refreshing the information inside some loop with a defined interval.
If the webpage is hosted by you, I suggest using some kind of webservice to recover such information.

Related

C# WPF, and data exchange with the browser

I've a C# WPF application developed in VS 2015, and I want the browser to read some data from it. Just a short string. I can save it in a text file, or in a variable but it should be visible to the browser (using JS I suppose). For instance using file:/// doesn't work if the original page is hosted online - as in my case (different source conflict). This should work in Opera and FFox, but looking at their extensions, it seems you can only develop with front-end technologies, which are not enough in my case since I use WPF to look into Win OS, and then I need to share the result with the browser.
I suspect it's possible, and no , it's not to write a malicious piece of code. For instance I can read the details of the graphic card for diagnostic purposes.
Please help, many thanks.
Browsers run in a security sandbox which is intended to stop them reading or writing files to the file system.
You could write to the user's appdata. There are various javascript frameworks which persist data to there so they can provide offline or static data.
I don't think that is a good plan though.
I suggest your first candidate would be a cookie.
Quick google on how to do that, I find:
How to create cookie in c#.net windows application?
From a web page you can use the content of a cookie dynamically. So you could change what you see in the web page after it's up and running from some process in your wpf app and do a counter or whatever.
I've not used this with windows apps and a browser but I have with a web app and Silverlight. I'm afraid I don't have that code to hand though.

Best way/solution to display json data from a local winform .net app on angularJS web dashboard applicaiton

can u please help me out with the best solution how to do this?
I have a windows form application, which is continuously doing something. (making screenshots and generating data) This app is running locally.
So I dont want to use teamviewer from office just to see what my application is doing. I want to create an AngularJS Web Dashboard application (load it on a webhost) and display this winform data (in form of charts,..), so that I can access from everywere.
What is the best solution for this?
I have experience with AngularJS and parsing JSON-Files from a webserver.
I preffer creating/serialize a json file (each second) from my winform app and load it somewhere on webhost and then access this json file with http.get from my AngularJS application.
Is this a possible solution? Any suggestions?
Thanks!
I agree with making a Angular web app (although you don't need angular for this, you can use jquery to make a simple ajax call, seems like it would be quicker to add the jquery reference than to setup the angular scaffolding just for one or two ajax calls) to call a web request where the winforms app stores the data.
Ex. you can create a web request (or directory save) in winforms app to perform the 'snipping tool' action described here: C# snipping tool service and send the data to somewhere to store it. If the snipping tool doesn't work then probably use an export of the chart or data you are capturing. Then the web app can query that directory to retrieve (ajax/http get) whichever data you need.
I would advise clean up on that directory as it could become quite big if you are saving to it every few seconds or so.

Access the Facebook //connect.facebook.net/en_US/fbevents.js with C#

I am working on pulling news and events to display in my Universal Windows Platform Application (UWP) using C# and have the Facebook SDK installed. The company uses the script below to access the information and display it on their log in website.
!function(b,e,f,g,a,c,d){b.fbq||(a=b.fbq=function(){a.callMethod?a.callMethod.apply(a,arguments):a.queue.push(arguments)},b._fbq||(b._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[],c=e.createElement(f),c.async=!0,c.src=g,d=e.getElementsByTagName(f)[0],d.parentNode.insertBefore(c,d))}(window,document,"script","//connect.facebook.net/en_US/fbevents.js");fbq("init","1446863745630648");fbq("track","PageView");
As you can see from the script they are using //connect.facebook.net/en_us/fbevents.js file to store the events. Is there a way I can access and read this file?
did you click my link above?? starting a url with // means that a page in http will prepend http, and a page in https will prepend https to it.. See stackoverflow.com/questions/11881054/… – mentat 3 hours ago

Share program variable values with Javascript running on browser

I'm developing a C# windows form application which scan passports in a client PC
in the same client PC user is going to open a webpage with which has some textboxes.
Is there any way to share some values of windows form application with the browser page?
(IS there anyway to invoke some functions in Windows App through RPC from the browser JavaScript, or any mechanism of share or send these values)
.
You can use the web server as a mutually accessible resource. The c# application can send data to the server, and the web browser can poll/listen for updates from the web server using AJAX. If the Windows application is also connected to the server, it could receive updates from the web page.
Alternatively, if you want to do a one-time sharing of data between the Windows app and the website, you could:
collect data in Windows app
send it to server
receive a unique ID
launch a web browser with the unique ID in the query string
website finds the data which was just sent by the Windows app.
Certainly there are other ways to do it as well. My goal would be to avoid having to have any knowledge of the web browser in use, e.g. requiring a plugin to be downloaded to facilitate the communication between the browser and the Windows application.
You'll want to implement a small http server in your C# app that can respond to http requests. Your web page can then make a GET request to the appropriate URL to fetch the data to populate the fields.

Windows Phone Web browser Thumbnail of Website

I have been wanting to get a thumbnail of websites for quite some time using the web browser control in Windows Phone.
My Question is quite simple, is there a way to gaining a thumbnail of the web page a user is currently on. I have done this before using C# standard web browser control and the DrawToBitmap method but this doesn't exist in Windows Phone (Atleast I was unable to find any documentation suggesting otherwise)
If there is anything you guys know that could point me in the right direction besides using online services such a glimpse or Amazon's Thumbnail Generators as I would like to keep this activity within the app, I don't want to do extra calls to another web service when the data is right there in their web browser.
I was hoping if there was a invoke script I don't know about or some libraries that are supported in Windows Phone which are able to do just this.
Thanks for your help, if you require more information just ask, or if you would like to know what or why I want this I will explain further here:
I have a News App that allows users to access a select few feeds, I have a dedicated page that hosts the web browser control to display the webpage with some other functionality like sharing the website using your email or pinning the web site to your home screen, I just want a more custom experience than the generic web browser one. And I think a thumbnail of the website would be nice as the Tiles background
If you have a better Idea on how to tackle something like this please do let me know I am open to suggestions :)
You could try rendering the browser control to a WriteableBitmap:
var bitmap = new WriteableBitmap(400, 400);
bitmap.Render(browserControl, null);
bitmap.Invalidate();
You can then use this bitmap as an ImageSource.

Categories

Resources