Monthly Archives: October 2015

So you are not Happy with your Job ? Here’s some Wisdom…

A very well known truth is, that it is hard to find a job which we would love, or be truly satisfied with it. Nearly 60% of the work force out there are suffering from unsatisfying jobs or career experience.

80605798[1]

I have published a post previously on, How it Feels like to be truly Satisfied and fallen in Love with your Job … But I thought I shouldn’t be so selfish to leave the other side of the scenario behind which is What if you aren’t satisfied our your job ? or hate you job ? as I, myself started off with a negative career experience and ended up here. 😉 So my advice ?

A lot of people go to work everyday being miserable and all they do is just talk about how miserable they are… but they don’t wanna do anything about it…

– Les Brown

First let that sink in…

The major reason why we have such a huge chunk of unsatisfied employees out there is precisely because of the above reason. Almost everyone only talks about how miserable they are at work or how they hate it or fed up of it, but none of them takes any actions towards it. Most probably due to the laziness or the fear of risk. But if you are not one of those people, then I suggest you keep on reading this article, 🙂 otherwise this article is no use for you…

Where%20is%20the%20care_Small_0[1]

Make it work…

If you have have a job, and you don’t feel satisfied, try to look for the positive aspects of it, all the good things, could be even teeny tiny bits. Trust me it’s worth it to focus on the tiny bit of positivity, even in the midst of whole bunch of negativity, because if you do, you might end up actually turning it upside down and begin to be satisfied with your job. 🙂 

If not take the next step…

What if that’s not very practical for you ? then keep on looking for your dream job! Keep working your way up, keep improving yourself, and keep an eye out for your dream job. Don’t be ashamed of yourself, first of all identify the reason why you couldn’t get your dream job (be honest to yourself), and then work up for it. Lack of experience ? paper qualifications ? poor interview performance ? identify what went wrong, and keep improving yourself to make sure it won’t happen again. And apply for it again and again.. 😉 Yes ! Make yourself heard !

There was this one company I wanted to get in so badly right after I graduated, so I sent them my CV, but they didn’t even consider me for an interview and replied me saying I lack experience they are looking for. I was terribly disappointed about myself. But I didn’t put myself down, I just kept on working and improving myself throughout every little opportunity I got. Well guess what ?
After one and half years, that same company contacted me on LinkedIn and said they are impressed with my portfolio and how I have engaged myself with technologies, and they would like to offer me a certain job, with a much higher salary than I’m currently getting… 😉 Likewise it’s never too late for your own improvement… Keep on working towards it, and never give up ! 😀

87705202[1]

Let go of fear and take risks… SERIOUSLY !

Just because you are unsatisfied with your current job, doesn’t mean all the other jobs would be the same, you may never know, your dream job might still be waiting for you to reach out for it…

– ÇøŋfuzëРSøurcëÇødë

Most of us fear that we won’t be able to get into our dream job and we would be unemployed for the rest of our lives if we leave our current job. It is not ! unless you keep on improving yourself and build your own brand ! 😉 Let go of the misery of life by wasting yourself for an unsatisfied job. There are plenty of jobs out there if you are willing work hard to achieve them, and never give up on yourself.

c4ppur4rzkmcg2xl_luefa[1]

Take risks towards your own success, let go of your fear and never give up… 😉 Eventually you will find it, and your life will never be the same again…

In Conclusion…

Well to simply put it, as a great man once said…

Cheers everyone ! Wishing you all Success ! 🙂

Stay Awesome ! 😀

All Images are fetched via Google Search, 2015

Advertisements

How it Feels like to be truly Satisfied and fallen in Love with your Job …

Before I begin, I am currently working as a Software Engineer at an Europe based IT company here in Sri Lanka. And YES ! surprisingly I am truly satisfied with my Job ! 😀

But some of you might be wondering what qualifies me to define the fine line between true job satisfaction and dissatisfaction. To keep it short, I have been to the both ends, and to elaborate let me give you a little insight of my story…

c4ppur4rzkmcg2xl_luefa[1]

So here is my Story…

I finished my degree by the age of 21, and right after that I got job offers from three famous companies in Sri Lanka after successfully passing through all their interviews. So what did I do ? like every other excited-inexperienced-smart graduate, I chose the Job offer with the highest salary and accommodation without considering my passion for innovation, creativity and new technologies as a fresh college graduate.

6935723_orig[1]

Everything was great and going smooth except for the job didn’t turned out to be what I was expecting, so I started to get bored of it. So after completing a considerable work period, I left the job, hoping for a different next step. Learning one of the biggest lessons of my life, when it comes to your Career, never choose money over your life’s passion… 🙂

A Little break for Life…

So for few months, I took a little break, did some freelancing, tried to start off something of my own. But mostly I guess, I just wanted to take a break and refocus on my passion. 🙂 So after two or three months, I got a new Job offer which seemed kind of interesting… 😉 So I thought of giving it a try.

A new Hope…

And I started off working, but I didn’t keep much hopes as I had for my first job, because I didn’t want to get disappointed and suffer later on. But surprisingly after few days of working, I fell in love with that job. I started to love every single day at work. It was the kind of job I have been dreaming to have, filled with innovation, new technologies, and experimentation. And whenever I got home, I couldn’t wait to go back to work the next day… 😉 My life started changing in so many ways since then, and after a long time I was feeling fulfilled about my life…

So starting from having a disappointing career experience and then ending up with a truly satisfied career experience… let me share some of my own Experience of How it Feels like to be Truly Satisfied with your Job… 😀
And Yes, I know this “satisfaction” may or may not last forever or for a long time, as nothing is permanent and everything is constantly changing in this universe by its nature, I’m really valuing and and enjoying it to the fullest while it lasts… After all, change is Inevitable ! 😉 That is Life !

So how does it really Feel ?

Now I should tell you, I have been observing and analyzing my own experience and behaviors regarding this since the beginning whereas I have been collecting facts to write this article since over 9 month. So summing up all the facts, Lemme being… 🙂

You can’t wait till you get back to work next day…

This is the first feeling you will encounter, at the end of the working day, you won’t be able wait till you get back to work on the next day. You prefer staying at office and keep on working even after office hours. Mostly you will wait till the security guards closes the office and shuts down all the light. This used to happen to me all the time, specially during the first 6 months, I was among the last few to leave office. (Later I forced myself not to wait till they close the office lol)
You may get forced to leave office being worried, thinking you couldn’t wait more longer and keep on working. And you may go home after closing the office, but still you will be impatiently waiting till the next day morning to get back to work. 😉

Weekends ? You will be counting hours till Monday!

Oh please, while your friends are waiting for the Weekends to arrive with all their #TBT #TGIF #ThankGodItsFriday and #FinallyItsFriday hashtags, you will hate it when the Weekend arrives. Yes it is true, when you are truly satisfied with your job, you won’t even think of the Weekends to arrive, in fact you wish if there were no weekend. And during your weekends, you will be literally counting hours for it to over and get back to work on Monday! While your friends be like,  #IHateMondays #OhShitItsMonday, and there you would be like all pumped up for work, counting hours for the Monday to begin. The best feeling when you are truly satisfied with your Job is that, when everyone is hating their Mondays at office, you would be loving the Mondays, you would be super energetic and pumped up to begin your work. Yep I know, sounds funny… but that is what happens when you are truly satisfied with your Job ! 😉

You will be like, Thank God It’s Monday #ThankGodItsMonday #TGIM #ILoveMondays…

Simply put, you are gonna love Mondays ! Like I mentioned earlier this is one of the best feelings you would ever encounter. While everyone is hating Mondays, you would absolutely love Mondays, and you would be thanking whoever the guardian higher power you believe in.. 😉 You would be counting hours during weekends and once the Monday arrives, you would be super energetic and pumped up to begin your work while everyone is cursing their Mondays. Personally this is by far one of the best feelings I have ever encountered, because I used to hate Mondays during my previous job, but now I absolutely LOVE MONDAYS ! ❤ 😀

You wish if you could work on Weekends as well…

Yes weirdly enough, you are gonna wish if you could work on Weekends as well. There was this one time I couldn’t bear it up and I asked the manager if I could come to office on Saturdays and keep on working, where he advised me not to even think of it and go out to enjoy real life. lol (whereas later I adopted some habits and activities to do on weekends, such as going out on adventures, cycling, running and so on)
This occurs especially during the first few months of your job once you get satisfied (but later you might find some alternatives to do like I did)… When you are in love with your job, you begin to dislike weekends, and you wish if you could work on Weekends, because simply you are bored of Weekends, having nothing to do, or even if you do have things to do, you would prefer your office work more than them.. 😉 And it gets worst, if you have nothing planned to do on your Weekends, you are going to be bored to death and you will be wishing to get back to work as soon as possible.

