31 Agu 2010

Simple LINQ Example on Sharepoint Items Query

Actually I don’t remember much about CAML that came up with Sharepoint. CAML is a basic XML based query to fetch some item based on criteria, just like query on SQL. But, It’s so hard to remember! I want to run code as fast as I can, and here’s the answer, LINQ. So, can we start and try this?

OK, before we start, we must ensure that we have .NET Framework 3.5, coz that’s the framework to do the LINQ, and import System.Core.dll to your project. and add the imports below.

using System.Collections;
using System.Collections.Generic;
using System.Linq;

LINQ gives you so many solution to get queries easily, and you don’t need to remember CAML or whatever you’ve called. You can get raw IEnumerable<SPListItem> from the LINQ, but if you want to iterate through query result, you must use foreach.

IEnumerable<SPListItem> LiColl = from SPListItem Li in Lhr.Items where Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days <= 0 &&
Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days >= (_DayIndex * -1) select Li;

Another way, you can get items, using IList<SPListItem> and you can iterate with any iterator.

IList<SPListItem> LiColl2 = (from SPListItem Li in Lhr.Items where Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days <= 0 && Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days >= (_DayIndex * -1) select Li).ToList();

And the other way, you can get items, and returning array of SPListItem.

SPListItem[] LiColl3 = (from SPListItem Li in Lhr.Items where Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days <= 0 && Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days >= (_DayIndex * -1) select Li).ToArray();

Rename Sharepoint Site URL using STSADM

Sometimes you faced a little problem with Sharepoint, and what if the problem is you do not like the existing Site Collection URL? For example, http://intern.contoso.com/sites/HRArea and you want to change it to http://intern.contoso.com/sites/HR ? Try this STSADM Commands…

The method is involving backup, delete and restore command in STSADM, so be careful to do this, and trying not to make any mistakes. First time, you must confirm the old URL and the new URL. Maybe you would like to try my another solution using STSADM, so you don’t need to write the full path of STSADM, coz it so annoying.

STSADM –o backup –url <the old url> –overwrite –filename <the backup filename>

So, the example would be like this, STSADM –o backup –url http://intern.contoso.com/sites/HRArea –overwrite –filename D:\BackupHR.dat. This will make backup for the old URL, including contents.

STSADM –o deletesite –url <the old url>

Make sure that the first command completed successfully, so you can do this command, to delete the old site URL. The example is STSADM –o deletesite –url http://intern.contoso.com/sites/HRArea.

STSADM –o restore –url <the new url> –filename <the backup filename>

And the next command is to restore the backed up site. So the site will run with the new URL. And you’re done….

28 Jul 2010

Easier STSADM Tips by Adding PATH into the Environment Variables

Sometimes you don’t realize that you’re wasting your every seconds just for typing and finding where’s STSADM located. Everytime you remote on a Sharepoint Server, and needs to call STSADM, you type this before calling STSADM…

image

What a waste time…. eh..! You can try to add the path of Sharepoint 12 Folder, to Environment Variables. Here’s how….

image

Click Advanced system settings…

image

Go to tab Advanced and then Environment Variables…

image

in the System Variables, find PATH, and add the 12 BIN sharepoint folder, usually at “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\”, and don’t forget to add “;” delimiters (without quotesBig Grin).

image

Missing Site Actions Menu after Sharepoint Backup or Restore

A couple weeks ago, I ran into a problem, it’s so annoying and stupid. I have a scenario that I must copy an entire Site Collection and restore it on another server. After I tried to backup all of site collection and then restore it on another server, all seems good and nothing’s error found. But when I hitting the front page, and click Site Action, some of menus are missing!

After a few days, I found that both of the source and destination server, are locked by default when you try to backup or restore by using STSADM. and you can check the site whether it’s locked or not by using this command.

image

and this command does unlock the site…

image

And, voila……. the Site Actions menu shown up again….!!!

Merging Two Virtual Hard Disks with Virtual Server 2005

You can merge two Virtual Hard Disk (VHD) into one VHD by using Virtual Server 2005. But as far as I know, you can only merge VHD with Differencing VHD type. What is that? Differencing VHD actually two VHD, with one as the parent which holds the most common and shares the same configuration with the children VHD. And the other one is the child, which holds the changes in every events.

