Session ins and outs of Duet Enterprise Feature Pack 1 on TechDays Netherlands
For the TechDays in the Netherlands I posted a wildcard session, and people can vote to see the session. The session will be about the ins and outs of Duet Enterprise Feature Pack 1. I will address the following topics and more:
1. What will you get when you use Duet Enterprise for communication between SAP and SharePoint?
2. How does this work?
3. What do you need to be able to use it? What do you need to configure?
4. What are benefits and what are challenges?
5. Authentication
6. How can these projects best be done?
7. Oppertunities and lessons learned
8. Development in SharePoint and the BCS
So if you are interested and coming to the techdays, please vote for my session http://www.techdays.nl/WildcardSessieDetail.aspx?sid=62352
Using ASP.NET MVC 3 framework
A couple of weeks ago a colleague asked me what I thought of using the MVC 3 Model in the framework that we were constructing. So that made me think of the advantages of using the MVC 3 framework. So here are the advantages that I saw:
1. First of all the MVC 3 framework makes it possible to really make a distinction between front-end, data and business logic. In our case for the frontend Razor was used. We used JQuery, AJAX and Json calls. It did remind me a bit of the old ASP. But I think it is a lot cleaner. In the controllers the data is passed through from the models to the front-end views. This also makes everything loosely coupled.
2. Re-usability is another advantage. In a framework this is a very important issue. I was able to create screens that could be used for different puposes in different situation. For example, I was able to create a view for the selection and copying of documents. Where the documents came from or where they were copied to did not matter. I could even use different controller code for different situations.
3. Easy learning for the MVC part. If you already knew the MVC design pattern than it is easy to follow how the MVC 3 framework works. It comes with a lot of examples and standard coding.
4. It was easy to learn Razor. This is because it is based on C# language and Visual Studio includes intellisense for creating the code. Of course you can always decide to use a different view engine.
5. On our project it was easier for someone without knowledge of coding but with knowledge of design to change the design code in the views. This did not touch the code and a lot of the design was stored in a CSS file of course. But for the part that was not in a CSS file it was also easy to change.
6. There is no viewstate and Postback events.
7. There is no Page lifecycle. So you do not have to think about what gets called first. We also did the project with Web forms programming and sometimes we had a lot of hassle with what got called first and where errors were coming from. Here it is pretty clear what happens when.
There are some things to be careful with if you are using MVC3:
1. If you are not familiar with JQuery, javascript, Ajax and JSon it will take some time to learn. Personally I think it is worth it and it gives you a lot of control.
2. Even with javascript it is possible to create dependencies between views. This is done for example when in one view you adress a javascript function which is defined in another view. You should be careful by doing so.
3. On the internet some people say that performance is less. In the framework we created the performance with the MVC 3 framework was even better than with the ASP.NET controls.
4. In Web forms programming you have a lot of built-in controls, which you do not have in the MVC model.
5. You should be thinking about how to maintain state before hand. It could be that your forms are working differently than in web form development. For instance it could be necessary to save a form much sooner than you want.
Keep in mind that it is always possible to write code that is not clean. The MVC framework leads you in a certain direction. But it is still your own responsibility to keep your controller code and views clean. You still have to think about the architecture beforehand. If you create dependencies that should not be there, because you do not have a lot of time right now, remember that in most cases time is always a problem. The code never gets changed again and it could save time in bug fixing and learning just to take the time to do it in a clean way.
I saw a great advantage in framework programming to use the MVC3 model.
Creating a hiërarchy of document library folders and subfolders using SharePoint 2010 Client Object Model
Working with the client object model of SharePoint 2010 I wanted to create a way to be able to create a multiple subfolder structure within a document library. Here I describe the way you can do that. At first a procedure was written to create a subfolder under a folder in the documentlibrary:
public void CreateSubFolderForFolder(string subfolderName, string folderName)
{
//This procedure creates a subfolder for a folder in a documentlibrary list
var clientContext = new ClientContext(Uri);
var list = clientContext.Web.Lists.GetById(ListId);
if (list != null)
{
ListItemCreationInformation newFolder = new ListItemCreationInformation();
newFolder.UnderlyingObjectType = FileSystemObjectType.Folder;
//This function gets the complete url to the folder where the subfolder is created for
newFolder.FolderUrl = GetUrl(folderName);
newFolder.LeafName = subfolderName;
ListItem item = list.AddItem(newFolder);
item.Update();
clientContext.ExecuteQuery();
}
}
In order to create a complete layer of subfolders in a documentlibrary the function above should be placed in a loop. But how can you pass a hiërarchical structure to such a function. You can do that for instance by supplying the following structure: /Folder1/Subfolder2/Subfolder3. This states that Subfolder2 needs to be created underneath Folder1 and Subfolder3 needs to be created under Subfolder2. When you pass the structure to the function below this is done:
public void CreateFolderSubFolderStructure(string relativeFolderPath)
{
string totalFolderName = String.Empty;
string[] folders = relativeFolderPath.Split(‘/’);
foreach (string folderName in folders)
{
if (!String.IsNullOrEmpty(folderName))
{
//This checks if the folder already exists
Folder folder = GetFolder(folderName);
if (folder == null )
{
if (!String.IsNullOrEmpty(totalFolderName))
{
CreateSubFolderForFolder(folderName, totalFolderName);
}
else
{
//This function creates a folder directly under the root
CreateFolder(folderName);
}
}
totalFolderName += “/” + folderName;
}
}
}
The GetFolder function in the function above checks wether the folder already exists. If it exists than the folder is not created again but
used to create the next folder. See below:
private Folder GetFolder(string folderName)
{
var clientContext = new ClientContext(Uri);
var list = clientContext.Web.Lists.GetById(ListId);
Folder existingFolder = null;
if (list != null)
{
FolderCollection folders = list.RootFolder.Folders;
string folderUrl = GetUrl(folderName);
IEnumerable<Folder>existingFolders= clientContext.LoadQuery(
folders.Include(
folder => folder.ServerRelativeUrl)
);
clientContext.ExecuteQuery();
existingFolder = existingFolders.FirstOrDefault(
folder => folder.ServerRelativeUrl.ToLower() == folderUrl.ToLower());
}
return existingFolder;
}
-
Recent
-
Links
-
Archives
- December 2011 (2)
- September 2011 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS