27 Temmuz 2011 Çarşamba

WSS Backward-Compatibility Comparison Table

ASP.NET Web Parts
SharePoint Backward Compatibility
WebBrowsableAttribute
BrowsableAttribute
WebDisplayName
FriendlyName
WebDescription
Description
Personalizable
WebPartStorage
PersonalizationScope
Storage
EditorPart
ToolPart
EditorPartCollection
ToolPart[]
CreateEditorParts()
GetToolParts()
RenderContents()
RenderWebPart()
SetPersonalizationDirty()
SaveProperties

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

19 Temmuz 2011 Salı

Web Part Fundamentals

System.Web.UI.WebControls.WebParts namespace'ine ait bir sınıftır. WebPartManager ve WebPartZone adında kontrolleri vardır.

WebPartManager, content database ile WebPartZone arasında köprü görevi görür. WebPartManager, web partları WebPartZone'a koyduğunda aslında web partın serileştirilmiş instance'ını content database'e ekleriz.

namespace CompanyWebParts {
  // A very simple webpart
  public class HelloWebPart : System.Web.UI.WebControls.WebParts.WebPart {
    protected override void RenderContents(System.Web.UI.HtmlTextWriter writer) {
      writer.Write(string.Format("Hello, {0}!", this.Page.User.Identity.Name));
    }
  }
}

Web Partlar chrome'un içinde render edilir. Chrome ortak bir kullanıcı arayüzü elementleri olduğunu söyleyebiliriz. Chrome render'lanması Web Part WSS'e deploy edildiği sırada uygulama tarafından handle edilir.

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

18 Temmuz 2011 Pazartesi

Master Pages for WSS 3.0

Herşeyden önce site sayfaları ve web application'ların farklı master page kullandığını aklımızda bulundurmamız gerekir.

Standart master page alttaki klasörde tutulur.

C:\Program Files\Common Files\Microsoft Shared
\web server extensions\12\TEMPLATE\GLOBAL\default.master

Default.master 3 önemli bileşen bulundurur.

  • Linkler için kontrol, menüler, ikonlar ve navigasyon bileşenleri
  • Named placeholders
  • Delegate kontrolleri
Named placeholders master page'e bağlı page template'lere veya page instance'lara benzersiz içerik eklemeyi sağlayan bir mekanizmadır. Delegate kontrolleri default.master sayfasının layout'undaki elementleri değiştirmeyi sağlar.

<%@Master language="C#"%> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, …" %>
<HTML runat="server">
<HEAD runat="server">
<!-- SharePoint Utility Controls --> <SharePoint:CssLink ID="CssLink1" runat="server"/>
<SharePoint:Theme ID="Theme1" runat="server"/>
<!-- Named Placeholders --> <Title ID=onetidTitle>
<asp:ContentPlaceHolder id=PlaceHolderPageTitle runat="server"/>
</Title>
<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server"/>
<!-- Named Delegate Control -->
<SharePoint:DelegateControl ID="DelegateControl1" runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
</HEAD>

default.master page'in HEAD elementi standart WSS server-side controllerinin kullanımını gösterir, örneğin CssLink veya Theme. Bu kontroller encapsulate edilerek CSS ile entegresi sağlanır. Ayrıca HEAD elementi iki placeholder tanımlar: PlaceHolderPageTitle ve PlaceHolderAdditionalPageHead. Bunlardan ilki yeni bir template veya özelleştirilmiş sayfa yaratırken sayfanın title'ını değiştirmeye yarar. İkincisi ise HEAD tag'ına daha fazla tag eklemeye yarar.

<%@ Page MasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageTitle" runat="server"
             ContentPlaceHolderID="PlaceHolderPageTitle">
  My Custom Page Title
</asp:Content>

<asp:Content ID="AdditionalPageHead" runat="server"
             ContentPlaceHolderID="PlaceHolderAdditionalPageHead">
  <META name="keywords" content="Software, Consulting, Money, Fame" />
