Archive

Archive for December, 2007

Microsoft in 2008: ZDNET Predictions

December 31, 2007 Simeon Lobo Leave a comment

I was very excited to read some of the anticipated technology releases from Microsoft.

 From FIJI (the next version of Windows Media Centre) to Office 14 Beta to OOXML getting the ISO nod, it sure sounds like we have a G-R-E-A-T year ahead.

For the full article http://content.zdnet.com/2346-12558_22-180846-1.html

zunephone.jpg

Categories: Theoretical Tags:

SharePoint Solution: Pre-Analysis Considerations

December 27, 2007 Simeon Lobo Leave a comment

The below should typically be covered during costed initial consultations with the client to focus all stakeholders on the difference with Functional and Non-Functional requirements and shape the solution with respect to compliance. 

  1. Investigate the business vision and produce a resulting Vision Document
    1. Investigate ROI to highlight the solution’s value proposition to the client. From experience I have noticed that this gives your consultancy’s sales force the impetus they require to address any uncertainty or doubts client upper-level management at the  may have. 
    2. Create a high-level Vision Document that will set the agenda for discussions that the sales team at your consultancy may have with client stakeholders. This Vision Document should articulate the business problem, proposed solution and expected benefit. This should be carefully documented as this will set expectation through the project.
  2. Investigate the following boundary conditions for the solution,
    1. Policies: Restrictions placed on the organization by its management and articulated as simple statements. A successful SharePoint project must identify all policies that will constrain it.
    2. Practices: Are similar to policies in that they act as boundary conditions on the solution design. However, practices are more closely associated with the tactical processes used by the organization to do business.
    3. Regulations: Local or international regulatory requirements that the system must adhere to to ensure compliance.
  3. Investigate Service Level Agreements (SLA’s): Some SLA’s like expected availability of the system should be addressed in the Non-Functional Design of the solution in close consultation with the client. However, the sooner your consultancy can identify the SLA’s the more mitigated the risk.
  4. Produce a brief Technical Feasibility Study document that outlines technical options available for implementation, if the client’s business operates in silos. From experience, this helps if project stakeholders exist in multiple departments and the client’s I.T. department needs to sign off in the initial stages. 

Visual Studio: Clearing the ‘Recent Project’ List

December 26, 2007 Simeon Lobo Leave a comment

There is no GUI functionality in the Visual Studio Start Page to configure the list of recent projects but you could add/remove project items at the following registry path – HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList.

Quite handy if you want to clean up old projects from the list and only retain client projects that you are currently working on. 

Categories: Technical Tags:

ASP.NET: Disabling ViewState from a DataGrid

December 26, 2007 Simeon Lobo Leave a comment

For performance reasons, I prefer to disable ViewState in all ASP.NET controls unless I explicitly need to. This arises from my desire to keep web page HTML payload to 15KB for sub-second response times (a personal UI design goal).

 

/// <summary>

/// Class member used to disable ViewState at the DataGridItem level. This method must be

/// called after every databinding event

/// </summary>

/// <param name=”dg”></param>

public void DisableViewState(System.Web.UI.WebControls.DataGrid dg)

{

    foreach (System.Web.UI.WebControls.DataGridItem dgi in dg.Items)

    {

        dgi.EnableViewState = false;

    }

}

/// <summary>

/// Sets the selected item for a control. Use this to reset listboxes or dropdown

/// boxes and minimise the use of ViewState between PostBacks

/// </summary>

/// <param name=”lc”>The instance of the Control that we wish to databind</param>

public void SetSelectedItem(System.Web.UI.WebControls.ListControl lc)

{

    String val = Request.Form[lc.ID];

    if (val != null)

        for (int i = 0; i < lc.Items.Count; i++)

            if (lc.Items[i].Value == val)

            {

                lc.Items[i].Selected = true;

                return;

            }

}

 

Categories: Technical Tags: , ,

Improving speed and efficiency using T-SQL to concatenate data

December 26, 2007 Simeon Lobo Leave a comment

I personally prefer to avoid cursor-based looping in T-SQL or PL/SQL because of the obvious performance gains. This blog post is for a friend who needed a quick way of looping through and building a string in T-SQL without using cursors.

– Function to concatenate records in a single variable using set-based processing

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS OFF

GO

CREATE FUNCTION fnGenerateSkillXML (@intSkillGroupID numeric)

RETURNS varchar(8000)

AS BEGIN

DECLARE @strReturn VARCHAR(8000)

SET @strReturn =

SELECT @strReturn = @strReturn + ‘<SKILL><SKILL_ID>’ + convert(varchar, SKILL_ID) + ‘</SKILL_ID><SKILL_NAME>’ + SKILL_NAME + ‘</SKILL_NAME></SKILL>’

FROM VW_DISTINCT_SKILLS_BY_SKILL_GROUP

WHERE SKILL_GROUP_ID = @intSkillGroupID

ORDER BY SKILL_NAME  

return @strReturn

 

END

GO

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS ON

GO

 

 

 

–Application

SELECT  distinct skill_group_id,  dbo.fnGenerateSkillXML(skill_group_id)

FROM VW_DISTINCT_SKILLS_BY_SKILL_GROUP

 

RESULT

101    <SKILL><SKILL_ID>102…..
102    <SKILL><SKILL_ID>103…..
103    <SKILL><SKILL_ID>108…..
104    <SKILL><SKILL_ID>122…..

Categories: Technical Tags: , ,

SharePoint Analysis: Grouping and Segmenting Information Workers

December 26, 2007 Simeon Lobo Leave a comment

This information was summarised based on the Apress Publication, The Expert’s Voice in SharePoint

Segmenting Information Workers Comment w.r.t. SharePoint
Transactors Use LOB systems to enter business data. Eg; CSR’s User interface design for easy data input
Professionals Write emails, merge data from various systems into spreadsheets. Called “Human Middleware” SharePoint integration across LOB systems
Executives Monitor KPI data, use BI tools to make decisions SharePoint BI features and reporting
Segmenting Information Workers Comment w.r.t. SharePoint
Individuals Most important group to consider in design MySite (theoretically), MS Outlook (practically)
Departmental Teams Groups of 10 individuals typically Task management and information sharing are the primary need
Divisional Groups Broader systems, eg; purchasing. More complex management SharePoint solutions at this level often consist of document management, dashboard, and searching capabilities that aggregate information from many sources
Enterprise Personnel are typically dealing with policies, practices and regulations that govern their work. At this level, management communication and guidelines are critical to bind the various groups together SharePoint solutions at this level take the form of intranets
Extended Enterprise Solutions typically involve partners, suppliers and/or customers SharePoint can be used to create a public internet site as well as a secure extranet site for secure partner or customer interaction
Categories: Analytical Tags: ,

SharePoint Technologies: Comparing Features

December 24, 2007 Simeon Lobo Leave a comment

I found that the best place to get a comparison of WSS 3.0 versus MOSS 2007 features is at http://office.microsoft.com/en-us/sharepointtechnology/FX101758691033.aspx

C# Schema Validator

December 24, 2007 Simeon Lobo Leave a comment

Can be wrapped into a reusable function for easy reuse

//The C# validator
//———————                   

System.Xml.XmlDocument objWorkingXML = new XmlDocument();

System.Xml.XmlValidatingReader objValidateXML;

System.Xml.Schema.XmlSchemaCollection objSchemasColl = new XmlSchemaCollection();

System.Xml.XmlTextReader xmlTxtReader = new System.Xml.XmlTextReader(@”..\..\rss.xsd”);

objSchemasColl.Add(“urn:simeon.com/xmlschemas/dosvis/dosvisgrouppayauthority/”, xmlTxtReader);

//This loads XML string in.. but you can also load files similarly

objValidateXML = new System.Xml.XmlValidatingReader(new XmlTextReader(@”..\..\rss.xml”));

//This is how you CATCH the errors (with a handler function)

//AddHandler objValidateXML.ValidationEventHandler, AddressOf ValidationCallBack

objValidateXML.ValidationEventHandler += new ValidationEventHandler(MyValidationEventHandler);

objValidateXML.Schemas.Add(objSchemasColl);

//This is WHERE the validation occurs.. WHEN the XML Document READS throughthe validating reader

objWorkingXML.Load(objValidateXML);

<!– The XML (rss.xml) file –>
<?xml version=1.0 ?>

<parent_node xmlns=urn:simeonlobo/ xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=test.xsd>

</parent_node>

<!– The schema (rss.xsd) file –>
<?xml version=1.0?>

<xs:schema targetNamespace=urn:simeonlobo/ xmlns=urn:simeonlobo/  xmlns:msdata=urn:schemas-microsoft-com:xml-msdata xmlns:xs=http://www.w3.org/2001/XMLSchema elementFormDefault=qualified>

</xs:schema>

 

 

Categories: Technical Tags: , ,

.NET Security: Class for Symmetric Encryption

December 24, 2007 Simeon Lobo Leave a comment

Reusable class that seamlessly abstracts Symmetric Encryption

using System;

using System.IO;

using System.Security.Cryptography;

using System.Text;

namespace Simeon.Lobo.Security

{

    public class SymmetricEncryption

    {

        public SymmetricEncryption()

        {

            this.Algorithm = SymmetricAlgorithm.Create();

            for (int num1 = 0; num1 < this.Algorithm.LegalKeySizes.Length; num1++)

            {

                this.KeySize = this.Algorithm.LegalKeySizes[num1].MinSize;

                if (this.Algorithm.ValidKeySize(this.KeySize))

                {

                    break;

                }

            }

            this.Algorithm.Mode = CipherMode.ECB;

        }

        public SymmetricEncryption(SymmetricAlgorithm Algorithm)

        {

            this.Algorithm = Algorithm;

            for (int num1 = 0; num1 < this.Algorithm.LegalKeySizes.Length; num1++)

            {

                this.KeySize = this.Algorithm.LegalKeySizes[num1].MinSize;

                if (this.Algorithm.ValidKeySize(this.KeySize))

                {

                    return;

                }

            }

        }

        public SymmetricEncryption(SymmetricAlgorithm Algorithm, int KeySize)

        {

            this.Algorithm = Algorithm;

            if (!this.Algorithm.ValidKeySize(KeySize))

            {

                for (int num1 = 0; num1 < this.Algorithm.LegalKeySizes.Length; num1++)

                {

                    this.KeySize = this.Algorithm.LegalKeySizes[num1].MinSize;

                    if (this.Algorithm.ValidKeySize(this.KeySize))

                    {

                        return;

                    }

                }

            }

        }

        private string ByteArrayToString(byte[] source)

        {

            string text1 = string.Empty;

            StringBuilder builder1 = new StringBuilder(source.Length);

            foreach (byte num1 in source)

            {

                builder1.Append((char)num1);

            }

            return builder1.ToString();

        }

        public string Decode(string Input)

        {

            return this.ByteArrayToString(Convert.FromBase64String(Input));

        }

        private string Decrypt(string plaintext, byte[] key, byte[] initializationVector)

        {

            string text1 = string.Empty;

            try

            {

                MemoryStream stream1 = new MemoryStream();

                CryptoStream stream2 = new CryptoStream(stream1, this.Algorithm.CreateDecryptor(key, initializationVector), CryptoStreamMode.Write);

                stream2.Write(this.StringToByteArray(plaintext), 0, plaintext.Length);

                stream2.FlushFinalBlock();

                stream2.Flush();

                stream2.Close();

                text1 = this.MemoryStreamToString(stream1);

                stream1.Close();

                return text1;

            }

            catch (Exception)

            {

                return “”;

            }

        }

        public string DecryptString(string Input, string Key)

        {

            return this.DecryptString(Input, Key, Key);

        }

        public string DecryptString(string Input, string Key, string IV)

        {

            try

            {

                if (Key.Length != 0)

                {

                    goto Label_0019;

                }

                return “”;

            Label_0010:

                Key = Key + Key;

            Label_0019:

                if (Key.Length >= this.KeySize)

                {

                    Key = Key.Substring(0, this.KeySize);

                    if (IV.Length == 0)

                    {

                        IV = Key;

                    }

                    while (IV.Length < 0×10)

                    {

                        IV = IV + IV;

                    }

                    IV = IV.Substring(0, 0×10);

                    byte[] buffer1 = this.StringToByteArray(Key);

                    byte[] buffer2 = this.StringToByteArray(IV);

                    return this.Decrypt(this.Decode(Input), buffer1, buffer2);

                }

                goto Label_0010;

            }

            catch (Exception)

            {

                return “”;

            }

        }

        public string Encode(string Input)

        {

            return Convert.ToBase64String(this.StringToByteArray(Input));

        }

        private string Encrypt(string plaintext, byte[] key, byte[] initializationVector)

        {

            string text1 = string.Empty;

            try

            {

                MemoryStream stream1 = new MemoryStream();

                CryptoStream stream2 = new CryptoStream(stream1, this.Algorithm.CreateEncryptor(key, initializationVector), CryptoStreamMode.Write);

                stream2.Write(this.StringToByteArray(plaintext), 0, plaintext.Length);

                stream2.FlushFinalBlock();

                stream2.Flush();

                stream2.Close();

                text1 = this.MemoryStreamToString(stream1);

                stream1.Close();

                return text1;

            }

            catch (Exception)

            {

                return text1;

            }

        }