By merging this two VHD, you can increase a better performance for your Virtual Machine. You can try to merge this two hard disk by accessing Virtual Server Administration WebSite, and click Inspect under Virtual Disks.

image

After that, choose the Full Path of the Differencing VHD to Inspect, and click Inspect.

image

Click on the “Merge virtual hard disks”…

image

You can choose whether to merge with the parent virtual disks, or just create a new merged VHD, is up to your choice. And then click Merge.

image

And that’s how to do it…

10 Mar 2010

CPUZ, aplikasi informasi hardware akurat!

Beberapa aplikasi digunakan untuk tools kita membantu mengetahui segala sesuatu, dan membantu kita mempermudah pekerjaan. Salah satunya adalah mengetahui dengan persis tipe, clock processor, jumlah memori, berapa besar memori di setiap slot, dan lain-lainnya. 

Adalah CPUZ versi 1.53, adalah aplikasi untuk menampilkan detail dari hardware komputer bersangkutan. Baik clockspeed processor, codename dari processor, instruksi yang didukung, arsitekturnya apakah 32bit atau 64bit. Cara pakai gak terlalu sulit kok, tinggal jalankan aja. Kamu bisa download di sini.

8 Okt 2009

Pendahuluan Install Sharepoint


Topik :: Pendahuluan Instalasi Sharepoint
Spesifik :: Pendahuluan
Tools :: -
Tujuan :: Memahami instalasi Sharepoint di Windows Vista untuk Developing.
Pada saat sharepoint masih versi 2003, alias Sharepoint Server 2003 dan versi free-nya Windows Sharepoint Services 2.0, environment untuk developing masih menggunakan teknologi virtualisasi untuk melakukan developing. Karena Sharepoint memang tidak didesain untuk di-install di Windows XP atau Windows Vista sekalipun. Sharepoint memang untuk Server.

Tapi selalu ada banyak cara untuk melakukan instalasi Sharepoint di atas Windows non-Server. Bamboo Solutions menyediakan installer free untuk melakukan Instalasi Sharepoint di atas Windows Vista. Pasti dengan beberapa requirement tertentu seperti yang dimiliki oleh server. Kamu bisa lakukan langkah-langkahnya di Blog Bamboo Solutions.

Beberapa hal yang harus diperhatikan dan diperlukan di komputer Vista kamu, yaitu ada 4 poin.



  1. Install dulu SQL Server 2005 (either SQL Server 2005 Express atau yang standard / berbayar)
  2. Hanya bisa memilih Advanced Setup pada saat instalasi
  3. Mengaktifkan fitur-fitur yang ada di IIS (penjelasan ada di webBlog Bamboo Solutions tadi)
  4. Melakukan instalasi Visual Studio 2005 Professional
  5. Melakukan instalasi Visual Studio Extension WSS versi 1.1 (untuk Visual Studio 2005)


SQL Server diperlukan sebelum kita melakukan instalasi WSS 3.0 atau MOSS 2007 di Windows Vista. Kamu bisa memakai SQL Server 2005 versi berbayar dari Microsoft, ato pake versi Free SQL Server 2005. Yang jelas, pada saat instalasi SQL Server 2005 tersebut, DIWAJIBKAN memilih Advanced Setup mode untuk memilih menggunakan Mixed Mode authentication. Dengan cara ini, jika Windows Authentication mode itu fail, kamu masih bisa menggunakan SQL Authentication, dan sebaliknya. Hanya itu saja yang kritis di dalam instalasi SQL Server 2005. Ini untuk future enhancements.

Nah, pada saat instalasi MOSS 2007 atau WSS 3.0, kita musti pilih Advanced Setup > Web Front End. Hindari Instalasi Stand Alone, karena semua component terinstall sudah dipacking dan dikonfigurasikan, nantinya akan menyulitkan konfigurasi. Kelemahannya, kamu gak bisa lagi menambah Server utk ditambahkan dalam Server Farm. Nanti akan aku bahas di posting berikutnya tentang instalasi.

17 Sep 2009

Sebuah Misteri dari Sharepoint System Account



