Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Monday, February 14, 2022

Sunday, January 13, 2019

My to-read for Microservice


For me, the term Microservice in conceptual level is not new. I think it not much different from SOA. The different is just about how the term define how deep to decoupling/separate in programming level. Recently, with many development teams working on different features. Without causing and impact when changes, they have to be separate to each other which is not new. But now with the technogy improved, and tools are much more powerful. they help a lot to develop with Microservice architecture from start to finish a feature without worry in impact to other features.

Recently, I started to read and research more in details because of facing this problems. There are many sub features/modules in 1 product. Each have to work with different teams. In order to reduce an impact when deploy. I started to think about Microservice.

Concepts:

Before, I was thinking how they dealing with transactions because in monolithic software, it is usually connect to 1 or few data systems. So, they need to work around to cover and make it work by creating a rollback request.

Moreover, with many Microservices, I started to think about how they can working together. Because if many services working together and we have 1 service to Orchestrate them. I think this part will be tightly couple as same as monolithic software did. The link below is not solve the issues. It just talking about how many services can connect in easiest way, less impact and effort by using Kubernetes.

Programming:

Wednesday, May 2, 2018

Convert Microsoft Word (Thai language) to PDF without format or layout changed

There are many libraries out there to convert text into PDF or docx into PDF file. However, recently, I found the problem in Thai language which they usually use "Justify" alignment for their document. But for most of the libraries I found even paid the money one, they have problem in word segmentation. It will result in they can not do Justify alignment properly which very look like to align on the left.

In order to resolve this issue, I had tried to search many possible way to do it which are:
  • Use Microsoft Office Interop
  • Use Word Automation Services in SharePoint 2013
For the first solution, it is quite to easy to implement it. For example, follow the link below:

However, to use Interop, it won't work well on Server-Client architecture e.g. Web Server. It will similar to open Microsoft Word window for each request, which consume a lot of memory as described here: 

The first solution, I tried to implement it once on Web Server but fail due to it has an unknown formatting problem during convert on Web Server (this issue was not found when I try it as Console Application). The PDF file spacing was different from the master docx file for unknown reason.

Later on I found that if we have SharePoint 2013. We can use Word Automation Services which is available from SharePoint 2010 (but as job conversion). To do on demand conversion, it is available on SharePoint 2013. It is very suitable in Web Server solution, and found no issue during convert Thai docx into PDF file.

