DevOps Practice

Azure Pipelines – Integration with Github, Build pull requests prior to merge, Run tests, Deploy for any platform (Ubuntu, Mac, Windows). See more … (Azure Devops server 2019 can be used as Cloud hosted or setup On-Prem. The azure pipeline build yaml is checked in with your source code so your build process/tasks etc are […]

SOLID Principles

Single Responsibility Principle: A class should be limited to a single responsibility. There should be one and only one reason to change a class. Supported by Object Composition (Composites), Strategy/Template Pattern etc. Key guidelines clearly defined boundaries as to where a piece of functionality is “implemented”; information-hiding in components that protect the integrity of data; […]

Welcome to my blog!

This is where I’ll be sharing my thoughts on topics that matter to me. Who knows… I might even share pictures, videos and links to other interesting stuff. If I catch your interest, let me hear from you.

Creating Bootstrap datepicker

View <form> <input type=”text” id=”pickADate” data-bind=”value: dataModel().pickADate” class=”datepicker form-control” readonly name=”pickADate”​ /> <!– id, name can be anything. class is important –> <script>require[”…., “bootstrap-datepicker”, “bootstrap-datepickerGB”​], function(….,datepicker, datePickerGb) {                     moment.locale(“en-gb”); // Set Locale for moment (aka moment.locale(“en-gb”)) var vm.mydateDate = moment(data.MyDateDate).format(“L”); // we get dd/mm/yyyy $(‘.datepicker’).datepicker({ language: […]

Model binding Enum back to Object

Whe passing data from client (ko data back to MVC) where the object is an Enum of say 2 values. We need to either setup a Model Binder for that or take a shortcut ​as follows: <checkbox data-bind=”checked: viewModel.myStatus”> Enum MyStatus {Complete=1, NotStarted=0} And if myStatus is of type MyStatus then, we can say in ajax before […]

Long Running Task C#

Await and async in .NET 4.5 with C# public Task<string> RunSlowOperationTask()         {             return Task.Factory.StartNew<string>(RunSlowOperation);         } OR var taskData = new CalcTaskData {ForDate = forDate.Value, param2 = Value2};  Task t = new Task(() => DoCalcAsync(taskData));  t.Start(); // Long running Task private async Task DoCalcAsync(CalcTaskData calcTaskData) { // long operation // simulate long wait  (see note below) } Note that […]

Task.Run vs RunSynchronously

Task.Run = Tasks are executed asynchronously on a thread pool thread and do not block the calling thread. ​Task.RunSynchronously: Run on the calling thread, Blocks caller. Both cases need to Wait() to catch exceptions.. TaskScheduler: Latter: Task gets associated with the current TaskScheduler. If the target scheduler does not support running this task on the calling thread, the task will be […]

Export Table to Excel – Server side MVC

Excellent blogpost.. Using ClosedXml Nuget pkg.. ​​ Excerpt: public ActionResult ExportReportDataPerReport() DataTable dt = new DataTable(“ReportDataExport”); // tableName = ReportDataExport (also becomes sheet name in Xlsx) // Add Columns to the dt. Then add data using dt.NewRow and dt.AddRow … // Once dt is populated, run below code..             using (var wb = new XLWorkbook())   […]