</asp:Content>

Designing Site Pages by Using Controls

Consturcting Pages with Custom Controls

using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;

namespace CustomSitePages
{
  public class CustomControl1 : WebControl
  {
    protected override void RenderContents(HtmlTextWriter output)
    {
      SPWeb site = SPContext.Current.Web;
      output.Write("Current Site: " + site.Title);
      output.Write("<br/>");
      output.Write("Current Site ID: " + site.ID.ToString());
    }
  }
}

Yukarıdaki örnek RenderContents metodunu override ederek custom control sınıfını değiştirir.

Bir assembly DLL'ini deploy etmek için iki seçenek vardır. İlki DLL'i strong name ile compile ederek Global Assembly Cahce'e yüklemek. İkincisi DLL'i application'un root directory'sindeki bin klasörüne koymaktır.

Deploy işlemi tamamlandığında ASP.NET ile register edebilirsiniz.

<%@ Page MasterPageFile="~masterurl/default.master"
    meta:progid="SharePoint.WebPartPage.Document" %>

<%@ Register Assembly="CustomSitePages, ... "
    Namespace="CustomSitePages" TagPrefix="CustomSitePages" %>


<asp:Content ID="main"
     ContentPlaceHolderId="PlaceHolderMain"
     runat="server">

<h3>A custom control example</h3>

<CustomSitePages:CustomControl1 ID="cc1" runat="server" />

</asp:Content>

Eğer sayfa özelleştirilmiş ise, sayfa güvenli modda çalışacaktır. Bu durumda safe control olarak register edilmeyen kontroller hataya neden olacaktır. Bunu çözmek için web.config'e bir custom SafeControl eklememiz gerekmektedir.

<SafeControl
  Assembly="CustomSitePages, ..."
  Namespace="CustomSitePages"
  TypeName="CustomControl1"
/>

Consturcting Pages with User Controls

<%@ Control Language="C#" %>

<script runat="server">
  protected void cmdButton1_Click(object sender, EventArgs e) {
    lblStatus.Text = "Hello, World";
  }
</script>
<asp:Button ID="cmdAddCustomer" runat="server" Text="Add Customer"
            OnClick="cmdAddCustomer_Click" />
<br/>
<asp:Label ID="lblStatus" runat="server" Text="" />

Bu örnekte olduğu gibi user controllerine kolayca başlangıç yapabiliriz. Unutmamaız gereken bir ayrıntı olarak WSS user kontrollerinin kullanıcı özellleştirmesini destekleemz. User kontrolleri daima front-end Web serverın dosya sisteminden yüklenip assemblylere derlenir.

Ayrıca User Kontrollerine in-line kod da yazabilirsiniz.

<%@ Control Language="C#" %>
<%@ Assembly Name="Microsoft.SharePoint, ..." %>
<%@ Import Namespace="Microsoft.SharePoint" %>

<script runat="server">
  protected override void OnLoad(EventArgs e) {
    SPWeb site = SPContext.Current.Web;
    lblDisplay.Text = "Current Site: " + site.Url;
  }
</script>

<asp:Label ID="lblDisplay" runat="server" />

User Control ve Custom Control Templeate'leri C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\CONTROLTEMPLATES adlı klasörün içinde tutulur. Bu template'lerin virtual directory'si /_controltemplates'tir.

Custom Controls gibi User Controls'te de güvenli moda dikkat edilmelidir. Eğer bu kontrol özelleştirilmiş bir sayfaya uyarlanacaksa web.config'e SafeControl register edilmelidir.

<SafeControl
  Src="~/_controltemplates/*"
  IncludeSubFolders="True"
  Safe="True"
  AllowRemoteDesigner="True"
/>

Designing Web Part Pages

Web Part'ları özelleştirmek ve kişiselleştirmek site sayfalarında desteklenir fakat application sayfalarında desteklenmez. ASP.NET 2.0 application'ında web part oluşturmak için WebPartManager instance'ı ve bir veya birdefn fazla WebPartZone kontrolü içeren bir .aspx sayfası oluşturmamız gerekmektedir.