Nine to Five routine ? Screw that ! I want more…

Like I mentioned earlier, you are gonna get hungry for your work, you just don’t want the day to end, and specially while your friends are waiting for 5PM to get out of office, you wouldn’t even care about the time. You would simply want to keep on working and you wouldn’t even notice the time moving. And yes this phenomena, I still go through it almost every single day… 😛

You wake up with so much of Energy and Motivation!

Every single morning you will be waking up with so much of Energy and Motivation to go to work, and not only related to work, but also other aspects of your life. You will be pumped up, ready to get back to work every morning when you wake up. You would be ready to go through any challenge at work, and in fact you’ll be on fire at the moment you start working in the morning. With that mentality you get an extra push to set your mind to overcome any challenge or difficulty of your life.

You feel Fulfilled, Happy about Yourself and your Life…

You begin to feel fulfilled about your Life as well as Yourself as a whole, whereas in almost every aspect of your life you begin to feel complete and calm. That feeling of fulfillment and happiness is something truly amazing and very hard to come by for anyone. 😀 We all want to feel fulfilled, about ourselves, and being able to satisfy with your job, plays a huge role in that pursuit. Happiness is something that we all seek for, and let me tell you, when you are satisfied with your Job, you feel an immense amount of happiness throughout your day, whereas Happiness comes as a part of the fulfillment. 😉 You become more optimistic towards life and everything that you go through in your daily life.

You make everyone Happy around you…

With that energy, motivation, fulfillment and happiness comes another benefit, where you begin to make everyone around you Happy ! 🙂 As you become more positive towards every aspect of your life, you begin to direct the same mindset for people around you, your parents, life partner, family, friends and so on. You are always calm and you could easily tolerate anyone around you. You become more positive and cheerful when it comes to dealing with your loved ones so in return you end up making them happy…

Your Efficiency, skyrocketing at work…

One of the best results of being truly satisfied with your job, is that you become more efficient at your workplace, whatever the work you are given, or however challenging it is, you become insanely efficient in it. That very sense of motivation , fulfillment, and happiness become the key ingredients for this amazing force. As you begin to love your work, your efficiency may sky rocket in ways that you won’t even believe. Whatever the work you have given, you would be able to finish it off way better, way quicker in ways you wouldn’t have even thought of before. Your brain gets super focused during your work, that everything becomes so easy to you, that you could easily figure out anything, given any challenge and finish off your work even before the deadlines. Not only that, the quality of your work will begin to improve unbelievably. You will be very much confident in everything you engage with your office work, because you would be doing it with passion for the joy of the job you’re doing. 😉
This effect, I have experienced very well with my work as for the last few months, I have been noticing myself being able to finish almost all the tasks way before deadlines and getting way better at the approach of the work after each and every task. 🙂 Likewise overtime you get insanely efficient with your work, when you are truly satisfied with your job… 😀

…beginning to push through your limits beyond the impossibilities !

Along with all the above incredible side-effects of being in Love with your job, you get an extra super power to push forward through your limits, beyond your own impossibilities… expanding yourself into new horizons of success. 😉 Yep that statement may seem to be a little exaggerated, but yes it is kind of true, with proof of my own experience. You begin to explore more knowledge by yourself, and expand your potential. Personally last few months I was able to easily learn so many new things knowledge related to my career which I thought I never would. 😉
You automatically adopt the ability to learn anything easy without any stress, and rapidly absorb more knowledge and experience by yourself. Therefore your job satisfaction plays a huge role in pushing you forward through life and expanding your possibilities…

Now now…

Now I know the above facts/behaviors/effects/ are based on my own experience and could be easily differ from one person to another, depending on their own perspective, whereas one might have their own different ways of being satisfied with their job, with different experience. But overall I suppose most of these facts or experience are common for those who are actually satisfied or fallen in love with your jobs… 🙂

In Conclusion…

Well to simply put it, as a great man once said…

