Best ASP.NET MVC way to generate documents - asp.net-mvc

I'm currently working on a proof of concept web app project.
The idea is : ASP.NET MVC User Interface and ASP.NET MVC Web API linked to a C# class library for access data from an ODBC source and doing business treatments.
In this project, one of the biggest part is generate documents with datas collected on the ODBC, stock them in a file server and send them by mail.
What is the best way to do that? Directly PDF? or first Word (because documents are pretty complex, with charts,...)
The main fact, is that it must be fluent for the end user. May be using asynchronous programming on the server side?
Thanks for your advice and replies :)

Related

ASP.NET MVC 5-Best approach to load user data when page loads

I am building user portal and wants to load authenitcated user data from database when form authentication happens.
Can you please help me to understand what are best approach asp.net mvc have to load the user data from database when page load post the form authentication
One I can think of is JQUERY to query data from database using CONTROLLER
You should look into Microsoft's tutorials first, you can get started here. Follow these tutorials first before asking questions here.
Once you understand the concepts, I suggest you use the ASP.NET Identity framework to authenticate and authorize your users. It provides many out of the box features and allows customization according to your needs.
You should use what the ASP.Net MVC plumbing offers.
Specifically, use the UserManager<T> in namespace Microsoft.AspNet.Identity(maybe start here)
However, if this is your first time, in order to get you started, I would recommend you try to create a new MVC sample application instead of writing an application from an empty template: it will help you understand the mechanisms ASP.Net MVC exposes for your need.
Good luck :)

wcf and knockout.js combine

I got my datalayer, business layer ready. Now i want to to implement service layer.
I do not want to implement this layer in wcf ria services. Is there any other way to implement this layer in such a way using wcf, so that I get my model through wcf using js.
For example I have my domain 'Person'. (In domain project). Then in my 'PersonRespository' has
InsertPerson, GetPerson etc. to get and store the 'Person' in database.
Now I want to use asp.net mvc to show the person detais.
So next two layer will be Presentation Layer and service layer and manipulate data on client side using knockout.js and I am stuck on following issues.
Where will be mine Presentation layer will live. I am using asp.net mvc so It should be in model folder of mvc application, Is it wise to copy the same code class (Person) to model folder as well from domain model. Event when they are same.
How I will be able to get 'Person' model class in javascript and able to update it from javascript to database as well.
Is my architecture style is of enterprise level or i am missing something.
Any point to tutorial will be helpful.
If you have any further questions please let me know.
Thanks,
Daljit
Question 1:
No you should not be repeating your code. There is talk about this in the DRY (http://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principals of development.
Question 2:
It is recommended that you serialize your model using a json serializer and send it to your UI. It will be updated etc, and then sent back to the services. Google MVVM pattern in javascript to see how this is done. KnockoutJs is a great start in achieving what you want. Its probably best to check out some examples done in knockoutjs to see what is going on. There are also many examples in MVVM for WPF that might help understanding the pattern at a higher level. I would recommend seeing codeproject.com for indepth MVVM examples.
As far as your layers go, you have many options, but a generic recommendation would be:
1) Presentation must be triggered through MVVM bindings, ie if the binding updates, the UI will then update itself.
2) the asp.net side of things should only update the models when sending updates via ajax to the UI. (not everything needs to be sent via ajax, im not saying that. When it does, it shouldn't also send extra html or js to put in the page).
3) Your models should really come from asp.net to the html page. (this will make things easier later, as the page will only be updated via asp.net models and you won't get items coming from multiple domains, which ends up being a nuisance.
4) Your asp.net site should provide a wrapper for your WCF service, and can foward calls to WCF.
OR
If you didn't want to wrap WCF with asp.net and needed your UI to communicate directly via ajax to WCF (should be a rarer usecase like doing an igoogle like page with widgets, or maybe mobile development with no asp.net interaction, ie full js app) Then you can investigate CORS as an option to go from JS to WCF and JS to asp.net (This is of a hard difficulty, easy to program, hard to get working for WCF as there is very very low documentation on it for in my case non IIS hosted WCF). See this page for information: http://enable-cors.org/