WSS 3.0'ın Web Part altyapısı standart WebPartManager kontrolünü kullanmaz. Bunun yerine WebPartManager'dan türeyen SPWebPartManager kullanılır. Bu kontrol standart WebPartManager'ı override eder.

Çoğu zaman SPWebPartManager ile uğraşmak gerekmez çünkü bu kontrol zaten default.master sayfasında tanımlanmıştır. Yani siz master'ı default.master olan bir sayfa oluşturduğunuzda SPWebPartmanager otomatik olarak eklenecektir. Yapmanız gereken tek şey gerekli WebPartZone kontrollerinin eklenmesidir.

Bir sayfa template'ine WebPartZone eklemek için Microsoft.SharePoint.dll assembly'sinden bütün kontrolleri getiren bir Register eklememiz gerekmeketir.

<%@ Page MasterPageFile="~masterurl/default.master"
    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,
              Microsoft.SharePoint, [full 4-part assembly name]"
    meta:progid="SharePoint.WebPartPage.Document" %>

<%@ Register Tagprefix="WebPartPages"
    Namespace="Microsoft.SharePoint.WebPartPages"
    Assembly="Microsoft.SharePoint, ..." %>



Custom Web Part page






Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

17 Temmuz 2011 Pazar

Programming with SPFile Objects

WSS obje modelinden bir sayfaya ulaşmak için SPFile sınıfını kullanırız. Bir sayfayı SPFile objesinin GetFile metodunu kullanarak okuyup değiştirebiliriz.

SPWeb site = SPContext.Current.Web;
SPFile homePage = site.GetFile("default.aspx");

OpenBinary ve OpenBinaryStream metodu ile safyayı okuyabilir, SaveBinary metodu ile sayfayı güncelleştirebilirsiniz. Ancak unutulmamalıdır ki güncelleştirilen sayfalar özelleşecektir ve unghosted halini alacaktır.

Delete, MoveTo, CopyTo metodları ile sayfaları silebilir, kopyalayabilir hatta yerlerini değiştrebilirsiniz.

Add metodu ile yeni sayfalar oluşturabilir. MemoryStream metodu ile bu sayfalara kod yazabilirsiniz.

// write out new page in memory stream
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine("<html><body>");
writer.WriteLine("Hello, World");
writer.WriteLine("</body></html>");
writer.Flush();

// add new page to site
SPWeb site = SPContext.Current.Web;
site.Files.Add("hello.htm", stream);

Ancak Add metodu yalnızca unghosted sayfalar oluşturduğunu unutmamamız gerekir.

Sayfaların özelleştirilmiş olup olmadığını öğrenmemiz için SPFile sınıfı bize CustomizedPageStatus propertysini sunar. Dahası RevertContentStream metodu ile bir sayfanın özelleştirilen özelliklerini kaldırarak o sayfayı ghosted haline çevirebilir.

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

15 Temmuz 2011 Cuma

SharePoint Architecture

ASP.NET Framework aspnet_isapi.dll 'i ISAPI uznatısı olarak uygular.

.aspx, .ascx, .ashx, and .asmx dosya uzantılarını gören IIS isteği doğrudan aspnet_isapi.dll'e yönlendirir.

Temel hali ile ASP.NET konfigurasyon xml dosyası:
<configuration>

  <system.web>
    <customErrors mode="On" />
    <httpRuntime maxRequestLength="51200" />
    <authentication mode/>
    <identity impersonate="true" />
    <authorization>
      <allow users="*" />
    </authorization>
  </system.web>

</configuration>

ASP.NET çatısı, aynı IIS Worker Process te bile çalışsalar ASP.NET uygulamalarını birbirinden yalıtır.