quote-your-work-is-going-to-fill-a-large-part-of-your-life-and-the-only-way-to-be-truly-satisfied-steve-jobs-14-71-51[1]

It is hard to find a job that you would love or even like it up to some extent, but if you are determined enough, it is not that that hard to find, as it all comes down to our own determination and not giving up on our dreams. 😉

Once you find it, become truly satisfied and you begin to love your job… Your life would begin to change in so many amazing ways that haven’t even thought of before… 😉

Cheers everyone ! Wishing you all Success ! 🙂

Stay Awesome ! 😀

choose-a-job-you-love-and-you-will-never-have-to-work-a-day-in-your-life4[1]

All Images are fetched via Google Search, 2015

Tried the new Google Developer Console ? It’s awesome ! I started off with a new GCM Service…

Or in other words, How to create a new Android Google Cloud Message (GCM) Service in the new Google Developer Console ! 😉
Now getting back to the story, Google is rolling out a new re-designed gorgeous Google Developer Console recently, embedded with their cool fancy materialistic design and some new easy-to-use features. Few days back I tried out their Beta version, which I must admit, was awesome, and I love it. 😀 They had made major changes to the interface of the console, but the functionality and the features are somewhat almost the same.

https://console.developers.google.com/

behold the new Google Developer Console
…behold the new Google Developer Console!

Well just for giving it a try I created a new GCM service in the new Google Developer Console for one of my hobby-time apps. So let me show you how I did it…

Creating a new GCM Service in the new Google Developer Console

First of all click on the Home option in the left menu pane which will be popped up by the top left hamburger button. Usually when you login you will be automatically redirected to home page but in case if your not, you may follow the above instructions. Once you are in homepage you will see a drop down button right next to the top Search bar saying “Select a Project” but if you had any previous projects created in the Console, then it will show up the default selected project name, either way click on the down arrow and then click on the “Create a Project…” !

capture18

Alrighty go ahead and enter the name for your project, and click on “Create” or if you want any Advanced configuration, click on “Show advanced options”

capture19

Well if you clicked on advanced options, then you may follow as below, where you may give project name, edit the suggested project name, and select the app engine server location..

capture8

After everything is done, go ahead and create. Now that should smoothly create a new project for you. Then you dashboard will be automatically switched into your new project. You could see that in the above top right corner, where the “select a project” changes to whatever the new project you created. 😉

Then once you are done, we need to activate the API component we require for Google Cloud Messaging service which is, “Cloud Messaging for Android” which is under the APIs section.

So go ahead click on that top left hamburger, bring up the side menu, navigate to “API Manager” section.

capture20

That should direct you to the API components page as below. Next go ahead and click on “Cloud Messaging for Android” under Mobile APIs section.

capture9

Then you will be given an option to enable the API, so click on “Enable” and enable the GCM API for your project.

WOOT WOOT ! Time for happy dance 😉 you have successfully enabled the GCM API for your project..

capture10

Well then let’s head into creating access credentials for our service right ?

Right underneath the Overview section you may see the “Credentials” section, head into it to create our access credentials..

capture11

Click on “Add credentials” to choose the type of credentials you want to create…

capture12

Well in my case I just wanted to create an API access key, so I shall go ahead with it. (you are in luck if you needed the same option) 😉

That will pop up a small dialog as you what type of API key you require, so for that I’m gonna choose “Server Key” ! Because I am in need of connecting this new GCM service to my Azure Notification Hub. 🙂
But if you are looking for other type of API keys such as for your native Android/iOS/ or Web app, you may go ahead with it at this point.

capture13

Alright that will take you to creating a new server key. Provide a name for the key, and you could provide any specific server IPs you need to provide.

capture14

Hit Create and get your API key (make sure to copy and paste it somewhere safe) ! 😉

capture15

HAPPY DANCE ! 😀

Well you could create any number of keys as you wish, and easily access them anytime under “API Manager” -> “Credentials” section !

capture17

Well well that is it folks. If you haven’t used the new Dev console I strongly recommend you try it now, you would surely love it. Good job Google, finally a much appealing console.. 😉 You may access the help documentation of the new Google dev console from here. https://developers.google.com/console/help/new/

Have a nice time playing around with the new gorgeous Google Developer Console.. 😉

 

