How to use the SenseNet framework with our Database - sensenet

I successfully installed SenseNet Framework and it is running on my computer, but I don't know how to use this framework for our database to develop with my private website project and how to begin dev? can you help me ?
many thanks!

I'll try ro give an overview of the current possibilities (as of SenseNet version 6.5.4, because new options are coming in the near future).
Use SenseNet as a standalone web application
This is what you did: install the package and you get a full web app: portal UI and Content Repository (db). You can customize the GUI by creating a new skin or creating pages and moving portlets around on pages. Here are a few getting started links to begin with:
Getting started: using SenseNet
Getting started: building portals
Getting started: developing applications
About maintaining the project (e.g. backup, etc.) please take a look at the operator and dev articles on the wiki - or ask a specific question here :).
Use SenseNet as a backend service
Developers may build on the OData REST API we offer: you can manage content in the Content Repository through http requests (or using the client SDK from C#). This requires the same SenseNet installation as the first option, but you can keep your existing ASP.NET application and only make requests to the SenseNet rest api from your backend (it is also possible to make cross-site ajax calls from JavaScript, but you would have to deal with cross-site authentication in case of sensitive content).
Build an ASP.NET webforms or mvc app on top of SenseNet Content Repository
Currently this is a bit tricky as there is no 'how to' wiki article for this scenario. Basically you would be able to use your existing (or new) ASP.NET webforms or MVC application, and build on the Content Repository as a storage. This way you would loose the built-in UI and the possibility of making REST API calls to the repo (as it is possible in the previous options), but you could still connect directly to the repo usig the SenseNet C# api (this is called in-proc behavior).
To achieve this, you have to copy all the contents from the built-in SenseNet web.config to your app's web config file, and if you want to do some initialization stuff at startup (MVC or web api routing, etc.) than you will have to inherit from the built-in global class (called SenseNetGlobal), implement the usual methods (app start, app end, etc) and register it in the global.asax file in your web root. If you have the correct connection string and all the other values set up in web.config, you should be able to use the SenseNet api (e.g. load and manipulate content items, query the repo) from now on.
Edit: details on custom tables
Custom database tables
Regardless of which way you go, you can of course add your own custom tables to the SenseNet database. Before you do that, please consider storing your objects as regular Content items in the Content Repository though, that way you may benefit from the built-in features of the platform, e.g. indexing and permissions.
But if you already have a table structure you want to reuse or integrate, or it is easier to implement it independently from SN, you can store your custom data in the same database. We offer an API for accessing the database, you do not have to worry about connection strings and other stuff, you can simply use the SqlProcedure SenseNet helper class for executing direct SQL queries.
using (var cmd = new SqlProcedure { CommandText = "SELECT * FROM MyTable WHERE RefId = #MyId", CommandType = CommandType.Text })
{
cmd.Parameters.Add("#MyId", SqlDbType.Int).Value = myId;
var result = new List<int>();
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
result.Add(reader.GetSafeInt32(0));
return result;
}
}
It is also possible to present or even edit external items (e.g. records in your custom table) using the built-in ASP.NET webforms user interface of SenseNet. The platform (with a small amout of development) is able to display external object with built-in field controls (e.g. short texts, dropdowns, etc) and let users manipulate them, without you having to create CRUD user interfaces from scratch.
Of course you can also build a custom UI using your existing dev skills and preferred controls.

Related

Multiple web MVC projects in one SLN and routing to the correct view folder