Master Page tanımı için @Master direktifini sayfanın üstüne koyarız
<%@ Master %>
<html>
<body>
  <form id="frmMain" runat="server">
    <table width="100%">
      <tr>
        <td> <!-- Display Litware Banner -->
          <h1>Litware Inc.</h1><hr />
        </td>
      </tr>
      <tr>
        <td> <!-- Display Main Body of Page -->
          <asp:contentplaceholder id="PlaceHolderMain" runat="server" />
        </td>
      </tr>
    </table>
  </form>
</body>
</html>

İçerik sayfası oluşturmak için @Page direktifi ve içine MasterPageFile özelliğini tanımlar ve uygun .master uzantılı dosyayı değer olarak verebilirsiniz.
<%@ Page Language="C#" MasterPageFile="~/default.master" %>
<script runat="server">
  protected override void OnLoad(EventArgs e) {
    lblDisplay.Text = "Hello World";
  }
</script>
<asp:Content ID="main" Runat="Server"
             ContentPlaceHolderID="PlaceHolderMain" >
  <asp:Label ID="lblDisplay" runat="server" />
</asp:Content>

WSS tarafında MasterPage zaten tanımlı olup biz ContentPage tanımlıyor ve WSS nin masterPage ine referans veriyor olacağız. Bu durumda WSS takımının bizler için hazırladığı PLACEHOLDER ları öğreneceğiz.

Http Request Pipeline 3 değiştirilebilir bileşene sahiptir: HttpHandler, HttpApplication, HttpModule. Bu bileşenleri kendi bileşenlerimizle değiştirebiliriz.

İstekler(Requests) geldiğinde hepsi bir kuyruğa sıralanır ve bir worker thread atanır. Sonra bu thread sırayla HttpHandler, HttpApplication, HttpModule bileşenlerden geçirir.

HttpHandler sınıfı IHttpHandler arayüzünü uygular. Kendi handlerimizi aşağıdaki gibi oluşturup web.config dosyasına ekleyerek kullanabiliriz.
using System.Web;
public class KendiHendlirim:IHttpHandler
{
    public bool IsReusable
    {
        get { throw new System.NotImplementedException(); }
    }

    public void ProcessRequest(HttpContext context)
    {
        throw new System.NotImplementedException();
    }
}

HttpApplication sınıfında BeginRequest, AuthenticaRequest, AuthorizeRequest eventlerini geçtikten sonra HttpHandler'a doğru isteği taşırız.

HttpModule benzer şekilde değiştirilebilir componenttır. HttpApplication sınıfı taraından tanımlanan eventlerin handle edilmesiyle değiştirebiliriz. Bu değişiklik, kontrolün HttpHandler sınıfına gönderilmeden önce gerçekleştirilir. Örneğin BeginRequest, AuthenticateRequest, and AuthorizeRequest gibi request-level eventlerini handle etmemiz için özel bir HttpModule component oluşturabiliriz. Bu değişiklikleri IHttpModule arayüzü ile implemente edip HTTP Request Pipeline'a bağlayan bir class yazarak gerçekleştirebiliriz. IHttpModule arayüzünü pipeline'a bağlamamız için web.config'e configuration elementlerini eklememiz gerekir.

Ayrıca HttpApplication'dan farklı olarak birden fazla HttpModule eklenebilir ve machine level'da değiştirilebilir.

Son olarak ASP.NET, HttpContext'i barındıran bir requesti başlatı ve HTTP Request Pipeline'a gönderir. Zaman perspektifinde baktığımızda HttpContext bütün custom kodların execute edilmeden önce oluşturulur. Bu durumda Request, User, ve Response objelerini her zaman programlayabiliriz:

HttpContext currentContext = HttpContext.Current;
string incomingUrl = currentContext.Request.Url;
string currentUser = currentContext.User.Identity.Name;
currentContext.Response.Write("Hello world");

