Thursday, December 29, 2011

To Access SharePoint fields in JQuery

To Access SharePoint fields in JQuery
By default we can access by
$("input[title='title name']") 
or
$("input[VALUE='OK']")    // for OK button

If we modify to  Sharepoint List form field
See the source of the form and find out the ID in SPD.
Example $("#[id*='ff2_1']")     // 2nd  field.

Tuesday, December 27, 2011

SharePoint Infopath Forms Library missing

I have created a new 2010 portal with publishing features template. And tried to create a forms library, ohh gosh!! where is the Form Library under 'Create'. Searched the settings in 'Central Administration', everything seems to be right there.
Got an idea... go to InfoPath Designer and publish a new form template from there to this portal.
Every thing went on smooth except the it has created a simple document library instead forms library.Very Bad.

Ohhh may be i might have missed some thing  let me check the site settings
  • Site Collection Features –> Office SharePoint Server Enterprise Site Collection features
  • Site Features –> Office SharePoint Server Enterprise Site features
No luck dude, still no forms library.

After lot of search & struggling around... found out that
  • Site Features –> Team Collaboration Lists
thats SharePoint!. :)

Friday, December 9, 2011

Dime, cent, Pennie and Nickel

In US coins
a dime  = 10 cents (10 ¢)
a quarter  = 25 cents (25 ¢)
a pennie  = 1 cent  (1¢)
a nickel  = 5 cents (5¢)

Monday, November 21, 2011

SQL Server Transaction Isolation Level - READ UNCOMMITTED

BEGIN TRAN
UPDATE tableA SET
    HourlyRate = 100
WHERE ConsultantName = 'Raj'
Note that the transaction is not committed or rolled back. Since the transaction is open, the lock applied on the row being updated is not released yet. Now, open a second window (Query Window 2) and run the following.
SELECT * FROM tableA

As expected, this will block. The query will try to read a row locked exclusively by another transaction and cannot proceed until the lock is released. Now, let us see what happens under READ UNCOMMITTED isolation level.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT * FROM tableA 
OR
SELECT * FROM table A WITH(READUNCOMMITTED)
 

Wednesday, August 24, 2011

What are the features available in SharePoint 2010 which are not available in MOSS 2007?

1.      New User Interface including Ribbon
2.      Sandboxed Solutions
Also called as User Solutions, is a new concept which allows site collection administrators to deploy solutions at the site collection level which is safe to run and not affect the other site collections and web applications running on the same farm. Farm administrators can monitor sandboxed solutions and place restrictions on the resources, such as memory and CPU cycles, they can use. Sandboxed Solutions does not cover full SharePoint object model but it addresses the key scenarios like custom web parts and event receivers. The solution deployment as in SharePoint 2007 is still exists in SharePoint 2010 but those solutions are called as Farm solutions.
3.      SharePoint Workspace
Microsoft Office Groove has been renamed to SharePoint Workspace in SharePoint 2010. SharePoint Workspace provides local and offline read-write access to SharePoint lists and libraries and also incorporates offline-online synchronizations.
4.      Stsadm command-line tool is superseded by Windows PowerShell 2.0
5.      BCS(Business Connectivity Services) 
Provides Read-Write capable connectivity from Client and Server to Database, WCF/Web Services and .Net Sources.
6.      Client Object Model
The SharePoint 2010 Client Object Model is a very cool feature of SharePoint 2010 Foundation Server that enables developers to write applications that access SharePoint data from a .NET application running on a client computer, from a Silverlight application, and from JavaScript running client-side in a SharePoint web part.  The client object model enables this without requiring the developer to write or install code on the SharePoint server. (Using Microsoft.SharePoint.Client namespace)
7.      Visual Web parts
8.      Redesigned Central Administration web site
9.      Shared Service Provider (SSP) no more exists
SSP's have been replaced by Service Applications in SharePoint 2010. Earlier in SharePoint 2007, all services were combined into a SSP. Now in SharePoint 2010, all services are running as independent Service Application.
10.  Built-in Silverlight Support         
11.  Rich and Improved Theming Support
The new 2010 themes use an entirely different design. SharePoint 2007 themes used CSS and images while the new 2010 themes use the .thmx format. This means themes can be easily created using PowerPoint or any other tools(ex Microsoft Theme Builder)
12.  Multiple Browser Support  - IE, Firefox & Safari
13.  Rich Media support and Digital Asset Management
SharePoint 2010 includes a Media web part built using Silverlight, Video content type, Audio content type, and Image content type. 

Friday, August 5, 2011

SSIS-Script Task - Generics List use

