SharePoint

Labels
AJAX(112) App Studio(7) Apple(1) Application Builder(245) Application Factory(207) ASP.NET(95) ASP.NET 3.5(45) ASP.NET Code Generator(72) ASP.NET Membership(28) Azure(18) Barcode(2) Barcodes(3) BLOB(18) Business Rules(1) Business Rules/Logic(140) BYOD(13) Caching(2) Calendar(5) Charts(29) Cloud(14) Cloud On Time(2) Cloud On Time for Windows 7(2) Code Generator(54) Collaboration(11) command line(1) Conflict Detection(1) Content Management System(12) COT Tools for Excel(26) CRUD(1) Custom Actions(1) Data Aquarium Framework(122) Data Sheet(9) Data Sources(22) Database Lookups(50) Deployment(22) Designer(177) Device(1) DotNetNuke(12) EASE(20) Email(6) Features(101) Firebird(1) Form Builder(14) Globalization and Localization(6) How To(1) Hypermedia(2) Inline Editing(1) Installation(5) JavaScript(20) Kiosk(1) Low Code(3) Mac(1) Many-To-Many(4) Maps(6) Master/Detail(36) Microservices(4) Mobile(63) Mode Builder(3) Model Builder(3) MySQL(10) Native Apps(5) News(18) OAuth(8) OAuth Scopes(1) OAuth2(11) Offline(20) Offline Apps(4) Offline Sync(5) Oracle(10) PKCE(2) PostgreSQL(2) PWA(2) QR codes(2) Rapid Application Development(5) Reading Pane(2) Release Notes(179) Reports(48) REST(29) RESTful(29) RESTful Workshop(15) RFID tags(1) SaaS(7) Security(80) SharePoint(12) SPA(6) SQL Anywhere(3) SQL Server(26) SSO(1) Stored Procedure(4) Teamwork(15) Tips and Tricks(87) Tools for Excel(2) Touch UI(93) Transactions(5) Tutorials(183) Universal Windows Platform(3) User Interface(338) Video Tutorial(37) Web 2.0(100) Web App Generator(101) Web Application Generator(607) Web Form Builder(40) Web.Config(9) Workflow(28)
Archive
Blog
SharePoint
Wednesday, April 16, 2014PrintSubscribe
Touch UI, Firebird Database, Azure SDK 2.3

Code On Time release 8.0.4.0 introduces a new user interface concept Touch UI and support for Firebird Database Server.

Touch UI (former Mobile Client) is the next generation of the client library. Mobile Client has been introduced in December of 2013. The main objective was to offer a close-to-native mobile experience when using web applications created with Code On Time. We have come to realize that intuitive navigation and new presentation style can benefit greatly users working with desktop computers. During the past two months we have reworked the Mobile Client and turned into a universal touch-enabled presentation system.

The purpose of the new UI is to enable development of a single app that displays equally well on end-user devices of any type. The new enterprise computing concept BYOD (bring your own device) becomes a reality with Code On Time. If you are building an app with Code On Time, then you have already accommodated users of smart phones, tablets, and desktop computers.

Try an app with Touch UI right now!

An app with Touch UI displayed in iPad Air. The app has been created with Code On Time app generator.

An app with Touch UI is displayed in iPhone 5s. The app has been created with Code On Time app builder.

An app with Touch UI is displayed in IE 11. The app has been produced with Code On Time generator.

Touch UI uses the same code base and the same set of business rules. If you are a building a line-of-business app for desktop users then you have already created a mobile version of it. If you are only looking forward and trying to please your mobile user base, then you are also offering a first class experience on the desktop (even if you don’t want to).

Firebird database server is now supported by Code On Time app generator. This is another highlight of the release. Download Firebird and build powerful line-of-business applications with a lightweight database server.

The following enhancements are also included in the release:

  • Touch UI is based on jQuery Mobile 1.4.2.
     
  • Client library provides an enhanced progress indicator.
     
  • Mandatory input fields display “Required” watermark if a custom watermark is not provided.
     
  • Batch Update commands correctly work with modal forms in Desktop UI.
     
  • Azure SDK 2.3 support is integrated in the app generator.
     
  • App generator uses “All CPU” parameter when building projects with MSBuild.
     
  • URL Hashing allows _mobile switch in the browser address bar to enable testing Touch UI on desktop computers.
     
  • Method ControllerNodeSet.CreateBusinessRuleFilter correctly works with data controller virtualization rules.
     
  • Tools for Excel recognizes Watermark property of data fields.