WSS de bir web uygulaması için standart web.config dosyası
<configSections>
    <sectionGroup name="SharePoint">
      <section name="SafeControls" type="..." />
      <section name="RuntimeFilter" type="..." />
      <section name="WebPartLimits" type="..." />
      <section name="WebPartCache" type="..." />
      <section name="WebPartWorkItem" type="..." />
      <section name="WebPartControls" type="..." />
      <section name="SafeMode" type="..." />
      <section name="MergedActions" type="..." />
      <section name="PeoplePickerWildcards" type="..." />
    </sectionGroup>
  </configSections>

  <SharePoint>
    <SafeMode />
    <WebPartLimits />
    <WebPartCache />
    <WebPartControls />
    <SafeControls />
    <PeoplePickerWildcards />
    <MergedActions />
    <BlobCache />
    <RuntimeFilter />
  </SharePoint>
</configuration>

Microsoft Office SharePoint Designer ile WSS içindeki .aspx ve .master dosyalarımız özelleştirebiliriz. Değiştirilmiş dosyaları kaydettiğimizde, WSS değişimi content veritabanına yazar. Bu sayfayı istemci talep ettiğinde DB den çekilerek gönderilir.

The idea behind a virtual path provider is that it abstracts the details of where page files are stored away from the ASP.NET runtime.

SPVirtualPathProvider gider ASP.NET sayfasını content DB den çekip onu ASP.NET page parsırına gönderir ve oradan gelenide SPPageParserFilter ile DLL dosyasına çevirir. İstenirse bunu web.config de belirtilmesi kaydıyla DLL yapmadan da tutabilir.

SPVirtualPathProvider isteğin ghosted mı unghosted mı olduğuna karar vererek sayfayı content db den çeker.

Ghosted Pages:

UnGhosted Pages:

Virtual Directories

_vit_bin : dll ve .asmx dosyalarımızı barındırır.
_controltemplates : User controllerini barındırır.
_wpresources : Web Part lar tarafından kullanılan resource dosyaları tutar.
_layouts :Application page leri tutar.

Site Pages vs Application Pages

Özelleştirilmiş sayfalar bize büyük bir esneklik sağlıyorken dezavantajları da var. Özelleştirilmiş sayfalar content database'de saklandığı için her unghosted sayfa performansı etkileyecektir. Ayrıca bu sayfalar güvenlik açığına da sebebiyet verecektir. Örneğin admin izni olan bir kullanıcı in-line code ile DB'de tutulan özelleştirilmiş sayfaya saldırıda bulunabilir. Ancak WSS application sayfaları (.aspx) \LAYOUTS isimli bir directory'de tutarak hem özelleştirilmesini önler ve hem de compile edilmesini devre dışı bırakarak güvenliği üst seviyede tutar. Bu sayfaların fiziksel olarak aşağıdaki dizinde tutulmaktadır.

c:\program files\common files\microsoft shared
\web server extensions\12\TEMPLATE\LAYOUTS

Her yeni Web Application oluşturulduğunda \LAYOUTS directory sanal _layouts directoy'sine map edilir. WSS'de farklı siteler açıldığında buralardaki sanal _layouts directory'sine map edilerek de application'lara ulaşılabilir.

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

The Web Part Life Cycle

Method/Event
Description
OnInit
Handles initialization of the control.
OnLoad
Handles the Load event.
CreateChildControls
Creates any child controls that are used as part of a composite control.
EnsureChildControls
Ensures that CreateChildControls has executed. Use this to ensure that a control you are referencing exists before accessing its data.
OnPreRender
Handles or initiates tasks such as data loading that must complete before the control can render. Asynchronous page tasks should be started from this method.
Page.PreRenderComplete
The page fires the PreRenderComplete event after all controls have completed their OnPreRender methods and the page has completed asynchronous tasks.
Render
Renders the entire control, including the outer tags and Web Part chrome.
RenderContents
Renders the contents of the control only, inside of the outer tags and style properties.

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

12 Temmuz 2011 Salı

Programming Against the WSS Object Model

Another important aspect of WSS development is programming against the WSS object model. The core types provided by the WSS programming model are exposed through a standard WSS assembly named Microsoft.SharePoint.dll.