' Microsoft SQL Server Integration Services Script Task
Imports
System
Imports
System.DataImports System.MathImports Microsoft.SqlServer.Dts.RuntimeImports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports
Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports
System.CollectionsImports System.Collections.Generic
Imports
System.TextImports System.Data.SqlClientImports System.NetImports System.Net.MailPublic
Class ScriptMain' The execution engine calls this method when the task executes.' To access the object model, use the Dts object. Connections, variables, events,' and logging features are available as static members of the Dts class.
----------------------------------------------------------------------------------------------------
' Public Sub Main()'' Add your code here


Dim Users As New List(Of User)Dim Managers As New ArrayList()Dim objUser As UserDim objManager As String


Dim smtpConnectionString As String = DirectCast(Dts.Connections("SMTP_CONN_MAIL_SERVER").AcquireConnection(Dts.Transaction), String)Dim smtpServer As String = smtpConnectionString.Split(New Char() {"="c, ";"c})(1)Dim htmlMessageFrom As String = Dts.Variables("emailFrom").Value.ToString()Dim htmlMessageTo As String


Dim htmlMessageSubject As String = Dts.Variables("emailSubject").Value.ToString()Dim htmlMessageBody As New StringBuilder()' get users objectUsers = getUsers()
' create a unique list of manager list contains email address
For Each objUser In UsersIf Not (Managers.Contains(objUser.strManagerEmail.ToString().Trim())) ThenManagers.Add(objUser.strManagerEmail.ToString().Trim())
End IfNext' send Mail
  htmlMessageTo = objManager.ToString()
For Each objManager In Managers'objUser.strManagerEmail.ToString()
  htmlMessageBody.Append(
    For Each objUser In Users      If (objUser.strManagerEmail.ToString() = objManager.ToString()) Then ' get list of users for a manager
          htmlMessageBody.Append(
"text" & objUser.strPSTSize.ToString("###,###,###,##0") & ")      End If  Next
htmlMessageBody.Append(

SendMailMessage(htmlMessageTo, htmlMessageFrom, htmlMessageSubject, htmlMessageBody.ToString(),
"some text")True, smtpServer)' reset the bodyhtmlMessageBody.Remove(0, htmlMessageBody.Length)
htmlMessageTo =
String.EmptyNextDts.TaskResult = Dts.Results.Success
End Sub
----------------------------------------------------------------------------------------------------




Public Function getUsers() As List(Of User)Dim objUsers As List(Of User) = New List(Of User)()Dim newUser As UserDim cm1 As ConnectionManager = Dts.Connections("ISTools_ADO.NET")'Dim cm2 As ConnectionManager = Dts.Connections("ISTOOLS_OLEDB")
Dim oReader As SqlDataReader' For an ADO.Net ConnectionManager using a SqlClient provider

oCmd.CommandType = Data.CommandType.Text
oCmd.CommandText =
Dim sqlConn As System.Data.SqlClient.SqlConnection = DirectCast(cm1.AcquireConnection(Dts.Transaction), SqlConnection)Dim oCmd As SqlCommand = New SqlCommand"select * FROM table"oCmd.Connection = sqlConn
'sqlConn.Open()oReader = oCmd.ExecuteReader()
If oReader.HasRows Then
objUsers.Add(
Convert.ToInt32(oReader(3)), Convert.ToInt32(oReader(4)), Convert.ToString(oReader(6)), Convert.ToString(oReader(7))))
While oReader.ReadNew User(Convert.ToString(oReader(0)), Convert.ToString(oReader(1)), Convert.ToInt32(oReader(2)), _End WhileEnd If'release the object finally
cm1.ReleaseConnection(sqlConn)


----------------------------------------------------------------------------------------------------Private Sub SendMailMessage( _ByVal SendTo As String, ByVal From As String, _ByVal Subject As String, ByVal Body As String, _ByVal IsBodyHtml As Boolean, ByVal Server As String)If (SendTo.Trim() = "") Then SendTo = FromDim htmlMessage As MailMessageDim mySmtpClient As SmtpClientDim maSendTo As New MailAddress(SendTo)Dim maFrom As New MailAddress(From)New MailMessage(maFrom, maSendTo)New SmtpClient(Server)End Sub








htmlMessage =
htmlMessage.Subject = Subject
htmlMessage.Body = Body
htmlMessage.IsBodyHtml = IsBodyHtml
mySmtpClient =
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(htmlMessage)
htmlMessage.Dispose()
----------------------------------------------------------------------------------------------------



Private Function uniqueArray(ByVal str() As String) As ArrayListDim noDups As New ArrayList()For i As Integer = 0 To str.Length - 1If Not noDups.Contains(str(i).Trim()) ThennoDups.Add(str(i).Trim())
End IfNext
---------------------------------------------------------------------------------------------------- Class
End
----------------------------------------------------------------------------------------------------Public
Class User' User Object to hold each user record. Create pr0perties to read/write'Dim strLanid As String'Dim strFullName As String'Dim strHDriveSize As Integer'Dim strPSTSize As Integer'Dim strNonPSTSize As Integer
'Dim strUserEmail As String
----------------------------------------------------------------------------------------------------









----------------------------------------------------------------------------------------------------Private p_strLanid As StringPrivate p_strFullName As StringPrivate p_strHDriveSize As IntegerPrivate p_strPSTSize As IntegerPrivate p_strNonPSTSize As IntegerPrivate p_strUserEmail As String
-properties
Public Property strLanid() As StringGet
Return p_strLanidEnd Get
p_strLanid = value
Set(ByVal value As String)End SetEnd PropertyPublic Property strFullName() As StringGet
Return p_strFullNameEnd Get
p_strFullName = value
Set(ByVal value As String)End SetEnd PropertyPublic Property strHDriveSize() As IntegerGet
Return p_strHDriveSizeEnd Get
p_strHDriveSize = value
Set(ByVal value As Integer)End SetEnd PropertyPublic Property strPSTSize() As IntegerGet
Return p_strPSTSizeEnd Get
p_strPSTSize = value
Set(ByVal value As Integer)End SetEnd PropertyPublic Property strNonPSTSize() As IntegerGet
Return p_strNonPSTSizeEnd Get
p_strNonPSTSize = value
Set(ByVal value As Integer)End SetEnd PropertyPublic Property strUserEmail() As StringGet
Return p_strUserEmailEnd Get
p_strUserEmail = value
Set(ByVal value As String)End SetEnd PropertyPublic Property strManagerEmail() As StringGet
Return p_strManagerEmailEnd Get
p_strManagerEmail = value
Set(ByVal value As String)End Set
----------------------------------------------------------------------------------------------------
Public Overrides Function ToString() As String






----------------------------------------------------------------------------------------------------
End
----------------------------------------------------------------------------------------------------
Class
----------------------------------------------------------------------------------------------------
InnerList.Add(GenericObject)
----------------------------------------------------------------------------------------------------
InnerList.RemoveAt(index)
Public Sub Remove(ByVal index As Integer)End Sub

----------------------------------------------------------------------------------------------------End
Class 'End of GenericCollection class
Public Function Item(ByVal index As Integer) As GenericTypeReturn CType(InnerList.Item(index), GenericType)End Function
Public Sub Add(ByVal GenericObject As GenericType)End Sub
GenericCollection(Of GenericType)Inherits Collections.CollectionBase
Class 'End of Employee Class
Return ("LanId : " + strLanid + vbCrLf + _"FullName : " + strFullName + vbCrLf + _"HDriveSize : " + strHDriveSize.ToString() + vbCrLf + _"PSTSize : " + strPSTSize.ToString() + vbCrLf + _"NonPSTSize : " + strNonPSTSize.ToString() + vbCrLf + _"UserEmail : " + strUserEmail + vbCrLf + _"ManagerEmail : " + strManagerEmail)End Function
End Property
Private p_strManagerEmail As String
Sub New(ByVal Lanid As String, ByVal FullName As String, ByVal HDriveSize As Integer, ByVal PSTSize As Integer, _ByVal NonPSTSize As Integer, ByVal UserEmail As String, ByVal ManagerEmail As String)Me.strLanid = LanidMe.strFullName = FullNameMe.strHDriveSize = HDriveSizeMe.strPSTSize = PSTSizeMe.strNonPSTSize = NonPSTSizeMe.strUserEmail = UserEmailMe.strManagerEmail = ManagerEmailEnd Sub
'Dim strManagerEmail As String
Return noDupsEnd Function
Return objUsersEnd Function
Text")
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
' Developed by Rajesh Subbiah on 5 Aug 2011

Thursday, July 28, 2011

The disk is write protected usb

If you still get the error after the external switch is off, try this registry hack!!!!

1.Run Registry Editor (regedit).
2.Navigate to the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
3.Create a New Key named as StorageDevicePolicies.
4.Highlight StorageDevicePolicies, and then create a New DWORD (32-bit) Value named as WriteProtect.
5.Double click on WriteProtect, and set its value data to 1.
6. If WriteProtect Value is set to 0, it's not writeProtected.
Enjoy!!!!!

Tuesday, July 19, 2011

Basic SSIS Package

 
1.Open 'Business Intelligence Development Studio' comes with SQL 2005 or VS 2008 and create Integration Services project
2.Design .dtsx ( pakage file)
3.Our goal is to import .xlsx file data to SQL DB, log package status and if error occurs log error & send Email.
4.
Create connection managers like ADO.NET connection, OLEDB connection, and SMTP connection etc
OLEDB Connection


    xlsx file-OLEDB connection
  1.  
     

4. Drag & drop control flow items as shown here depends on the design. Create Variables as shown in the figure.
The SSIS package

 5. In the 'Data Flow' connect the source and destination connections through a data convertor.
6. Create an onError Event Handler, and create a 'Script Task'. Set the values like 'System::ErrorDescription' as   read only variable and 'User::errorMessages' as readwrite variable.

7. Click on Design Script & create code to capture the all errors into a Colloection.
8. Create 'Sequence Containers' as shown in the SSIS package and create 'Script Task' to capture all errors into a single string and insert to DB and send Email.

9. Click on Design Script
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
'Developed By : Rajesh Subbiah
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports System.Data.SqlClient
Imports System.Net
Imports System.Net.Mail
Public Class ScriptMain

Public Sub Main()
Dim errorDesc As String
Dim messages As Collections.ArrayList
Try
messages = CType(Dts.Variables("errorMessages").Value, Collections.ArrayList)
Catch ex As Exception
'If there is an exception – the object was never initialized, so there were no errors
Return
End Try
For Each errorDesc In messages
Dts.Variables("emailText").Value = Dts.Variables("emailText").Value.ToString + errorDesc + vbCrLf
Next

Dim smtpConnectionString As String = DirectCast(Dts.Connections("SMTP_CONN_MAIL_SERVER").AcquireConnection(Dts.Transaction), String)
Dim smtpServer As String = smtpConnectionString.Split(New Char() {"="c, ";"c})(1)
Dim htmlMessageFrom As String = Dts.Variables("emailFrom").Value.ToString()
Dim htmlMessageTo As String = Dts.Variables("emailTo").Value.ToString()
Dim msgErrors As String = Dts.Variables("emailText").Value.ToString()
Dim htmlMessageSubject As String = Dts.Variables("emailSubject").Value.ToString()
Dim htmlMessageBody As String = "
Warning ! : The following error occured while running the SSIS package
"
htmlMessageBody = htmlMessageBody + " " + msgErrors + "."
LogError(msgErrors) ' Log the error into DB
SendMailMessage(htmlMessageTo, htmlMessageFrom, htmlMessageSubject, htmlMessageBody, True, smtpServer)
Dts.TaskResult = Dts.Results.Success
End Sub

Private Sub SendMailMessage( _
ByVal SendTo As String, ByVal From As String,ByVal Subject As String, ByVal Body As String, _
ByVal IsBodyHtml As Boolean, ByVal Server As String)
If (SendTo.Trim() = "") Then SendTo = From
Dim htmlMessage As MailMessage
Dim mySmtpClient As SmtpClient
Dim maSendTo As New MailAddress(SendTo)
Dim maFrom As New MailAddress(From)
htmlMessage = New MailMessage(maFrom, maSendTo)
htmlMessage.Subject = Subject
htmlMessage.Body = Body
htmlMessage.IsBodyHtml = IsBodyHtml
mySmtpClient = New SmtpClient(Server)
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(htmlMessage)
htmlMessage.Dispose()
End Sub

Private Sub LogError(ByVal msgErrors As String)
Dim cm1 As ConnectionManager = Dts.Connections("ISTools_ADO.NET")
'Dim cm2 As ConnectionManager = Dts.Connections("ISTOOLS_OLEDB")

' For an ADO.Net ConnectionManager using a SqlClient providerDim sqlConn As System.Data.SqlClient.SqlConnection = DirectCast(cm1.AcquireConnection(Dts.Transaction), SqlConnection)
Dim oCmd As SqlCommand = New SqlCommand
oCmd.CommandType = Data.CommandType.Text
oCmd.CommandText = "INSERT INTO Log_SSIS_Status(PkgName,PkgStatus,IsSuccessful,Notes) VALUES('HScan-ImportFile','SSIS-Failure.Logged,Sent Email',0,'" + msgErrors + "')"
oCmd.Connection = sqlConn
'sqlConn.Open()
oCmd.ExecuteNonQuery()
'release the object finally
cm1.ReleaseConnection(sqlConn)
End Sub
End Class

10. The variables can be configured via a config file.

11. run in development environment.Set Break points to debug.
12.Deploy the package to the Server and view the job through 'Server Agent' in the management studio.