How to resolve – Failed to validate credentials with APNS in Azure Notification Hub …

So this happened when I was in the midst of moving one of my Azure Notification Hubs into a new one, where during the configuration I removed the APNS certificate (p12 file) from the old Azure Hub and tried uploading to the new Azure Hub, but during the upload there was some network interference and it didn’t get uploaded and I refreshed the page.

So then I tried again, I got to be honest the internet connection was pretty messed up that day, and the above same scenario happened two more times and I wasn’t able to upload the file. Then after yelling at the Network admin, and getting the connection fixed up, I tried reuploading the p12 file.

Then suddenly this error popped up…

Failed to validate credentials with APNS. Error is Authentication failed because the remote party has closed the transport stream…

Below is a screenshot of the weird moment I experienced.

capture18

The reason why I called it was weird because, there shouldn’t be any issue with the p12 file as I had generated it accordingly and I also had used it before. So I dived into the issue online.

After going through some posts, I couldn’t find anyone who’s had the same above issue, and even they had similar issues, they were able to fix it by regenerating the p12 file as they had missed some steps during the previous creation. So just like that I was clueless…

So I assumed that this must be coming from the APNS authentication service end, which should probably be some unexpected error. And also could be the cause of me trying to upload the same p12 file several time and got interrupted in the middle of the upload due to the network connectivity issues.

So what I did was I waited for about 15 minutes, hoping for the APNS service to clear out the logged error and stop my upload from being rejected, cleared the web browser cache in case if some cookies were messing it up, and changed my IP Address, as if by any chance they were tracking the upload client through the IP address, so with a new IP it would be considered as a fresh upload. Then I tried uploading, guess what ? it worked like a charm ! 😀

It seemed to be my above assumption was right, and probably I was being kicked out by the APNS service for continually failing the file upload.

So I just put up this blog post if by any chance someone experiences the same issue and had no clue what to do, and this is how I resolved it… 😀

Hope this was helpful for any of your fellow awesome developers out there…

Cheers ! 😀 Stay Awesome ! ^_^

 

Microsoft Azure Notification Hub Diagnostics in Visual Studio…

So the other day I wanted to Monitor some activities in my Azure Notification Hubs, well of course you get the “Monitor” tab in the ANH panel online, but it’s hard to get into details with it as it only shows numerical statistics. I wanted to be more specifically look into the Device registrations, platform types, available Tags usage, registration expiration and so on.

Then quite surprisingly I came through this tool which was sitting right inside Visual Studio this whole time, which I hadn’t noticed before. Behold, the “Azure Notification Hubs Diagnostics” tool in Visual Studio. (Well actually Microsoft hasn’t given it a proper name though 😛 , but I wish if they did…)

Capture22

Capture21

(Sorry I had to blacken out the sensible information 😉 )

Just as a side-note I actually wish if Microsoft included these features in the online Azure Notification Hub Monitoring panel as well.

I’m really surprised why I haven’t noticed about this tool this whole time working with Azure PNH ! Therefore I thought of writing a small article about this awesome tool, if by chance any of you fellow awesome developers had missed on this tool… 🙂

Yes its pretty useful…

With the use of this tool you could do easily accomplish all the following requirements,

  • Easily Send Test/Debug Push Notifications (A huge variety of devices through respective PNS)
  • View all the Device Registrations along with their Platform types, Tags, PNS Identifiers, Registration IDs, and Expiration Days.
  • View all the above info in real time as it updates
  • Edit any Tags of the registered devices
  • Remove any Registrations
  • Sort through your specific Tags of the registered Devices
  • View overall registration stats of each platform
  • and many more uses if you are smart enough… 😉

Yep it’s sitting right here…

Simply go to your Sever Explorer Panel -> Sign into your Azure Account (click on Connect to Microsoft Azure Subscription) -> expand Notification Hubs -> choose your desired Notification Hub -> Right Click -> Diagnose !

Capture20

It will open up the Azure NH diagnostics tool, and let the fun begin… 😉

Sending Test/Debug Push Notifications…

When you open up the Diagnostics, by default it opens up the Test/Debug Push Notification Panel as follows.

Capture23

As I have highlighted above, this option beings some very useful features. You could include the tags you need to include in your test push notification messages easily or if you want to send without tags, you could keep the Broadcast option.

Next you will be surprised that there is a long list of mobile platforms you could choose to send the test notification as shown below.

Capture24

Best yet it also by default generates the sample body, and you just have to insert the required parameters and values, and hit send.

Let’s say if you wanted Widows Phone – Toast type notification ? No problem !

Capture25

oh how about Apple iPhone type notification ? Here you go…

Capture26

Likewise, it is super easy to send test push notifications right from here.

Not only sending. but also viewing their results could be done in a very specific manner, which devices received them, any errors occurred and so on. 😉

Viewing Device Registrations and other Stats…

This awesome tiny tool also allows you to view all of the Device Registrations along with the following very useful information.

  • Platform
  • Registration Type
  • Tags
  • PNS Identifier
  • Registration ID
  • Expiration Date

Now the above information may seem quite preliminary, but still when it comes for serious monitoring and debugging those are very useful.

Capture19

Simply go to the “Device Registrations” tab to navigate to this section and start playing…

Now we all know how much we use tags along with our Azure Notifications, which is an incredible feature that allows us to send targeted push notifications to groups or individual devices. And guess what ? this tool allows you to easily search and filter through any available tags and view those registration information.

Capture24

Also you can easily sort through the above listed information columns (Platform, Registration Type, Tags, etc) by acceding or descending order as you wish, which makes it really easy to monitor and debug.

Capture25

What if you ever wanted to Edit or Remove some registrations or their data in case of an emergency ? Yep you can easily do that from this tool.

Capture24

Yep do you see that tiny set of controls in the top left side of the panel ? It allows you to easily,

  • Edit any available Tags
  • Delete any selected Registrations
  • Refresh the Registrations in real time

which are very much useful when monitoring and debugging push notification processes. 😉

Finally another feature this brings is the overall registration statistics of any given platform, which is useful but not very informative though as much as the “Monitor” tab in the online Azure NH Console.

Capture26

There you go, if you haven’t yet noticed about this useful tool, head in right now and give it a try. I grantee you it will come very handy in cases of monitoring and debugging you push notification related executions… 😉
I still wish if Microsoft had made all the above features available in the online Azure Hub Monitoring section, which I sincerely hope they would do someday.
The above mentioned features may not seem to be advance enough, but still they become very handy and useful and if you are smart enough you could use this for many more other purposes.. 😀

Hope this was helpful for any of your fellow awesome developers out there… 🙂

CHEERS ! Stay Awesome ! ^_^

UPDATE 26/10/2015 : 

One of our readers @milenppavlov has suggested another great tool for even more detailed diagnostics for Azure Notification Hub. And yes I agree with him, it seem to be a very useful tool. So if any of you are looking for more specific diagnostics try his recommendation here. https://code.msdn.microsoft.com/windowsapps/Service-Bus-Explorer-f2abca5a

 

 

How to read a Language Resource (AppResources.resx) file in C# and write to Excel

Backstory…

So I’m working on an enterprise level Mobile Application using Xamarin Forms, which is also a multilingual supported app, and there was this one time my boss asked me to prepare an excel document with all the language strings we are using in the app, along with their available translations.

Now I knew I would be able to easily do this in my Xamarin Forms project, but how about writing the extracted resource strings into an excel file ?  and hell no I didn’t want to complicate and mess our project code. So yeah, I had to execute this outside the the project code we had implemented.

Simply put I had to read the content of all the language resource files and write their content accordingly, aligning with their available translations, into an Excel document.

To be more exact, we had three language files for, English, French, and Dutch whereas whenever we add a new Language String in English we had to convert it into the other two languages and add to those two files respectively. But sometimes we miss a one or two translations during development, so to check whether all the strings are translated we needed check the existence of all the strings and their translations in all three languages using an MS Excel document.

So here is how I did it… 🙂

I created a simple WPF based C# project and copied all three language files into it (to the project’s root folder). You could even create a Command Prompt based C# solution also, its totally up to you as long as it’s a desktop-supported dot net solution.

Also keep in mind, I’ll be writing this article based on the three language file I had to deal with, but if you have any more number of language resource file, don’t be afraid to follow the same procedure and make the necessary code modifications accordingly. 🙂

Make sure to copy only the “.resx” extension files, as that’s all we need to retrieve the available language strings. And ignore the “.Designer.cs” that comes attached with it in dot net projects.