Background: I'm working on a project to compare the different ways of building an api alongside the different ways to present views to the client. Namely, comparing a level 2 REST API, a level 3 REST API (with HATEOS), and a GraphQL api.On the client I want to compare a standard MVC web application, a Razor one, and an Angular one. You can see the current state of my project here. I used a couple of Pluralsight courses to configure identity server. Its nothing special and its mostly a bunch of random features for the sake of learning.
I dont want to duplicate a ton of logic and I enjoy the challenge. So I want to find a way to serve the different projects in the same sln. So far I've configured the authentication, data layer, and server projects.
The server is where the main and startup classes live.
Question: How can I serve views from controllers in different projects. In API. Authentication I want the Login views kept in that project.
I used this SO question to get me pointed in a direction:
How to specify the view location in asp.net core mvc when using custom locations?
In my Startup class I have this:
services.Configure<RazorViewEngineOptions>(options => {
options.ViewLocationFormats.Clear();
options.ViewLocationFormats.Add("/API.Authentication/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
});
When I go to localhost:8000/login it errors but it says that its looking in the correct location.
How can I configure to point to multiple folders outside of the Startup Classe's directory?

Should I have views in a .NET Core API

At the company I work at we have a couple of different services
API (.NET Core)
Internal Frontend (React)
External Frontend for customers (React)
I was asked to create some views which will be converted to PDF's by an API, but I can't decide where to put them as they are not related to our Internal- or External-facing projects.
My first thought was to put them in our .NET Core API. However this has previously been a strict json-only API, so I have an itch that this is not the intended use.
So internet, my questions are as follows
Is it a big NO-NO to put Razor-views in our API?
Should I dedicate a microservice to this?
What is best practice?
Thanks in advance!
You're right, Razor views will be excess. I see two options:
Backend: Create an endpoint which will return a PDF file based on passed data. Of course you can expand data. This way is similar with Razor: you have a view model and render it to PDF file. An example of library: iTextSharp.LGPLv2.Core
Frontend: Convert HTML to PDF on client's side. Something like react-pdf
I prefer first option, because, first of all, there is already an option "Save as PDF" in browsers, so it will be some kind of duplication of functionality. And on the other hand back-end PDF generation seems more flexible (you can use all of your domain and you can create independent layout either) and you can organise some kind of file cache.

Approach at designing ASP.NET Core 2 applications that share functionality

Currently I've been tasked to create a bunch of small-to-medium applications, each of them having some common functionality.
Implement a preapproved boostrap-based graphical design. Therefore, they will use the same assets, images, css and JavaScript components.
Share the same licensing-based mechanism. An application service will be built where it will scan a file or database to get the number of licenses available for each app, thus granting or denying access to users. The only thing that varies is the name of the application instance itself.
Use AzureAD authentication.
Each must use the same authorization mechanism. A claims-based mechanism will be built to retrieve the claims from the database, given a user AAD account.
Each must share the same administration console.This console will be the one needed to populate user information and common catalogs.
A service will be built, to show toast notifications within the apps.
An email notification service will be built, to send emails to users when triggered by business rules.
And some other, less important features, but these are the core ones.
A first, perhaps naïve approach, was to create an ASP.NET Core 2 solution for each application, and implement the shared functionality in a sort-of Core assembly that can be shared by each app. However, while this could work for points 2 to 5, I'd still be repeating the graphical UI design for each app (basically, copying the wwwroot folder as well as the shared razor views five times). So, a change tomorrow in a CSS would have to be replicated five times.
Another approach would be to create a single ASP.NET Core 2 solution, implement the shared functionality and the UI, and then use the "areas" feature o ASP.NET Core 2, each area being a different app. The problem to this approach is shipping the app: if I have to install the five apps in a customer's server, no problem. If I have to install, say, only two apps, then I'd have to ship the five apps anyway and find a way to disable the other three apps.
So, I'd like to know if there is a feature in ASP.NET Core 2 for handling this type of scenarios, or alternatively, what are industry-standard architectural designs that could apply here.
In Windows Presentation Foundation with Unity, I can create a common shell, and then load modules in that shell, within the same shell window. So, using configuration files, I can add or remove modules as I see fit. What I'm looking is something similar in concept. I do not want to create five ASP.NET Core solutions and copy-paste the wwwroot folder and implement the same mechanisms of authorization, notification, email, etc., but rather, find a way to load the core, common features and then load additional features.
Thanks in advance.

Real time data from VB.net app to web server

I'm fairly new to VB.net programming. I'd like some suggestions for methods/procedures for sending real time data from a VB.net app to a web server (asp.net) for real time display. My question relates to the best method to send the data from the desktop app and the best way to receive and handle the data on the server. I'm not asking for sample code, just some idea of what methods to research. I am currently using a text file upload method but I'm sure there is a more efficient way of achieving this. Thanks in advance for your help.
For sending data to the server, you may research about webservice or WCF.
http://en.wikipedia.org/wiki/Web_service
http://msdn.microsoft.com/en-us/netframework/dd939784
For retrieving data from the server to your ASP.Net application, you can research about AJAX.
http://www.w3schools.com/ajax/default.asp
http://api.jquery.com/jQuery.ajax/
If you are using the MVC framework for ASP.NET (which I strongly recommend over WebForms), MVC4 which has recently gone into RC mode features a very nice new web API:
http://www.asp.net/web-api
"ASP.NET MVC 4 includes ASP.NET Web API, a new framework for creating HTTP services that can reach a broad range of clients including browsers and mobile devices. ASP.NET Web API is also an ideal platform for building RESTful services."
It allows you to define quite simple methods on the server which work directly with your actual domain objects and it does the work of returning data in an appropriate content type (e.g. JSON, XML) based either on the incoming request or a specific configuration you may set.
Your web app could then poll the GET methods on the same API controller class via Ajax (jQuery is nice) to display the results.

Android MySQL php+JSON alternative

I have written a simple database driven app in C# which uses a 2 table MySQL database. This is all a learning curve for me (except c#, which I am now comfortable with)
The app is small, has a couple of datagridviews, uses a few sql select/inserts statments to populate the datagridviews and also update records.
I want to port this app to Android. All of the internet sources I can find recommend a middle php sript which accepts http requests in order to fetch the data from MySQL and then return the results back to the android device where it is parsed with JSON etc etc.
This method is a little out of my reach since I dont have php experience, all of my attempts to implement the php layer have failed, speciially the android app was not receiving any data back, I'm assuming I messed up somewhere inside the php file.
Is there an easier (more noobproof) way to interact with the MySQL database from within android which doesnt require the need for php + JSON? Any ideas are appreciated, thank you in advance.
If you are comfortable with C#, why not use ASP.Net MVC for the middle man?
MVC is especially easy to deal with JSON, and you actually only need to create those "controllers" (as models should already be there from your existing app, and JSON don't need the View to display).
You can create a Web Service with C# that handles the data retrieval from the database; no need to go with PHP. Try create one with WCF API (check this question in order to create one). In order to create an Android client that consumes JSON on Android check this link.
If your mobile application have to access a database over the network you should indeed build a web service fronted to the database.
By putting a web access layer on top of the database you can expose the required queries in an abstracted, secure and convenient manner.
Though this sort of web service architecture can be implemented with PHP + JSON other technologies can be used as well. If you feel more comfortable with C# you can use it to build the web service instead. By doing so you may even be able to reuse some of the code from your existing application.
Actually, it would be better to take php in middle of android & mysql, due to the security concern and by the way this is the most easiest & comfortable method. here is link link. I hope you like it.