What’s Next?

Touch UI is not completely replacing the current desktop presentation. We will continue supporting desktop and will enhance the client library with further improvements in SharePoint Factory and DotNetNuke Factory.

The desktop presentation in the other project types will eventually become a secondary “fall-back” option for browsers that do not support HTML 5. We will introduce built-in CMS (Content Management System) in the code base of these project types. This may become an attractive alternative to SharePoint and DNN if your application requires custom user-generated dynamic content.

Touch UI is the user interface of the upcoming http://cloudontime.com hosted service.

See the list of upcoming features that we are working on in the Roadmap 2014.

Wednesday, March 14, 2012PrintSubscribe
SPContext and SharePoint Factory

ASP.NET developers depend on the intrinsic  objects exposed as properties Request, Response, Session, and a few others in the code classes inherited from System.Web.UI.Page and System.Web.UI.UserControl.  Everything there is to know about the current web request and mechanism to produce an adequate response is encapsulated in these objects.

Microsoft SharePoint application developers similarly depend on the class Microsoft.SharePoint.SPContext also known as SharePoint Context.

ASP.NET developers may tap in the application foundational infrastructure  via System.Web.HttpContext class when programming web request processing logic outside of the boundaries of pages and user controls. For example, Code On Time applications are extended with business rules, which are not based on the pages. The application framework creates business rules classes in response to AJAX requests to process custom aspects of the application business logic.

For example, the following business rule written in Visual Basic will keep assigning an ever increasing generic label “New Product N” by replacing “N” with the counter whenever a new product is created in the Northwind sample.

Imports MyCompany.Data
Imports System

Namespace MyCompany.Rules

    Partial Public Class ProductsBusinessRules
        Inherits MyCompany.Rules.SharedBusinessRules

        <RowBuilder("Products", RowKind.New)> _
        Public Sub PrepareNewProductRow()
            Dim count As Nullable(Of Integer) = HttpContext.Current.Session("ProductCount")
            If Not count.HasValue Then
                count = 1
            Else
                count = count + 1
            End If
            HttpContext.Current.Session("ProductCount") = count
            UpdateFieldValue("ProductName", "New Product " + count.ToString())
        End Sub

    End Class
End Namespace

The method interacts with the user session object via Current static property of HttpContext class.

HttpContext.Current.Session("ProductCount")

SharePoint developers use exactly the same technique. The entire universe of Microsoft SharePoint server infrastructure is available via Current static property of SPContext class.

Business rule developers can take advantage of the shortcut property named Current to make interaction with ASP.NET runtime a little shorter.

Context.Session("ProductCount")

There is no shortcut that would allow access the SharePoint Context in the same fashion. As a matter of fact the application class library in a SharePoint Factory project does not even reference Microsoft SharePoint assemblies.

We have deliberately constructed the SharePoint Factory application generation project to be a solution composed of three Visual Studio projects. Only the project named WebParts is directly dependent on the SharePoint .

SharPoint Factory project in Solution Explorer

The class library of the project incorporates the entire application source code and resources including JavaScript, images, and CSS style sheets. Project named WebApp is used by the application generator to preview the application at design time.

Injection of SharePoint dependencies in either the class library or WebApp will make it impossible to preview the result of project customization. SharePoint is a 64-bit environment. Code On Time relies on IIS Express, the 32-bit application, for preview of generated web sites. These two are simply not compatible.

If you are building line-of-business web applications then having a direct SharePoint dependency can become obsolete with SharePoint Factory. In a matter of minutes your can generate an app straight from your database, customize it without having any idea about the actual intricacies of development with the rather complex SharePoint environment. Publish your application and the WebParts project will make the miracle of turning your app in a native citizen of the SharePoint Server a reality.

If you do need to take full advantage of vast capabilities of Microsoft SharePoint then with a little bit of effort you will outperform your peers and deliver amazing native SharePoint apps – SharePoint Factory will not let you down.

