Kentico, module with web part to upload CSV - module

I have a requirement to upload data a from CSV file into custom table in Kentico, I have created a custom table but don't know how to upload CSV and process it, I have also created a web part which I can use to upload CSV and Insert data into custom table but that web part is available on front end web page. I want user to login to Kentico backend first and then access a module and upload CSV file.
How can I build a module with a web part to upload a CSV file?

Kentico has quite well documented process of Custom modules creation:
https://docs.kentico.com/k11/custom-development/creating-custom-modules
What you are looking for is a module with custom UI:
https://docs.kentico.com/k11/custom-development/creating-custom-modules/manually-creating-the-interface-for-custom-modules
In here you are actually creating an ASPX template that will have any controls you need. You can add an ASP button and reuse code from your web part, or add whole web part to the template. If properly configured, module will run within administration and use template of your choosing along with appropriate code.

Related

Cumulocity File Repository

I am trying to load a csv file in the Cumulocity -> Administration - > Management - > File Repository. My objective is to access the file contents in the HTML widget and show the data in tabular or chart format.
I tried using the fetch() method to use csv file url , but it was not able to fetch the file. The file I believe has been locally stored into the Cumulocity platform now. How can I access the file via fetch().
You are trying to abuse the HTML widget for something it wasn't designed for.
Instead of hacking such logic into the HTML widget you should just extend the Cockpit application with your own widget which is honestly not much more difficult using the WebSDK. https://cumulocity.com/guides/web/introduction/
There is a XSRF protection to prevent exactly what you are currently trying: Bringing in custom javascript code into the live application and trying to access the platform API by "hijacking" the cookies of the logged in user (and you would either need the cookies or hardcode some credentials as you cannot access the API unauthenticated).
If you use the SDK there is even a proper Angular service in order to fetch the file for the API.

OData REST API for integrating MS Office

I need to open office documents from my Sensenet client application. My client application is in ReactJs and I need to invoke the document to open in MS office. Is there any OData REST API available for doing the same. Kindly help.
You have two options:
1. open a file in a desktop MS Office application
There is an action in sensenet that gives you the url for that. First, get the actions for a document, using a request like this:
https://example.com/odata.svc/Root/Content/myworkspace/Document_Library('abcdef.docx')/Actions
You'll get the list of available actions, which is a JSON array containing action properties, for example a url. Look for the action named EditInMicrosoftOffice. If you display the URL of that action and the users clicks on that link, the browser should open the appropriate desktop office app (e.g. Word). You may notice that the format of the url is special (something like ms-word:ofe|u|https://example.com/Root/...). Please do not try to assemble this url manually, use the one that sensenet generated for you.
2. open and edit a file in the browser
This requires Office Online Server to be installed and configured in your environment, and you also need to display an html containing an iFrame that'll display the editor.
A simple host page:
https://wopi.readthedocs.io/en/latest/hostpage.html#host-page
Geting data to display the host page:
https://example.com/odata.svc/Root/Content/myworkspace/Document_Library('abcdef.docx')/GetWopiData

How to change default folder structure of ASP.NET Core app that uses Individual Authentication

I created an Asp.Net Core web app and use the option Individual Authentication. The auto-generated code was structured like the picture bellow
enter image description here
I don't want the XxxViewModels (e.g. AccountViewModels) folders inside Models folder, but in a folder named ViewModels that is parallel with the Models folder. How I can achieve while that assuring that all the namespaces are still consistent with the new structure without having to manually change them?

How do I create my own API in Yii2?

I want to create API methods which you can access form another platform. Just see the following diagram.
In the above image you can see how to fetch data from Yii2 app using another application, I wanna use same procedure when I going to push data into Yii2 application from the another application. That's means Yii2 just provides api methods to clint to push/pull data.
Give me some suggestion?
Yii2 provides ready to use RESTful Web Service API. http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html
First of all, you will need separate module for API.
If you use Advanced template (with backend, frontend), you'll need to create api directory in root level of your project. If your project is big, and API will changes in future and your API is for many clients, you should make versioning API. Create directory "modules" in api directory, then create directory "v1" in "modules". In future, if you'll need make a huge changes, create second directory, like "v2".
If you use Basic template, just create modules directory, then create API module.

How to upload file directly to MVC4 web application

I have this MVC4 web application that does CRUD actions for my database. Now I need to upload log files from native mobile application to database. Since it upload log file directly from mobile application code, it does not use RAZOR web page. I'm not sure how to set controller parameter to accept log file. Please give me some hint!