Because of some urgent reasons, I'll have to do some quick ramp and understanding on certain latest technologies.
I'll start on Windows Workflow Foundation.
Where to find the resource? Googling? Yeah, it's good actually. But I afraid that I found hundred or thousand of link / resource that are not appropriate, not specific, not very useful, not too informative, or too advanced for a starter to learn. Sometimes starter confuses where to start and what to learn first.
The answer is here. .NET Framework 3.0 Training Kit and Visual Studio 2008 Training Kit! You'll find the presentation from the expert, demo code, and hands on lab. It's perfect for the starter.
Introduction
Okay, before we go in to the Windows Workflow Foundation, let's define what the term "Workflow" is. Workflow is:
- The organization of work business process or application login.
- A set of activities that coordinate people or / and software
- Something that we face every day in our daily life (maybe sometimes, we don't aware of it)
- Request a leave to our boss is also to be considered as a workflow (do you? J)
Actually at the earlier, Microsoft has started to aware the important of the workflow in software development.
It would be nice if:
- there is something that can help us easier to make a workflow
- We can integrate the workflow activity with our other application / action
- I can send a request to my supervisor to take a leave via web application; my supervisor could reply me his decision. When my supervisor agrees, there would be an email that will be sent automatically to the HR department. Finally, my leave credit at the database would be automatically deducted.
Those requirements forced the birth of a cool stuff named Windows Workflow Foundation (WF, not WWF coz WWF has been taken and known, stands for World Wrestling FederationJ)
In formal definition, Windows Workflow Foundation is the programming model, engine and tools for quickly building workflow enabled applications on Windows.
Architecture
I fully agree with what Mr Risman said. "Learning the How To is easy; understand the concept and architecture of how something works is more important". As the result, in this post, I'll start from the concept and architecture first. Hopefully, I can continue the "How To" part in the next post.
So next, let's step in to the architecture.
Let's dig it reversely from the bottom.
From the big box, we can see that the workflow foundation would be treated as a "Hosted Process" that are ready to listen any action or request.
Inside the host process, there will be the Workflow Foundation that contains 3 important layers:
-
Runtime Service
This is where the heart of the WCF is. It makes the WCF alive. We can say, it's the foundation for others layer.
-
Runtime Engine
Runtime Engine runs on the top of Runtime Service. It handles some stuff like the workflow execution and the state management.
-
Base Activity Library
This is the library of the WF. We will need the library to build our workflow. We are given, all we need to do is learn how to use it J.
If you are familiar with the .NET Framework architecture, imagine it like the BCL (Base Class Library / Framework Class Library)
On the top of the 3 important layers that I mentioned above, there is Custom Activity Library. It is sure that we will need something the Base Activity Library doesn't provide us; we need to build it ourselves or buy it from 3rd party vendor. Here's the Custom Activity Library located.
After we are ready with those things above, we now are ready to develop our workflow. We can design our workflow using the libraries such as:
- Code Activity
- Delay
- Conditional (If – Else)
- Looping (While)
- Listen
- Etc
To make us easier in building the workflow design, Visual Designer offers us a great help. All the action or process could be done by click and drag visually. Of course, Visual Designer is integrated in the Visual Studio (2005 and 2008).
Workflow Authoring Modes
How to create a workflow? There are several authoring modes to creating the workflow:
- Markup Only / Declarative -> Could be done using XAML (eXtensible Application Markup Language)
- Markup + Code -> XAML + (C# / VB)
- Code Only -> (C# / VB)
- Application Generated -> Application creates activity tree and serializes it into one of the things above.
All of the 4 modes above will be compiled by the Workflow Compiler (wfc.exe) and will be compiled once again be language compiler (either C# or VB), then finally become the .NET assembly.
Activity
Another important point / concept in Workflow Foundation is Activity.
Activity is:
Here's the concept and architecture part first. Hopefully, I can continue the "How To" part in the next post.
Resources:
Forum – http://www.windowsworkflow.net/forums
http://www.kompas.com/read/xml/2008/06/28/11521947/bill.gates.berhenti.dari.microsoft
SAN FRANCISCO, SABTU - Visinya terhadap komputer agar
ada di setiap rumah telah berkembang di dunia, kini Bill Gates
memutuskan untuk berhenti pada pekerjaan penuh waktu di Microsoft pada
Jumat untuk fokus di bidang kerja amal yang ditujukan memperbaiki
perawatan kesehatan dan memberantas kemiskinan di dunia ketiga.
"Selama
ini tidak ada sehari pun dalam hidup saya, saya tidak memikirkan
tentang Microsoft, hal besar yang telah kami kerjakan dan membantunya,"
kata Gates, 52, dengan matanya yang agak berkaca-kaca saat berpidato di
kegiatan perusahaannya.
Gates mendirikan perusahaannya yang
bernilai 260 miliar dolar AS itu pada tahun 1975 dan telah mengalihkan
kekayaannya ke dalam yayasan Bill and Melinda Gates. Berkat bantuan
orang terkaya di dunia Warren baffet, yayasan itu sekarang menjadi
badan amal terbesar di dunia dengan aset hampir 40 miliar dolar AS.
Kedua orang kaya itu telah berjanji untuk menyumbangkan seluruh
kekayaannya ke yayasan itu sebelum mereka meninggal.
Gates
berencana menduduki posisi strategi level tinggi di badan amal itu dan
akan menggunakan seluruh pengaruhnya sebagai salah satu orang terkaya
di dunia untuk meningkatkan agenda yayasan dalam basis kerja penuh
waktu.
Namun ia akan tetap menjadi "non-executive chairman" di
Microsoft dan hanya mendedikasikan satu hari sepekan untuk bekerja di
perusahaannya. Gates menyerahkan perannya sebagai kepala eksekutif
(chief executive) Microsoft kepada mitra kerjanya yang sudah lama Steve
Ballmer di tahun 2000, saat Bill Gates menjadi kepala arsitek piranti
lunak perusahaan.
Dengan program suksesi terencana, tugas Gates
akan diambil alih oleh dua eksekutif Microsoft. Ray Ozzie akan
melaksanakan peran yang mengelola manajemen harian, sedang Craig Mundie
akan menjalankan peran mengelola rencana jangka panjang.
Ballmer
pada Jumat mengakui, meski ada rencana teratur, pendiri perusahaan itu
akan meninggalkan perusahaan. "Tidak ada cara apa pun untuk mengatakan
terimakasih kepada Bill. Bill adalah sang pendiri. Bill adalah sang
pemimpin," kata Ballmer pada acara internal perusahaan itu. "Inilah
bayi Bill."
Perusahaan komputer ini, memiliki penguasaan
pada piranti lunak sistem pengoperasian windows, yang 90 persen
digunakan pada komputer personal di dunia. Perusahaan ini memiliki
kapitalisasi pasar sekitar 260 miliar dolar AS dan mempekerjakan lebih
dari 78.000 orang di 103 negara.
Bagian ini khusus memperlihat kan aspek – aspek teknikal yang digunakan dalam project LibraLINQ.
Berikut adalah bukti / capture screen teknologi-teknologi yang digunakan di project LibraLINQ ini.
Microsoft .NET Framework 3.5
ASP.NET 3.5 – ListView, DataPager
Windows Form Application
Bahasa Pemrograman : C# 3.0
ORM : LINQ to SQL
Database : SQL Server 2005
ASP.NET Ajax
Windows Communication Foundation
Silverlight
Microsoft Visual Studio 2008 – Unit Test
Microsoft Visual Studio 2008 – Web Test
Untuk web application, terdiri dari 2 aplikasi:
- Web portal LibraLINQ
- LibraLINQ Backend Application – Admin pages untuk manage web portal
Web Portal LibraLINQ
Web Portal inilah yang akan menjadi sumber informasi bagi calon atau pengunjung untuk mendapatkan informasi-informasi yang terkait. Terdapat beberapa halaman pada web portal yaitu sebagai berikut:
Home
Halaman utama web portal. Pada halaman ini, terdapat bagian untuk News (berita – berita) dan New Collections (koleksi terbaru).
Search
Untuk mempermudah pengunjung mencari buku yang diinginkan, pengunjung dapat menggunakan fasilitas Quick Search maupun Advanced Search.
Pengunjung dapat mencari buku berdasarkan Judul buku dengan memasukkan kata kunci tertentu pada textbox di bagian atas.
Pengunjung juga dimungkinkan untuk mencari secara lebih detail criteria yang dimasukkan seperti ISBN, Judul, Pengarang, dan Penerbit.
Searched Result
Baik dengan Quick Search maupun Advanced Search, pengunjung akan memperoleh hasil pencarian pada halaman ini.
Aspek teknikal yang digunakan : ListView, DataPager – ASP.NET 3.5
Regulation
Halaman ini berisi peraturan-peraturan yang harus Anda patuhi untuk memasuki LibraLINQ.
Aspek teknikal yang digunakan : Collapsible Panel – AjaxControlToolkit
FAQ
Sering terdapat pertanyaan-pertanyaan yang serupa dan dijawab juga tentunya dengan jawaban serupa, oleh karena itu, LibraLINQ menyediakan FAQ yang telah kami kumpulkan.
Aspek teknikal yang digunakan : Accordion – AjaxControlToolkit
Login
Anggota yang telah mendaftar di LibraLINQ akan diberikan sebuah account (username dan password). Account tersebut dapat digunakan bila Anda mengunjungi website LibraLINQ.
Histori Peminjaman
Halaman ini hanya bisa diakses untuk anggota yang telah login. Pada halaman ini, anggota dapat melihat histori peminjamannya (tanggal pinjam, tanggal kembali, tanggal harus kembali, judul buku, dll)
Saran / Pertanyaan
Bila anggota memiliki saran / pertanyaan, anggota dapat masuk ke menu "saran / pertanyaan" dan mengisi saran / pertanyaannya. Staff kami akan segera membalasnya.
Anggota juga dapat melihat saran / pertanyaan yang pernah diajukan sebelumnya.
Aspek teknikal yang digunakan : Tab – AjaxControlToolkit
About Us
Halaman About Us memungkinkan pengunjung untuk melihat lingkungan perpustakaan LibraLINQ melalui video online.
Aspek teknikal yang digunakan : MediaPlayer – Microsoft Silverlight
LibraLINQ Backend Application
News List
Halaman ini digunakan admin untuk melihat News yang ada. Admin dapat menambah, mengubah, dan menghapus News yang ada.
Add News
Halaman ini digunakan admin untuk menambahkan News baru.
FAQ List
Halaman ini digunakan admin untuk melihat FAQ yang ada. Admin dapat menambah, mengubah, dan menghapus FAQ yang ada.
Add FAQ
Halaman ini digunakan admin untuk menambahkan News baru.
List Saran
Saran / pertanyaan yang ditanyakan anggota di web portal LibraLINQ akan muncul di halaman ini. Pada halaman ini, admin dapat melihat semua saran / pertanyaan yang diajukan. Untuk melihat detail saran, admin dapat meng-click tombol detail.
Detail Saran
Ketika tombol detail pada List Saran di-click, maka halaman ini akan muncul. Pada halaman ini, admin dapat membalas / menjawab saran / pertanyaan yang diajukan oleh anggota.
About Us Management
Halaman ini adalah halaman untuk mengatur tulisan dan video yang akan tampil pada web portal.
Aplikasi ini merupakan Sistem Informasi bagi pengguna khususnya staff atau petugas perpustakaan dalam mengelola kegiatan operasional perpustakaan.
Berikut adalah penjelasan form – form yang terdapat pada aplikasi ini:
- Form Utama (sebelum login)
Form Penerbit
Form untuk memanipulasi (insert, update, delete) data penerbit.
Form Anggota
Form untuk memanipulasi (insert, update, delete) data anggota.
Form Buku
Form untuk memanipulasi (insert, update, delete) buku.
Form Petugas
Form untuk memanipulasi (insert, update, delete) data petugas.
Form Peminjaman
Form untuk melakukan transaksi peminjaman.
Form Pengembalian
Form untuk melakukan transaksi pembelian.
Form About
Introduction
LibraLINQ adalah hasil implementasi dari sistem informasi dan web untuk perpustakaan. Dibangun dengan teknologi development terbaru dari Microsoft seperti:
Visual Studio adalah sebuah IDE (Integrated Development Environment) yang tidak perlu diragukan lagi karena kemampuannya dalam membantu developer untuk pengembangan aplikasi sangat baik. Visual Studio 2008 adalah versi terbaru dari Visual Studio.
Versi terbaru .NET Framework yang terrilis berbarengan dengan Visual Studio 2008. .NET Framework 3.5 mencakup .NET Framework 3.0, LINQ, dan API lainnya.
ASP.NET 3.5 mencakup ASP.NET 2.0 ditambah dengan ASP.NET Ajax dan beberapa web controls lainnya seperti (LinqDataSource, ListView, dan DataPager)
Masa kejayaan windows form application pada zaman Visual Basic 6.0 dilanjuti oleh .NET Windows Form Application. Windows Form Application sangat powerful dalam membuat aplikasi smart client.
C# adalah salah satu bahasa pemrograman yang utama di dunia .NET. Saat ini versi terbaru C# adalah 3.0.
ORM / Object Relational Mapper adalah tool untuk memetakan table – table yang ada di dunia relational menjadi class – class di dunia Object Oriented. LINQ to SQL merupakan ORM built-in pertama dari Microsoft.
SQL Server merupakan database server yang paling terkemuka oleh Microsoft. Versi SQL Server yang digunakan di aplikasi ini adalah SQL Server 2005.
Ajax tidaklah menjadi sesuatu yang asing buat web developer. ASP.NET Ajax mempermudah developer untuk membuat aplikasi yang lebih responsif berbasis Ajax.
WCF adalah framework untuk komunikasi yang dikembangkan oleh Microsoft untuk menjawab berbagai perbedaan teknologi komunikasi. Tujuan WCF adalah unify dan juga memungkinkan semua teknologi untuk berkoloborasi sesama lainnya. WCF juga memiliki kemampuan untuk backward-compatibility yang bagus (mendukung MSMQ, ASMX, dll).
Silverlight adalah web browser plug-in yang mendukung rich-internet application seperti animasi, video, dll.
Nama LibraLINQ berasal dari Library by LINQ yang berarti Library application yang dibangun dengan LINQ (Language Integrated Query).
Architecture
Database Engine yang digunakan adalah Microsoft SQL Server 2005. Object Relational Mapper yang digunakan adalah LINQ to SQL. Terdapat sebuah Data Access Layer (dalam bentuk class library) yang menjembatani LINQ to SQL / Database dan WCF Service. WCF Service adalah sebuah service yang dapat dikonsumsi oleh client baik web application maupun desktop application.
Dalam project LibraLINQ ini, system informasinya dibangun dengan desktop application. Sedangkan frontend / web nya dibangun dengan ASP.NET 3.5.
Dalam solution LibraLINQ, terdapat 7 buah project yaitu sebagai berikut:
LibraryEntities adalah sebuah class library yang utamanya adalah mengandung sebuah file LINQ to SQL (Library.dbml). Selain itu, terdapat pula LibraryDataContext yang merupakan partial class untuk custom code.
LibraryDAL
LibraryDAL juga merupakan sebuah class library (dalam bentuk dll). LibraryDAL mengandung kelas-kelas Data Access Layer untuk masing2 table dalam database.
LibraryService
LibraryService adalah implentasi dari Windows Communication Foundation Service.
LibraryWin
LibraryWin adalah system informasi perpustakaan yang digunakan oleh petugas perpustakaan untuk melakukan transaksi seperti peminjaman dan pengembalian buku.
LibraryWeb
LibraryWeb dibuat dengan ASP.NET 3.5. Website ini bisa diakses melalui internet. Pengunjung / calon pengunjung bisa melihat informasi-informasi mengenai LibraLINQ yang terdapat di website ini.
Library Test
Library Test adalah unit test yang akan menguji aplikasi LibraLINQ secara keseluruhan.
Library Web Test
Library Web Test adalah web test project yang digunakan untuk menguji performa dari web LibraLINQ.
Introduction
LibraLINQ adalah sebuah perpustakaan dimana pengunjung dapat membaca dan meminjam buku. LibraLINQ bersifat umum sehingga bisa dikunjungi oleh siapa aja baik siswa, tenaga professional, pengajar, dan lain – lain.
Perpustakaan LibraLINQ menyediakan berbagai macam buku dari berbagai bidang seperti:
- Information and Technology
- Matematika
- Computer Science
- Science / Kimia
- Biologi
- Teknik / Engineering
- Bahasa / Sastra
- Psikologi
- Kedokteran
dll
Waktu Operasional
Waktu operasional Perpustakaan adalah sebagai berikut:
- Senin - Jumat : 08.00 - 21.00
- Sabtu - Minggu : 09.00 - 17.00
(Hari libur tetap buka seperti biasa)
Larangan dan Sanksi
Larangan | Sanksi |
- Membuat gaduh
- Tidur
- Makan dan minum
- Menggunakan fasilitas perekam secara tidak legal
- Membuang sampah sembarangan
- Merokok
- Berpakaian tidak sopan
| Dikeluarkan dari perpustakaan |
Merobek, menyilet, mencuri atau merusak koleksi perpustakaan | Dicabutnya keanggotaan perpustakaan untuk selamanya, wajib mengganti koleksi yang dirusak. |
Proses Pendaftaran
Pengunjung dapat mendaftar menjadi anggota dengan syarat sebagai berikut:
- Mendatangi front desk untuk meminta form pendaftaran
- Membawa kartu identitas (KTP / SIM / Passport, dll)
- Mengisi form registrasi keanggotaan
- Mengembalikan form registrasi yang telah diisi lengkap
Petugas perpustakaan akan memproses registrasi calon anggota. Bila registrasi telah berhasil dilakukan, maka anggota akan diberikan kartu anggota. Dengan kartu anggota inilah anggota dapat meminjam buku. Pada kartu anggota tersebut juga, terdapat account untuk mengakses web LibraLINQ.
Keanggotaan
Terdapat beberapa perbedaan antara pengunjung non-anggota dan anggota:
Jenis Fasilitas | Non-Anggota | Anggota |
Memasuki perpustakaan LibraLINQ | Ya | Ya |
Meminjam buku untuk dibaca ditempat | Ya | Ya |
Meminjam buku untuk dibawa pulang | Tidak | Ya |
Mengunjungi web portal LibraLINQ | Ya | Ya |
Memiliki account untuk login ke portal LibraLINQ | Tidak | Ya |
| | | |
Peminjaman dan Pengembalian Buku
Buku dapat dipinjam untuk dibaca di tempat dan atau dapat dipinjam dibawa pulang dengan syarat tertentu.
Baik pengunjung anggota maupun non-anggota diperbolehkan untuk membaca buku ditempat.
Bila pengunjung ingin meminjam buku untuk dibawa pulang, maka harus dan mematuhi peraturan berikut:
- Buku dapat dipinjam gratis.
- Buku dapat dibawa pulang selama 7 hari (1 minggu – termasuk hari libur). Buku dapat diperpanjang peminjamannya 7 hari lagi dengan syarat buku belum di-booking orang lain.
- Buku harus dikembalikan sebelum tanggal yang ditentukan.
- Buku yang terlambat dikembalikan akan dikenakan denda sebesar Rp 1000 per hari per buku. Maksimal denda adalah Rp 30000 per buku.
- Periksa lah kondisi buku sebelum dipinjam, bila terjadi kerusakan, segera lapor kepada petugas.
- Buku yang telah dikembalikan, akan diperiksa oleh petugas lagi. Bila terjadi kerusakan dan hal serupa, anggota akan dikenakan sanksi tergantung kesalahan yang dibuat.
Syarat untuk meminjam buku untuk dibawa pulang:
- Yang berhak meminjam Telah terdaftar menjadi anggota.
- Maksimal banyaknya buku yang dipinjam dalam satu waktu adalah 3 buah buku.
Anggota berperilaku baik, dalam hal ini misalnya:
- Tidak melanggar peraturan / larangan pada perpustakaan
- Selalu mengembalikan waktu tepat pada waktunya
- Buku yang dikembalikan dalam keadaan baik / tidak merusak buku.
- (Pertimbangan lainnya)
Bila ternyata anggota melakukan satu atau beberapa hal di atas, maka peminjaman buku akan dipertimbangkan, tidak segera diterima.
Donasi
LibraLINQ sangat berterima kasih bila ada yang ingin mendonasi ke pihak perpustakaan. Donasi dapat berupa uang, keperluan perpustakaan (alat tulis, kursi, meja, dll), ataupun buku. Bila ada ingin ingin berdonasi, silahkan hubungin front desk atau petugas kami.
Sebagai tanda terima kasih, nama pendonasi akan kami publish di web portal LibraLINQ. Selain itu, pendonasi akan diberi fasilitas / toleransi khusus misalnya bisa meminjam buku lebih dari 3 pada satu waktu atau buku dapat dipinjam lebih lama tanpa denda, dlsb.
Web Portal LibraLINQ
Web Porta LibraLINQ adalah sebuah website dimana pengunjung bisa mendapatkan berbagai informasi yang berkaitan dengan perpustakaan LibraLINQ. Informasi – informasinya adalah sebagai berikut:
Melakukan fasilitas pencarian buku / searching.
Terdapat 2 macam pencarian buku:
- Quick Search : pencarian buku pada bagian header website, yang difilter adalah judul bukunya.
- Advanced Search : pada halaman advanced search. Proses pencarian dapat difilter berdasarkan judul, pengarang, penerbit, dan isbn.
Dengan fasilitas ini, pengunjung dapat mengetahui apakah buku yang dicari tersedia atau tidak. Tentunya sangat memudahkan pengunjung.
Melihat berita / kegiatan terbaru perpustakaan. Misalnya:
- Telah datangnya buku baru
- Acara seminar
- Perubahan peraturan
- Dll
- Melihat peraturan, waktu operasional, dan keanggotakaan perpustakaan
- Melihat FAQ – kumpulan dari pertanyaan – pertanyaan yang sering ditanyakan
- Melihat daftar nama donatur yang telah menyumbang kepada LibraLINQ
- Melihat profil perpustakaan (dalam bentuk video) sehingga pengunjung dapat melihat secara visualisasi perpustakaan LibraLINQ.
Khusus untuk anggota yang telah menerima kartu anggota, dapat melakukan login, sehingga memiliki fasilitas lebih seperti:
- Melihat histori peminjaman
- Mengajukan saran atau pertanyaan.
Untuk memperbaik perpustakaan LibraLINQ, anggota dapat mengajukan saran atau pertanyaan.
Dari namanya saja LibraLINQ. Apa yang Anda bayangkan? Not bintang Libra, okay! Maksudnya adalah Library Application yang dibangun dengan LINQ J, tentunya tidak hanya LINQ. But, it's ok, I am the founder, terserah mau kasih nama apa, yang penting enak disebut saja. So I call it LibraLINQ (baca : libra link, BUKAN libra LIN que).
Berawal dari bulan Maret ketika MSDN Day Sharepoint, Pak Risman mengumumkan akan ada sebuah competition yang bernama .NET Developer Idol (kayak Indonesian / American Idol aja). Tapi yang ditandingkan di sini bukanlah nyanyi (kalo nyanyi saya gak ikutan deh), but buat aplikasi perpustakaan. Kelihatannya kompetisi ini adalah hasil kerja sama Microsoft Indonesia dan
PCMedia (mungkin ada pihak yg lain?).
Pada kompetisi ini, peserta diwajibkan untuk membuat aplikasi perpustakaan menggunakan teknologi terbaru keluarga Visual Studio 2008 (.NET Fx 3.5, C# 3.0, etc). Kriteria penilaiannya ada di sini.
Sepertinya seru! Saya rasa mungkin banyak juga yang mau ikut mengingat hadiah nya lumayan (walaupun tidak ada tunai, hehe). Tapi bagi teman – teman yang bekerja fulltime, jadi agak susah untuk meluangkan waktunya untuk mengikutinya mengingat this is actually just a competition, belum tentu bisa menang. Maybe, lebih baik kerjain project commercial aja, haha… Benar gak?
Kebetulan saja, saat itu saya sudah quit dari pekerjaan full time saya, jadi hanya part time mengajar sebagai instruktur di BinusCenter. Oleh karena part time, waktu cukup bisa diatur, ya pintar – pintar sendiri lah atur waktu. Saya memutuskan untuk ikut competition ini. Kalo bisa menang, ya syukur, kalo gak menang ya gpp. At least dengan adanya kompetisi ini, saya jadi terpacu untuk explore mainan – mainan baru. Menang atau tidak, menurut saya gak rugi kok, setidaknya sekarang saya tau dan pernah mengimplementasikan C# 3.0, LINQ to SQL, WCF, etc di project. Daripada sebelumnya, cuman tau tau doank, coba – coba bentar, kurang termotivasi. Sempat muncul jug ide – ide bagus seperti pengunjung bisa melihat letak buku berada di rak mana dan lantai berapa dengan menggunakan animasi Silverlight, so Silverlight yang akan consume database untuk menampilkannya, cukup keren kalo itu bisa terwujud. But I'm sorry, gak sempat researchnya kelamaan, akhirnya bagian ini saya lepas (daripada yang lain gak jadi).
Sekitar pertengahan April sampai akhir May saya mengerjainnya. Terus terang, cukup banyak rintangan / masalah yang ditemukan (bahkan ada yang sampai saat ini belum saya temukan jawabannya L). WHY? These are new technologies yang baru launch beberapa bulan. Kalo ada problem mau tanya ke siapa? Om google sometimes juga tidak bersahabat baik, walaupun benar topic yang saya masukkan, but different case. Even orang – orang Microsoft di forum pun kadang saya tanya gak ada balasan. So, cukup susah mencari resource. Ya memang ada juga sih banyak professional / MVP seperti Rich Stalt, David Hayden, etc dengan artikelnya help me to solve my problem (mostly LINQ to SQL). Luckily, sebagian (desktop) application nya telah jadi, walaupun tidak perferct (jujur neh).
Awal Juni sampai July, project LibraLINQ sempat saya tinggalkan berhubung ada project (jujur aja commercial), haha… Tetapi saya juga tidak ingin meninggalkan LibraLINQ yang saya buat dengan susah payah. Akhirnya setelah project saya hampir kelar, untungnya submission dari competition ini ditunda 1 bulan. Saya masih sempat melanjutkannya, khususnya bagian web application. (Akan saya post pada artikel berikutnya). Menurut saya sendiri, design web nya kurang bagus dan kurang rapi ( L what can I say, I'm a developer, not a designer). Dan itupun sejujurnya saya ambil dari template web, hehe…
Sampai saat ini, bisa dikatakan bahwa LibraLINQ telah selesai, walaupun sebenarnya aplikasi tersebut bisa di-enhance lebih jauh lagi supaya lebih berguna.
OK, I think that's all dulu. See you in my next post tentang bisnis proses nya LibraLINQ.
Microsoft Excel has been widely used in office and business application. When you are building enterprise business application that used to do something with excel, you need to integrate your application with excel.
One of the most simple step is reading data from excel. Actually there are some techniques to achieve it. But one of the most popular techniques is make use of ADO.NET. Let ADO.NET to treat the excel file as the data source. Here's the code sample:
string cs = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + filename + @"; Extended Properties=""Excel 8.0; HDR=YES""";
using (OleDbConnection con = new
OleDbConnection(cs))
{
con.Open();
string query = "SELECT Number, Name FROM [Sheet1$]";
OleDbCommand cmd = new
OleDbCommand(query, con); OleDbDataAdapter adapter = new
OleDbDataAdapter(cmd);
DataTable db = new
DataTable();
adapter.Fill(dt);
return dt;
}
Firstly, you need specify the connection string. Treat it as the OleDB. Specify the data source property with the physical location of the file. Next you are ready to read the certain column from the certain Sheet using OleDbCommand. Now you are ready to store your data source to the datatable or collection.
The query
The above query "select Number, Name FROM [Sheet1$]" means to select Number and Name from the Sheet1 Sheet.
What if you want to select certain columns and row, you can do it like this "select Number, Name FROM [Sheet1$A3:G8]". Now the scope would be narrowed to the A3 till G8.
What if you want to select the condition like above BUT we don't know how many records exits (the above example stated G8, means that till the 8th row). You can do it like this "select Number, Name FROM [Sheet1$A3:G]". Now, it would be flexible, depending on how many records you have.
One important issue
I found this issue unintentionally when doing my project. Here's the story.
Firstly, here's my data:
Number | Name |
1 | Joe |
2 | Hansel |
3 | Dwight |
4 | Correy |
It seemed to working well.
Now when my data goes:
Number | Name |
1 | Joe |
2 | Hansel |
3 | Dwight |
4 | Correy |
e | Michael |
f | Roy |
We cannot read e and f. Hm… What's going on?
Then I modified my data:
Number | Name |
a | Joe |
b | Hansel |
c | Dwight |
d | Correy |
e | Michael |
f | Roy |
Now everything was doing well.
I changed my data again into:
Number | Name |
a | Joe |
b | Hansel |
3 | Dwight |
d | Correy |
5 | Michael |
f | Roy |
Now we could not read record 3 and 5.
The conclusion: ADO.NET tries to guess you data type of your column. Once it found some records that do not meet others records type, it will treat it as null, so it will be ignored.
To tell the ADO.NET "Hey, please don't guess my data type, just read what you see!", you need to modified your connection string to put IMEX=1;
string cs = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + filename + @"; Extended Properties=""Excel 8.0;IMEX=1;HDR=YES""";
For more detail information, see http://support.microsoft.com/kb/194124
Now everything works well :D
In my previous post, I illustrated about ORM. In this post, I'll show you one of the great ORM tool, SubSonic. Actually, SubSonic is not just an ORM, it offers more than that. From its motto "All your database are belong to us", you can see that it is cool J.
Moreover, the good news is, SubSonic is not only free, but also open source.
Lately, I do some research on Subsonic and implement it on my project. I found that I really fall in love with this thing. Thanks very much to Rob Conery, the creator of Subsonic. You help so many people in this world with it :D.
Now, let me show you what the Subsonic is and its brief conceptual before we move on to the technical step / set-up / coding it (I'll try do it in my next post).
What is Subsonic?
Many people give their own definition on SubSonic.
For me, I agree with the illustration of this picture about SubSonic.
It's a multifunctional tool indeed.
From the SubSonic's website:
What is it?
A Super High-fidelity Batman Utility Belt. SubSonic works up your DAL for you, throws in some much-needed utility functions, and generally speeds along your dev cycle.
Why SubSonic?
Because you need to spend more time with your friends, family, dog, bird, cat... whatever. You work too much. Coding doesn't need to be complicated and time-consuming.
What do I need?
Something else to do - you're about to save a bunch of time. We support SQL Server 2000 or 2005, MySQL, or Oracle (with SQLLite, SQLCE, and PostGres coming soon!)
Let's see what it offers…
One of the essential parts of SubSonic is ORM; it helps up map from the relational tables to object oriented data classes.
To access it, you can simply write it like this:
Data Access Layer (DAL) Code Generator
Built on Active Record Pattern, SubSonic generates Data Access Layer for us, usually CRUD (Create, Retrieve, Update, and Delete). The generated file would be named xxxController where xxx refers to the table's name.
We don't have to care about the DAL because SubSonic has done these for us. To use it, just:
What data source /database does it support?
- SQL Server? Yes!
- MySQL? Yes!
- Oracle? Yes!
etc
Libraries
SubSonic provides us a huge numbers of libraries (classes, method, etc) to enhance the development process. For instance, we need query to Customer table where the City is Washington and the ContactName starts with "J". We could do it like this.
According to the query above, what does the return type is? DataReader? DataSet? Or CustomCollection?
The answer is all of them! Yeah, you can have it all.
Component
There are some handy components that are offered by SubSonic:
I will try to describe these more detail in next posts.
You can find more information on Rob Conery's blog and SubSonic official website.
I regret that at my first almost two years of software development, I still coded (sometimes copy and paste) my Data Access Layer manually. How many hours that I spent for that? It almost took 30% - 50% of my entire time on my development. Anyway, forget it. I'll show you something cool.
If you are still coding the plumbing Data Access Layer manually like me before, I suggest you to look what ORM is. In short, ORM is the mediator between the relational database and the object oriented application. We know relational is a popular technique in the database world, but in application / our code, usually Object Oriented rules!
So, what we have to do? Usually we build data class based on the table.
Column | Type |
StudentId | Nchar(10) |
StudentName | Nvarchar(200) |
Email | Nvarchar(200) |
DateOfBirth | smalldatetime |
For example:
We have MsStudent table in the database like this:
In our application, we try to build our data class. We would map the table in the database to a class, let's call it Student. All the columns in the table are supposed to be properties in that data class. Moreover, we could add some method to the Student class.
public
class
Student
{
public Student()
{
}
private
string _studentId;
public
string StudentId
{
get { return _studentId; }
set { _studentId = value; }
}
private
string _studentName;
public
string StudentName
{
get { return _studentName; }
set { _studentName = value; }
}
private
string _email;
public
string Email
{
get { return _email; }
set { _email = value; }
}
private
DateTime _dateOfBrith;
public
DateTime DateOfBirth
{
get { return _dateOfBrith; }
set { _dateOfBrith = value; }
}
}
If you have 10, 20, 50 of tables, you have to write it manually. Don't you feel that you are doing something that a machine / computer could do as well? These are plumbing works.
In fact, you generate these codes, based on the table structure using some code generator such as CodeSmith, etc. To do that, you have to build the template first, and then take the table and others properties as parameters, and then the code generator will generate the code for you. Well, but this is not my main point. I'll show you another approach.
ORM comes in to help you doing the mappings. By using ORM, you don't have build the template first. All you have to do is just set-up the configuration to point to the data source you want to map. The ORM tools would map it for you. You'll have the Student class like that as well.
ORM tools / product
There are some ORM tools in the market. Some of them are commercial, some of them are free to use, and some of them even are open source.
Most of them come from third party vendors. But, lately, in .NET Framework 3.5, Microsoft introduces the built-in ORM, it's LINQ to SQL (was DLINQ). Next few months later, you'll see another baby comes up; it's ADO.NET Entities Framework (ADO.NET EDM).
Let's see what they are:
Ahah! This is my favorite tools. I have fallen in love with it. In fact, Subsonic offers more than an ORM. SubSonic is a very useful and awesome tool. It is easy to use and configure.
In brief, SubSonic is open source, and it is created by Rob Conery. For information, Rob has been hired by Microsoft on ASP.NET team.
I'll post more details about SubSonic on next post.
In Java world, Hibernate is a very popular and mature ORM. Most of Java developer has used it in development.
NHibernate is .NET version of Hibernate. NHibernate makes use of XML as the metadata to map between tables in the database and classes in our application.
It is the first built-in ORM from Microsoft. You can find it in .NET Framework 3.5. LINQ to SQL is quite easy to configure and use. You can add LINQ to SQL class easily by adding new item, and choose Linq to Sql classes. Its extension is .dbml.
One big advantage of using LINQ to SQL is we can use LINQ, the built-in query expression in language (C# 3.0 and VB 9.0).
In contrast, you just only can use SQL Server (2000 and 2008) as the backend database.
You can find LINQ to SQL posts by Scott Gu here.
This product haven't released yet. But most people believe that ADO.NET EDM offers higher functionalities than LINQ to SQL does. At least, it supports any data source / database.
Some people believe that ADO.NET has the ability to reduce / get rid of impedance mismatch. Does it? Let's wait and see.
See Wikipedia's description.
- And so many more…
I bet you might have this question in your mind. "Which .NET ORM is the best?"
Well, it depends on many factors and point of view. You can take this discussion for your reference.
Yesterday, I joined CCNA Fundamental Community Class at Brainmatics. It was just a fundamental and introduction to Cisco Networking. Well, I still want to focus on software development career, attending this short workshop / training was only want to enrich my other knowledge. Since I almost have no idea about networking and CISCO, this one-day long class was an appropriate option to me.
Another strong point that attracted me to join this training is the instructor. The instructor is a famous guy in Indonesia's IT. The founder of www.ilmukomputer.com, the free computer studies community in Indonesia. I had not met him before yesterday. I bet most of you know him already. Yeah, he is Mr. Romi Satria Wahono. Indeed, he is an unordinary man. By looking at his profile, you can feel how superb he is. He got scholarship in Japan from Bachelor till Doctoral Degree. Moreover, he writes a lot of book and does a