Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Monday, December 11, 2017

Access Google gmail Inbox via 3rd Party Application

Hi folks,

Today, I’m come up with a pretty impressive application, which is allow you to access to your gmail inbox and get the feed about the latest email. This simple application based on Atom Google gmail inbox feed. Before I go to development session, let me explain about the atom, according to Google,
Atom is a system which makes it easy for you to receive, in one place, regular updates from news websites, blogs, and/or Gmail. You can use Atom with an aggregator (also known as a newsreader, feed reader, or RSS/Atom reader) to receive new message alerts.Here we go, this is the way to do it.

Pre Requirements.

In order to access gmail account, you have to allow to access ‘less secure Application’. You can easily do it by referring following screen shots.  

Go to Settings and then click Other Google Account settings

Click Apps with account access

Allow to Access Allow less secure apps

I’ll create a separate class to represent email object, and another separate class to get the data from atom the feed.




Get the sample project from GitHub Repository  


Happy Coding,


Best Regards,
Denuwan Himanga

Tuesday, September 1, 2015

LINQ (Language Integrated Query)



Hi guys,

The revolution of the computer programming technology rapidly change, Industry leaders such as Microsoft, Adobe try to add some values to their product in each releases. Within large amount of various product Microsoft own “C#” do an incredible revolution change in computer program developing history. They try to build universal language as well as universal IDE instead of different IDEs and different programing languages.   
According to their huge vision, Microsoft introduce Language Integrated Query with their amazing IDE called Visual Studio in 2008. Basically LINQ provide power full language capability to C#. Very simple explanation is, you can use only one programing language instead of SQL, XML etc.


In this demo, I’ll explain how to retrieve a data from SQL data base without using SQL query. LINQ consider table as a class, as well as data tuple as an object. That feature make computer programing technology to an amazing place J

Demo (Retrieving data from SQL database to WPF Application)    

Create a windows presentation foundation (WPF) application.



After that drag and drop a ‘list box’ from tool box, then formatted that list box according to our SQL table. In my case, Vehicle table formatted like this.


Using XAML code, we can easily format list box according to our requirement. Following XAML code segment format list box according to Vehicle table.

<ListBox x:Name="vehicleListBox" ItemsSource="{Binding}" Margin="0,40,0,0" >

            <ListBox.ItemTemplate>

                <DataTemplate>

                    <Grid>

                        <Grid.ColumnDefinitions>

                            <ColumnDefinition/>

                            <ColumnDefinition/>

                            <ColumnDefinition/>

                        </Grid.ColumnDefinitions>

                        <TextBlock Text="{Binding Vehicle_Name}" Grid.Column="0" Width="150"  FontSize="18" />

                        <TextBlock Text="{Binding Vehicle_Price}" Grid.Column="1" Width="150" FontSize="18"/>

                        <Image Source="{Binding Vehicle_Image}" Grid.Column="2" Width="150"/>

                    </Grid>

                </DataTemplate>

            </ListBox.ItemTemplate>

</ListBox>

Now we need to build a connection between SQL server and application, traditionally connection string responsibility for do this part. But in LINQ, add a .dbml Data classes and call when we need.
Add a .dbml data class to the project.


Add tables on to design surface.



After that, need to create a data classes data context object inside the application.

DataClasses1DataContext DB = new DataClasses1DataContext();

Finally we can easily call a values into special data type call ‘var’, this data type formatted according to values, which is assign to the variable. 

var result = from dt in DB.Vehicles
                         select dt;

vehicleListBox.ItemsSource = result.ToList<Vehicle>();
  
Source code/Project Repo.

Happy coding....

Best regards,
Denuwan Himanga.