Simple querying a database using apps for office? - c#

I am trying to begin writing my first app for office.
What I would like to do is simple. I have a database of IDs for my customers. When I hover over one of these IDs, I'd like the app to query a database and display the customers info on the right hand side of the app.
This should be a pretty simple thing to do using apps for office, but I can find no guidelines or help on their web page.
Can anyone provide some simple sample code for doing this?
Thanks very much.

I can say that I spent some time going through this tutorial trying to get a solution for this question. I have a few suggestions about how you will need to proceed in writing your Office App.
I would not advise having the data populate when you hover over an ID field in Excel/etc. You will be hitting your database too many times. I would have set it up, that the user with select a cell with the ID in it and then in your app panel, there will be a button click or event that will make a call to the SQL Server to return the data.
You will need some sort of a web API that you can use to retrieve the data from your SQL Server. The event will pass in your ID that the user selects and then the web API will return the customer details to be populated in your app panel.
Setting up the App Panel seems pretty straight forward in the tutorials on the MSDN site. You can set it up using HTML and CSS to design the page.
I think the biggest thing that you will have to do is set up the API to access the data.

I think these official Microsoft examples will help you a lot.
Example 1 (Bit complex)
http://msdn.microsoft.com/en-us/library/fp142290(v=office.15).aspx
Example 2 (Looks Easy)
http://msdn.microsoft.com/en-us/library/fp142161(v=office.15).aspx
Example 3 (With using Visual Studio)
http://msdn.microsoft.com/en-us/library/fp179835(v=office.15).aspx
Happy Coding...

Related

Login, get info of a table, click buttons, etc in a web page from c# app (GET - POST HTTP)

I want to get some information of a web page (Where I have customers, current balance, etc) in my C# application. I thought in use POST - GET methods, but I don't know how to use them. The first problem, I have to login in the page:
Login page
I guess I have to get boxes id, and button id, then, complete them in the C# app. Next I want to get table contents. The table is like this: Table
How I can get customer id, customer name, and customer balance? And if the customer balance is updated, check it on the app? I think with this is to be able to do the rest on my own.
This could be very difficult depending on exactly how the site is architected. Does the site have an API you might be able to use instead of trying to go through the UI?
If you have no choice, I would consider using something like PhantomJS which is basically a scriptable headless browser. To make it a little easier to use with C#, you might also consider Selenium WebDriver and their PhantomJSDriver.
Selenium is used for automated testing of websites, but you can just as easily use it to automate repetitive UI interaction in websites. The biggest issue you generally face is keeping your scripting from being so brittle that anytime a change is made to the site, it breaks your automation. You might want to read up on the Page Object Pattern as it can help you minimize redundancy and keep your code maintainable.
Also, it was recently announced that Chrome v59 will be able to be ran headless, so that might ultimately be an alternative to PhantomJS.

Get Html from Web page and create Setup project for Wpf Application (C#)

I'm trying to create a wpf application such as a movies library because i would like to manage and sort out my movies with a pretty interface.
I'd like to create a library with all my movies getting information from the web, but i don't know how very well.
I thought to get the information from a web site, for example imdb, but i don't know if it's legally to capture html from page to get the nested information.
It's my first desktop application and I would also like to know if it is necessary to create a database within the project and then create a setup project with specified script for deploy it.
Sorry for the confusion but i would like to know too much things :)
Thanks a lot in advance.
The legality of web scraping is a grey area. See my question, "Legality of Web Scraping vs Normal Use" and the corresponding answers for some insight.
Even if the legality is not a problem, web scraping is a flimsy approach because the webpage structure may change without notice, making your application suddenly useless until you update it to the new format. You are much better off using some sort of web API (if the site providing the information offers it).
Whether you need a database or not depends entirely on what your application will be doing and how you design it - it's not something any of us can tell you.
Same goes for the setup project - in fact I wouldn't worry about that until you actually have a working application. Take it step by step and keep the scope within control.
Yes I did not think about api.
It's a great idea, maybe use "themoviedb".
But if i create an application based on it, that has to show all the movies that you have stored on your hdd and get , for example, the posters, the description and the ranking, i have to create a database according to you?
Thanks a lot.

How can I go about saving the state of my panels to my DB without using PHP

The link below explains exactly what I am trying to do, and I have used it as a guide for my implementation so far. I have two columns filled with panels that can be moved around or collapsed. In the end, I want to save the state information about each panel on drop(as soon as the user changes it) so that when each individual user leaves or logs off, everything is where they left it upon return. I am using jquery, and c#.net for my back-end, which from what I understand makes it very difficult to incorporate PHP. I am wondering if anyone knows how I can accomplish what is demonstrated in the link, but using a method that does not include PHP?
http://webdeveloperplus.com/jquery/saving-state-for-collapsible-drag-drop-panels/
Thanks in advance
You seem a bit lost (nothing wrong about it), but since you're using C#, you should find a way in C# to access your database. PHP is just a server-side language you could use, but it means installing PHP on your server... and I don't think this is what you want/need.
I'm pretty sure, there are very nice tutorials on the web on how you can interact with your current DB (what are you using? MySQL?)
Basic tutorial for SQL with C# https://www.youtube.com/watch?v=1EpYqtSlOr8

How to create fastest searching (filtering data) field in C#

I need to create User selection page for my web based application (User searching page), I have millions of registered users in my database and I want to search that users by typing the name in the text field.And by the way it should be suggest the name of users when i am typing the letters on the field (Like jquery tables).
I am using .net MVC3 for develop my web application
I am using Amazon database server for store my data (Amazon S3)
Millions of people will access this site.
-- I have tried to come up solution with elasticSearch I think this is well suited for document text search.
I want to know the way of, how can i speed up searching result? Is there any techniques to speed up filtering data from Database? Can I use ElasticSearch for this?
Please anybody can give me a best solution/ suggestions for come up with this problem?
If you can give me a examples it will be a great help. Thanks in advance.
There is no much tecniques on this:
Use AJAX to query the subset of users
On server side, one time request was got, get first (say) 10 elements of the subset found and send it to the user
On client side use defered scrolling: the control that shows the list of users do not show all users od subset got from the server, but only set of them. When user scrolls down/up list refreshes by querying again the server. Say on list view it's possible to see 10 users at a time, you get from server 15, so on scrolling at least next 5 will appear immediately.
Something like this.

Show message in application when new record inserted into the table

I am creating a web application using Dot net 3.5(c#).
Needs:
One user is accessing the entry page(Updating the database)
Another user is in report page. Once the table get updated i want to show popup message to indicate the user about the update in the database.
Is it possible to achieve this task. How to do this.
It's possible, but to do it your report page has to use ajax requests on a timer to check with the server for new records.
It seems that you can apply SQLCacheDependency for your issue. You can compare is it fit to your requirements when read this article from ASP.NET website.
Better approach is to use the
SqlCacheDependency class so that data
remains cached until its underlying
data has been modified in the SQL
database. This tutorial shows you how.
You can try LinqToCache for a LINQ sensible wrapper around the Query Notifications infrastructure used by SqlDependency and the like. You can read this article to understand how SqlDependency works.
This will give you the active notifications mechanism for your web app to detect changes that occur on the database. For the popup part, there are well know methods using various Comet techniques.

Categories

Resources