C# Adding a Data Source User Guide

C# Adding a Data Source User Guide

What is C#?

When developing applications on the Kuika platform, you can use various data sources and create Custom Action. One of these operations can be performed using the C# language. C# is a widely used programming language in modern application development and can be used as a powerful data source integration tool on the Kuika platform. In this course, you will learn how to connect to databases, apply object-oriented programming principles, and develop performance-oriented applications with C#.

To extend C# with AI Assistant, your subscription plan must support this feature. For more information, please visit the Pricing Page.

This training content consists of the following topics:

  • Data source connection and Custom Action creation with C#
  • C# module anatomy
  • Create C# functions with artificial intelligence assistant
  • Custom Authentication Provider
  • Custom Authorization Provider
  • Custom Verification Code Sender Provider
Create Data Source Connection and Custom Action with C#
  1. Log in to the Kuika platform and open the project you will work on from the Apps screen.
  2. Select the Data Sources module. Here you can view existing data sources, actions and tables or add a new data source.
  3. Click the + icon next to the Sources heading.
  1. Select the C# data source, give it a name and choose the method to use.
  2. Create the data source by clicking the CREATE button.
Anatomy of a C# Module

After adding a C# data source, the following fields appear on the detail screen:

  • Action naming field: You can add or update the action name. You can use English characters in the naming, as well as the special characters “-” or “_”.
  • C# Template Field: You can use predefined templates (Default C# Function, Custom Authentication Provider etc.).
  • External Libraries: In this area, you can define external libraries that you want to use in your action. Libraries accessible via NuGet packages can be added here. For example, popular libraries such as Newtonsoft.Json and RestSharp are supported. The libraries you add become available for use in your C# code. Paying attention to library versions is important for compatibility.

Changes you make in this field will delete the script you wrote before in the Editor.

  • Artificial Intelligence Assistant: You can create AI assisted functions.
  •  Using the Tidy Up Button:
    • You can click the Tidy Up button to ensure that the code you write in the C# editor is organized and aligned. This button automatically aligns and organizes your code so that it is more readable and visually understandable.
  • Saving Functions: After creating the functions in the C# Editor, you can save them by clicking the CREATE button.
Creating C# Functions with AI Assistant
  1. Generate with AI  to open the AI-powered chat field.
  2. Define a function (“Hello world rotating function” etc.).
  3. Copy the code generated by AI and add it to your C# editor.
Custom Authentication Provider

Custom Authentication Provider allows you to create customized authentication systems.

  1. Select the C# data source, enter a name.
  2. Select the Custom Authentication Provider method.
  3. Click the CREATE button.

The Custom Authentication class implements the Custom Authentication interface and defines the authentication functions. The following methods are readily available for users:

  • Login Method: Allows users to log in. There are two different versions:
    • Login with username and password.
    • Login with username, an external token and a refresh token.
    • The user's login must be authenticated. This can be done via REST API or a custom database.
  • Refresh Token Method: Used to refresh an expired token.
  • Find Manager Method: Used to find the manager of a user. It is frequently used in Process Automation.
  • Logout Method: Allows the user to log out of the system. This method has no return value.
    • In Custom Authentication Provider, fields that do not contain a return null value are valid.

In Kuika, fields containing return null are invalid. Therefore, when the null is returned, the values in Kuika are valid.

Custom Authorization Provider

Custom Authorization Provider is used to determine the roles of users within the application.

  1. Select the C# data source, enter a name.
  2. Select the Custom Authorization Provider method.
  3. Click the CREATE button.

Custom Authorization Class and Get Roles Method

Kuika provides a ready-made C# predefined function in Custom Authorization for users. This function contains the following methods and variables:

  • Get Roles Method: Returns which roles the user has in the application.
    • Parameters:
      • App Id: The unique ID (GUID) of the app.
      • App Name: The name of the app.
      • Screen Id: Unique screen-specific ID (GUID).
      • Screen Name: The name of the screen.
      • User Name: Email address or ID of the user.

If no custom authentication system is to be applied, return null should be used. In this case the default system behavior is preserved and no special role is assigned to the user.

The comments provided in the code help developers understand how to use the function. In particular, editable areas of the code are specified for developers who want to define custom roles. This structure can be used to define customized roles for workers on specific screens or application sections.

Verification Code Sender Provider

Verification Code Sender Provider is used to send verification codes to users.

  1. Select the C# data source, enter a name.
  2. Select the Verification Code Sender Provider method.
  3. Click the CREATE button.

Verification Code Sender Provider is used to send verification codes to users of an application. Generates and transmits single-use verification codes for user authentication processes using different communication channels such as SMS, email or push notifications.

Basic Functions of Verification Code Sender Provider

  • Generating Verification Codes: Generates single-use verification codes via SMS or email to authenticate users.
  • Sending Codes to Users: Transmits codes using different communication channels such as SMS, email, push notifications or in-app messages.
  • Processing and Tracking Codes: Manages the process of entered and verified codes, monitors the validity period of codes and prevents reuse.
  • Error and Security Checks: Performs usability and validity checks to ensure the accuracy and security of the code.
  • Improving User Experience: It provides a user-friendly verification process, making it possible for users to easily receive and redeem codes.

Send Verification Code via SMS or Notification

  1. Select the C# data source, enter a name.
  2. Select the Verification Code Sender Provider method.
  3. Click on the CREATE button.

Once this is done, the verification codes will be sent by the specified method. The created data source takes the following information as a parameter:

  • E-mail (User Name)
  • Username and surname (First-Last Name)
  • User Number (User Phone)

The user must select the method (e-mail, SMS, push notification, etc.) by which the verification code will be transmitted and filled in the relevant fields.

After completing the required information entry, complete the process by clicking the CREATE button. These steps ensure that users receive verification codes and that security processes are supported.

C# Example

In this example, we create a class called Calculator and include a method that performs addition. Explanations are also added for each section:

  1. Using System
    • Adds the System library, which is necessary to use basic system functions in C#. For example, it allows you to use the Console class to get console output.
  2. Calculator Class
    • Created to perform mathematical operations.
    • Add Method:
      • public int Add(int a, int b) takes two integer (int) parameters and adds them.
      • return a + b; returns the sum of the variables a and b.
  3. Program Class
    • Main Method:
      • This is where the program starts running. It is considered the starting point of a program in C#.
      • Calculator calculator = new Calculator(); creates an object of the Calculator class.
      • The expression int result = calculator.Add(5, 3); calls the Add method to calculate the sum of 5 and 3 and assigns the result to the result variable.
      • Console.WriteLine($“Result: {result}”); prints the calculated result to the console. The $ sign allows us to print the variable directly by string interpolation.

This example shows the process of creating a class in C#, defining methods and using those methods to perform a simple calculation.

Other Related Content

No items found.

Glossary

No items found.

Alt Başlıklar