Topik :: Tools for System Engineer
Spesifik :: Windows Sharepoint Services
Tools :: None
Tujuan :: Mengetahui apa itu System Account
Sharepoint System Account? Hmm, User ini ada di Windows Sharepoint Services. By Default, kalo kita login menggunakan User yang digunakan sebagai Sharepoint System Account Administrator saat instalasi Sharepoint, maka saat kita login ke situs manapun, username yang tertampil, bukan lagi Username yang bersangkutan.

Let's say aku pake user RADIT\raditz, dimana property Name dari user itu adalah Radityo Ardi. Pada saat login di salah satu situs under Sharepoint, akan tertulis seperti di
 gambar, System Account.

Pada saat aku melakukan coding untuk retrieve gambar si user ini, error terjadi, bahwa user ini tidak ketemu. Tapi bagaimana bisa berubah menjadi System Account dengan login name SHAREPOINT\System?

Here's it how. Pada saat Sharepoint menerima login user, Sharepoint akan melakukan cek, apakah login-nya sama dengan Identity yang digunakan di Application Pool. Jika sama, maka System Account-lah yang muncul.

20 Feb 2009

Remote Desktops



Topik :: Tools for System Engineer
Spesifik :: Remote Desktop
Tools :: Remote Desktops
Tujuan :: Multiple Remote Desktops
Pernahkah kamu menggunakan Remote Desktop? Seberapa sering kamu pakai Remote Desktop? Seberapa banyak kamu membuka Remote Desktop dalam satu waktu? Jika ya dan lebih dari satu, ada tools dari Microsoft yang memudahkan kita menggunakan Remote Desktop secara multiple. Bukannya sudah ada? Ya memang sudah ada, dan fitur itu hanya ada di varian server, mulai dari Windows 2003 dan Windows 2008.

Cara menggunakan cukup mudah, klik kanan saja Remote Desktops > Add New Connection.
Kemudian muncul window yang bisa digunakan untuk settingan yang disediakan. Cukup mudah dan tidak memakan banyak waktu. Bagi kamu yang sudah familiar dengan Windows 2003 dan Windows 2008 Family, pasti sudah gak asing lagi dengan Tools ini.

Apa spesialnya sih? Kok begitu getol tulis artikel ini? Tahukah kamu kalau Remote Desktops saya ini terinstall di komputer saya? Dengan spesifikasi OS Windows Vista? Ya, terinstall di Windows Vista, dan bisa diinstall di Windows XP. Jauh lebih mudah me-manage Remote Desktop di komputer kamu, daripada capek-capek remote ke server, banyak Remote Desktop window, susah manage, harus minimize dulu, dan banyak kendala lain.

Kamu bisa download di sini dari Microsoft! Agak menyulitkan memang jika Vista yang kamu punya itu bajakan. Make sure Vista yang kamu punya bukan Vista bajakan.

Yak, kamu bisa download yang gak perlu verifikasi Vista asli atau enggak di sini! Tapi, aku gak tau tar efeknya apaan kalo gak Vista asli. Coba aja deh...

Give it another try...

19 Feb 2009

Aplikasi Iseng :: MV Best Friends

Aplikasi Iseng kali ini adalah MV BestFriends. Aplikasi ini cuma iseng untuk mengisikan value ke dalam Software Marketiva, karena Streamster Marketiva, saya kesulitan mengisikan multivalue yang begitu banyak, dg penambahan 10 pips, plus stop loss dan target.

A little easy, disinilah aku mendapatkan pengalaman menggunakan Win32 API, karena tidak disediakan oleh VB.NET untuk melakukan modifikasi Control / Form dari aplikasi lain, maka satu-satunya cara adalah menggunakan Win32 API. Begitu pentingnya konversi dari VB String (BStr) ke C String (Null-terminated String - LPCSTR), sehingga aplikasi ini bisa jalan. Pada dasarnya aplikasi ini memindahkan value atau data dari aplikasi, ke aplikasi lain, yang pastinya butuh API untuk Find window yang bersangkutan, trus enumerate control yang ada di dalam window itu...


Selalu prinsip utamaku adalah OPEN SOURCE, even it's VB.NET based! Download Source Codenya di sini! Dan bisa kamu download aplikasinya di sini!

Give it a try, it's all free....