Capture4

Once that’s done, next make sure you have set their Build Action to “Embedded Resource“.

Capture5

Then we have to add necessary reference for accessing Microsoft Excel functionalities, and for that go to Add Reference -> COM -> Type Libraries -> type in “Microsoft Excel” !

There you should get a search result with “Microsoft Excel XX.XX Object Library” the XX.XX could change according to the Microsoft Excel version you have installed in your PC. Select that and click “OK” to import the reference.

Capture6

Alright, now that we are done setting up let’s dive into coding…

Reading content from Language Resource Files

Below code will be reading the content from the embedded Languages resource files…

public Dictionary<string, string> ReadEmbededLanguageFile(String language, Assembly assembly)
{
	Dictionary<string, string> VALUES_LIST = new Dictionary<string, string>();

	ResourceManager resmanager = new ResourceManager("LanguageFileReader.AppResources", assembly);
	ResourceSet resourceSet = resmanager.GetResourceSet(new CultureInfo(language), true, true);
	foreach (DictionaryEntry entry in resourceSet)
	{
		string resourceKey = entry.Key.ToString();
		string resource = entry.Value.ToString();

		VALUES_LIST.Add(resourceKey, resource);
	}

	return VALUES_LIST;
}

 

You are passing in the type of language you need to read from and the assembly reference of the current program instance, which is to access the embedded resource files. While reading from the resource file, it will create a Key Value Dictionary array list and add the keys and values of the resource file into this array.

We could use this above method for reading any king of a language resource file and retrieve the values to a Key-Value pair Array list.

Writing the Results to MS Excel file

This below code will write whatever the results you have retrieved from the Resource files into an excel file accordingly aligning with the string keys and their available translation values.