Development of Sharepoint Data Entry Site

I am in the process of developing several data entry forms that the client has asked to be accessible through the SharePoint interface (2007 WSS version).
The forms will, among other requirements, consist of multiple drop downs that have to be loaded from tables in SQL Server. These lists of data are updated frequently through a process that sucks data in from Great Plains.
My inclination is to create a Web Part Page with a Page Viewer Web Part and go full screen like this: http://blogs.msdn.com/b/malag/archive/2008/09/15/story-of-a-mischievous-page-viewer-web-part.aspx
...and then to do the pages in ASP.NET MVC3. Is there a better story than this? The integrated SP development paradigm seems like waaaay more overhead.
This sounds like a common issue with developers new the SharePoint paradigm, especially for 2007. The short answer is that your solution will be the quickest way to get to where you want to go but isn't the "cleanest".
The other option is to create a SharePoint Solution and publish an application page to the _layouts directory. A quintessential "hello world" example can be found at http://msdn.microsoft.com/en-us/library/bb418732(office.12).aspx.
New SP developers will find the hardest transition with deployment. The WSPBuilder codeplex project http://wspbuilder.codeplex.com/ has become the industries default solution for doing this. An example of using this can be found at http://www.greggalipeau.com/category/sharepoint/wspbuilder/.
For you I would say the key words are Application Pages and WSPBuilder.

how do you integrate a save/publish invoked from excel to asp.net mvc?

I've been probing around and have not found any hits nor do I have a lot of experience with this topic. I would like to open an excel document (ideally from an asp.net mvc model) and then post this model back to an asp.net mvc controller action for a save/publish through the application.
I would prefer to stay away from excel storing directly to the database, opting instead to go through the mvc action in order to adjust cache, run business rules, etc.
Any tips on places to look or how this is done? I know TFS 2010 does this fine as does sharepoint but I'm not aware of the underlying technologies.
Thank you in advance!!
Jim
After more research it is apparent the answer to this lies in the VSTO libraries. Initially I had a hurdle in place with our virus scanner which would not allow me to build a custom ribbon giving 'access denied' when attempting to load in my .dll's.
Beyond this, the API is fairly straightforward for adding a custom ribbon which has access to WCF, among any other .NET APIs within Excel (or any office tool). This WCF service can invoke the MVC Controllers, if required, or directly perform business logic themselves - the sky's the limit.

How do you place a web services aside with your ASP.NET MVC web application

I currently have a web application written by ASP.NET MVC. Now I want to add a web service so that some people can easily build application upon it. Shall I just create the asmx in the MVC Web project or create another project referencing to the Model project? And what's the pros and cons?
Thanks in advance!
Easy decision - if your MVC Web project depends on the web service at all, keep it in the MVC Web project. If not, create a separate project for the web service with reference to your model.
Keeping projects seperate allows people to read and understand your code more effectively. If your service makes use of your model, but is not part of that model, than it should definitely be a standalone project with reference to the model. This is clean design.
for my opinion I would do something like this in my solution
solution.Model -- the model that reflects your db,
solution.Repository
solution.MVC -- your model will be the refined Model, referencing the solution.Model
solution.Test
solution.WebService -- referencing solution.Model
I keep my Model outside my MVC Web application and just put the refined ViewModels in my MVC Model folder. I don't know much about pro's and con's but this is just a better way of doing it for me.
Doing this, you can use your Model anyway you want. Maybe you want to use it for WebService as what you ask. Or for another Application. You just reference your Model project to other projects that you need them.
I would look for Odata -> WCF Data Services formaly know as "Astoria".
If you are using for example linq-to-sql or EF you can make your data in a restful manner availale and provide a basic api...
You can define your endpoint like you do in WCF because the underlying service is based on WCF. And I would use a different namespace...
Website
http://msdn.microsoft.com/en-us/data/bb931106.aspx
Beginners guide with videos
http://msdn.microsoft.com/en-us/data/ee720180.aspx
open data format
http://www.odata.org/

Resources