Right-click the WebParts project of your solution and select Set as StartUp Project option in the context menu.

Expand the class library node of the solution, right-click References. Select option Add Reference. Note that if you are developing a Visual Basic application then right-click the class library project name instead.

Adding a reference to Microsoft SharePoint to the class library project of a SharePoint Factory project

Find the SharePoint namespace on the .NET tab of Add Reference dialog and click OK.

SharePoint assembly in 'Add Reference' window

Choose File | Save All option in the Visual Studio menu.

Start the web application generator, click on the name of your project and choose Settings. Select Business Logic Layer and proceed to enable shared business rules.

Enabling shared business rules in a Code On Time web application

Click Finish button. You will end up on the Summary page. Click Cancel  to return to the start page of the generator.

Select the project name on the start page of the application generator one more time and choose Settings. Activate Web Server Configuration settings

Uncheck “Run application upon completion of code generation” option and click Finish.

Disabling automatic launching of the application upon completion of code generation in Code On Time web application generator

This time generate your project.

Select the project name on the start page and choose Develop to launch the Visual Studio development environment. You will be prompted to authorize the elevated permissions required for SharePoint development.

Double-click the shared business rules class of the class library project to open it in the text editor.

Shared Business Rules class in a Code On Time web application

Enter the following code in the class definition. The class implements a method that allows verifying if a the current SharePoint application user belong to a certain SharePoint user group.

C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using MyCompany.SPDemo.Data;
using Microsoft.SharePoint;

namespace MyCompany.SPDemo.Rules
{
    public partial class SharedBusinessRules : MyCompany.SPDemo.Data.BusinessRules
    {

        public bool BelongsToGroup(string name)
        {
            foreach (SPGroup group in SPContext.Current.Web.CurrentUser.Groups)
                if (group.Name.Equals(name))
                    return true;
            return false;
        }
    }
}

Visual Basic:

Imports MyCompany.SPDemoVB.Data
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Linq
Imports Microsoft.SharePoint

Namespace Rules

    Partial Public Class SharedBusinessRules
        Inherits MyCompany.SPDemoVB.Data.BusinessRules

        Public Function BelongsToGroup(ByVal name As String) As Boolean
            For Each group As SPGroup In SPContext.Current.Web.CurrentUser.Groups
                If (group.Name.Equals(name)) Then
                    Return True
                End If
            Next
            Return False
        End Function

    End Class
End Namespace

Microsoft SharePoint takes advantage of Windows Active Directory and also contributes a proprietary method of organizing users. This method empowers SharePoint administrators to create application-specific user groups that do not necessarily match the corporate domain organization.

Our method will scan the groups assigned to the current user and will return true if the match is found.

The base class BusinessRules implements the method UserIsInRole. The method allows verifying if the current user is a member of an Active Directory user group. Our new addition effortlessly enhances the framework with the ability to analyze membership in the SharePoint user groups.

Let’s take advantage of this method.

Click on the project name on the start page of the code generator and select Design. Activate the Controllers tab in Project Explorer and double-click any data controller. Our sample has been built from the Adventure Works 2008 R2 database. We will customize the HumanResources_Shift data controller. Enter the name of the custom business rule class that will handle the life-cycle of your data controller.

We have entered “ShiftBusinessRules” in the Handler property. Make sure to click OK button to save the changes.

'Handler' property of the business rules class in SharePoint Factory web application created from 'Adventure Works' database

Exit the designer and click Generate.

Return to Visual Studio – you will be prompted to reload the project.

The new file will show in the project solution under the Rules folder of the application class library.

'ShiftBusinessRules' class in SharePoint Factory project

Double-click the file name and enter the following code.

C#:

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using MyCompany.SPDemo.Data;
using System.Xml;
using System.Xml.XPath;

namespace MyCompany.SPDemo.Rules
{
    public partial class ShiftBusinessRules : MyCompany.SPDemo.Rules.SharedBusinessRules
    {
        public override bool SupportsVirtualization(string controllerName)
        {
            return true;
        }