By the way, in order to run Word Automation Services. It is very important that the machine that run this service must not be the same machine that installed Active Directory, it will result in service does not work (sorry, I can't remember the error message, but it will stuck for awhile before throwing an error). It can be converted from many formats e.g. stream, file location, and byte array.

To use Word Automation Services in C#:
Below is the example cut from the reference link above as snippet. Replace "WORD_AUTOMATION_SERVICE" with your registered service name.
using (MemoryStream destinationStream = new MemoryStream())
{
     //Call the syncConverter class, passing in the name of the Word Automation Service for your Farm.
     SyncConverter sc = new SyncConverter(WORD_AUTOMATION_SERVICE);
     //Pass in your User Token or credentials under which this conversion job is executed.
     sc.UserToken = SPContext.Current.Site.UserToken;
     sc.Settings.UpdateFields = true;
 
     //Save format
     sc.Settings.OutputFormat = SaveFormat.PDF; 
 
     //Convert to PDF by opening the file stream, and then converting to the destination memory stream.
     ConversionItemInfo info = sc.Convert(li.File.OpenBinaryStream(), destinationStream);
 
     var filename = Path.GetFileNameWithoutExtension(li.File.Name) + ".pdf";
     if (info.Succeeded)
     {
          //File conversion successful, then add the memory stream to the SharePoint list.
          SPFile newfile = library.RootFolder.Files.Add(filename, destinationStream, true);
     }
     else if (info.Failed)
     {
          throw new Exception(info.ErrorMessage);
     }
}
In the end, I would like to share my research for this issue because it used quite some time before I found the solution. Hope it can help ^^.

Wednesday, March 28, 2018

ICT Hakathon 2018

Hi, it is such a long time that I didn't update the blog. I have been very busy lately due to my jobs and it caused many of my snippets/topics still kept in my OneNote.

Last week, I had a chance to be able to be a committee in ICT Hackathon 2018 hosting by Mahidol University. The event was held during 24-25 Mar 2018. It is an joint event which sponsored by Atos (my current place), and Innotech. It was very good chance to see what is the current state of academic, and very proud to know that it is still in good shape. Maybe, it is even better than during my studied time here.

For this Hackathon event, it was asked to create a platform to solve specific business issues. In this time, I had been a secondary judge to help verifying their works and provide technical score (one of the judges from my company is not from technical area). So, it was a good experience for me to a judge for a first time (first row seat LOL). It is also good opportunities to let me learn new things from students, because most of time when I doing my work, technology being used in the project is locked. So, sometimes this limit my experience for try implementing new technology into real project.

At the end, it was fun and feel like to be a student again. If I have more chance to participate this kind of event, I hope I am be able to do it again :D.


Links:
Main web site
Organizing Committees
Judges

Thursday, August 17, 2017

"This feature has been disabled by your administrator" error in Office 2013

"This feature has been disabled by your administrator" error in Office product is really annoying due to maybe from company policy or something else. Some people, like me, use OneNote a lot to keep important stuffs for work but it was blocked!! To trying to solve this problem follow the steps in the following link:
https://support.microsoft.com/en-us/help/3039000/-this-feature-has-been-disabled-by-your-administrator-error-in-office

The newer version of Microsoft Office may be fixed by follow the steps in this link.

Friday, September 9, 2016

Useful CMD tips

SSRS - By pass specific user to Reporting Server

When we browse to Reporting Server, it usually ask a username and password to access. However, sometime we want to avoid that by using specific account (treat like webapp that know db password). To do that we have to implement a custom web application that host a web page which can load ReportViewer. Then that page have to specifically implement parameter specification before by pass its parameters to ReportViewer control. The steps are shown below:

By pass anonymous access for reports using custom web app as a proxy
  1. Create ReportViewer in custom web app

Create self WCF Windows Service

SSIS - Parameter things

In SQL Server Integration Services, sometime we have to use the values that can be varied on circumstances e.g. parameter. For my frequent cases, there are 2 cases listed below:
  1. SSIS Variables Object - read from DB
These links explain how to load parameter which values are from database, and how to use parater into SQL query task.

Thursday, February 18, 2016

How to add parameters into a WebRequest?

Conditional Logic in PowerShell


Operator
Description
-eq
Equal to
-lt
Less than
-gt
Greater than
-ge
Greater than or Eqaul to
-le
Less than or equal to
-ne
Not equal to


perator
Description
-not
Not
!
Not
-and
And
-or
Or

Query SQL in Powershell

The following snippet will query data from SQL into DataSet format:

$ServerName = "_ServerName_"
$DatabaseName =
"_DatabaseName_"
$Query =
"SELECT * FROM Table WHERE Column = 'XXX'"
#Timeout parameters
$QueryTimeout =
120
$ConnectionTimeout =
30
#Action of connecting to the Database and executing the query and returning results if there were any.
$conn=
New-Object System.Data.SqlClient.SQLConnection
$ConnectionString =
"Server={0};Database={1};Integrated Security=True;Connect Timeout={2}" -f $ServerName,$DatabaseName,$ConnectionTimeout
$conn.
ConnectionString=$ConnectionString
$conn.
Open()
$cmd=
New-Object system.Data.SqlClient.SqlCommand($Query,$conn)
$cmd.
CommandTimeout=$QueryTimeout
$ds=
New-Object system.Data.DataSet
$da=
New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
[
void]$da.fill($ds)
$conn.
Close()
$ds.
Tables

Sunday, June 14, 2015

Run Unit Test as 64 bit in Visual Studio

Sometime you cannot run unit test because it ask you to run on 64 bit. However, changing debug mode does not help and cause you do not see any unit test methods. In order to make it work, You need to go to Test Settings under Test tab then set Default Processor Architecture.

Tuesday, May 19, 2015

Archeblade Internet Server Configuration

To configure Archeblade server, do the following steps:
  1. by default Archeblade server use 3 ports starting with port 7777. For example, if the textbox in Port Num is 7777, it will use ports 7777-7779.
  2. Firewall: disabled or add Inbound Rules in Advance Firewall settings. Then, allow TDP for ports 7777-7779 and another one for UDP in the same ports.
  3. Configure your router for Port-Forwarding to receive incoming port 7777 to local port 7777 on your specific server ip address for both TCP and UDP.                      
  4. Do step 3 more for port 7778 and 7779.
  5. Done

Wednesday, March 4, 2015

Extract Text from PDF in C#

Hi, long time no see. Currently, I am working as a Consultant at Atos Thailand, so I hardly find a good timing to write an interesting post. For today, I will just paste the link for code snippet to hook up PDF content into text using C#. Take a look at http://www.codeproject.com/Articles/14170/Extract-Text-from-PDF-in-C-NET.

Wednesday, July 9, 2014

Run a set of Visual Studio load tests at once using Command Line

Normally, if you have only one load test environment and have a bunch of load tests that need to run, you need to wait for each test finished then start to run the next test manually.

In order to run them all at one time, we can use Visual Studio Command Prompt to run load tests. But we need to prepare .loadtest files for each load test run separately. It means that if you want to run 15 load tests, you need 15 of .loadtest files.

A command to execute load test has shown as follows:
mstest /TestContainer:[Load Test Name].loadtest /resultsfile:[Load Test Result Location].trx
Then, to run a next load test after another finished, create a command prompt script to run them automatically.

For example - create a loadtest.cmd then add the following lines into the script:
mstest /TestContainer:TestA.loadtest /resultsfile:C:\TestA.trx
mstest /TestContainer:TestB.loadtest /resultsfile:C:\TestB.trx
In case run a distributed load test using test controller and agents from the command-line, it need to add "/testsettings:[Test Setting Name].Testsettings" after specify result file in a command.

For more information about load test, you can take a look at http://msdn.microsoft.com/en-us/library/ms182588(v=vs.110).aspx.

Wednesday, July 2, 2014

Full restore using Windows Server Backup - Network path not found

To full restore from Network drive 1. A user that used to retrieve backup must gain full control all files and folders within that drive. 2. To gain full control, it is not only just gain full control from security tab. It must be included from Advanced menu in security tab then adding / changing an owner, full control permission for all childs, Auditing, and Effective Access to that user. 3. After completed, now, restored machine can full restore from Network drive if everything is done correctly. More information: 1. How to use Windows Server backup http://blogs.technet.com/b/dpm/archive/2011/11/01/data-protection-manager-2010-and-bare-metal-restore.aspx. 2. Resolve Network Path was not found http://blogs.technet.com/b/dpm/archive/2011/11/01/data-protection-manager-2010-and-bare-metal-restore.aspx 3. How to set IP in Command Prompt (during boot) http://www.howtogeek.com/103190/change-your-ip-address-from-the-command-prompt/http://technet.microsoft.com/en-us/library/ee441257(v=ws.10).aspx

Saturday, May 31, 2014

How to setup DLNA media server on Windows 8

You can share media stream over network using Windows Media Player. But it is not available by default. So, in order to enabling this feature, you need to open Windows Media Player and select Stream menu. Then, it will open Media streaming options. So select Turn on media streaming button. You can list which DLNA devices are available on the same network. Select the one you want to share with and then press OK. Note that you also can select specific devices can access only specific folders from your Libraries.

Rename Network in Windows 8

Take a look on:http://superuser.com/questions/550178/how-can-i-rename-a-network-in-windows-8.

Open regedit and edit the following of these registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Nla\Cache\Intranet
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged