Monday, October 26, 2009

Silverlight Organization Chart – Part 1 – Read XML file

I’m sorry I did not post the details of how to do the Silverlight organization chart as was expected.

I’ll not go in details of how to create a Silverlight application; you can see these details here.

In my organization chart I make option either to read the nodes from XML file for read them from a web service (reading the data from Active Directory), I’m here will just talk about the XML file.

Point 1: the XML file

My XML file looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<Persons>

  <Person>

    <ID>1</ID>

    <Name>Mostafa El Mashad </Name>

    <Title>CEO</Title>

    <Department> </Department>

    <Extension>1111</Extension>

    <Email>mostafa.elmashad@domain.com</Email>

    <ManagerID></ManagerID>

  </Person>

  <Person>

    <ID>2</ID>

    <Name>Ahmed Sadek</Name>

    <Title>HR Manager</Title>

    <Department>HR</Department>

    <Extension>1200</Extension>

    <Email>Ahmed.sadek@mydomain.com</Email>

    <ManagerID>1</ManagerID>

  </Person>

  <Person>

    <ID>3</ID>

    <Name>Hanan Youssef</Name>

    <Title>Sales Manager</Title>

    <Department>Sales</Department>

    <Extension>1300</Extension>

    <Email>hanan.youssef@mydomain.com</Email>

    <ManagerID>1</ManagerID>

  </Person>

</Persons>



and you can add as much as person nodes as you want.

Where:
ID: Is the identity of this person
Name: The person name
Title: His job title
Department: The department he is working in
Extension: Phone extension
Email: his email address
ManagerID: The identity value used in his manager data

In our example:
Mostafa – the CEO – he has no manager, so the ManagerID is blank
Hanan and Ahmed are reporting to Mostafa, so the ManagerID equal 1, which is Mostafa’s ID

Note: this XML file will be deployed with the XAP file at the end.


Point 2: The Person class

I’ll need to make a class to represent the Person object, and while reading the data from the XML file I’ll put it in an list of Persons.

public List<Person> persons = new List<Person>();

Also I’ll need some extra data to be stored with each person, like:
Level : The person level, in our example, Mostafa #1, Ahmed and Hanan #2
SubNodes: How many person are reporting to the current, 2 are reporting to Mostafa
HiddenSubNodes: The same as the SubNodes in case the node is not collapsed.
NodeOrder: The order of this node between the same level under the same parent
MinChildWidth: The display minimum width allowed for the child nodes
X: The X coordinate of the node on the screen, the Y position is calculated from the node level
StartX: The parent X
Opened : is this node displayed or not
Collapsed: Is this node’s child are displayed or not


Point 3: Reading the XML file

In the page load of my Silverlight control, I’ll call the method that will read the XML file:

private void LoadXMLFile()

        {

            WebClient xmlClient = new WebClient();

            xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);

            xmlClient.DownloadStringAsync(new Uri("OrgChart_Data.xml", UriKind.RelativeOrAbsolute));

        }



void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)

        {

            if (e.Error == null)

            {

                Person firstNode = Person.GetPerson("OrgChartRootNode", "LINK Development", "", "", "", "", "");

                firstNode.MinChildWidth = totalWidth;

                persons.Add(firstNode);

 

                XElement lobjDocument = XElement.Parse(e.Result.ToString());

 

                var Result = from view1 in lobjDocument.Descendants("Person")

                             select new Person

                             {

                                 Name = (string)view1.Element("Name"),

                                 ID = (string)view1.Element("ID"),

                                 ManagerID = (string)view1.Element("ManagerID"),

                                 Title = (string)view1.Element("Title"),

                                 Department = (string)view1.Element("Department"),

                                 Extension = (string)view1.Element("Extension"),

                                 Email = (string)view1.Element("Email")

                             };

 

                Person[] nodes = Result.ToArray();

 

                for (int i = 0; i < nodes.Length; i++)

                {

                    if (string.IsNullOrEmpty(nodes[i].ManagerID))

                    {

                        nodes[i].ManagerID = "OrgChartRootNode";

                    }

                }

                persons.AddRange(nodes);

                Start();

            }

        }






Here in my control, if any node did not has a ManagerID value, I’ll consider it as a parent node just under the organization root element.

In the last line of code, you will see a call to a Start method, which will start calculating and building the organization chart nodes. And we will talk about the calculations in a separate post soon isA.

Saturday, October 24, 2009

Otlob.com on mobile

I have an account on Otlob since 2001 and make all my orders through it in Egypt. But using Otlob in KSA is a problem, all the restaurants are closing between 30 to 60 minutes for praying four times a day and you cannot place an order and you have to wait all this time - And you will not see a message when actually your order will be delivered - currently it is 40 minutes fixed- which is the same if you are going to make your order and eat in the restaurant.

Another problems that is facing me while using Otlob web site in KSA is the address, as still in KSA there is no accurate addresses in many places, and for each address I want the food to be delivered to I have to make a profile, while in some places I don’t know what is the address but I can just describe it.

A lot of people come to KSA to do some tasks and then return back to their countries, and those are the most people whose needs to order fast foods, they did not have time, and they may not have any internet access to browse the Otlob website.

A mobile application (not a mobile website) is a good idea for this scenario, the user will download the application from the net, and he can select which restaurants he wants to download its menus. He can check this menu while he is in the taxi and offline for example.

He can also just check for the menu and go directly to the restaurant, but he knows already what the menu is and what are the prices, he may select to “prepare the order for me” service, to be able to go and eat it before the prayer time. He can also pass through and take it home.

For the addresses, GPS became available in every mobile, so the user can set an order and select to receive it in the location where he is now. He doesn’t need to make a new profile for these addressees, as he may be today in Riyadh and tomorrow in Jeddah and so on.

Preferred orders, will be much easier, as the mobile will display a reminder “Do you want to make the order now? It will be delivered after one hour”, he can select “Just prepare it for me, I’ll be there before the prayer time to take it home.”

Just ideas. And that is what I want from a mobile application.

What do you think? any ideas?

Friday, October 23, 2009

SharePoint4Arabs

A year ago, I met with Ayman El Hatab http://www.aymanelhattab.com/ before he joined ITWorx, then two weeks ago I found him on Twitter. He sent to me an email introducing http://www.sharepoint4arabs.com/ website, and I found it really interesting to make Arabic trainings, articles and video tutorials.

Till now, they are focusing on the end user; for example: What is SharePoint, how to make a site columns, content types, and managing site security.

I started with them by recording my first video “SharePoint Pages” talking about the Basic and the Web Part Pages, the related content types and its page layouts. And there will be soon another video that is talking about the “Publishing Pages” then “SharePoint MasterPages” and “Page Layouts” that will be in Arabic as well isA.

Hopefully this series help in introducing SharePoint to Arabic audience and give them their first step on using, customizing, managing SharePoint sites.

Thursday, October 22, 2009

Waiting for SharePoint 2010

No date for releasing the software and no actual date as well for the beta version (possibly mid of November), but everyone is waiting.

But the good thing is that there is Development Hands-on Labs since the second day in the conference http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c010fc68-b47f-4db6-b8a8-ad4ba33a35c5

Besides, there are ten modules to start developing on SharePoint 2010 http://msdn.microsoft.com/en-us/sharepoint/ee513147.aspx

As well, there will be a group of SharePoint 2010 courses (webcasts/offline) in December by a group of SharePoint MVPs (Andrew Connell is one of the instructors) http://www.andrewconnell.com/blog/

And today I have attended the Riyadh Community Summit, an event sponsored by Microsoft KSA and organized by three user groups in Riyadh:
1. Riyadh SharePoint User Group – http://www.rsug.net/
2. DevLifeStyle - http://www.devlifestyle.net/
3. CΏdeβettěЯ - http://www.codebetter.net/

The event was at Al Yamamah University where all the software events are currently happened there.

And it was really good to listen to someone talking about SharePoint 2010 at the same time as in #SPC09 (GDC09 will be in Riyadh isA 13-15 December)

BTW, at the end of today’s sessions, the two persons that were sitting beside me on both sides have won a 1 year access to http://www.microsoftelearning.com/ and for me I have received a book “Object Thinking” http://www.amazon.com/Object-Thinking-DV-Microsoft-Professional-David/dp/0735619654

Wednesday, October 21, 2009

Nice !!!

Nice #1:

This is the word that my son – 2 years - learned to say while patting on the cat; his mom told him to be nice with the cat and showed him how to pat smoothly, but he understand it as “pat a cat” = “Nice”.
http://www.facebook.com/photo.php?pid=8907036&id=610370569


Nice #2:

But I saw the word “Nice” in a blog, it was in the comments, and it was repeated many times plus some other words like “Extremely Interesting” and “Just Great”. I was happy to see these comments as the blog is related to a friend and a colleague and it was just his second post, but one comment stopped me, which is “You made some good points there” while the post was just a link to another website with two lines describing this link!

I started to check, who add this comment and I found that his name is redirecting to a loans website, and the surprise was that some other comments are added by the same user (same site URL) and most of the comments are added by someone just want to increase the number of the sites that referring to his site!


Nice #3:

I have received a link to http://www.personalizemedia.com/ in this page you will find a flash object with numbers that are changed so fast. It is the social media counter, it shows you how many new Twitter user, or how many video are watched now on YouTube, or how much Facebook collected from the Gifts. The user who post the article said that you can embed this counter in your site like this:



Very Nice!!!

But the first thing that I thought about is the number of hits to all this information sources; take into consideration that ANYONE can embed it anywhere, which means that extra number of hits; also it was very strange that this person know how to read all these updated information and with this high frequency, instantly I switched off my wireless connection, but the numbers still increasing!

Then I returned back to read and I found a link to the details page http://www.personalizemedia.com/garys-social-media-count/#more-1734 that his numbers are calculated based on facts, and not a real numbers.

Monday, October 19, 2009

SharePoint 2010 - Day 1

It is 4:00 AM, and I’m online on twitter for more than three hours, trying to know as much as I can from the people at the SharePoint 2010 conference #SPC09, and it seems now that the most important thing is that #NoCofee and other people are asking about the #Power to recharge their laptops and mobiles (as per one of the attendees 40% are MAC).

Well, I just realized the importance of twitter, it is great, and people there are wearing shirts and hats with their Twitter ID on it, but some users are describing this as cacophony, but for me it is really interesting.

But actually I’m not going to talk about Twitter more than that, as I have to focus on SharePoint which I’ll work on isA and I have to manage some projects before they came up with the new versions - I’m sure it will be very soon.

SharePoint 2010 comes up with a lot of changes and new features; the most thing that disappointed me is the new Silverlight Organization Chart. So, what can I do now with my Silverlight OrgChart? :(

Now my plan is to:

1. Send email to my boss requesting some new Laptops and PCs for me and for my team. Check this link http://blogs.msdn.com/opal/archive/2009/10/19/sharepoint-2010-what-does-that-mean-for-it-pros.aspx
2. Start reading and studding SharePoint 2010 – check this http://blogs.msdn.com/sharepoint/archive/2009/10/19/sharepoint-2010.aspx
3. SharePoint Designer 2010 – it will be free the same as 2007 – check this http://willhlaw.wordpress.com/
4. Visual Studio 2010
5. .NET 4.0
6. Silverlight
7. More XSLT
8. More LINQ
9. PowerShell
10. …..
11. …..
12. …..
13. …..

Now what? It is the same as changing the study courses each year in the school “Sorry, but you must start again from KG1, everything is changed!” and with every new version we hear people say: “we will not find anything to do, the new application will do everything, and we will lose our jobs”, but actually with every new software and new programming language there are much more things to do, and I’m really excited to start developing with the new things.

But before developing, we have to support our sales team to bring new projects to be done over the new SharePoint, and as I’m working in KSA office, I think it is one of my tasks and it will start very soon isA.

Saturday, October 17, 2009

20 Years Ago...

For me it sounds like an old man telling the story of his life, but it really seems like this when the story is that of the internet and computer technologies, comparing it to what was there about 20 years ago.

My PC was a 386 with only 1 MB ram, 1 floppy 5.25” (360 Kb, 1.2MB), floppy 3.5” (720 Kb, 1.44 MB) and a hard disk of 40 MB (I did not hear that any of my friends or relatives had larger than the 40 MB for another two years) this is how I started my life on computers, and it was something that our brains can accept bit by bit, but now things are changed and changed again two or three times without even hearing about the changes in between.

Today, it is a human right in Finland to have a broad band connection 1MB, you can access the internet anywhere via your mobile, but 15 years ago I was sharing the same internet password with 10 of my friends (only one user can log in at a time)

One MB email inbox, now I don’t know what is the used or the available space on my Gmail account.

I do not remember how many students from my school growing up had a computer at home they may have been 4 or 6 (not Atari or Shakhr) but now there are 600k new user registrations on Facebook every day!!

20 years ago, it was a fact that there is something named Magnetic Field and nothing about the Magnetricity, now Facebook, Twitter, LinkedIn,… are facts, and accept it or not, you are in the Google Age!

Tuesday, October 13, 2009

فتحي رضوان : مبادئ مصطفى كامل

قصة الغلاف : مبادئ مصطفى كامل


قال الملك السابق لوزرائه: "لو أفرجتم عنه ... فإنه سوف يقتلني"

فلقد كانت قضايا "الاغتيالات" هي القاسم المشترك الأعظم في حساة ذلك الشاب اللذي يخفي ثورة جيل كامل وراء ذلك الهدوء العجيب الذي معدنه .. ووراء هذه الابتسامة البريئة الحلوة التي ترتسم دائما على شفتيه وكأنها صادرة من أعماق قلبه .. ووراء تلك الشعيرات البيضاء التي تكلل هامته كما يكلل الثلج قمم الجبال العالية على الرغم من أنه لا يزال في الحادية والاربعين من عمره.لقد اتهم فتحي رضوان و اعتقل في أكثر من ست قضايا للاغتيالات منها محاولة اغتيال مصطفى النحاس واغتيال أحمد ماهر واغتيال النقراشي و اغتيال أمين عثمان.

فمن يكون فتحي رضوان؟

شرقاوي

لقد ولد في 14 مايو 1911 في المنيا وكان والده مهندس ري المنيا .. أما جده فقد كان ضابطا في الجيش التركي أحيل على التقاعد عندما بلغ السن القانونية ثم هاجر وتزوج من سيدة مصرية، وعاش حياته في بلدة المنير بالقرب من مدينة القناطر.

وفي هذه القرية اشترى قطعة من الارض بمعاشه ، كان يفلحها ويزرعها بنفسه ثم يوزع الايراد على القرويين ولذلك أحبه الفلاحون و أصبحوا يحاكمون إليه في منازعاتهم ومشاجراتهم ويقبلون حكمه.وعندما مات اعتبروه وليا من أولياء الله الصالحين وشيدوا له ضريح لا يزال قائما حتى الآن ويعرف بإسم "ضريح الشيخ عثمان" ثم راحوا يحتفلون كل عام بمولده.

السيد فتحي

واسم وزير الدولة في شهادة الميلاد هو "السيد فتحي" .. ولذلك قصة طريفة فقد كانت والدته تتمنى من الله أن يرزقها بمولود ذكر، و في إحدى الليالي رأت في الرؤيا السيد البدوي و هو يحمل طفلا بين يديه قدمه إليها وقال لها: "سترزقين بولد .. فسميه فتح الله" فتفاءلت الام بهذه الرؤيا و ارادت ان تجمع بين اسم السيد البدوي و بين الاسم الذي ذكره لها في الرؤيا فسمته "السيد فتحي"

ومنذ اليوم الاول لميلاد فتحي رضوان وهو فريسة عدة امراض، فقد توالت عليه معظم الادواء فأصيب بالتيفود و الديفتريا والجدري والحمى القرمزية والروماتيزم.

وكان والده – وهو لا يزال حتى الآن في قيد الحياة – كثير التنقل بين مديريات الوجه القبلي شأنه في ذلك شأن الموظفين الآخرين .. و أخيرا عين في مديرية الجيزة "باشمهندس" للري .. فأقامت الاسرة الصغيرة – وكانت تتكون من ولد واحد هو فتحي رضوان و ثلاثة بنات – في منزل صغير في حي السيدة زينب تملكه بريمادونة مصر في ذلك الوقت "امليا ديان" المشهورة باسم "مليا" وكانت هي الممثلة الاولى في فرقة الشيخ سلامة حجازي.

وكانت اسعد اللحظات في حياة الطفل فتحي رضوان هي تلك اللحظات التي كانت تحضر فيها "مليا" بنفسها لتتسلم ايجار الشقة وتدعو الاسرة في بعض الاحيان إلى مسرح سلامح حجازي أو تجلس "لتدردش" عن نهضة المسرح وتاريخه وعن سلامة حجازي وفنه.

مصطفى كامل

و سمع فتحي رضوان عن مصطفى كامل لأول مرة في مدرسة الجمعية الأهلية المصرية ، و كان ناظرها "محمود أنيس" أحد الذين اتهموا في قضية اغتيال بطرس غالي بالاشتراك مع الورداني و لكن التهمة لم تثبت عليه فأفرج عنه المستشار متولي غنيم لانه لم يجد وجها لاقامة الدعوى ضده. ولكن الحكومة فصلت محمود انيس ففتح هذه المدرسة الأهلية ، ولما كان انيس صديقا حميما لوالد فتحي رضوان فقد ألحق بها نجله تشجيعا لصديقه، وكان ناظر المدرسة محمود أنيس ينتهز كل عام فرصة نهاية العام الدراسي فيقيم حفلا وطنيا كبيرا ويخطب فيه في الطلبة ويتحدث عن مزايا مصطفى كامل وعن دوره في الحركة الوطنية.

ثورة 1919

وعندما بدأت ثورة 1919 كان فتحي رضوان في السنة الاولى الابتدائية بمدرسة محمد علي.

إنه ما زال يتذكر ذلك اليوم الذي دخلت فيه اخته المنزل وهي تنشج بالبكاء فسألتها أمها: ماذا حدث؟

فقالت أخته: لقد أهانتني ناظرة المدرسة مسز كارتر الانجليزية .. كم كنت أود أن أصفعها.

فقالت لها أمها: ماذا قالت لك؟

قالت لي انك تلميزة مشاغبة ومن الافضل فصلك لانك تريدين أن تشعلي نار الثورة في المدرسة وانك بذلك تعرضين نفسك للطرد والفصل.

وماذا قلت لها؟

قلت لها.. أن وطني يجئ في المرتبة الأولى وأنه في حاجة إلى جميع مجهوداتنا .. أما أنت .. فاذهبي إلى وطنك واحتفظي بوعيدك ونصائحك لنفسك.

أعتقال

ويقول فتحي رضوان: وراحت انباء الثورة تتواتر إلى سمعي .. اعتقالات في كل مكان .. رصاص .. ثورة .. مدافع .. دماء .. اعتداءات من الانجليز على الارواح البريئة .. قطع خطوط السكة الحديد.

ولكني تعلمت دور الوطنية الاولى من المنزل .. بل من أمي بالذات .. كنت أعود من المدرسة .. فأجدها متجهمة الوجه .. ثائرة الأعصاب .. و في أحد الايام قالت لي أمي: يا فتحي .. ناد اخواتك و تعال.

وعندما عدت بعد لحظات مع شقيقاتي الثلاث ، وجدت أمي تجلس على أحد المقاعد وأمامها سلة كبيرة مغطاة ، وما كادت ترانا حتى قالت: هل أنتم جميعا هنا اجلسوا حولي.

ثم رفعت أمي غطاء السلة وأخرجت منها مجموعة من جريدة اللواء وبدأت تقرأ في صوت مرتفع خطب مصطفى كامل ومقالات مصطفى كامل.

و في إحدى الامسيات عدت إلى المنزل متأخرا فوجدت شقيقاتي وأمي وهن ينتحبن في صوت مسموع وأمامهن جريدة اللواء، وارتعدت لهذا المنظر فقلت في سذاجة: أمي .. ماذا حدث .. هل مات أحد؟

فقالت أمي: أجلس يا بني .. اني اقرأ لشقيقاتك وصف جنازة مصطفى كامل!

النشاط الأول

وفي المدرسة الابتدائية التقى فتحي رضوان بأحمد حسين .. وقاما بأول نشاط .. فلقد انشآ بالاشتراك مع عباس حلمي – وهو الآن بكباشي بالبوليس – جمعية أطلقوا عليها اسم "نصر الدين الاسلامي" وكانت هذه الجمعية تطبع منشورات وتوزعها على الطلبة وعلى رواد المقاهي تدعو فيها الناس إلى التقوى والولرع والعمل الصالح.

وفي أحد الايام استدعى ناظر المدرسة - وكان اسمه محمد توفيق البرادعي – أعضاء هذه الجمعية وهددهم بالفصل إذا لم يكفوا عن طبع هذه المنشورات، ومن الطريف أن أحمد حسين وفتحي رضوان لم يحاولا أن يدفعا تهمة توزيع المنشورات عن نفسيهما ، بل دافعا عن فكرة الجمعية وعن أهدافها ومراميها .. في الوقت الذي تخلى فيه أعضاء الجمعية عنها و القيا عليهما كل المسئولية. و كان هذا أول اصطدام بين فتحي رضوان والسلطات المختصة بخصوص المنشورات التي تدعو إلى فكرة معينة.

التلميذ الصحفي

وفي مدرسة أسيوط برز فتحي رضوان كصحفي، فقد دعا الطلبة إلى اصدار مجلة للمدرسة على غرار مجلة الخديوية والسعيدية.. فكانت بذلك أول مجلة لمدرسة أقليمية خارج القاهرة.

كما كتب أول مقال له في جريدة اللواء المصري التي كان يصدرها الاستاذ أمين الرافعي عام 1925 وكان المقال حول تنقيح البرامج المدرسية وهو البرنامج الذي وضعه "علي ماهر" وزير المعارف في ذلك الوقت.

وكانت أول محاضرة القاها فتحي رضوان عن داروين ومذهب التطور في جمعية القلم التي كان يرأسها الاستاذ حافظ محمود.

حادث طريف

وقد حدث أثناء هذه المرحلة التي قضاها فتحي رضوان في مدرسة بني سويف أن قام الملك فؤاد بزيارة لمدارس الوجه القبلي .. و كان ضمن برنامج الملك زيارة مدرسة أسيوط. فانتدبت المدرسة فتحي رضوان لالقاء قصيدة عصماء من تأليف الاستاذ علي الجارم مفتش اللغة العربية في ذلك الوقت أمام الملك. وكان مطلع القصيدة:يا مالك ملك القلوب .. فكان خير المالكين.

و كان مقررا في الحفلة أن يزور الملك فؤاد الفصول .. ثم يقف في الشرفة الكبيرة المطلة على فناء المدرسة فيستعرض فرق الالعاب الرياضية والكشافة .. ثم ينزل الدرجات العريضة للشرفة .. وعنئذ يشق فتحي رضوان صفوف طلبة الالعاب الرباضية .. وعلى بعد خمسة أمتار من الملك يلقي القصيدة.

والذي حدث أن زيارة الفصول استغرقت أكثر من الوقت المحدد لها وبدأت الشمس تميل إلى المغيب والملك يستعرض الفرق الرياضية .. فما كادت الالعاب تنتهي حتى أسرع الملك في الخروج.

ولاحظ فتحي رضوان ذلك وكان حريصا على إلقاء القصيدة فخرج يعدو وراء الملك .. وكان من عادته وهو يجري أن يضع يده في جيبه و يخرج منديلا ابيض اللون .. ولكنه في ارتباكه هذه المرة وضع يده في جيبه ولم يخرجها .. فاعتقدت حاشية الملك أن فتحي رضوان يحاول ان يغتال الملك أو انه على الاقل اعتزم القيام بعمل ما. وصرخ ناظر المدرسة – وكان اذ ذاك الاستاذ محمد رفعت – وقال للمدرسين: ماذا يريد هذه الولد .. امنعوه. وقبل أن يمنعوه كان الطالب فتحي رضوان على بعد متر واحد من الملك والورقة ترتعش بين إصبعه وهو يقول: يا مالك ملك القلوب ....

مقلب

ومما يذكر أيضا ان الاستاذ لطفي السيد – وكان وزير المعارف وقتئذ – جاء لزيارة المدرسة .. و تفقد الدراسة فيها .. وكان المفروض أن يقف فتحي رضوان بالنيابة عن الطلبة فيلقي قصيدة عصماء كتبها ايضا الاستاذ علي الجارم.

وقبل الزيارة قامت المدرسة باجراء عدة "بروفات" كان يقف فيها فتحي رضوان ويلقي القصيدة مرة ومرتين وثلاث مرات .. وعندما حان موعد الزيارة .. تقدم فتحي رضوان في خطوات جريئة واخرج القصيدة من جيبه .. ولكنه بدلا من ان يقرأها كورها بين اصابعه ورماها على الارض وارتجل كلمة نثرية قال فيها: يا وزير المعارف .. اعلم تماما اننا لا نحتفل بك لانك وزير .. فلقد كنت أول من علمنا أن الوظائف تقليد لا تخليد .. وانما نحتفل بك كصاحب "الجريدة" ورئيس تحريرها .. وانك علمت فيها هيكل ومصطفى عبدالرازق والدكتور طه حسين ومنصور فهمي.

وتستطيع أن تتصور ايها القارئ مدى الرعب الذي بدا على وجه الناظر وهو يستمع إلى طالب في الخامسة عشرة من عمره يخوض في السياسة ويتحدث عن طه حسين وهيكل كانداد و يحكم عليه حكم قاض مجرب!!

وما كاد الحفل ينتهي حتى اقبل لطفي السيد على هذا الطالب الجرئ ووضع يده على كتفيه وقال له : قل لي يا شاطر .. احنا صديقان .. انت ابن مين؟؟!!

في الجامعة

والتحق الطالب "المناكف" بكلية الحقوق .. وكانت السنة الأولى التحضيرية في كلية الآداب .. وأراد أن يشبع هوايته الصحفية.. فأجر جريدة اسمها "الصرخة" مع بعض شباب الطليعة في جزب مصر الفتاة وكان فتحي رضوان يكتب فيها قصة مسلسلة اسمها "غيور" تعالج بعض المشاكل النفسية. ولكن حدث أن اختلف فتحي رضوان مع صاحب الجريدة فامتنع عن اصدارها.

وكم كانت دهشته بالغة عندما تلقى انذارا من صاحب جريدة الصرخة يطلب فيها منه ارسال بقية القصة المسلسلة وإلا فان صاحب الصرخة نفسه سوف يكملها بنفسه و يبدل ابطالها ويشوه معالمها!!

من المحيط الضيق

وبدأ فتحي رضوان يخرج من المحيط الجامعي التعيق إلى المحيط الخارجي .. فدعا إلى عقد مؤتمر للطلبة الشرقيين .. يجتمع كل عام في عاصمة إحدى الدول الشرقية وتنظم فيه العاب اوليمبية شرقية.

وسافر فتحي رضوان إلى سوريا والعراق وتركيا وفلسطين .. وحدث أن ألقى محاضرة في الجامعة السورية يدعو فيها إلى فكرته وشرح أهدافها ومراميها .. فرفضت لبنان دخوله وقالت السلطات المختصة ان هذه الدعوة دعوة سياسية وطرد بالقوة.

وعندما عاد فتحي رضوان إلى القاهرة .. نشر بيانا وجهه إلى شباب مصر ودعاهم إلى أن يعملوا على تدعيم زعامة مصر.وكانت الحكومة القائمة في ذلك الوقت هي حكومة اسماعيل صدقي. وفهم صدقي أن فتحي رضوان بدعوته إلى تدعيم زعامة مصر إنما يرمي إلى تدعيم زعامة النحاس على مصر!!

فأصدرت الحكومة قرارا بحل المؤتمر وكانت لجنته العليا مكونة من علي ابراهيم رئيسا ومصطفى مشرفة واحمد أمين وعبدالوهاب عزام ومنصور فهمي أعضاء من الاساتذة.أما الشبان فكانوا مجموعة غريبة من بينهم عبدالقادر الحسيني وموسى الحسيني واسعد طلسي وجميل المسلمي وعبد القهار المذكر ومصطفى الوكيل وعمر الدسوقي وغيرهم.

بدء الحياة السياسية

بدأت حياة فتحي رضوان السياسية مع مشروع القرش .. فالذي حدث أن احمد حسين – صاحب المشروع – قد دعا بعض الذين تعاونوا معه في المشروع من الشبان وعرض عليهم برنامج الحزب فوافقوا عليه .. اما فتحي رضوان فانه رفض التوقيع على هذا البرنامج لانه كان يرى – مع موافقته على مبادئ الحزب ، وهي خلاصة تجارب طويلة في الحقل المدرسي – أن مشروع القرش مشروع قومي يستحق ان يستنفد جهود اعضائه بضعة أعوام .. وأنه ليس مشروعا اقتصاديا بحتا .. انما كان ذا أسس أدبية وروحية يتيح للقائمين عليه تنظيم الشباب والخطابة فيهم وتوجيههم .. وبمعنى أصح كان مشروعا بنائيا من الناحية السياسية.وانه يكفي تقديم مشروعين قوميين ناجحين للرأي العام كمشروع القرش ومؤتمر الشباب العربي ليكونا دعاية حسنة للشباب الواعي الجديد .. وذلك بدلا من صبغ مثل هذه المشروعات بالصبغة الحزبية.

وقد حدث ما توقعه فتحي رضوان .. اذ قام ألوف بحملة شعواء ضد مضروع القرش بدعوى أن القائمين به ذوي اللون الحزبي .. فاستقال احمد حسين ثم استقال من بعده فتحي رضوان.

نشاط جديد

وكان أحمد حسين وفتحي رضوان قد فكرا من قبل في اخراج جريدة .. وكان من رأي فتحي رضوان ان تكون هذه الجريدة أدبية .. أما أحمد حسين فقد رأى أن تكون هذه الجريدة سياسية .. وأخيرا رأى الاثنان ان يوحدا جهودهما في جريدة واحدة وهي "الصرخة" اقرارا لمبدأ التعاون.

ثم ظهر بعد ذلك خلاف جديد في الرأي .. كان أحمد حسين يرى أن سياسة الجريدة يجب أن تتجه نحو مهاجمة الامتيازات الاجنبية التي كانت السبب الاول في بالء الاستعمار .. وكان فتحي رضوان يرى أن الاحتلال هو أصل البلاء .. وأخيرا اتفقا على أن يكتب كل منهما عن وجهة نظره.

وصدرت الجريدة الجديدة وكان اسمها الصرخة .. وفي 13 نوفمبر 1933 وبعد صدور ثلاثة أعداد .. صدرت الصرخة في عدد خاص كان يتضمن حملة شعواء على الاحتلال وعلى الانجليز وأعوان الانجليز وكان أكثر هذه المقالات بقلم أحمد حسين نفسه. ولم ترق هذه الحملات لرجال الحكومة في ذلك الحين .. فأصدر النائب العام أمرا بالقبض على أحمد حسين وحافظ محمود رئيس التحرير المسئول وفتحي رضوان وأودعوا في قسم الموسكي.ومن الطريف أن فتحي رضوان عندما سئل عن كاتب هذه المقالات أصر على أنه هو كاتبها .. و عندما سئل أحمد حسين أصر على أنه هم نفسه كاتبها.. فاضطرت النيابة أمام اصرار الاثنين إلى القبض على ثلاثتهم مدة 18 يوما .. وبعد معارضتين افرج عنهم.

عواصف

ومنذ عام 1937 وحياة فتحي رضوان سلسلة من العواصف.وكان أول عهده بالاعتقال في جريمة اغتيال .. في نوفمبر 1937 .. عندما قبض على أحد أعضاء مصر الفتاة في شارع عباس بمصر الجديدة بتعمة الشروع في اغتيال النحاس .. فقبضت الحكومة على جميع المنتمين إلى حزب مصر الفتاة.وأمضى فتحي رضوان في سجن الاستئناف شهرين ثم ما لبث أن افرج عنه.

ومما يذكر أن رئيس المحكمة وقتئذ فكر في أن يجدد في الاساليب القضائية ، فكان يرى أن ملف القضية ليس سرا على المحامين والمتهم وحدهم كما جرى التقليد فيما بعد ، بل كان يراه ايضا سرا على قضاة المعارضة .. فكان القضاة يجتمعون في حجرة رئيس المحكمة ويسمعون مرافعات جماعية عن جميع المتهمين ثم يصدر الرئيس بعد ذلك قرارا برفض المعارضة أو بالحبس بالنسبة لجميع المتهمين دفعة واحدة.

الحزب الوطني

وكان عام 1939 هو مفترق الطرق في حياة فتحي رضوان السياسية .. فقد انفصل عن حزب مصر الفتاة انفصالا فعليا .. و أن اتخذ هذا الانفصال شكله الرسمي في عام 1942 .. وكان سبب الاستقالة هو احتجاج فتحي رضوان على أحد تصرفات أحمد حسين.

وتفصيل القصة هو أنه حدث أثناء اعتقال أحمد حسين في عام 1942 ان سمع جزءا من قصة 4 فبراير فهم منها أن النحاس انقذ البلاد من كارثة محققة وانقذ العرش من الاعتداء عليه .. فأرسل خطابين سريين احدهما إلى مصطفى النحاس والآخر إلى مكرم عبيد سكرتير الوفد يثني فيهما على النحاس ويؤيده في موقفه.

وعلى الرغم من سرية الخطابين فقد نشرهما الوفد في جريدة المصري .. ولذلك رأى فتحي رضوان أن يقدم استقالته لأن تصرف أحمد حسين لم يكن يتفق مع حقيقة الموقف في 4 فبراير .. كما انه كان يتنافى مع التقليد الصحيح للأحزاب.

وانحصر بعد ذلك نشاط فتحي رضوان في المحاماة والقضايا السياسية فترافع في قضية المنشورات لمحمود العيسوي وفي قضية مدحت عاصم وهي قضية منشورات ايضا وقضية الشيخ توفيق الملط وهي قضية احراز مواد مدمرة.

وفي عام 1944 انضم إلى الحزب الوطني .. فقد كان من رأي سليمان حافظ ومصطفى مرعي أن يدعما الحزب بعناصر جديدة .. وقد مهدا لهذه الفكرة عند حافظ رمضان الذي ما لبث ان قبل الفكرة وانضم إلى الحزب : فتحي رضوان ونور الدين طراف وحسين ابو زيد وزهير جرانه ومصطفى المنزلاوي وغيرهم ممن كونوا فيما بعد اللجنة العليا للحزب الوطني عندما وجدوا ان مجال التعاون بينهم وبين الجيل القديم ضيق عسير.

فكرة اعلان الحرب

ومما يذكر ان هؤلاء السبان لعبوا دورا خطيرا في حياة الحزب الوطني .. فلقد بدأوا بمجرد انضمامهم يغذون فكرة استقالة حافظ رمضان من وزارة أحمد ماهر حتى نجحوا في ذلك بسبب تضارب سياسة هذه الوزارة مع سياسة الحزب الوطني.فقد حدث عندما عرضت فكرة إعلان الحرب على المحور .. ان اجتمع الحزب وقرر معارضة هذه الفكرة .. وكتب حافظ رمضان استقالته احتجاجا على دخول مصر الحرب .. وسلمها إلى فتحي رضوان .. فقدمها بدوره إلى أحمد ماهر ثم ما لبث ان طبعها في منشورات سرية ووزعها على لجان الحزب الوطني في جميع انحاء مصر!!

الأقدار

وقد لعبت الاقدار دورا عجيبا في حياة فتحي رضوان .. وفي اعتقاله كان كل ما حدث يقع في مصر يعتبر فتحي رضوان مسئولا عنه .. عزيز المصري يهرب بطائرة مع اثنين من الطيارين هما : حسين ذو الفقار وعبدالمنعم عبدالرؤوف فيقبض عليه .. وما كاد يفرج عنه بعد يوم واحد حتى يقبض على عزيز المصري في منزل المثال المعروف عبدالقادر رزق .. وتشاء المصادفات ان يجد البوليس في جيب عبدالقادر خطابا من عزيز المصري باسم فتحي رضوان فيعتقل مرة اخرى .. وما كاد يفرج عنه بعد يومين حتى يأمر الحاكم العسكري باعتقاله للمرة الثالثة ستة أشهر أمضى بعضها في سجن الاجانب والبعض الآخر في معتقل الزيتون.

ويغتال أحمد ماهر في البرلمان .. وتشاء المصادفات أن يكون فتحي رضوان داخل البرلمان .. وتشاء المصادفات ايضا أن يدعوه اسماعيل صدقي مع النائب السعدي عبدالمنعم ابو زيد للانصراف معا والركوب في سيارته فيخرج .. وذلك قبل صدور الاوامر بإغلاق الابواب ومنع جميع الموجودين من مغادرة دار البرلمان بما فيهم كبار الموظفين ورجال البوليس سواء منهم من كان بثيابه العسكرية أو المدنية.ويعلم وزير الداخلية أن فتحي رضوان في داخل البرلمان .. فيأمر بالقبض عليه وعندما يبحثون عنه داخل البرلمان لا يجدونه فيثبت في يقينهم انه اشترك في الاغتيال وأن اعوانه في الجريمة قد استطاعوا ان يهربوه من البرلمان.

ويقبض على فتحي رضوان في منزله ويستدعيه النائب العام .. وفي داخل الغرفة يجد فتحي رضوان رئيس الوزراء وكبار رجال الأمن وبعض الوزراء .. و يوجه إليه النائب العام السؤال التالي: أين كنت في ذلك اليوم؟

ويقول فتحي رضوان في بساطة : كنت في البرلمان

وتعلوا الدهشة جميع الوجوه .. فقد كانوا يعتقدون أنه سينكر لأنه لا يمكن ان يقامر برأسه إلى هذا الحد ويعتقل فتحي رضوان ثلاثة أشهر.

وتشاء المصادفات مرة أخرى ان يكون وزير العدل حافظ رمضان .

ومرة ثالثة تلعب المصادفات دورا جديدا .. فقد حلت جمعية الاخوان المسلمين في ديسمبر 1948 ووقف الحزب الوطني يعارض في اجراء الحل ويعتبره اجراء غير دستوري .. ويحاول طبع هذا البيان فتصادره الرقابة .. وتشاء المصادفات ان يتخذ حسن البنا من مكتب فتحي رضوان مكانا مختارا يأتي إليه كل ليلية و ان يكون للاخوان المسلمين يد في اغتيال النقراشي .

الشربيني .. الشربيني

وتقبض الحكومة على الاخوان المسلمين وتضعهم في المعتقالت .. وتشاء المصادفات ان يهرب بعضهم عبر حدود مصر إلى ليبيا .. ويكون بينهم أحد الاخوان واسمه محمد الشربيني.

و يلتقي رئيس الوزراء بمصطفى مرعي فيقول له : اننا مضطرون للقبض على فتحي رضوان .. فقد ضبطنا مكالمة تليفونية بينه وبين ذلك الهارب الذي يدعي الشربيني.

ومرة أخرى تشاء المصادفات ان يكون لفتحي رضوان في مكتبه وكيل اسمه الشربيني.

وبعد



و بعد .. ان الشاب الثائر الذي كانوا في الماضي القريب يدفعون به إلى أعماق المعتقل ليبعدوا نار ثورته عن هشيم الرأي العام يتربع اليوم على مقعد وزارة الدعاية في وزارة الثورة .

Monday, September 21, 2009

Customer satisfaction through requirements sign-off

In my previous post “Customer satisfaction VS Project sign-off” I focused on the customer satisfaction, but I’m not neglecting here the project sign-off, as signing-off a project on time with all the features that were in the RSD and with the required quality means customer satisfaction. But when the way became the target and all our effort is to achieve the points on the way without understanding what is the target of the project, for sure we will get the wrong results.

Customer satisfaction is the responsibility of everyone involved in a project since its early days when it was just a lead, some projects failed or faced a lot of problems just because the sales person told the customer something that can’t be done, or told him something and write something else in the proposal, but it is there in the customer’s imagination and he is waiting for it at the end.

Projects like this may be canceled just after this point while collecting the detailed requirements, the customer may hear too many times “out of scope and you have to pay for this and we will change the delivery date” that lets him think that he was talking to someone from another company and this is not a good company, and in this case it will be so difficult to achieve this customer satisfaction.

Please, if you are a sales person or helping the sales team, make sure that everything is clear to the customer and is written in your proposal, otherwise don’t blame the delivery team that they didn’t satisfy the customer because it was just you who lost him.

As a project manager this conflict must be solved immediately through good communication not just sending emails and receiving emails between you and the customer and the sales team, and don’t start this project before solving this problem, as you can’t start project and you can’t write the requirements, and for sure you can’t manage a project without knowing that is the requirements of this project.




As a conclusion, the first step to satisfy the customer and to sign-off the project is to have clear written requirements, and to sign it off after reviewing it perfectly by your team and make sure that the customer understands what is written and has reviewed it and say it to him face to face: "You must read the document!!!" in our region you will hear it many times from customers: "I didn’t read it before, it is too much and it is in English" No problem if he said it in the beginning, but it is a disaster if he said it after a while.

Monday, September 14, 2009

Customer satisfaction VS Project sign-off

“Satisfaction”, is a very big word epically when it relate to customers. Satisfying a customer sometimes can’t be achieved, but we have to plan and work on making it.

In many companies, developers and all the related jobs like the graphics designers and even the project managers in some cases are all focusing on the delivery and the sign-off within the time frame in the first place then the budget then the quality. And no one is caring about the sales person and how his task may be impossible when he wants to make another deal with the same customer on another project or add new requirements to the same product.

Making new deals with the same customer mean “customer satisfaction” mainly not the feedback you are receiving from the customer as customers may not say it to you when they are not satisfied, but they will say it everywhere else the way that will affect your future business.

From my experience with customers especially in KSA, they are going with the one who are working on the satisfaction of the product’s end user not just the customer himself. Going to an extra point with most customers in our region is the main key even if he is very professional and understands that delivering the written agreed requirements must be the only thing that governs our tasks.

But also in all cases don’t go too much away from the project plan, and remember that you are hired to deliver the project, and sometimes you may need to say it to your customer that you can’t give him any extra point and you have to balance.

Customer satisfaction is not just a good or neutral feedback with the closure of the project; it is the things that force your customer not to go with your competitors in the next project (hopefully not the same project).

Sunday, September 13, 2009

Supported web browsers

Developing a web page was and still a fun task, but one of the main problems that may face a web developer or as we said these days “Web UI Developer” is the variety of the browsers in the first place, as web developer must learn how to display his page on seven different browsers and each browser has something to force the web developer to work around.

I was reviewing and analyzing the browsers statistics on W3Schools (http://www.w3schools.com/browsers/browsers_stats.asp) where you will find that the main browsers that we MUST support are Internet Explorer (39%) and Firefox (45%) and if you want to support an extra browser so you have to support Chrome (7%)

Microsoft has announced that they will support IE6 until 2014, what that mean to web developers? In my opinion this is not affecting them by any mean, as the main factor that forcing them to make their web pages IE6 friendly is the percentage of visitors (13%) and not anything else! Also IE8 (10%) must be supported beside IE7 (15%). As you can see the differences between each other is very small and you cannot select one over the other.

On the other hand, building a page that is supporting Firefox must include FF 3.0 (24%) and FF 3.5 (21%), and no need to support FF 2.0 (< 2%) any more.

Regarding the screen resolution, the statistics shows that most (93%) of the internet users are using 1024x786 or higher resolution.

But please take care, all the above percentages may be changed dramatically if your page will be a part of an intranet site for example, as the numbers may be changed to 100% for IE6 on 800x600. So it is depending on collecting the right information from the customer before starting on developing your pages, as you will save too much time and serve your customer better.

Finally, it is not a matter of colors and shapes that must be exactly the same on all the browsers, it is all about talking to your visitor the best way you can, as this is your main role as a web developer, and as you started your site by reading numbers representing the percentage of each browser usage, develop your page the way that will make the maximum number of visitors enjoys your site.

Sunday, August 02, 2009

SilverLight Organization Chart


There was an Organization Chart in the scope of one of the projects I’m managing, and it came to me the idea to make it in SilverLight the same way in http://svdemo02.ilog.com/SilverlightOrgChart/OrgChart.html


And here are the main points to make it out:

1. Working with Canvas
2. Drawing Lines and Boxes
3. Using ScrollViewer
4. Using Slider (for the scale)
5. Using SilverLight UserControls (the node element with the person information)
6. Reading data from XML files and web services
7. Some Calculations

And isA I’ll describe these main ideas in details during the coming days.

Update: for the source code go to http://silverorgchart.codeplex.com/

Clip a TextBlock in SilverLight

One of the things that you may need to do in SilverLight is to limit the display area of a TextBlock, and you can do that using the Clip property, there are two ways to do that.

1. From the XAML

<TextBlock x:Name="tbExtension" Width="130" Height="30" Foreground="Black" Canvas.Left="5">
<TextBlock.Clip>
<RectangleGeometry Rect="0, 0, 130, 30"/>
</TextBlock.Clip>
</TextBlock>

2. From the code behind

tbExtension.Clip = new RectangleGeometry() {
Rect = new Rect(0, 0, width, height)
};

Monday, July 20, 2009

SSO and IFrame, more details please

I have faced some projects for example intranet portal for a company or organization, and one of the modules is to make SSO with an existing application and that we will load the application within an IFrame in our page, something seems very simple, but is it that simple in the client imaginations or he will find something else at the end with the delivery, so we must make some point clear to the customer from the beginning like:

A. Points related to the SSO:
1. SSO itself
2. Sign out
3. Session expiration
4. Browse directly to the application URL

B. Point related to the Frame:
1. Frame/Iframe
2. Header
3. Welcome Message
4. Navigation



A.1. SSO itself:
A group of questions we must know here depend on the case , is it a product or the client have the source code, can we add some pages or DLLs to the application, can we use cookies, what will be the authentication type in both applications, can we encrypt/decrypt, can we use ISA to authenticate the users, can we use MOSS SSO, is there a common membership provider, and so on.

A.2. Sign out:
Is it required to sign the user out from the portal if he click on sign out in the other application, or is it required to sign him out from the application if he click on sign out from the portal? Where I’ll redirect the user in the portal if he logged out from the application?

A.3. Session expiration
How we will manage the session expiration in any of the two applications, the user may expend more time on the application and his session on the portal is expired and vies versa. Is it required to keep the session live while the user is browsing the other application?

A.4. Browse directly to the application URL
What if the user type the URL of the application while he is already signed in on the portal, is it required to authenticate him on the application also or not.

B1. Frame/Iframe:
What about the look of the page, is it okay to have many scroll bars in the same page, is the size of the frame is sufficient to display the application screens? What about the color schema of the application, is it okay with the portal colors? So we can ask, what is the problem with a popup/new window?

B2. Header:
If the application has his own header, so you will have two headers in the same page which mean more lost space, and may be two logos.

B.4. Navigation:
The same here for the navigation, if the application has its own navigation, so we will have extra navigation and extra lost space, and for the usability it is not a good practice.

B3. Welcome Message:
In case the two applications have separated membership providers or user profiles, you will see in the same page for example, Welcome omourad and Welcome Osama Mourad, is it okay? And the user may sign in with another user in the application, you will see in the same page for example Welcome omourad and Welcome Ahmed El Said.

Tuesday, July 14, 2009

Paging SPList with ListItemCollectionPosition

Using ListItemCollectionPosition to make paging is somehow tricky, you have to take care if you are using order in your CAML query that you need to make paging on, as the parameters passed to ListItemCollectionPosition like “Paged=TRUE&p_ID=8” is not just to say star from the itemID = 8, when it is used like this, the paging will page based on the default order.

But if you want to order by example the created date in your CAML query, so you have to include that also in your ListItemCollectionPosition parameters, ex:

Paged=TRUE&p_Created=20091208%2006%3a24%3a35&p_ID=8

Where p_Created=20091208%2006%3a24%3a35 is the created date of the itemID = 8

If it is not used like that you will see unrealistic output.
A good idea to make paging is by making an array that its index will be the page index, and its value will be the ListItemCollectionPosition.PagingInfo like this:

void SetupPager(SPList tmpList, string queryString)
{
    myPagingData.Add("Paged=TRUE");
    SPQuery query = new SPQuery();
    query.Query = queryString;
    query.RowLimit = 5;
    do
    {
        SPListItemCollection itemList = tmpList.GetItems(query);
        query.ListItemCollectionPosition = itemList.ListItemCollectionPosition;
        if (query.ListItemCollectionPosition != null)
        {
            myPagingData.Add(query.ListItemCollectionPosition.PagingInfo);
        }

    }
    while (query.ListItemCollectionPosition != null);

}

The above method can be called in the first time the page is opened, and you can add array to the viewstate and reload it with each postback and pass it to the query like this:
SPListItemCollectionPosition objSPListColPos = new SPListItemCollectionPosition(myPagingData [e.CurrentPage]);
query.ListItemCollectionPosition = objSPListColPos;

Wednesday, July 08, 2009

Forms Authentication with LDAP provider in Sharepoint - Part 2

We talked on how to configure a SharePoint site to use Forms Authentication on LDAP provider, but to complete the scenario we have to update the UI of the login page, this will work the same if any other forms authentication providers will be used.

Once the authentication provider is changed from the central administration the web.config file will be also updated as:

<authentication mode="Forms">
<forms loginUrl="~/layouts/ login.aspx" />
</authentication>

Where the login.aspx file is the default login page for SharePoint and you can go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS and update the login.aspx directly in this path, or make a copy from this page to any folder under your application ex. In a folder named login, you may also need to update the master page that this page is using, you can do this, by coping the new master page to the same folder, or copy simple.master from the same path and update it.

To change the master page that the login.aspx page use you can type:

<script runat="server">
void page_PreInit(object sender, EventArgs e)
{
this.Page.MasterPageFile = "~/login/mymasterpage.master";
}
</script>

This will update the master page on the fly as you can't just update the masterpage path from the aspx page.

Also, you may need to add StyleSheet file and some images to be displayed in this login page, and you can’t reference any file stored in the SharePoint libraries and you have to be authenticated first, so you can add a web.config file in the same folder that just have:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>

This will allow the anonymous user (till now) to be able to request the css, js and images.

Tuesday, July 07, 2009

Forms Authentication with LDAP provider in Sharepoint - Part 1

I was working on an extranet SharePoint project, on the requirement gathering it was agreed to have windows authentication, but after the deployment and during the UAT, the customer reported to us that he didn’t like the popup login window, and he want it to be forms authentication to have a better look, one solution is to publish the site using the ISA server that will request the username and password from the user via a form and path it to the SharePoint. Here is a good article on how to be done.

Another solution is to use forms authentication with LDAP provider, and here are the steps to do it:

Configure the Central Administration and the application:
1. Extend the application
2. Update the authentication type of the extended application to forms authentication, add the membership provider name, ex: LdapMembership
3. In the extended site folder update the web.config file, add:

<membership defaultProvider="LdapMembership">
<providers>
<add name="LdapMembership"
server="devtfs08-ksa"
port="389"
useSSL="false"
userDNAttribute="distinguishedName"
userNameAttribute="sAMAccountName"
userContainer="CN=Users,DC=Devksa,DC=com"
userObjectClass="person"
userFilter="(ObjectClass=*)"
scope="Subtree"
otherRequiredUserAttributes="sn,givenname,cn" type="Microsoft.Office.Server.Security.LDAPMembershipProvider, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C" />
</providers>
</membership>

4. In the above code, “devtfs08-ksa” is my server name, my domain name is “devksa.com” The port number 389 is the default number, and userFilter=”(ObjectClass=*)” will get all the users and groups.
5. Update the web.config file of the central administration site to be able to set the site administrator, you can make the first user as the admin on the default zone, and the second user is the admin on the extended zone.
6. Browse to the extended site and test the login.

Configure the User Profiles import:
1. Go to the User Profiles and Properties in the SSP
2. Click on View Import Connections, delete the current Active Directory connection, and create a new one.
3. Select the type “LDAP Directory” and use the same values in the above membership provider as a values to the form.
4. Click on the button “Auto Fill …”
5. In the search base update it to use UserContainer value from the values above.
6. Update the user filters to use the same values as above.
7. Add a username and password to an account that can list the directory.
8. Start full import.

The same can be done for MySite, but the user will be asked for his username and password when he browse from the intranet portal to his Site in case they are both on different application polls which is recommended.

Monday, June 29, 2009

UmAlQura Calendar in SharePoint

I was working on a calendar webpart that is used to display events stored in a MOSS list, each item in the list will have a start date and end date, when this webpart is added in an English site it shows Gregorian calendar and on an Arabic site is shows the Hijri calendar based on the regional settings for each site, but the problem was that the Hijri calendar is not accurate and the admin must go the regional settings page to add or subtract day or two to show the right dates.

On the other side there is the UmAlQura calendar which is based on an array that relate the start of each Hijri month to a Gregorian calendar day, It can be used for dates in range between 1318/01/01 and 1450/12/29 which is good to be used for articles dates and events and birthdates and so on.

So I changed the calendar format for my culture to be UmAlQura and it works perfect, but the problem is that the events are added in the list that is using Hijri calendar as a default for the Arabic site, and there is no UmAlQura calendar option in the regional settings to select, so I searched for how to make and add a custom calendar to SharePoint and found this link but still can’t find the answer

The other thing I found and it was very weird when I write e.Day.Date in the calendar cell (in the Arabic site) it gives me a full Hijri date (27/09/1430) but when adding e.Day.Date.Day it gives me the equivalent day number from the Gregorian calendar

Wednesday, June 17, 2009

Alternate Styling

Want to make alternate styling in a DataViewWebPart or ContentQueryWebPart? Here is the way:

<tr>
    <xsl:if test="position() mod 2 = 0">
        <xsl:attribute name="class">AlternatingClass</xsl:attribute>
    </xsl:if>

    <td ...>
    ...
</tr>

Where AlternatingClass: is the alternating class name that will be the value of the class attribute of the TR tag.

Saturday, June 13, 2009

Separate XSL files for Content Query Webpart (CQWP) - Part 2

We have talked before on how to Separate XSL files for Content Query Webpart (CQWP), but we didn’t go in details for how to make your own Main.xsl file that can be used as the ContentQueryMain.xsl, the steps in the previous post will be used, we will create a new XSL file and name it for example “usefulLinksMain.xsl” and add its path to the “MainXslLink” property in the webpart file.

The next step is to have a look on the minimal main xsl file:

<xsl:stylesheet
version="1.0"
exclude-result-prefixes="x xsl cmswrt cbq"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime"
xmlns:cbq="urn:schemas-microsoft-com:ContentByQueryWebPart">


<xsl:include href="/Style Library/XSL Style Sheets/ContentQueryMain.xsl"/>


<xsl:template match="/">
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:variable name="RowCount" select="count($Rows)" />
<xsl:variable name="IsEmpty" select="$RowCount = 0" />
<xsl:choose>
<xsl:when test="$IsEmpty">
<xsl:call-template name="OuterTemplate.Empty" >
<xsl:with-param name="EditMode" select="$cbq_iseditmode" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>

<xsl:when test="dsQueryResponse/Rows/Row/@Style='UsefulLinks'">

<xsl:for-each select="$Rows">
<xsl:variable name="CurPosition" select="position()" />
<xsl:call-template name="MyMain.CallItemTemplate">
<xsl:with-param name="CurPosition" select="$CurPosition" />
</xsl:call-template>
</xsl:for-each>

</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="MyMain.CallItemTemplate">
<xsl:param name="CurPosition" />
<xsl:apply-templates select="." mode="itemstyle">
<xsl:with-param name="CurPos" select="$CurPosition" />
</xsl:apply-templates>
</xsl:template>

</xsl:stylesheet>



You can also update the three values to point to the same xsl file like that:

<xsl:stylesheet version="1.0"
exclude-result-prefixes="x d xsl msxsl cmswrt"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:template match="/">
<xsl:call-template name="MyTemplateName" />
</xsl:template>

<xsl:template name="MyTemplateName">
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<xsl:for-each select="dsQueryResponse/Rows/Row">
<tr>
<td><a href="{@LinkUrl}" ><xsl:value-of select="@Title"/></a></td>
</tr>
</xsl:for-each>


</table>

</xsl:template>
</xsl:stylesheet>

The two solutions are the same idea, but in the first one you can select the ItemStyle you want from the content query web part tool part.

Sunday, June 07, 2009

MCTS: Microsoft Office SharePoint Server 2007 – Configuration

I have attended a five days course “50047A: Advanced IT Pro Course for Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0” at Microsoft Innovation Center – Al-Yamama University , The instructor was Muhannad Omar. At the end of the course Muhannad gave me a book “Microsoft Office 2007 – Best practice” and it was very nice from him.

And today, Al-Hamd Lellah, I passed the exam “70:630 - Configuring Microsoft Office SharePoint Server 2007” and now I’m Microsoft Certified Technology Specialist: Microsoft Office SharePoint Server 2007 – Configuration.

أمي ... أبي

كتبت هذه الاسطر في الصف الأول الثانوي لأهديها لأمي وأبي:

أمــــي أبــــي ، قــط وليــث عــنـدنـا و حـبـذا الأبـويـن في الحيـوان
فـالـقـط معـروف بتربية الصغار والـلـه قـد خلقه لكون حـــــــــــنان

الناسُ قـد شهدوا النظافة للقطط، أحـرص عليها فإنها لإيــــــــــمـان
والأًســدُ تـرعى م الـمـخـاوف شبلهـا والـلـه قـد خلقه لكون أمــــان
إن كنت تعرف في الأسود شجاعة، فالشبل يعرف في الأسود حنان

Tuesday, May 26, 2009

From My Site to the Portal

Many people are asking “Why there is no link to go back from My Site to the portal?” and the answer is very simple, My Site may be shared between more than a portal, in this case which link you will display?

But still you can make a link to a preferred portal, go to Site Actions > Site Settings > Site Collection Administration > Portal Site Connection > then type the URL and the title for the portal you want the users go back to from My Site.

Monday, May 25, 2009

Absolute Paths in SharePoint

What if you want to add an image to your MasterPage that will be changed in each sub site, a logo for example, you can add an image tag like this:

<img src="../SiteImages/MyLogo.gif" alt="SubSiteLogo " />

This is fine when you are browsing a page in the Pages list (http://www.mysite.com/subsite/pages/mypage.aspx), but what if you are browsing an overview.aspx page for example for a Survey list (http://www.mysite.com/subsite/lists/surveyname/overview.aspx), you will need to change the tag to:

<img src="../../SiteImages/MyLogo.gif" alt="SubSiteLogo " />

So how to add the image tag to make it work for both pages?
The solution is to change your tag to this:

<img src="<% $SPUrl:~Site/SiteImages/MyLogo.gif %>" alt="SubSiteLogo" runat="server"/>

Where ~Site is your absolute current site URL

Okay, now what if this image is not changed per sub site, but it is changed per SiteCollection and the url is something like this: (http://www.mysite.com/anothersitecollection/subsite/pages/mypage.aspx), in my default SiteCollection I can make the tag like this:

<img src="/SiteImages/MyLogo.gif" alt="SubSiteLogo " />

But in another site collection this will not work with me, so I can make it like this:

<img src="<% $SPUrl:~ SiteCollection/SiteImages/MyLogo.gif %>" alt="SubSiteLogo" runat="server"/>

The same thing here with the stylesheet, you can do the same:

<link rel="stylesheet" type="text/css" href="<% $SPUrl:~Site/StyleSheets/MyStyle.css %>" runat="server"/>

Wednesday, May 13, 2009

Things to ask the client about before working on My Site

In a MOSS project the RSD may say: “out of the box My Site”, but you have to make sure that the system analyst has asked the client the below questions:

1. Do you really need My Site, or can the requirements be developed?
Sometimes the user just wants to display the user information, but he heared that there is something called MY SITE and he wants it.

2. What is the expected number of users that will create My Site?
The expected number of MY SITEs is very important, as it is a factor of space and performance, as each My Site is a site collection and the default quota is 100 MB for each site. I was working on a project for a big organization that has 15000 users, but for obviously not all of those users will create My Site.

3. Will all the users be able to create "My Site"?
Some organizations like the 15k users case, for obviously not all of them will be able to create My Site as some of them are contractors that are doing a task and will leave after two or three months and may be more, but they will not be allowed to create My Site.

4. Do we need the 100MB for each site?
100MB is a very large space, and may be very small for others, but the expected or the planed size is very important to make your hardware architecture regarding the performance and the storage space and the storage place (this is another question but you will need to answer it yourself, as you may need to create a group of My Sites that belong to a group of users in a place and another group in another place).

5. Do you have only one AD domain or more?
More domains means that a username may be duplicated, so you must configure the settings to take the domain name in site URL, not just the username.

6. What is the authentication type of the OWA, In Case you will use Outlook webparts?
You will need to know this, as the forms authentication will display the login window inside each webpart iframe with a scroll if the webpart size is smaller, you may decide to pass the credentials using JavaScript and submit the form (you have to configure the trusted sites in the browser and make the OWA and the intranet site on the same domain but using a different sub-domains) , also what is the used version of the Exchange Server

7. Is the email address the same as the username?
Some organizations are using username like domain\usr24hr and the email for this user is ramy.fawzy@domain.com for security reasons. In this case take care while working on customizing Outlook webparts automatically to set the exchange server address and the email inbox name.

8. Will you allow the user to select his "My Site" language or not?
In multiple language websites it may be a needed to allow the user to select his My Site interface language. The client may imagine that it can be English/Arabic the same as his portal for example.

9. Do you need to customize in the layout or not?
Some customers ask for My Site, but they don ‘t know that it will not inherit the portal MasterPage, and they will be shocked after the site deployment, so make it clear from the beginning for him and for yourself.

Wednesday, May 06, 2009

Listing Folders, SubFolders and Items in one page

It was requested from me to make a page in MOSS that will display Departments in an organization, and there is a set of sub departments and in each sub department there may be another group of sub departments and then a list of file library that may also be divided into groups.

I want to save all these files in only one document library but divide them into folders and subfolders as required, and make the minimum number of pages and code to display these folders and items and without any .net coding.So my solution is to make a page in SharePoint designer and add a DataSource and a DataView then make the following steps:

1. In the SPDataSource add Scope="RecursiveAll" this will make the datasource get all the items (folders and documents) not just the folders in the first level.

2. Add parameter to the DataView, ex. Name: FolderPath, Source: QueryString, QueryStringVariable: FolderPath, DefaultValue: En/DownloadCenter/Documents (which is the path to your document library)

3. Make a filter in the DataView to have Path, Equals, [FolderPath]

4. Make a variable to be used as the page link or the document link as:

<xsl:variable name="url">
<xsl:choose>
<xsl:when test="@ContentType = 'Folder'">documents.aspx?FolderPath=<xsl:value-of select="substring(@FileRef, 2)">
</xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@FileRef"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

5. The above code will check if the item is a folder so we will need the link to redirect to the same page (documents.aspx in our case), and if the item is a document so we need to redirect to the document URL.

6. substring(@FileRef, 2) is used to remove the first / character in the URL Path (not the Path), to know what is the difference between both, Path: En/DownloadCenter/Documents, URL Path: /En/DownloadCenter/Documents/Subfolder1

Tuesday, April 28, 2009

Separate XSL files for Content Query Webpart (CQWP)

Using the same ItemStyle.xsl for all the content query webparts in the site is a very bad thing to do, especially with the big sites.
But you can make an XSL file for each content query webpart and here is how to do:

  1. Edit the page you want to add the webpart in.
  2. Add a content query webpart.
  3. Export the webpart.
  4. Open the exported file.
  5. Search for “ItemXslLink”
  6. Update the line to:

    <property name="ItemXslLink" type="string">/Styles/XSL/MyCQWebpart.xsl</property>

  7. Update the property "ItemStyle" to the templete name ("UsefulLinks" in this example)
  8. Upload the XSL file (remember to update "CommonViewFields" as needed)
  9. The XSL file can be something like this to display a useful links (Title, Link):

    <xsl:stylesheet version="1.0" exclude-result-prefixes="x d xsl msxsl cmswrt" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:template name="UsefulLinks" match="Row[@Style='UsefulLinks']" mode="itemstyle">
    <xsl:param name="CurPos" />
    <xsl:variable name="TitleLenght" select="string-length(@Title)" />
    <xsl:variable name="RowLimit" select="40" />
    <xsl:variable name="LinkURL" select="substring-before(@Link,',')" />
    <xsl:variable name="LinkText" select="substring-after(@Link,',')" />
    <li>
    <a href="{$LinkURL}" target="_blank" title="{$LinkText}" class="newsTitle">
    <xsl:value-of select="$CurPos" /> - <xsl:value-of select="@Title" />
    </a>
    </li>
    </xsl:template>
    </xsl:stylesheet>

  10. Import the webpart and configure it to read from the right place, filtration and sorting order and so on.
  11. Go to the “ContentQueryMain.xsl” file and search for “OuterTemplate.CallItemTemplate”
  12. In <xsl:apply-templates select="." mode="itemstyle"> add <xsl:with-param name="CurPos" select="$CurPosition" /> and any other parameters you want to send to the itemstyle.
  13. You can also make your own ContentQueryMain XSL by updating the “MainXslLink” property in the webpart file, and the same for the header by updating the “HeaderXslLink” property.

Monday, April 27, 2009

Delete WorkItem from TFS database

To delete workitem added by mistake, you have to delete every thing related to it, so you can go to the TFS database and run the following

Declare @DeleteThisID int set @DeleteThisID = 10000

DELETE FROM [WorkItemLongTexts] WHERE ID = @DeleteThisID
DELETE FROM [WorkItemsAre] WHERE ID = @DeleteThisID
DELETE FROM [WorkItemsWere] WHERE ID = @DeleteThisID
DELETE FROM [WorkItemsLatest] WHERE ID = @DeleteThisID

Monday, April 20, 2009

Error 'Code-blocks are not allowed in this file'

http://www.hammendorp.net/post/Error-Code-blocks-are-not-allowed-in-this-file.aspx

Features included in Office SharePoint Server 2007

"Features are modular groups that provide a collection of functionality. Features are available depending on the license type of the Office SharePoint Server 2007 installation, and are activated at various levels of the logical structure of Office SharePoint Server 2007: farm level, Web application, site collection, and site level."

http://technet.microsoft.com/en-us/library/cc678862.aspx

This article contains information about Microsoft Office SharePoint Server 2007 features and the level at which you can activate them.

Sunday, April 12, 2009

SPListItem: Update(), SystemUpdate() and UpdateOverwriteVersion()

If you are working with MOSS APIs to create list items and updating them, you have the option to update the item by using Update(), SystemUpdate(), SystemUpdate(false) or UpdateOverwriteVersion() methods, but what is the difference between them?

Update()

  • will make a new version of the item
  • Update the modified time and modified by fields
  • If the item is published it will be pending again
UpdateOverwriteVersion()
  • No new version.
  • Updates the item without creating a new version of the item
  • Update the modified time and modified by fields
SystemUpdate()
  • Nothing will be changed in the item except the fields you want to change
  • No new version (You can pass false to the method just to enable generating a new version)
  • The events will be fired and the modifications will be logged, but no alerts will be sent, and you can disble the event firing before using the SystemUpdate then enable it again

SystemUpdate() is very useful if you want to modify something like the rating value after the item is published without reapproving it every time.


Saturday, April 11, 2009

كان يا ما كان

رسالة كتبتها لأودع فريق العمل اللذي عملت معه بشركة لينك ديف بمصر للعمل بفرع الشركة بالسعودية


كان يا ما كان


هل سمعتم عن إمارات الأبدان؟ ليست ببغداد ولا إيران! في كل حين وآن وأوان يُحكى عن إمارة في كان يا ما كان.. العقل لها حاكما ومُستشاره القلبُ بالانسان، الشعبُ عاش خلالها لبرهة من الزمان فترة رخاءٍ وامانٍ. وفي يوم من الأيام أصدر العقل حكماً قاسياً ليس فيه رأفة ولا إحسان، لم يُستشار المُستشار في الحكم حيث أنه أول من يدان، لم يرتكب القلب جُرما بل يُخشى منه على باقي الجسمان، العقل يخشى ان تثور عليه يدٌ او اذنٌ من الاذنان، أو قد تنقلب عليه قدميه أو يعارضه اللسان، كل هذا لأنه أخذ القرار وعلى البقية السمع والطاعة للسلطان. وفي ساعة المحاكمه (الآن) وقف العقلُ مُحاكماً لكنه يعلم ان مكانه مع البقية خلف القضبان، وبعد مرافعة القلب المُستشار والبلاغة في البيان، والتي ادت لهطول امطار غزيرة بمنطقة العينان وإثارة العواصف بمنطقة الرئتان. في الحال اُصدر الفرمان وقد تناقلته وسائل الاعلام.. بتوقيع اتفاق دبلوماسي مع باقي الامارات من الزملاء والاحباب والخلان، أن يترك بكل امارة ذكرى كسفير خير عبر الايام، و يَحِقُ للمتهمين زيارة السفراء كلما كان ذلك بالإمكان، لتجديد هعد وفاء وإخاء و سلام، وفي النهاية ختم الحكم بقوله: في هذا الزمان هذا ما كان يمكن ان يكون بالإمكان، فسلام.



Tuesday, March 24, 2009

CSS best practice

Inline style is not a good practice if you want to work with styles, as it is difficult to update if you want to make a modification across the site.

So, some WEB-UI developers start making a new framework to use while making their styles without using the inline style, they develop a class for each style, ex: .Width150px { width:150px;} and another one .Red {color:red;} and use it like this class=”Red Width150px”!
For me, using inline style is better as it will be much more faster while developing than using the above way.

The better practice for using CSS is by defining a meaning full name that describes the thing that will take the style, ex: .PageTitle {color:red; width:150px;} and give the DIV class=”PageTitle”, so I can update all the pages titles just by updating the CSS file, not going to each page title and update the class name.

DIVs vs TABLES

Lots of WEB-UI developers are thinking of replacing all the tables with DIVs which in my opinion is not right, they are using DIVs even if they want to render a table saying that it is better in performance.

But the right thing is: use div when you need it and use tables when you need it.
Using DIVs with CSS can make a lot of things that can’t be done by TABLEs, for example it you want to display data in rows and each row or some rows will not be aligned with the others and using TABLEs will make complicated TDs with a lot of COLSPANs, but displaying a form data can be done with TABLEs perfectly.

But it is preferred to use DIVs if you want to work with the page layouts, as you will be able to change the layout just by using the CSS.

Wednesday, March 11, 2009

setAttribute('maxlength', 5);

Setting maxlength with Javascript using the setAttribute() function will not work with IE like this: setAttribute('maxlength', 5);

You have to make it setAttribute('maxLength', 5);

Monday, March 02, 2009

Team Foundation Sidekicks

Team Foundation Sidekicks is a suite of tools for Microsoft Team Foundation Server administrators and advanced users providing Graphic User Interface for administrative and advanced version control tasks in multi-user TFS environments.
Version 2.2 of Team Foundation Sidekicks includes Permission Sidekick, Code Review Sidekick, Shelveset Sidekick, Labels Sidekick, History Sidekick, Workspace Sidekick and Status Sidekick in uniform GUI stand-alone application, and Visual Studio Integraton Package providing VS integration for all sidekicks as well as additional features such as Search Items dialog, dynamic History and Build Type editing support.
Single installation package contains versions of application compatible both with Team Foundation Server 2005 and Team Foundation Server 2008.

Move site collections to a new database (split a content database) (Windows SharePoint Services 3.0)

This is a very usefull article talking about how to move a site collections to a new database

You can also have a look on Microsoft SharePoint Administration Toolkit

Saturday, February 28, 2009

Kid's Corner in Microsoft MSDN

Are you a cool kid who wants to impress your friends and family with your mad skillz? Check out the Kid's Corner for lots of fun, easy to understand lessons on programming!

Wednesday, February 25, 2009

I was asked if I worked before on making a module to allow the users from downloading a document without the direct access to that document, the document (not just images) may be saved in SQL or on MOSS document library with no read access to the user.
Yes I worked before on file types like word files, but general files NO. and I give him the main idea of adding the document stream response and change the response content type.
And after a while I asked him about the output and he sends this code to me:



System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"C:\d\AhmedCV.doc");
System.IO.FileStream fl = fileInfo.OpenRead();
byte[] file = new byte[(int)fl.Length];
fl.Read(file, 0, (int)fl.Length);
fl.Close();
System.IO.MemoryStream mem = new System.IO.MemoryStream(file);
Response.Clear();
Response.ContentType = "application/x-unknown";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
mem.WriteTo(Response.OutputStream);
Response.End();