DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Curious about the future of data-driven systems? Join our Data Engineering roundtable and learn how to build scalable data platforms.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Threat Detection: Learn core practices for managing security risks and vulnerabilities in your organization — don't regret those threats!

Managing API integrations: Assess your use case and needs — plus learn patterns for the design, build, and maintenance of your integrations.

Avatar

Ayobami Adewole

Lead Software Developer at Guestlogix Inc.

Toronto, CA

Joined Jan 2012

http://ayobamiadewole.com

About

Software Engineer & Author

Stats

Reputation: 26
Pageviews: 429.3K
Articles: 6
Comments: 0
  • Articles

Articles

article thumbnail
Writing Large Datasets to Excel Files Using EPPlus in C#
Recently, I had to resolve an issue of a corrupt report file of an enterprise application in production. People suggested I use EPPlus, and I was NOT disappointed.
December 15, 2017
· 55,872 Views · 2 Likes
article thumbnail
Bulk Data Insertion into Oracle Database in C#
Bulk insertion of data into database table is a big overhead in application development.
January 28, 2015
· 43,374 Views
article thumbnail
Deserializing Json to a Java Object Using Google’s Gson Library
javascript object notation (json) is fast becoming the de facto standard or format for transferring, sharing and passing around data. be it on the web, rest service, a remote procedure call or even an ajax request. json is light weight with little memory footprint when compared to an xml. the content of a json string in its raw form when observed looks gibberish. to make the content usable it needs to be deserialized or converted to a useable form usually a java object (pojo) or an array or list of objects depending on the json content. a typical json string is as shown below {"city":"jos","country":"nigeria","housenumber":"13","lga":"jos south", "state":"plateau","streetname":"jonah jann","village":"bukuru","ward":"1"} there are a lot of frameworks for deserializing json to a java object such as json-rpc , gson , flexjson and a whole lots of other open source libraries. of all the libraries mentioned i would in this blog post demonstrate how to use google-gson library to deserialize a json string to a java object. you can download the gson library from https://code.google.com/p/google-gson/ . to have the json string deserialized, a java object must be created that has the same fields names with the fields in the json string. there is a website that provides a service for viewing the content of a json string in a tree like manner. http://jsonviewer.stack.hu paste the json string in the text tab and view the fields and the content from the viewer tab i would deserialize a json string that contains address details to an address pojo, the address object follows the structure as seen from the json tree view above. public class address{ private string city; private string country; private string housenumber; private string lga; private string state; private string streetname; private string village; private string ward; public string getcity() { return city; } public void setcity(string city) { this.city = city; } public string getcountry() { return country; } public void setcountry(string country) { this.country = country; } public string gethousenumber() { return housenumber; } public void sethousenumber(string housenumber) { this.housenumber = housenumber; } public string getlga() { return lga; } public void setlga(string lga) { this.lga = lga; } public string getstate() { return state; } public void setstate(string state) { this.state = state; } public string getstreetname() { return streetname; } public void setstreetname(string streetname) { this.streetname = streetname; } public string getvillage() { return village; } public void setvillage(string village) { this.village = village; } public string getward() { return ward; } public void setward(string ward) { this.ward = ward; } @override public string tostring() { return "address [city=" + city + ", country=" + country + ", housenumber=" + housenumber + ", lga=" + lga + ", state=" + state + ", streetname=" + streetname + ", village=" + village + ", ward=" + ward + "]"; } } to perform the deserialization with gson is easy, create pojo classes to hold your data, import the packages com.google.gson.gson and com.google.gson.gsonbuilder, to your project. then create and instance of the gson class and then perform the deserialization as shown below. gson gson = new gsonbuilder().create(); address address=gson.fromjson(json, address.class); voila, you have your json deserialized! the source code listing is below. package jsondeserializer import com.google.gson.gson; import com.google.gson.gsonbuilder; public class tester { public static void main(string[] args) { string json ="{\"city\":\"jos\",\"country\":\"nigeria\",\"housenumber\":\"13\",\"lga\":\"jos south\",\n" + "\"state\":\"plateau\",\"streetname\":\"jonah jann\",\"village\":\"bukuru\",\"ward\":\"1\"}"; gson gson = new gsonbuilder().create(); address address=gson.fromjson(json, address.class); system.out.println(address.tostring()); } }
August 27, 2014
· 89,232 Views
article thumbnail
How to Enable .Net Framework 3.5 on Microsoft Windows Server 2012 R2
recently, i had to put on my system administrator cap for couple of hours. i was to set up two dell poweredge 1720 server computers for use as test servers. the two servers were to run microsoft windows server 2012 r2 and that .net framework 3.5 must be enabled on the servers as it is one of the requirements needed by the enterprise application to be installed on the servers. enabling .net framework 3.5 on windows server 2012 r2 can be done through the server manager by clicking on add roles and features and then under features selecting .net framework 3.5 or through command prompt or windows power shell. as it is microsoft’s custom to put the required files for required role or features in the side-by-side folder. one would have thought that .net framework 3.5 files should be in the folder also as it is in windows server 2012’s side-by-side folder. so an attempt to enable .net framework 3.5 on windows server 2012 r2 would give an error “that installation of one or more roles, role services or features failed. the source file could not be found” like the one shown in the picture below. this means that the .net framework 3.5 (which includes 3.0 and 2.0) files are not included in windows server 2012 r2 setup. if the server is connected to the internet and it has windows update enabled, the framework can be pulled from the internet and added to the windows installation folder by the os when enabling the feature. but the servers i was configuring had no internet connections which means that there was no way the framework could be pulled from the internet. what i did was to copy the side-by-side folder from windows server 2012 setup, (not windows server 2012 r2 setup) since it contains the files needed to install the .net 3.5 framework, i then ran command prompt as an administrator with the following commands. dism.exe /online /enable-feature /featurename:netfx3serverfeatures /source:d:\sxs to enable the feature dism.exe /online /enable-feature /featurename:netfx3 /source:d:\sxs /limitaccess to install the feature where d:\sxs is the path of the folder containing the required files that i copied from windows server 2012 setup side-by-side folder. i hope i have been able to save someone precious time.
July 20, 2014
· 34,662 Views · 1 Like
article thumbnail
How to: File Sharing Application in C#
This is a sequel to my blog post on "A Client Server File Sharing Application in C#" I have received several emails asking for the application to be made into a whole package instead of having it as a separate client and server applications. In order to save time and not to send the solution as email to people again, I have decided to make it a blog post and make the whole package available. The application is written in C# and it will allow files to be sent from one computer to another on the network. It attempts to compile what both the client and server applications in my previous post- A Client Server File Sharing Application in C# do into a single project. To gain a full understanding of the workings, I recommend you read the following- The full listing of the source code is below. using System;; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace FileSharingApp { public partial class Form1 : Form { private static string shortFileName = ""; private static string fileName = ""; public delegate void FileRecievedEventHandler(object source, string fileName); public event FileRecievedEventHandler NewFileRecieved; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.NewFileRecieved+=new FileRecievedEventHandler (Form1_NewFileRecieved); } private void Form1_NewFileRecieved(object sender, string fileName) { this.BeginInvoke( new Action( delegate() { MessageBox.Show("New File Recieved\n"+fileName); System.Diagnostics.Process.Start("explorer", @"c:\"); })); } private void btnListen_Click(object sender, EventArgs e) { int port = int.Parse(txtHost.Text); Task.Factory.StartNew(() => HandleIncomingFile(port)); MessageBox.Show("Listening on port"+port); } public void HandleIncomingFile(int port) { try { TcpListener tcpListener = new TcpListener(port); tcpListener.Start(); while (true) { Socket handlerSocket = tcpListener.AcceptSocket(); if (handlerSocket.Connected) { string fileName = string.Empty; NetworkStream networkStream = new NetworkStream (handlerSocket); int thisRead = 0; int blockSize = 1024; Byte[] dataByte = new Byte[blockSize]; lock (this) { string folderPath = @"c:\"; handlerSocket.Receive(dataByte); int fileNameLen = BitConverter.ToInt32(dataByte, 0); fileName = Encoding.ASCII.GetString(dataByte, 4, fileNameLen); Stream fileStream = File.OpenWrite(folderPath + fileName); fileStream.Write(dataByte, 4+fileNameLen,( 1024-(4+fileNameLen))); while (true) { thisRead = networkStream.Read(dataByte, 0, blockSize); fileStream.Write(dataByte, 0,thisRead); if (thisRead == 0) break; } fileStream.Close(); } if (NewFileRecieved != null) { NewFileRecieved(this, fileName); } handlerSocket = null; } } } catch { } } private void btnBrowse_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "File Sharing Client"; dlg.ShowDialog(); txtFile.Text = dlg.FileName; fileName = dlg.FileName; shortFileName = dlg.SafeFileName; } private void btnSend_Click(object sender, EventArgs e) { string ipAddress = txtIPAddress.Text; int port = int.Parse(txtPort.Text); string fileName = txtFile.Text; Task.Factory.StartNew(() => SendFile(ipAddress,port, fileName,shortFileName)); MessageBox.Show("File Sent"); } public void SendFile(string remoteHostIP, int remoteHostPort , string longFileName, string shortFileName) { try { if(!string.IsNullOrEmpty(remoteHostIP)) { byte[] fileNameByte = Encoding.ASCII.GetBytes (shortFileName); byte[] fileData = File.ReadAllBytes(longFileName); byte[] clientData = new byte[4 + fileNameByte.Length + fileData.Length]; byte[] fileNameLen = BitConverter.GetBytes( fileNameByte.Length); fileNameLen.CopyTo(clientData, 0); fileNameByte.CopyTo(clientData,4); fileData.CopyTo(clientData, 4 + fileNameByte.Length); TcpClient clientSocket = new TcpClient(remoteHostIP, remoteHostPort); NetworkStream networkStream = clientSocket.GetStream(); networkStream.Write(clientData, 0, clientData.GetLength (0)); networkStream.Close(); } } catch { } } } } The Complete source code of the application is available for download Here
June 7, 2012
· 23,844 Views
article thumbnail
Scheduling a Job Using The NCron Library
Introduction NCron is a .Net scheduling framework, it is a .Net version of Cron - the time based job scheduler found on unix like operating systems or Cron4j - scheduling library for Java. Ncron is light weight and easy to use, with little learning curve. It comes with some cool advantages, being that you can use it in C#, Vb.net or any other .Net programming language. It takes your mind off the details of scheduling and you can focus on how to implement the business logic of your application or the job to be scheduled. Details such as threading and timers have been taken care of. Ncron Library You can point your browser to http://code.google.com/p/ncron/downloads/detail?name=ncron-2.1.zip to download the ncron library. You need to add reference to the Ncron library in your project so as to be able to access the classes and functionalities of the Ncron scheduling framework. Scheduling a Job When creating a job to be scheduled using NCron, the job is wrapped up in a class which must extend the class NCron.CronJob and override a void method Execute public class MyJob : NCron.CronJob { public override void Execute() { System.IO.File.Copy(@"c:\\output.out", @"f:\\output.out"); } } The job to be scheduled will be placed in the Execute method. The next thing to do is to give NCron control over the job execution, by calling the static method Bootstrap.Init() at the entry point of your application, for example this can be put in the Main method. You should have a static setup method, which I called JobSetup method that will be passed into the Bootstrap.Init() method. using System; using System.Collections.Generic; using System.Linq; using System.Text; using NCron.Fluent.Crontab; using NCron.Fluent.Generics; using NCron.Service; namespace NcronExample { public class Program { private static void Main(string[] args) { Bootstrap.Init(args, JobSetup); } private static void JobSetup(SchedulingService schedulingService) { schedulingService.At("* * * * *").Run(); } } } The line of code inside the JobSetup method is to specify how the Job is going to be run, and the parameter in the schedulingService.At() method is known as crontab expression which I will discuss shortly. The SchedulingService class has a number of methods of interest. service.Daily().Run(); //runs the scheduled job once every day service.Hourly().Run(); //runs the scheduled job once every hour service.Weekly().Run(); //runs the scheduled job once every week Crontab Expression A crontab expression is a string comprising of 5 characters, which are seperated by space. This crontab expression when parsed produces occurrences of time based on a given schedule expressed in the crontab format. NCron parses crontab expression through the use of NCrontab(Crontab for .Net) an open source library for parsing crontab expressions. A regular crontab expression is of the form * * * * * where the first * is for minute which can be from 0-59. The second * is for hour which can also be from 0-23. The third * is for day of the month from 1-31. The fourth * is for month from 1-12. The last * is for day of week from 0-6 where 0 represents Sunday. The asterisk or wildcard character if left in the expression indicates all valid or legal values for that column. If yIf you want the scheduled job to run every minute, the expresion will be in the form below. * * * * * The The expression below causes the scheduler to run the job at the fifth minute of every ninth hour everyday. 5 9 * * * To run a job every tenth minute of every hour from Monday to Friday only, the expression will be in the form below. 10 * * * 1,2,3,4,5 You can read more on crontab expressions at http://code.google.com/p/ncrontab/wiki/CrontabExamples Deploying the Scheduled Job After the application has been built and compiled, you can deploy the scheduled job as a service by opening command prompt and change directory to where the executable of the application is and then run the command. ncronexample install To install the scheduled job as a service, and that is it !!!
April 18, 2012
· 16,921 Views

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: