ASP.NET Code Generator

Blog
ASP.NET Code Generator
Sunday, February 5, 2017PrintSubscribe
DotNetNuke Factory and DotNetNuke SaaS

DotNetNuke (DNN) is a popular content management system build with Microsoft ASP.NET technology with the loyal following. Developers love the ease of customization and native support for Microsoft Development Tools. Nevertheless it is difficult to build complex user interface when large number of data entry screens is required. Code On Time application generator provides DotNetNuke Factory project designed to produce native DNN module with complex data entry screens created directly from your database.

Applications for DNN created with Code On Time have a Classical (Desktop) user interface and cannot run outside of the portal on their own. Over the past years we have developed a new powerful user interface called Touch UI. This user interface relies on the pages with special structure to enable execution on both mobile and desktop devices. It is impossible to plug such pages into the DNN portal without disrupting its core functionality.

Our product used to offer SharePoint Factory project designed to create native web parts for this portal in the fashion very similar to DotNetNuke Factory. In fact, some core capabilities were shared between the two. Microsoft has greatly changed SharePoint portal starting with SharePoint 2013. It became impossible to incorporate custom web parts directly in the pages of this portal. Instead, developers have to create dedicated applications, which run in a completely isolated environment frequently on a different physical server. The output of the custom code is displayed in an <iframe> element allocated on the SharePoint page for the purpose of integration. The custom code must use OAuth protocol for authentication if access to the host site data such as current user is required.

