I want to show the number of viewer for a particular Article. How i will do it in my program?
Any strategy, someone can suggest ...
If you aren't using any framework or CMS, then you can integrate either Google Analytics or Piwik into your website. Then use their inner data to display number of views/unique views per article.
Make a table with article id/url (or whatever you technique is), IP, user agent.
In every relevant page have each page access write down these values.
To display number of views simply select count
To display number of unique views display count(distinct)
Related
My application needs to show the user all Page categories available so he can choose which pages to follow and / or Like. Is there any way using the api in c# to get all the categories?
I also need to get all areas available in Facebook used as location and/or Home town etc.
After a bit of research, it doesn't seem possible. The Facebook FQL requires a where clause to search pages. This means you need to provide one of the following: a keyword, a page_id, a name, or a username. Since you don't seem to have any of these fields, or more specifically you want everything, so these fields are unimportant to you. To sum up: select categories from pages is not valid FQL, it have a where clause. Example:
select categories from pages where page_id = x
select categories from pages where keyword = x
select categories from pages where name = x
select categories from pages where username = x
This seems odd to me, since if one navigates to https://www.facebook.com/pages the site is certainly capable of enumerating the pages available. If you had simply an enumeration of all pages on the site, you could build your own list of categories based on a massive recursive search. This would need to be done infrequently and stored locally to your application.
To answer the second part of your question FQL allows to search for posts that have been tagged with location data (https://developers.facebook.com/docs/reference/fql/location_post) however this will only return results based on the following 4 rules:
you were tagged in the Post
a friend was tagged in the Post
you authored the Post
a friend authored the Post
The "you" they are referring to here is the owner of the OAuth token used to execute the query. Again, I do not believe this would result in you being able to retrieve a list of locations due to the same where clause limitation as seen above.
This ends the section of official Facebook API. You can certainly fall back on basic web page scraping, similar to the answer provided by Silamril. However I'm not sure if this will work for locations since that search box seems to be a live search autocomplete box. This means you have to put something in to get something out. I suggest you look at a geoapi provider or even simply scrape a wikipage like http://en.wikipedia.org/wiki/List_of_lists_of_settlements_in_the_United_States. There are providers of mapping information out there like OpenStreetMap that will be able to provide you with the same information in an API format. See the OSM wiki (http://wiki.openstreetmap.org/wiki/Key:place).
You can acquire all page categories with a script like on https://gist.github.com/bloudermilk/2173940
I am currently optimizing my site for search engines. It is mainly a database driven site. I am using C# on the back end but database content is loaded via jQuery ajax and a web service. Therefore, my database content is not in html at the point that the bots will crawl it. My site is kind of like an online supermarket format in that there are thousands of items in my database, users can load a single one of these or more onto the web page at a time and the page does not change significantly once items are loaded.
My question is, how (if at all) can I get my database contents indexed? I was thinking of having an anchor that links to an aspx page (eg called mydatabase) which loads all of my database items as a big html list. Then, using jQuery, I would make the anchor invisible to users. The data would still be accessible to users but not by this link, it would be accessed by using the jQuery interface I have created.
The thing is, I don't really want users to see this big, messy list - would google results show this page eg www.mysite.com/mydatabase.aspx as a search result? Also would google see this as "keyword rich" spam page? I have done quite a lot of research but found nothing on this. only instructions for php. Please help I'm not sure what to do and need to know the best way to go about this.
It's a shame you haven't taken the progressive enhancement approach as it would mean you would have started with a standard HTML output that's crawlable, and then adding the layering behaviour (AJAX) on top for the user experience.
Providing a single file (e.g. mydatabase.aspx) that lists all of your products in a list format provides no real value for the reason you gave - it would just be a big useless list. No editorial content relevance for each link etc.
You're much better off taking another look at your information architecture and trying ensure that each product is accessibile by it's own unique URL, then classifying the products into groups (result pages), being careful to think about pagination.
You can still make this act like a single-page application using AJAX, but you'd want to look into HTML5's History API to achieve this in a search engine friendly way.
I have 2 working sections of code and need to put them together
section 1 -
the user can visit a page, view & edit the contents of a database, which includes news articles, titles, related links etc, i've managed to get this working & the data is saved to the db
section 2 -
a javascript news scroller on the homepage of the site writes out a series of divs which are then rotated using javascript & CSS to make it look like they are scrolling, again this works fine. The news articles are drawn in from an array hard coded on the homepage
Problem - i want the user to be able to edit the news feed by editing the content of the DB, sort of like a homemade CMS system but only for 1 page.
How do i take a variable from the DB (i'm guessing using a SQLDataSource) and assign it to a variable which i can then write out to the javascript array & therefore into the news feed on the homepage.
I apologise if this is a simple question but i'm struggling with it, my C# & .net skills are quite limited any help would be very gratefully recieved
Thanks
Ben
The simple scenario
When a user visits a page where they can edit news items and updates/adds new news items, the application should persist those changes to the database.
When a user visits the page with the news scroller after a user has edited/added new news items, they will see the updated items as the application will get the news items from the database when the page is requested.
A more complex scenario
When a user visits a page where they can edit news items and updates/adds new news items, the application should persist those changes to the database.
The page with the news scroller polls the server using AJAX to get news items. Any new news items that it retrieves (perhaps by passing in the request an id or datetime of the most recent news item) will then be displayed. The newer news items may replace older news items that are held in a JavaScript array of news items on the client.
How the data is retrieved from the database could be done in numerous ways:
You could use a SqlDataSource control, but I'd only really recommend doing this if this is a small application because the control starts to mix data access logic into the presentation layer.
You could use vanilla ADO.NET with a SqlConnection, SqlCommand and SqlDataReader to read the records out of the database.
You could use LINQ to SQL to read the record out. This may save some time over number 2.
You could use any number of other data access tools such as Dapper.NET, Massive, Simple.Data, Entity Framework, NHibernate, etc. Your mileage may vary on what is the most appropriate tool for the complexity/simplcity of the application.
Let me know if this answers your question and if not, I'll see if I can elaborate.
You'll want to write a page in ASP.NET that takes POST variables and uses them to manipulate the database. The frontend can then use Ajax to post the variables into that page.
Ajax tutorial: http://www.w3schools.com/ajax/default.asp
In the codebehind of the home page, you will create a property (like NewsFeedText) and set it in the page load event. Then you can read that property on the client side as
var mynewsfeed = '<%= Me.NewsFeedText %>';
You can parse the mynewsfeed variable to create the array.
I am developing a web application which will deal with online examination. The requirement is:
There can be n-number of sections in
an exam and admin users should be
able to create questions/answers and
add to an exam.
The questions should be displayed
for a certain amount of time in the
browser with timeclock and it should
move to next question automatically.
User should not be allowed to open any other instance of the browser or login from another IP if the exam is in progress.
I am seeking community vote of how would someone design the application to meet all these criterias? What patterns should be used? What components can help to reduce the development time etc..
My technology stack is C#, ASP.NET MVC or ASP.NET with SQL Server.
Thanks in advance!!!
Rather than re-invent the wheel, you should look at a solution such as the Open Source DotNetNuke and either buy/build an extension for the portion specific to your scenario.
I think for the user app, you should consider a Silverlight app as this will give you granular and secure control over the experience.
Overall the solution would be like this:
DotNetNuke provides the foundation portal/Content Management so you can create a highly customized experience around the exam experience including support for user management etc.
The DotNetNuke extension would enable authorized administrators to manage exams and exam questions.
A webservice wrapper would provide access to the business controller used by the DotNetNuke extension.
A Silverlight app would interact with the webservice to enable authenticated users to take their exams
Overall, such a solution would give you a high degree of control over the user experience while enabling you to focus time/resources that are only specific to your situation while leveraging an existing, robust and popular solution on which to build your solution.
(Full disclosure: I am one of the co-founders of the company that manages DotNetNuke. In fairness, you can replace my suggestion for DotNetNuke with Orchard or Umbraco and the solution would be equally valid.)
For the Database side of things you would want something like:
Table Exams (ExamID, ExamName) //to hold all exams
Table Users(UserID, Username, Login, Password) //to hold all users
Table OpenExams(Exam_ID, User_ID) //to hold open exams
Table ExamSections(SectionID, Exam_ID, SectionName) //to hold sections of exams
Table Questions(QuestionID, Section_ID, QuestionName, Question, Answer) //to hold questions
This of course at its most basic and only 1 approach of many. You would need to add fields where required.
As for item 2, i would probably do it in the application layer (or in VS). I dont have much experience in web dev, but i would think that ASP could handle that. For item 3, you could run a simple SQl statement to get if the user trying to access the exam is currently taking the exam.
Lets also start mapping the processes:
User:
1. User logs in (to prevent multiple exams by one user).
2. User "starts" an exam -> Time is noted on the server-side and timer triggered on client-side. User gets a dynamic exam page 1.
3. User is done with page 1, clicks next -> Ajax-reloading the page content (the questions part). Timer for page 2 is started (server and client side)
3.a) detected login from a different IP - session broken, user marked as cheater :) or the login is simply rejected.
User times out on page 2 -> the page content (answers) are automatically submited. the timers are set for page 3. user gets page 3.
User clicks finish -> the exam is finished.
Admin:
Logs in -> show "add exam" option and table of existing exams
Adds an exam - open "exam page", add a new "exam" entity
Adds a page - > new "page" entity added to this exam, questions table is loaded in the gui
adds a question -> new "question" object added to page
end page -> the page is saved. options for end exam or add page are here.
add page -> go to step 3
finish exam -> save exam
optionally mark exam as "active/inactive"
add tables with "students" and their results and stuff like that.
This needs a lot of work, but when you have this you have the idea of what you need to put in your design.
I need to implement a form tamplate system. The form needs to be very dynamic. It will need:
Multiple textboxes
Multiple dropdown menus
Multiple Number fields
Multiple Date fields
Single Image field
Single Submit button
Any or all of these fields can be blank but must follow the field type. Therefore letters cannot go in number fields.
The form needs to grab all the values and there could be from 1 to 300 fields in one form or more. I could not find any examples of how to implement this online. Once I grap all these values I need to store them in the database. I think I know how to store them in the database but I am puzzled on how to extract the information from the form.
Have you looked into any of the existing options, like XForms? I believe this company produces a fairly nice product: http://www.orbeon.com/
Adobe has a nice product (which even scales to enterprise levels with things like LiveCycle) if you're OK with plugins / non-html-only... although they do offer HTML rendering, but I believe it's limited.
If you are OK with the price of Sharepoint, Microsoft has InfoPath, which is sorta neat.
What are your requirements? I'm assuming ASP.NET/ASP MVC based (based on your tags). I'm also assuming cross-browser. Do you need the data back in a particular format, or as a POST to a page? What about complex validations and field bindings?