Sharepoint connect to another SQL server? - c#

Here is the task I'm checking:
1) have a product database, which is managed by another application (it has no relation with sharepoint).
2) now, my boss want to have an application within the sharepoint portal to search this database, plus, audit the searches, i.e. who searched what at what time....
There is no problem if this is a regular asp.net application. But, what's the best way to do this in sharepoint?
My plan is to:
use team site template (or blank template), create a webpart. then have UI, and gridview to show the result.
is this the way to do? I try to find an example of using gridview in webpart, but cannot find it. Is there any limitation of using asp.net control in webpart? what about use ajax toolbox control in webpart? any example?
thanks

Roughly there are 2 approaches you could go for:
The webpart approach, just as your describe it. You can use an ASP.NET gridview with no problems in your webpart. As such, a webpart is nothing more (simplified...) than a user control with some dress up.
Go for BDC/BCS. This will allow you to consume the external database and show the information as be it 'native' SharePoint data. This has the added benefit that the content can be made searchable from within SharePoint. Using this approach you also do not have to create a UI to present the data, as SharePoint will present it using the out of the box view pages, etc.
The downside of the webpart approach (option 1) is that if you have multiple front end servers in your farm you need to handle the session in a way (e.g. by setting up sticky sessions on your loadbalancer, or by sharing your session somewhere centrally (in a db for instance)), as you don't want users to switch between servers in one session while they are using your webpart probably.
The downside of option 2 is that at first it might seem complex, but let that not scare you away :-)
http://msdn.microsoft.com/en-us/magazine/ee819133.aspx

You should code this as one or several web parts. You can use pretty much any asp.net controls in web parts. If you want to use any third party tools like DevExpress you must ensure that the binaries are strongly typed so that you will be able to register them in web.config, note that the registration can be done by the wsp deployment if correctly configured.
Web parts behave as any .net code except for the fact as I mentioned all references assemblies must be "safe".

Related

Sharepoint form writing to sql database

I want to build a form that will edit a table on SQL server. I known how to do it in ASP.NET (I need two drop down lists, gridview and button) but I want to make it as a part of SharePoint.
Can someone tell me what is the best technology to do that, I was looking at InfoPath but it seems I can not run it in web browser (only InfoPath filler). I just want to build simple form that is a part of Sharepoint and that is working in web browser. Please help.
Best regards
Daniel
One easy approach to read/write from/to SQL databases in SharePoint is to sync the external data with SharePoint lists. In this way you have the full feature set of lists available with best performance and highest security. Users are just working with a synchronized copy of the external data in the lists. To sync the data you can program by yourself, use PowerShell or 3rd party sync tools like the Layer2 Cloud Connector.
It is not a best practice in SharePoint to directly change the database.
One way you can do is Connecting to SQL Server Using the External Content Type Feature
http://www.dotnetcurry.com/sharepoint/794/sharepoint-2010-connect-sql-server-external-content-type
If you want to change directly , As you already know how to do it in Asp.net , you can go for Visual Webpart with same asp.net gridview and connection string

Yet another .net custom cms

I'm trying to switch my custom cms written in php into .net c#. I was thinking to use cms as a learning project. I'm going to use C#, NHibernate ORM layer, mssql, mvc3 and jquery.
I'm aware there are plenty of commercials or open source cms, but still I'm going to spend some of my free time trying to learn new technology working on project like this.
So, is there anyone out there who is willing to share some ideas on creating cms domain model, usefull link, ideas, etc.
Thanks
A really basic CMS consist of 3 elements:
one database table to hold your "pages". The table structure is "name" and "content"
a route to transform requests of type /cms/pagename to a fixed controller, the method called cms and pagename as a parameter
a embeddable html editor
Now, there are two ways your "page" can be invoked. It is either create mode or view/edit mode.
In "create" mode, the page is requested but it is not in the database yet (e.g. cms/announcement1). In this mode you create a view consisting of a html editor and upon submit, you persist the page to the database.
In "view" mode, the page is requested and is IS in the database. You perform any necessary rewriting (for example you rewrite internal links of the form [cms/pagename] to a fully routable http address) and render the content.
If the user is authorized to edit the page, you also show a "edit" button which then invokes the html editor with the page loaded and ready to be edited.
And that's it.
There are tons of additional elements (caching, different built-in page types, embedding images, youtubes, preformatted texts) etc. but all of them are optional and you can introduce new features when you have the core already implemented.
Once I wrote a simple CMS following the structure above, it was a part of a bigger solution and till now it's been sucesfully deployed several hundred times. An advantage of a custom CMS is that it can be really simple and easily maintanable.