Let’s look at a simple example. Imagine you have just created a console application, and you have added a reference to Microsoft.SharePoint.dll. The WSS object model exposes an SPSite class that serves as an entry point into the WSS object model at the site collection level. Each site within a site collection is represented as an SPWeb object. Each list within a site is represented as an SPList object. Here’s a simple example using the WSS object model to access the top-level site within a target site collection and discover all its lists.

using Microsoft.SharePoint;
namespace Hello_WSS_OM {
  class Program {
    static void Main() {
      string sitePath = "http://litwareinc.com";
      // enter object model through site collection.
      SPSite siteCollection = new SPSite(sitePath);
      // obtain reference to top-level site.
      SPWeb site = siteCollection.RootWeb;
      // enumerate through lists of site
      foreach (SPList list in site.Lists) {
        Console.WriteLine(list.Title);
      }
      // clean up by calling Dispose.
      site.Dispose();
      siteCollection.Dispose();
    }
  }
}

You should observe the two calls to the Dispose method at the end of this code example. Several object types in the WSS object model, such as SPSite and SPWeb, use unmanaged resources and must be disposed of in a timely manner. If you fail to do this and simply rely on the garbage collector of the .NET Framework to reclaim memory, your code can cause problems by consuming far more memory than it needs. As a rule of thumb, when you create a disposable object, you are also responsible for calling Dispose on it. However, object references obtained through the WSS Web application’s SPContext should not be disposed.

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

Development Opportunities in WSS

As a developer, you have many different avenues for extending WSS. You can develop many types of custom components for use within WSS sites. These components include standard ASP.NET server controls, Web Parts, event handlers, custom field types, and custom policies.

A site column is a reusable column definition that can be used across multiple lists. A site column defines the name for a column, its underlying field type, and other characteristics such as the default value, formatting, and validation. Once you have defined a site column, you can then use it as you define the schema for custom lists and document libraries.

A content type is a flexible and reusable WSS type definition that defines the columns and behavior for an item in a list or a document in a document library. For example, you can create a content type for a customer presentation document with a unique set of columns, an event handler, and its own document template. You can create a second content type for a customer proposal document with a different set of columns, a workflow, and a different document template. Then you can create a new document library and configure it to support both of these content types.

Another great new development opportunity is to work with the new Office Open XML file formats. This new technology introduced with Microsoft Office 2007 provides you with the ability to generate and/or manipulate Microsoft Office Word documents and Microsoft Office Excel documents from server-side code within custom components such as event handlers and workflows. What’s nice is that the Office Open XML file formats eliminate the need to install and run a version of a Microsoft Office desktop application such as Office Word or Office Excel on the server. Everything can be done by programming against server-side libraries, which provide high degrees of scalability and robustness.

WSS is built on top of Microsoft’s new Windows Workflow Foundation that is part of the .NET Framework 3.0. WSS adds an extra dimension on top of the Windows Workflow Foundation to provide a foundation for attaching business logic to list items and documents in a WSS site. WSS extends the basic model of the Windows Workflow Foundation by associating a task list and a history list with each workflow.

Rerefence: Inside Microsoft Windows SharePoint Services 3.0 by Ted Pattisonand, Daniel Larson

WSS 3.0 Kurulumunda Önemli İpuçları

Windows SharePoint Services 3.0 bilindiği üzere şirketler için tasarlanmış bir intranet portalıdır. Şirket içinden erişilebilen ve şirketle ilgili tüm belgeleri, şirket içi yazışmaları, organizasyonları tek bir ortamda birleştiren yararlı bir yazılımdır.

WSS 3.0 kurulumu normalde çok zor değildir, ancak kaçırılan önemli ayrıntılar yüzünden çok fazla hata çıkarabilir. Bu yazımızda bu küçük ayrıntıları ele alacağız.

