Thursday, 26 April 2018

Namely API - Integration with .NET Web application


Namely is an all in one human resource information system. Its offer HRIS, payroll, benefits administration & management, and performance reviews.

If any organization have the central system of namely that contains all employee information, there is a situation where the organization has a different application that requires accessing namely employee’s data. So that this blog is more specific to how to integrate existing Namely Employee data to other software.

Prerequisite:

Authorize namely software with Administrator access rights.

Authorization with Namely System:

In order to use the Namely API, the user must have permission within the system to generate either an API Client or Access Token object.




Once you do, you will see a form to create an API client and/or a form to create an Access Token, depending on which permissions you have. There are two ways to integrate one is API Client and other is Access Token object.

Access Token object:

Creating a Permanent Access Token is a way to bypass the OAuth flow. A Permanent Access Token is significantly longer lived, lasting 2 years. Anyone who has this Access Token is able to access Namely with it alone, which represents a significant security risk. While this access method may be convenient for your purposes.

Permanent Access Tokens:

If you decide to use Permanent Access Tokens, the interface is located alongside API Client creation and will be visible with the proper permission. Please consult your company's Namely or Namely Client Success Representative to have your permissions properly set up.

Namely also provides an interface to create long-lived Access Tokens. While these can be useful for server processes, we urge you to be cautious. Anyone with access to the Access Token can access your system. Avoid placing such tokens in shared code bases, etc.

Namely API request:

You need to include your Access Token in your request headers; you should place them in the "Authorization" element in your headers in the format 'Bearer [Access Token]'.

Below are the code snippets from C# - it passes two parameter – Namely API URL & Authentication Token.

 public ApiResult<bool> SyncNamelyProfiles(long userId)
        {
            NamelyProfileEntity namelyProfileEntity = new NamelyProfileEntity();
            var url = AppConfiguration.NamelyApiURL + "profiles";
            var pageNumber = 1;
            namelyProfileEntity = GetNamelyProfilesByPagination(AppConfiguration.NamelyApiURL, AppConfiguration.NamelyBearerAuthenticationToken, AppConfiguration.NamelyPageSize, pageNumber);
            while (namelyProfileEntity.meta.Count > (AppConfiguration.NamelyPageSize * pageNumber))
            {
                pageNumber = pageNumber + 1;
                namelyProfileEntity.Profiles.AddRange((GetNamelyProfilesByPagination(AppConfiguration.NamelyApiURL, AppConfiguration.NamelyBearerAuthenticationToken, AppConfiguration.NamelyPageSize, pageNumber).Profiles));
            }
            var result = iNamely.SyncNamelyProfiles(namelyProfileEntity, userId);
            return HttpStatusCode.OK.SuccessResponse<bool>(result);
        }


        private NamelyProfileEntity GetNamelyProfilesByPagination(string namelyURL, string token, int pageSize, int pageNumber)
        {
            var url = namelyURL + "profiles";
            var queryString = "?" + "per_page=" + pageSize + "&page=" + pageNumber;
            var client = new RestClient(url + queryString);
            var request = new RestRequest(Method.GET);
            request.AddHeader("authorization", "Bearer " + token);
            request.AddParameter("undefined", "{}", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);
            var result = Converter.Deserialize<NamelyProfileEntity>(response.Content);
            return result;
        }


It will return employee basic information and store it in individual database/store for an organization level different application usages.

Monday, 5 March 2018

Automation Process - Azure Storage Account To Azure Media Service Encoding Process




Today, I would like to share detail on automation process that we implemented in our recent development work.

I split blog in three division so that it would help for better understanding. 

Problem Statement:

We had implemented Cloud service for existing library files to process Azure media encoding and transcribing process so that it processed all the thousands of files successfully.

Now- Based on new requirement end user would upload files from the web application and that newly uploaded files would store in Azure Storage account.

We have to reuse existing cloud service source code logic so that it would process new uploaded media file for encoding and transcribing job.


The solution we design:

As we approach Azure function and mediator to communicate cloud service, new media upload.
Below is the high-level cross-functional diagram.



Actual Implementation: 

Azure functions is a solution for easily running small pieces of code in the cloud. we can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. 

We have implemented an Azure function in a language of choice, such as C#, F#, Node.js, Java, or PHP. 

We created in C# as per below code snippet so that once new blob upload from web to storage account it would auto trigger and send a message to blob queue.

#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Queue;

public static void Run(CloudBlockBlob myBlob, string name, ICollector<string> blobQueueItem, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n URI: {myBlob.Uri} ");
blobQueueItem.Add(myBlob.Uri.ToString());
}


On other ends Cloud, service would de-queue message and send new uploaded assets to process encoding and transcribing service.


 CloudBlobClient sourceCloudBlobClient = sourceStorageAccount.CreateCloudBlobClient();
CloudBlobContainer sourceContainer = sourceCloudBlobClient.GetContainerReference(AppConfiguration.SourceBlobContainerName);
CloudBlobClient amsCloudBlobClient = amsStorageAccount.CreateCloudBlobClient();

 CloudQueue AzureCloudQueue = AzureQueueClient.GetQueueReference(AppConfiguration.blobqueuename);
 var azureQueueMessageList = AzureCloudQueue.GetMessages();


I request you to share your thoughts on the same and I would really appreciate if you could provide your valuable feedback.

Thanks!!! 

Thursday, 8 February 2018

Welcome to the world of blog!

Hello Friends,


Hope you all doing great!!!

Welcome to my blog!!!

Thanks of being here.

See you soon...

Stay tuned!





Xamarin - Cross Platform Mobile Development

Xamarin - Cross Platform Mobile Development Xamarin is one of the most popular cross-platform frameworks at the moment. Xamarin devel...