        public string EncryptString(string Input, string Key)

        {

            return this.EncryptString(Input, Key, Key);

        }

        public string EncryptString(string Input, string Key, string IV)

        {

            try

            {

                if (Key.Length != 0)

                {

                    goto Label_0019;

                }

                return “”;

            Label_0010:

                Key = Key + Key;

            Label_0019:

                if (Key.Length >= this.KeySize)

                {

                    Key = Key.Substring(0, this.KeySize);

                    if (IV.Length == 0)

                    {

                        IV = Key;

                    }

                    while (IV.Length < 0×10)

                    {

                        IV = IV + IV;

                    }

                    IV = IV.Substring(0, 0×10);

                    byte[] buffer1 = this.StringToByteArray(Key);

                    byte[] buffer2 = this.StringToByteArray(IV);

                    return this.Encode(this.Encrypt(Input, buffer1, buffer2));

                }

                goto Label_0010;

            }

            catch (Exception)

            {

                return “”;

            }

        }

        private string MemoryStreamToString(MemoryStream source)

        {

            string text1 = string.Empty;

            return this.ByteArrayToString(source.ToArray());

        }

        private byte[] StringToByteArray(string s)

        {

            byte[] buffer1 = new byte[s.Length];

            for (int num1 = 0; num1 < s.Length; num1++)

            {

                buffer1[num1] = (byte)s[num1];

            }

            return buffer1;

        }

        public SymmetricAlgorithm Algorithm

        {

            get

            {

                return this.moAlgorithm;

            }

            set

            {

                this.moAlgorithm = value;

            }

        }

        public int KeySize

        {

            get

            {

                return this.mKeySize;

            }

            set

            {

                this.mKeySize = value / 8;

            }

        }

        private int mKeySize;

        private SymmetricAlgorithm moAlgorithm;

    }

}

 

 

Categories: Technical Tags: , ,

C# .NET Optional logging with StackTrace

December 22, 2007 Simeon Lobo 2 comments

In the event that simple application logging is required the below code could be used,

 

<!– application specific settings –>

<appSettings>

  <!– Use a value of either “OVERWRITE” or “APPEND” –>

  <add key=loggingType value=OVERWRITE />

</appSettings>

<!– Implementation –>

using System;

using System.Collections.Generic;

using System.Text;

using System.IO;

using System.Configuration;

using System.Diagnostics;

using System.Reflection;

    public class Log

    {

        private string _loggingType = String.Empty;

        private string _logFilePhyPath = String.Empty;

        public Log()

        {

            _loggingType = ConfigurationSettings.AppSettings["loggingType"];

            _logFilePhyPath = ConfigurationSettings.AppSettings["logFilePhyPath"];

        }

        public void WriteToErrorLog(string errorDesc, string errorStackTrace, string userName)

        {

            StackTrace stackTrace = new StackTrace();

            StackFrame stackFrame = stackTrace.GetFrame(1);

            MethodBase methodBase = stackFrame.GetMethod();

            if (_loggingType == “OVERWRITE”)

            {

                StreamWriter sw = new StreamWriter(_logFilePhyPath);

                sw.WriteLine(“========================\r\n” + “TIMESTAMP: “ + DateTime.Now + “\r\n\r\nUSER: “ + userName + “\r\n\r\nERROR LOCATION: “ + methodBase + “\r\n\r\nERROR DESCRIPTION: “ + errorDesc + “\r\n\r\nSTACKTRACE: “ + errorStackTrace + “\r\n========================”);

                sw.Close();

            }

            else if (_loggingType == “APPEND”)

            {

                StreamWriter sw = new StreamWriter(_logFilePhyPath, true);

                sw.WriteLine(“\r\n========================\r\n” + “TIMESTAMP: “ + DateTime.Now + “\r\n\r\nUSER: “ + userName + “\r\n\r\nERROR LOCATION: “ + methodBase + “\r\n\r\nERROR DESCRIPTION: “ + errorDesc + “\r\n\r\nSTACKTRACE: “ + errorStackTrace + “\r\n========================”);

                sw.Close();

            }

        }

    }

 

Categories: Technical Tags: ,