Öncelikle WSS 3.0, Windows Server işletim sistemiyle çalışabilen bir programdır. Bu programı kullanabilmeniz için öncelikle bu işletim sistemine veya bu işletim sisteminin sanalına sahip olmanız gerekmektedir. Windows Server 2003 versionu için, 2003'ün Service Pack 1'i bilgisayarınızda güncel olması gerekir. Windows Server 2008 ve 2008 R2 verionları için ise, "Windows SharePoint Services 3.0 with Service Pack 2"yi kurmanız gerekiyor.

İşletim sisteminin dışında bazı programlarada ihtiyacımız var. Daha sonra kurulacak olan Visual Studio Extension'u için Visual Studio 2005 veya 2008 kurmanız gerekiyor. 2010 versionu kesinlikle kurmayın çünkü henüz WSS 3.0 için bir 2010 Extension versionu bulunmamakta. Bunun dışında bilgisayarınızda Microsoft SQL Server servislerinin kurulu olması ve makinamızda Microsoft .NET FrameWork 3.0 ve üzeri versionlarının bulunması gerekiyor. Windows Server 2008'de 3.5.1 versionu update olarak geliyor. Son olarak IIS 6.0'a ihtiyacımız var. Eğer Windows 2008 kullanıyorsak IIS 7.0 kurmamız gerekiyor.