Creating an "Import External Data" admin page in Sitecore

As part of the development for a website powered by Sitecore 6.3.1, I will need to implement a way to manage data from a couple of external sources in Sitecore.
To accomplish this, the simplest solution appears to be to import the external data into Sitecore as content items with a special workflow that will export them back to the external data source when they reach the final state.
I came across this article which details the code required to import data into Sitecore, but I am uncertain as to the best way to make this functionality accessible.
Considering that this process will probably (but not certainly) only be done once after the site is completed, what approach (page/Sitecore item/shell application/?) could I take to provide a way for a developer user to perform the import?
Interestingly, the Sitecore classes are available even in web forms outside of Sitecore. I created a separate .aspx file and used Sitecore.Data.Database.GetDatabase("master") to interact with Sitecore's database.

Sharepoint intranet portal

Migrating (rewriting) a whole portal originally made in .net to shareopoint doesn't seem like a very easy thing to do.
I've been assigned such task and now i'm just learning, planning and starting to get things practical in order to accomplish it faster.
It's not exactly a question, it should be a discussion about it and may help others who might get to do the same job further on.
1 - There's something like a "message board" in the current portal, which i'm planning on building with a blog site kind, what do you sugest?
2 - as asked in another question, i have to manage users, and the local active directory is organized and reliable, so i guess that's what i'm going to use
3 - There's got to be a way to store files, images, documents and having version controlling in some of them.
4 - There's got to be a customization in design and a cleaning in the default controls of sharepoint masterpage (which may be useless for the desired purposes)
5 - About 30 local users and being accessible from the internet (local server) in case our consultors have to access it from clients
6 - i have available a version of the Visual Studio 2010 (already with the graphical webpart designer) because the company i work is MS gold partner.
7 - I'm going to program webparts in c#, and the designing part is still a mistery to me, since i'm not that familiar to shareopint yet.
I'd like some tips, links and answers.. i'm going to be watching this question from now on and answering any other information.
1.) SharePoint 2007 has some blog/wiki/board functionality but it's very immature. I tried to get my team to use them but the user interface is lacking and it is challenging to enhance those elements. SP2010 might offer a better experience though.
2.) User management in SharePoint is easy to perform but difficult to manage. Establish processes for adding/modifying end users and keep the number of people with that ability to a minimum. Otherwise it gets out of control and you end up not knowing who has access to what. I would also suggest relying on AD groups as opposed to giving individuals specific access in sites.
3.) Document storage is SharePoint's forte, I think you'll be impressed.
4.) SharePoint branding will require some time but other people have it down to an art form. Note that some pages (referred to as Application pages) shouldn't be fully controlled. Also note that you don't want to remove controls from the master page as some functionality in SharePoint assumes the controls are there - rather it is better to hide them using CSS.
5.) This sounds like a bad idea. SharePoint exposed to the Internet is supposed to be severely locked down - but if you lock it down (i.e. remove access to Application pages), the functionality that you seek won't be available. Have you considered an intranet and separate extranet?
6.) Should be okay, VS2010 is supposed to be a better development experience with regards to SharePoint.
7.) Keep your branding and functionality separate and be sure to deploy them using solution files (as opposed to working directly with the file system). Also, never ever read/write the database directly.
I think you'll find that replacing a custom intranet with SharePoint is a common task but there will be a learning curve. The hard part will be branding and data migration. End users will reject the new system if it is slow - so be sure to get the architecture and configuration right before launch (might require a consultant).
1 - There's something like a "message
board" in the current portal, which
i'm planning on building with a blog
site kind, what do you sugest?
SharePoint discussions are perfect for what they are intended ... small targeted discussions. A forum is very different. It is a centralized area with multiple threads with different topics. You can try CodePlex (which is your friend)
SharePoint Forums
2 - as asked in another question, i
have to manage users, and the local
active directory is organized and
reliable, so i guess that's what i'm
going to use
AD is perfect if you already have it ... nice thing is that you can use the Profile page to update AD information which syncs ... you have a lot of capability with this. But, one of the main benefits is that SharePoint can support multiple authentications. You can extend a SharePoint site and plug in a different authentication (like SQL Auth) and then multiple sets of users can interact on the same sites with different permissions. Not to mention that SharePoint doesn't just provide site access but you can make security granular all the wat down to individual items in a list or library.
3 - There's got to be a way to store
files, images, documents and having
version controlling in some of them.
This is where SharePoint has the most capability OOB.
4 - There's got to be a customization
in design and a cleaning in the
default controls of sharepoint
masterpage (which may be useless for
the desired purposes)
We have a completely customized MasterPage complete with code behind. You need to know about Feature Stapling and Feature Receivers. Also use Heather Solomon's website
5 - About 30 local users and being
accessible from the internet (local
server) in case our consultors have to
access it from clients
SharePoint seems almost overkill for this number of users.
6 - i have available a version of the
Visual Studio 2010 (already with the
graphical webpart designer) because
the company i work is MS gold partner.
Get the Visual Studio Extensions for SharePoint
7 - I'm going to program webparts in
c#, and the designing part is still a
mistery to me, since i'm not that
familiar to shareopint yet.
Look into Application Pages instead of WebParts ... Application pages are way more flexible for custom forms than web parts. Web parts are only usefull for when functionality needs to be available on an ad hoc basis so that you can allow users to drag the functionality onto a page or if you need to restrict functionality to specific sets of users (since layout pages are available to all sites).
The answers to this person's similar but not identical question may be helpful: Sharepoint for a C# Asp.net Developer
There's a lot of help available in other existing SO questions. Just click on the "sharepoint" tag, then sort by votes, and you'll find a lot of interesting reading.
Regarding 7 - Programming web parts:
Have a look at SmartPart on CodePlex. This is a fairly easy way to create simple web parts especially if you have some ASP experience.

Adding Tasks programmatically into the taskList in sharepoint

I have Task List on URL, what I want , when the page loads, the Task list should be loaded with all the aggregated tasks of its sub sites.
I want to do it in C#
You may not need to develop this yourself as there are out-of-the-box solutions available.
Out-of-the-box
If you have Office SharePoint Server 2007 (not just WSS 3.0) just add the Content Query Web Part do the page where you'd like to add the aggregated data. Then configure it to display items from the Task list only.
Another option which works if you have WSS 3.0 as well is SharePoint Designer. You can add the data view web part to the page and configure it to do the same, although only from a fixed set of sites.
There are also other solutions out there that you can purchase.
Custom
If you'd still like to go down the custom route, there are also several options. Have a look at what they are on this SharePoint Dev Wiki page. Again, some of these have a requirement of Office SharePoint Server.
There is also the method of looping through the sub-sites, getting an instance to each list, and then querying that list using the techniques listed here. This isn't recommended if you have several sub-sites or lists containing a lot of items as it will be time consuming, tough on memory, and you will need to implement a caching solution.
You can use a content query web part and scope only Task Lists of sub sites:
http://www.novolocus.com/2008/07/18/content-roll-up-options-part-ii-content-query-web-part/

Categories