        public override void VirtualizeController(string controllerName,
            XPathNavigator navigator, XmlNamespaceManager resolver)
        {
            if (BelongsToGroup("Team Site Owners"))
            {
                XPathNavigator grid1 = navigator.SelectSingleNode(
                    "//c:view[@id='grid1']/c:headerText", resolver);
                if (grid1 != null)
                    grid1.SetValue(
                        "Welcome, <b>Site Owner</b>. These are the shifts that you can see.");
            }
        }

        [AccessControl("", "ShiftID", "[Name]='Night'")]
        public void ShowTheNightShiftOnlyToTeamSiteOwners()
        {
            if (BelongsToGroup("Team Site Owners"))
                RestrictAccess();
        }
    }
}

Visual Basic:

Imports MyCompany.SPDemoVB.Data
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Linq
Imports System.Xml
Imports System.Xml.XPath

Namespace Rules
    
    Partial Public Class ShiftBusinessRules
        Inherits MyCompany.SPDemoVB.Rules.SharedBusinessRules

        Public Overrides Function SupportsVirtualization(controllerName As String) As Boolean
            Return True
        End Function

        Public Overrides Sub VirtualizeController(controllerName As String,
                navigator As XPathNavigator, resolver As XmlNamespaceManager)
            If (BelongsToGroup("Team Site Owners")) Then
                Dim grid1 As XPathNavigator = navigator.SelectSingleNode(
                    "//c:view[@id='grid1']/c:headerText", resolver)
                If (Not grid1 Is Nothing) Then
                    grid1.SetValue(
                        "Welcome, <b>Site Owner</b>. These are the shifts that you can see.")
                End If
            End If
        End Sub

        <AccessControl("", "ShiftID", "[Name]='Night'")> _
        Public Sub ShowTheNightShiftOnlyToTeamSiteOwners()
            If (BelongsToGroup("Team Site Owners")) Then
                RestrictAccess()
            End If
        End Sub
    End Class
End Namespace

The code will virtualize the Shift controller by changing the header text of the grid view to a custom text if the current user belongs to Team Site Owners group.

It also restricts the list of shifts to the “Night” shift only. The actual database contains “Day” and “Evening” shifts as well but there is nothing the user from the group “Team Site Owners” can do to see the data.

The default instance of Microsoft SharePoint Foundation is configured to execute in Minimal trust mode. Open “C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config” file in a text editor and make sure to that the trust is set to at least “Medium” or “High” level.

<trust level="WSS_Medium" originUrl="" />

Run the solution. Visual Studio will deploy the solution to your local SharePoint instance. Place the application web part on any site page and activate the logical page named “Human Resources | Shift”.

Activating logical page 'Human Resources | Shift' in the webpart created with SharePoint Factory and Code On Time

Save changes in the part editor and exit the page edit mode.

If you are the site owner then this is what you will see.

Only the “Night” shift is visible.  Also a custom message will be displayed at top of the Shift grid view.

User from 'Team Site Owners' group is effected by access control rules and virtualization. Only the 'Night' shift is visible.  Also a custom message will be displayed at top of the 'Shift' grid view.

The applications users that do not belong to the Team Site Owners group will not be affected by virtualization and access control rule.

Sunday, January 22, 2012PrintSubscribe
SharePoint Factory

Microsoft SharePoint Foundation 2010 is the fast growing corporate intranet portal gaining momentum in the development community and businesses. Powerful collaborative platform attracts developers and business users finding creative ways to utilize easy-to-build custom lists integrated with user generated content.

Developers soon discover that the custom list capabilities are limited and Microsoft does not recommend creating lists exceeding a couple of thousand records. The natural solution is the traditional database.  Fortunately the development of applications based on Microsoft SharePoint is very simple. Install SharePoint Foundation 2010, build your app using Visual Studio 2010 and deploy to the server instance from Visual Studio.

There is a downside as well. It is your responsibility to write the code interacting with the database and presenting the results to the end users.

Code On Time and SharePoint Factory will greatly simplify the production of powerful database web applications that can be deployed natively to Microsoft SharePoint portals. These web applications will have a perfect visual match to SharePoint user interface elements. Generated web applications will provide data filtering and searching capabilities exceeding the comparable features of custom SharePoint lists while handling database tables of any size.

image