Starting with release 8.5.12.0 we are retiring SharePoint Factory project and make it possible to integrate any Web Site Factory or Web App Factory project in Software-as-a-Service mode into SharePoint Online (http://sharepoint.com), SharePoint 2013, and above. A free web part from Microsoft Office Store (https://store.office.com/en-us/app.aspx?assetid=WA104380704) makes it easy to integrate Code On Time apps in SharePoint sites (http://codeontime.com/learn/sharepoint/add-in/configuration).

We will bring Touch UI and SaaS integration technology to DotNetNuke users in release 8.5.13.0.

Developers will create either Web Site Factory or Web App Factory project on top of their database. The database will have its own security system to maintain users and roles. The following will be performed when application is ready for integration:

    1. Application will be deployed to either dedicated server or on the machine where DNN portal is running.

    2. Developer will generate a secret key stored in the application database.

    3. Developer will install a Data Connector for Cloud On Time module into the portal and have it configured on portal page.
        1. The module will be placed on the page of the portal.

        2. The secret key generated in step #2 will be specified in the module properties.

        3. URL of the application page or its root address must be specified.

        4. Optional DNN tokens can be listed in the Data Connector configuration.

      1. Data Connector will communicate with the the application instance when the page is rendered by the portal on the server:
          1. Connector will make a server-to-server request to the application passing the encrypted secret key, name of the user, roles, and  optional values of DNN tokens.

          2. Application will confirm the secret key, process tokens, and return login token to the Data Connector.

          3. If the portal user does not exist in the application database, then the user with the same name and random password is created.

          4. User roles in the application database are synchronized with the portal roles.

          5. Data Connector will render an <iframe> element in the output of the page with the login token in the URL pointing to application page.

        1. The page with the <iframe> will be rendered by the web browser on the client device.

        2. Application will perform single-sign-on for the current user with the help of the login token in the URL of the <iframe>.

          Universal Business Applications created with Code On Time and Cloud On Time will work both on their own and also in SaaS mode within DotNetNuke, Microsoft SharePoint Online, and Google G-Suite. If a hosted UBA is accessed directly, then the hosting environment will perform user authentication, which makes possible using apps on mobile devices outside of the host environment.

          Code On Time will continue to ship with DotNetNuke Factory. If developers have existing projects of this type, then they may choose to continue creating native DNN Factory apps with Classical user interface.

          Monday, January 2, 2017PrintSubscribe
          Authenticating Users with Windows Live

          Every application requires a list of user accounts that have been granted (or denied) access to the data. In order to maintain membership consistency, every user needs to be associated with a password. Recommended practices for passwords dictate that every password must be unique, contain a long series of mixed alphanumeric characters, and that users should change their passwords regularly. It is likely that many users do not follow these recommended practices, and tend to reuse simple and easy to remember passwords across various systems. This can lead to a security issue if one of the systems becomes compromised – malicious users can then gain access to all systems that share the same password.

          In an attempt to solve solutions to the problems mentioned above, authentication can be delegated to a “higher authority”. Application admins can register their app to accept responses from a federated authentication server. When a new user attempts to sign up to the application, they can choose to register an account using their federated account. They will be redirected to the authentication server’s login page, and grant permission for the app to gain access to their email. This information is then used to automatically create an account in the app and sign them in. Therefore, the user simply has to ensure that their account in the federated system is secure.

          Applications created with Code On Time can use OAuth 2.0 to register their users. Simply define a resource under the Content Management System (CMS) that lists your client ID, client secret, and redirect URI. A local redirect URI can be defined for testing purposes.

          Registering Your App

          The first step to enable Windows Live authentication is to register your app.

          Navigate to https://apps.dev.microsoft.com. In the top-right corner, press “Add an App”. Enter a name for your app and press “Create Application”.

          Adding an application to Windows Live.

          Under the “Application Secrets” section, press “Generate New Password”.

          Generating a new password for the application.

          Make sure to copy the new secret.

          Next, press “Add Platform” under the “Platforms” section. Select “Web”.

          Adding a platform for the app.

          Enter your application URI, with the path “/appservices/saas/windowslive”. Optionally add a local URI for testing purposes.

          Adding redirect URI for the app.

          Scroll to the bottom of the page, and press “Save”.

          Enabling Windows Live Login in the App

          The connection needs to be registered in your application. Navigate to the Site Content page of your app, and create a new record with the following settings:

          Property Value
          File Name windowslive
          Path sys/saas
          Text

          Client Id:
          1234567890

          Client Secret:
          12345mysecret67890

          Redirect Uri:  
          https://demo.codeontime.com/appservices/saas/windowslive

          Local Redirect Uri:
          http://localhost:31733/appservices/saas/windowslive

          Make sure to change the Text to the correct values for your app.

          Logging In with Windows Live

          Log out of your app, and press Login to open the login form. The “LOGIN WITH WINDOWS LIVE” action will now be displayed.

          The login form now displays a button to "LOGIN WITH WINDOWS LIVE".

          Press “LOGIN WITH WINDOWS LIVE”, and you will be redirected to the Windows Live login screen. Once logged in, a permission request will be displayed.

          Windows Live displays a permission request - the app is requesting access to the profile's email.

          Press “Yes”, and your browser will be redirected back to the app. The app will attempt to sign in with the account matching the returned email. If no account is found, then an account will be created with the email as the username, and a random GUID assigned to the password and password answer.

          Thursday, June 23, 2016PrintSubscribe
          Source Code Version Control

          Every user of a computer has experienced a situation when they really wish they could wind back time. From hardware failure losing recent work, to changes made to a file that need to be undone, this capability is necessary to ensure productivity is not lost.

          Software development is no different. The most common solution to this problem is through the use of source control systems such as Git, Microsoft Team Foundation Services (TFS), or Apache Subversion (SVN). These solutions will monitor a specific set of files, and allow the user to “commit” a version of files to a repository. When necessary, the user can revert to older versions of these files. Even better, it allows the development of software projects among multiple users. 

          Code OnTime app generator makes it easy to use source control with your project. When the type of source control is specified, the generator will create requisite files that allow easy exchange of application files and changes made to project configuration.

          Getting Started With Source Control

          Let’s place our sample Northwind project under source control using Git. On the home page of the app generator, click on the project name. Select “Settings” from the Project Action screen, and then select “Source Code and UI”.

          From the Source Control dropdown, select “Git”.

          Selecting a source control for the project.

          Press the Finish button, and then press “Generate” to generate the application. If the project folder is inspected, two files have been added to the root.

          Project with source control now generates sync files.

          A default “.gitignore” file is added, based on the standard file created by Visual Studio, with several Code OnTime files listed at the bottom. If TFS source control was selected, a corresponding “.tfignore” file will be added.

          The other file will be named “Sync.[Machine Name]-[User Name].xml”. This file holds all transactions made in the Project Designer by the current user and machine. When the application is refreshed, all “Sync.XXX.xml” files at the root of the project will be merged together and sorted by transaction timestamp. The merged file is used to create the “Controllers.Log.xml” and “Application.Log.xml”, which hold transactions that are applied to controllers and application pages, controls, and data views, respectively.

          This allows work from multiple machines to be smoothly integrated, without having to deal with manually merging XML files.

          Next, let’s push this project to a new repository. This process may differ based on the source control and tool used to initialize the repository.

          On the home page of the app generator, select the project name and press Develop to open the project in Visual Studio.

          In the Solution Explorer (typically found on the right side of the screen), right-click on the solution node and press “Add Solution to Source Control”.

          Adding the solution to source control using Visual Studio.

          In the “Choose Source Control” popup that opens, select “Git” and press OK.

          Selecting Git for the source control.

          If the Visual Studio Git Provider has not been used before, it will require configuring your user name and email address. Click the “Configure” link, visible at the top of the Team Explorer window, set your desired settings, and press Update.

          Next, enter a commit message, and press Commit to create the first commit in your local repository. Make sure that the necessary files are included in the commit.

          Creating the first commit.

          If the commit was successful, a message will appear at the top of the screen, stating that the commit was created. It will also prompt to sync the repository with a server. Click the “Sync” link to sync to a server.

          The same screen can be reached by pressing the Home icon from any screen, and selecting “Sync” option.

          The first commit was created successfully locally. Time to synchronize online.

          Several options will be available. For this example, we will use GitHub. If you have not logged into GitHub on this computer, click the “Login” button, enter your credentials, and press “Login” again.

          Logging into your GitHub account.

          Select “Get Started” link under the “Publish to Github” section.

          Getting started to synchronize your repo with Github.

          Select your account, enter a repository name, and add a description (optional). Please note that private repositories require a subscription on GitHub. If the repository is public, then anyone can find the source code on the Internet. Choose accordingly.

          Press Publish to push your repo to GitHub.

          Selecting project name and description for pushing to Github.

          Once the upload process is complete, you will be able to access your repository online.

          The online repository on Github.

          Synchronizing Changes

          Now that the repository is online, you will need to synchronize it. Suppose that several changes have been made to the web app. Pages have been shuffled around, data fields customized, models added, business rules changed. Make sure to generate the application before synchronizing any changes.

          Open the project in Visual Studio, open the Team Explorer, and select “Changes”. You can also right-click on the solution and press “Commit”.

          Uploading a new commit to Github.

          Enter a commit message, and click the dropdown next to “Commit”.

          Press the “Commit” button if you wish to create a local commit, but not upload your changes to the server.

          Press “Commit and Push” to upload your commit to the server.

          Press “Commit and Sync” to upload your commit, and download any changes that may have been pushed to the server previously.

          At this point in time, press “Commit and Push”.

          Commiting and pushing your commits to the online server.

          When the process is complete, a message will be displayed.

          Downloading a Web App From Source Control

          Suppose a team member has joined your team. You will need to give your teammate access to your repository. Log into your repository server and give your team member’s account access to the repo.

          For a GitHub repo, you will need to navigate to the correct webpage on the GitHub website. Select the Settings tab near the top of the screen, and switch to the “Collaborators & Teams” section. Enter your member’s screen name in the Search bar and press “Add collaborator”.

          Adding a collaborator to the repo.

          On your team member’s computer, start Visual Studio. Press “Open From Source Control…” on the Start Page if visible. Otherwise, press the green Connections icon on the Team Explorer.

          Connect pane in Team Explorer.

          Select the “Clone” link under GitHub section. Click the repository you shared with the team member, and enter the correct path. In this case, the path is “~/Documents/Code OnTime/Projects/Web Site Factory”.

          Selecting a repository to clone.

          Restart the app generator. If the repository has been placed in the correct location, a new project will appear in the project list.

          Pulling Changes From The Server

          Suppose that your team member has made some changes, and you wish to pull these changes down to your computer.

          Open the project in Visual Studio. In the Team Explorer, select “Sync” button.

          Home page of Team Explorer.

          The Synchronization pane offers several options.

          The “Fetch” button will download pending commits, but will not integrate changes.

          The “Pull” button will download pending commits and perform merge operations if necessary to bring your repository in line with the server.

          The “Sync” button will uploading pending commits, downloads commits from the server, and performs merge operations to integrate remote changes with your local changes.

          At this time, press “Sync”. The commits made by your coworker will be downloaded and integrated.

          One last step is needed. Switch back to Code OnTime app generator. Select the project name, and press “Refresh”. This will integrate synced changes into the current project.

          Refreshing the project with Code OnTime app generator to integrate new changes into the project.