public void WriteToExcelFile(Dictionary<string, string> VALUES_EN_LIST, Dictionary<string, string> VALUES_FR_LIST, Dictionary<string, string> VALUES_NL_LIST) 
{
	Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
	
	if (xlApp == null)
	{
		MessageBox.Show("Excel is not properly installed!!");
		return;
	}

	
	Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
	Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
	object misValue = System.Reflection.Missing.Value;

	xlWorkBook = xlApp.Workbooks.Add(misValue);
	xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

	int rowNo = 1;
	
	foreach (var item in VALUES_EN_LIST)
	{
		xlWorkSheet.Cells[rowNo, 1] = item.Key;
		xlWorkSheet.Cells[rowNo, 2] = item.Value;

		CheckAndAddExistingTranslationForKeyValue(ref xlWorkSheet, item.Key, rowNo, 3, VALUES_FR_LIST);

		CheckAndAddExistingTranslationForKeyValue(ref xlWorkSheet, item.Key, rowNo, 4, VALUES_NL_LIST);        

		// Add more method calls as above for all the available translation resource files you have

		rowNo++;
	}

	xlWorkBook.SaveAs(@"C:\Users\<username>\Desktop\Language-Translations.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
	xlWorkBook.Close(true, misValue, misValue);
	xlApp.Quit();

	releaseObject(xlWorkSheet);
	releaseObject(xlWorkBook);
	releaseObject(xlApp);
}

private void releaseObject(object obj)
{
	try
	{
		System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
		obj = null;
	}
	catch (Exception ex)
	{
		obj = null;
		MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
	}
	finally
	{
		GC.Collect();
	}
}

 

There as you can see, we are passing in the VALUES_EN_LIST Dictionary list, which has the full collection of Language Strings which will be use to cross check the availability of translations for all the given string keys. This is very cruicial, because this parameter will be used to cross check the availability of the translations in the other resource Dictionary lists. You can see I have two more parameters VALUES_FR_LIST and VALUES_NL_LIST these are the other resource Dictionary lists which I need to cross check with the VALUES_EN_LIST in order to write to Excel file aligning with the string keys.

You can see above that I have created an Excel.Workbook and Excel.Worksheet to be incorporated with our writing to an Excel file. Inside the loop we are adding the String Keys and String Values, column by column and row by row. There you can see we are also calling a method CheckAndAddExistingTranslationForKeyValue() which will be given next, where as this method cross-check for the existence of translations for a given String Key and adds the values to the Excel worksheet that we are passing the reference to.

Also there you can see I have added columns as 1,2,3… so on, which is to move from one column to another, accordingly to the amount of translation resources we have.

Then we are increasing the value of rowNo to move on to the next Row in the next iteration of the loop.

And at the end it calls the SaveAs() method and write the file to the disk according to the given Path (make sure you give the accurate path along with a valid file name), and finally release the MS Excel objects. 

public void CheckAndAddExistingTranslationForKeyValue(ref Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet, String Key, int rowNo, int coulumNo, Dictionary<string, string> VALUES_LIST)
{
	// Checking for availability of the translation for the key and writing to Excel Sheet
	if (VALUES_LIST.ContainsKey(Key))
	{
		String ValueFound = VALUES_LIST[Key];

		xlWorkSheet.Cells[rowNo, coulumNo] = ValueFound;
	}
}

 

This is the method that I have used inside the above code’s loop, which cross-checks for the available translation values for a given key and write the found value to the worksheet accordingly to the given column.

Finally let’s put it together…

Alright now let’s put those above methods to use.

public void ExecuteReadingAndWriting()
{
	Dictionary<string, string> VALUES_EN_LIST = new Dictionary<string, string>();
	Dictionary<string, string> VALUES_FR_LIST = new Dictionary<string, string>();
	Dictionary<string, string> VALUES_NL_LIST = new Dictionary<string, string>();

	// Create the resource manager.
	Assembly assembly = this.GetType().Assembly; 

	VALUES_EN_LIST = ReadEmbededLanguageFile("en", assembly);
	VALUES_NL_LIST = ReadEmbededLanguageFile("nl", assembly);
	VALUES_FR_LIST = ReadEmbededLanguageFile("fr", assembly);

	WriteToExcelFile(VALUES_EN_LIST, VALUES_FR_LIST, VALUES_NL_LIST); 
}

 

As you can see, I have defined a three Dictionary arrays for the three language Resource files I have and then inside the ExecuteReadingAndWriting() method I’m calling the ReadEmbededLanguageFile() method to read the content from each resource file according to their culture suffix (“en” – English, “nl” – Dutch and so on).

You can define any number of Dictionary arrays for the number of Language Resource files you have, but make sure to use a sensible naming conversion for them. (VALUES_EN_LIST – for Dictionary array which holds English strings)

Then finally I’m calling the WriteToExcelFile() method to write the read values to an Excel file.

Alright let me give and overall-put-together view of the whole code… 😀

// Call this method to start executing...
public void ExecuteReadingAndWriting()
{...}

public Dictionary<string, string> ReadEmbededLanguageFile(String language, Assembly assembly)
{...}

public void CheckAndAddExistingTranslationForKeyValue(ref Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet, String Key, int rowNo, int coulumNo, Dictionary<string, string> VALUES_LIST)
{...}

public void WriteToExcelFile(Dictionary<string, string> VALUES_EN_LIST, Dictionary<string, string> VALUES_FR_LIST, Dictionary<string, string> VALUES_NL_LIST) 
{...}

private void releaseObject(object obj)
{...}

 

Now that’s how our whole code should look like when put together along with all the above methods I have given you. So go ahead and just call the ExecuteReadingAndWriting() method to fire it up. 😉

If you had programmed it exactly I have shown here, it should work out without any issue. 😉 Once the execution is complete, go ahead and open the Excel Document, it should be show as below, first the String resource Key, String value in English, String value in French (if available) and so on based on the number of language resources you added. Well I haven’t added any special formattings to the excel document sheet in the above code, but you can do it pretty easily by playing around with the code. 😉

Capture7

Well there it goes folks, hope this post was helpful for you and prolly saved you a lot of time… 🙂 Please share this among other developers and you may save another developer’s time as well… 😉

Cheers ! Stay Awesome ^_^ !

 

One of the Greatest Secrets of My Life…

For me its not about Winning or Losing, Its about reaching my limits, going as far as I can go and then going farther… One of the greatest secrets of my life is, I never executed for victory against anyone else, or being better than anyone else…
I have always executed for the ultimate victory over myself, becoming the best I can be, breaking through my own impossibilities, redefining possibilities, and achieving greatness !

– ÇøŋfuzëÐ SøurcëÇødë
[Udara Alwis]