Installing Development Tools

Start by installing a Microsoft Foundation 2010 on your Windows 2008 or Windows 7 machine. We have compiled a useful tutorial that guides through the SharePoint Foundation 2010 installation steps.

Download  and install Visual Web Developer Express and SharePoint Tools.

Download Code On Time web application generator at http://codeontime.com/download.aspx and install it on the same computer.

For the purpose of this tutorial we will create a web application that uses Microsoft SQL Server as the database backend.

Building a SharePoint Factory Project

Start Code On Time and select SharePoint Factory in the list of available project types.

image

Enter the project name and select the programming language that must be used to generate the project source code.

image

Click Create and validate the connection to your SharePoint instance.

image

Proceed to the Database Connection page of the project wizard. Click the button next to the Connection String input field. Enter the server name. If you are connecting to SQL Express instance then enter “.\SQLExpress”. If you have an instance of SQL Server then enter “.” in the Server field. Configure the login identity.

We will create a blank database and populate this database with the sample Northwind dataset. You can connect to an existing database if you wish.

Enter “SharePointNorthwindDemo” in the Database field  and click Create button, select “Northwind” in the Sample Tables drop down and click Install.

image

Click OK button and continue to Reporting page of the project wizard. Enable dynamic and static reports and proceed to the Features page.

Activate Package Properties section and enter the title and description values as shown in the picture.

image

Click Next a few times until your reach the page displaying a summary of application data controllers. Proceed to generate the web application.

image

A sample web site will launch in the default browser when the web application code generation is over.

The web application displayed in the web browser does look a lot like Microsoft SharePoint portal. In fact, this is a sample ASP.NET web site created as a part of your project to allow quick prototyping and design that does not involve the actual instance of the portal.

The right-hand side of the page presents an area similar to the actual SharePoint Web Part property editor. Select the logical application page constructed by the code generator to activate the Preview mode.

image

Click OK button and you will see the selected logical application page in action.

image

Use Code On Time designer to customize the web application as needed.

Deploying SharePoint Factory Web Applications

The constructed web application solution include a special project that implements a single SharePoint 2010 web part. Web parts are building block of SharePoint sites.

Here is how you can deploy the application to the SharePoint portal installed on your computer.

Select the project name on the start page of the web application generator and click Publish.

image

The code generator will package the application for deployment and in a few short moments you will see a Windows prompt asking to allow the command line processor to alter settings on your computer.

The prompt will be launched to execute a Windows PowerShell installation script that requires elevated permission to run. The script will deploy your application to the SharePoint instance on your computer.

image

You will also see a folder with binary files that can be passed to your network for deployment on the production server. Notice that Deploy.bat and Retract.bat batch files are configured to run specifically on your computer and the administrator will have to change them to work correctly in the production environment.

Both batch files require elevated permissions to run. You can retract or re-deploy your web application if you right-click the corresponding file and choose “Run As administrator” option.

image

Using Generated Web Application in SharePoint

If the deployment has been successful then you are ready to start using your web application.

Launch a web browser and navigate to your local SharePoint instance. The following page will be displayed.

image

Create a new page by selecting Site Actions | New Page option in the menu.

image

Enter “Products” as the page name field and click Create button.

image

The new page will be displayed in design mode. 

Select Insert tab on the ribbon and click Web Part button.

Select Web Apps under categories. You should see the single web part named “Share Point Factory Demo” listed under the category.

image

Click Add button to insert the web part in the page.

You will see the instruction in the main area of the page suggesting to select the logical application page. This is the default message rendered by your application when the web part is inserted in the page layout.

image

Choose Edit Web Part option in the context menu of the web part on the page.

Select the logical page Categories | Products and click OK button.

image

Exit page design mode and try interacting with your web application.

The next screen shot shows a SharePoint Factory web application up and running in the actual SharePoint portal.

image

Conclusion

SharePoint Factory  and Code On Time allow quick and easy creation of powerful database web applications designed to operate in Microsoft SharePoint portal instances.

Create a collection of application pages implemented as user controls; package them for deployment as Microsoft SharePoint 2010 Feature with a single Web Part. Integrate a line-of-business database application with a widely adopted corporate web content management system.