WSS 3.0 kurulumuna geçmeden önce birkaç yapılandırma yapmamız gerekiyor. Başlat menüsünün solunda bulunan Server Manager'ı açıyoruz. Sol barda bulunan Features'a tıklayarak sağda açılan sayfadan Add Features seçeneğini tıklıyoruz. Açılan pencerede aşağıdaki seçeneklerin seçili hale getirip feature'mızı kuruyoruz.
  • .NET Framework 3.5.1 Features (2003 için 3.0)
    • .NET Framework 3.5.1 (2003 için 3.0)
    • WCF Activation (Extension Tool'lar için gerekli!)
      • HTTP Activation
      • Non-HTTP Activation
  • Windows Internal Database

Ayrıca Roles'de eklememiz gerekiyor. Yine sol taraftan Roles'e tıklayıp Add Roles'ü seçiyoruz ve aşağıdaki seçenekleri işaretleyip kuruyoruz.


Web Server
  • Common HTTP Features
    • Static Content
    • Default Document
    • Directory Browsing
    • HTTP Errors
Application Development
  • ASP.NET
  • .NET Extensibility
  • ISAPI Extensions
  • ISAPI Filters
Health and Diagnostics
  • HTTP Logging
  • Logging Tools
  • Request Monitor
  • Tracing
Security
  • Basic Authentication
  • Windows Authentication
  • Digest Authentication
  • Request Filtering
Performance
  • Static Content Compression
  • Dynamic Content Compression
Management Tools
  • IIS Management Console
IIS 6 Management Compatibility
  • IIS 6 Metabase Compatibility
  • IIS 6 WMI Compataibiliyity
  • IIS 6 Scripting Tools
  • IIS 6 Management Console

Yukarıdaki bütün gereksinimleri ve donanım gereksinimlerini karşıladığımızda WSS 3.0'ımızı kurabiliriz. Henüz işin başındaysanız Basic seçeneğiyle kurmanızı öneririm, şirketiniz SharePoint'in altyapı aşamasındaysa Basic doğru bir seçenek olacaktır.

WSS 3.0'ı kurduktan sonra Configuration Wizard'ımızı da çalıştırıyoruz. Bu işlemden sonra WSS 3.0 Central Administration otomatik açılacaktır ve sizden kullanıcıadı ve şifre isteyecektir. Şimdilik hiçbirşey yapmadan sayfayı kapatın ve Visual Studio versionunuza göre Visual Studio Extension Tools for Windows SharePoint Services 3.0'ı kurun. Böylece bu toollarla solutionlar generate edebilirsiniz.

Konumuzun sonuna doğru gözden kaçabilen çok önemli bir ayrıntıyı paylaşmak istiyorum. Windows Server kurduğumuzda klavye dili varsayılan olarak İngilizce ayarlanıyor. Böylece kullanıcı şifremizi girerken İngiliz klavye takımına göre ayarlıyor. Eğer şifrenizin içinde harf ve sayı dışında özel karakterler bulunuyorsa bu ileride başınıza büyük belalar açabilir. Çünkü kullanıcıların çoğu Windows'u ilk kurunca şifrelerini İngilizce klavyesinde atıyorlar ve daha sonra Türkçe'ye çevirip kullanmaya devam ediyorlar. Eğer şifreniz karmaşık ise WSS 3.0'ın Central Administration sayfına Türkçe klavyeden şifre girmeye kalkarsanız şifrenizi kabul etmeyecek ve bunun nedenini internette saatlerce araştırmaya kalkarak büyük zaman kayıpları yaşayacaksınız. Bu durumdan kurtulmanız için önce Windows'u ilk kurduğunuzda basit bir şifre atayın ve daha sonra Control Panel>Change Keyboards and other input methods'a gelerek buradan Keyboards and Languages sekmesine gelin. Change Keyboards'a tıklayın ve klavye servislerine Turskih Q'yu yükleyin. Default intput language kısmını yine Turkish Q yapmayı kesinlikle unutmamalısınız. Yoksa siz manuel olarak her Türkçe klavyeye geçtiğinizde bir süre sonra varsayılan klavyeye döneceği için aynı sorunlarla karşılaşabilirsiniz. Klavyenizi Türkçe yaptıktan sonra kullanıcı şifrenizi atayabilir ve WSS 3.0'ü rahatlıkla kullanmaya başlayabilirsiniz.

7 Temmuz 2011 Perşembe

PowerShell Script'lerini Zamanlama

PowerShell script'leri bilindiği üzere birçok işinizi sistematik bir biçimde hallederek sizlere zaman kazandırır. Ancak buna rağmen bazı script'lerinizi hergün, hatta günde defalarca çalıştırmanız gerekebilir. Bu da işlerinizin yoğunluğu arasında sizleri iyice boğar. Bu yazımızda bir PowerShell script'ini Windows Task Scheduler yardımıyla nasıl zamanlayacağımızı göreceğiz.

Bunun için öncelikle script'imizi çalıştıracak bir bat veya cmd dosyasına ihtiyacımız var. Bir not defteri açalım ve farklı kaydederek uzantısını bat veya cmd yapalım, dosyayı da script'in bulunduğu klasörün içine atalım. Bu dosyanın içine aşağıdaki kodlarımızı yazıyoruz:

cd\
powershell -command "& './ScriptinBulunduguKlasor/Script.ps1' "

Öncelikle kodumuzun başına cd\ komutunu koymamızın sebebi Windows Task Scheduler'ın komut istemini C:\Windows\System32 konumundan açmasıdır. Bu komut C: kök dizine gider ve aşağıdaki kodumuza da scriptin bulunduğu konumu doğru şekilde yazdığımız taktirde kodumuz çalışacaktır. Örneğin bat/cmd dosyamız kullanıcı klasörümüzün içindeyse bu sefer konum bölümüne './Users/KullaniciAdi/Script.ps1' yazmamız gerekecekti. Eğer script'imiz D: gibi başka dizinlerdeyse cd\'nin altına D: yazarak önce o dizine geçiş yapmamız gerekiyor.

Task Scheduler'ımızı açtığımızda sağ barımızda bulunan Create Basic Task'a tıklayarak bat/cmd dosyamızı zamanlıyoruz. Action sekmesine geldiğimizde Start a Program seçeneğini seçmeyi unutmayın. Buradan başlatılacak dosyamızı browse ediyoruz. Add Arguments ve Start in bölümlerini boş bırakıyoruz. Next ve ardından Finish'e tıklayarak zamanlayıcımızı ayarlamış oluyoruz.

Artık script'imiz zamanladığımız şekilde periyodik olarak çalışıyor olacak. Gönül rahatlığıyla diğer işlerimize yoğunlaşabiliriz.