Thursday, December 29, 2011

SharePoint 2010 Client object Model

Using the SharePoint Foundation 2010 Managed Client Object Model:

http://msdn.microsoft.com/en-us/library/ee857094(office.14).aspx

Reading Data from External List using the SharePoint 2010 Client Object model:

http://blogs.msdn.com/b/steve_fox/archive/2010/01/19/reading-data-from-external-list-using-the-sharepoint-2010-client-object-model.aspx


Using the SharePoint Foundation 2010 Managed Client Object Model with the Open XML SDK 2.0:

http://msdn.microsoft.com/en-us/library/ee956524(office.14).aspx



Working with the ECMAScript Client Object Model (JSOM) in SharePoint 2010–Part 1 (Nikhil Sachdeva):

http://blogs.msdn.com/b/sharepointdev/archive/2011/07/13/working-with-the-ecmascript-client-object-model-jsom-in-sharepoint-2010-part-1-nikhil-sachdeva.aspx

Converting Word Documents to PDF Using SharePoint Server 2010 and Word Automation Services

Introducing Word Automation Services:
http://blogs.office.com/b/microsoft-word/archive/2009/10/26/introducing-word-automation-services.aspx

Over the last couple of months, we've posted about many of the exciting new features of Word 2010 – Co-authoring, the new Find experience, and the Word Web App. This week, at SharePoint Conference 2009, we announced one more (and one that I'm especially excited about): Word Automation Services.




In the post on framing the Word 2010 release, one of the pillars described is "Word Power in New Contexts". Word Automation Services is a big part of that pillar, and represents our desire to ensure that the power and functionality of Word is available beyond the desktop; in this case, by enabling developers to harness the capabilities of Word on the server as part of SharePoint 2010.



Word Automation Services

Have you ever wanted to convert .docx files into PDF? We've heard from many customers trying to perform server side conversions of Open XML files (.docx) into fixed formats (PDF and XPS) using the Word desktop application, and that's what motivated us to create Word Automation Services.



As a component of SharePoint 2010, Word Automation Services allows you to perform file operations on the server that previously required automating desktop Word:



•Converting between document formats (e.g. DOC to DOCX)

•Converting to fixed formats (e.g. PDF or XPS)

•Updating fields

•Importing "alternate format chunks"

•Etc.

If you've done any automation of Word, you're probably familiar with the challenges of doing so – challenges well documented by this Knowledge Base article: http://support.microsoft.com/kb/257757. With Word Automation Services, those challenges are a thing of the past:



•Reliability – The service was built from the ground up to work in a server environment, which means that you no longer have to worry about issues like dialog boxes that bring the process to a halt, expecting a user to provide input; creating interactive user accounts under which to run the application to avoid running into permissions issues, etc.

•Speed – The service is optimized to perform server-side file operations, and in doing so provides performance significantly better than existing solutions.

•Scalability – The service can take advantage of the processing power available on typical server hardware (multiple processors, additional memory). For example, although a single instance of WINWORD.EXE can only utilize a single core of processing power, with Word Automation Services, you can specify the number of simultaneous conversions (and the # of processing cores) to use based on the available hardware.

And you still have a solution that has 100% fidelity with respect to the Word desktop application – documents are paginated the same way on the server as they are on the client, ensuring that what you see on the client is what you get from the server.



In future posts, I'll spend some time digging into exactly how the service works, as well as each of these benefits of the service in further detail.




Summary: Learn to programmatically convert Word documents to PDF format on the server by using Word Automation Services with SharePoint Server 2010.


Sample Code:
using System;


using System.Security.Permissions;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Security;

using Microsoft.SharePoint.Utilities;

using Microsoft.SharePoint.Workflow;



using Microsoft.Office.Word.Server.Conversions;



namespace ConvertWordToPDF.ConvertWordToPDFEventReceiver

{

///

/// List Item Events

///


public class ConvertWordToPDFEventReceiver : SPItemEventReceiver

{

///

/// An item was added.

///


public override void ItemAdded(SPItemEventProperties properties)

{

base.ItemAdded(properties);



// Verify the document added is a Word document

// before starting the conversion.

if (properties.ListItem.Name.Contains(".docx")



properties.ListItem.Name.Contains(".doc"))

{

//Variables used by the sample code.

ConversionJobSettings jobSettings;

ConversionJob pdfConversion;

string wordFile;

string pdfFile;



// Initialize the conversion settings.

jobSettings = new ConversionJobSettings();

jobSettings.OutputFormat = SaveFormat.PDF;



// Create the conversion job using the settings.

pdfConversion =

new ConversionJob("Word Automation Services", jobSettings);



// Set the credentials to use when running the conversion job.

pdfConversion.UserToken = properties.Web.CurrentUser.UserToken;



// Set the file names to use for the source Word document

// and the destination PDF document.

wordFile = properties.WebUrl + "/" + properties.ListItem.Url;

if (properties.ListItem.Name.Contains(".docx"))

{

pdfFile = wordFile.Replace(".docx", ".pdf");

}

else

{

pdfFile = wordFile.Replace(".doc", ".pdf");

}



// Add the file conversion to the conversion job.

pdfConversion.AddFile(wordFile, pdfFile);



// Add the conversion job to the Word Automation Services

// conversion job queue. The conversion does not occur

// immediately but is processed during the next run of

// the document conversion job.

pdfConversion.Start();



}

}

}

}

Important Links:
http://msdn.microsoft.com/en-us/library/ff181518.aspx


http://msdn.microsoft.com/en-us/library/ff742315.aspx

Word Automation Services:

http://msdn.microsoft.com/en-us/library/gg703645.aspx

Sample Code download:

http://code.msdn.microsoft.com/SharePoint-2010-Converting-7904ca12

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/661ab377-6f6a-40f0-8c83-8a0300a9a470

http://msdn.microsoft.com/en-us/library/gg703645.aspx

http://blogs.msdn.com/b/ericwhite/archive/2010/03/17/word-automation-services-determining-which-documents-failed-to-convert-using-c.aspx


Using Word Automation Services in a Workflow custom activity for SP Designer Workflows:

http://blogs.msdn.com/b/chandru/archive/2010/09/04/using-word-automation-services-as-a-workflow-custom-activity-in-sp-designer.aspx


What is the Difference between ‘Word Automation’ and ‘Word Automation Services’?:

http://blogs.msdn.com/b/ericwhite/archive/2010/12/07/what-is-the-difference-between-word-automation-and-word-automation-services.aspx




Customization of Sharepoint Barcode

1.Go to  Inforamtion Management Policy Settings,Enable Define Policy.
    Enable barcode feature.
2.When Customized for your Requirements throught Coding.


 using (siteCollection)


{

using (site)

{
SPList list = site.Lists["MyList"];

SPListItem item = list.AddItem();

item["Title"] = "test2";

// this file just ensure item.File non-null. You could set it to arbitrary value.

SPFile file = site.GetFile(http://wjc:1130/SiteAssets/CEWP.aspx);

FieldInfo itemFileInfo = item.GetType().GetField("m_file", BindingFlags.NonPublic
BindingFlags.Instance);
itemFileInfo.SetValue(item, file);
FieldInfo itemFileInitInfo = item.GetType().GetField("m_fileInit", BindingFlags.NonPublic
BindingFlags.Instance);
itemFileInitInfo.SetValue(item,true);
//item.Update();

System.Drawing.Image img;

string id = "0123456789";

Barcode.ProvisionBarcodeWithValue(item, true, ref id, out img);

Barcode.SetBarcodePreview(item);
item.Update();
Console.Read();
}

}



Links:
http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010programming/thread/b4fab7a5-d21d-4a40-9cec-e9e145802958

http://www.sharepointsecurity.com/sharepoint/sharepoint-development/programmatically-changing-a-sharepoint-barcode/

http://social.technet.microsoft.com/Forums/is/sharepoint2010setup/thread/f232e9d1-09bb-423a-9780-b69d16d51698

http://blogs.msdn.com/b/recman

SharePoint Server 2007 and Records Management

This blog series will address the role that SharePoint can play in Records Management within an organization and the abilities and functionality that can be leveraged from the platform. The blog consists of four posts:




1. Introduction to Records Management, and Definition of Terms (this post)


2. Records Management using Standard SharePoint Features



3. Using the DOD 5015.2 Records Management Resource Kit



4. Commonly Requested Enhancements and Features

Link:
http://blogs.msdn.com/b/uksharepoint/archive/2009/09/29/sharepoint-and-records-management-part-2-of-4.aspx

AutoRemainder: Using Sharepoint Designer and Information management policy.

Task:
 Remainder Email goes Incase if person  no action is taken in 48 hours.

Solution: Using Sharepoint Designer and Information management policy.

 Check this Link:

 http://www.sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?List=676af157-7d96-4e15-a987-54b8a3e4d948&ID=72

Monday, December 26, 2011

How to Export Data to Excel from an ASP.NET Application + Avoid the File Format Differ Prompt

 ExportToExcel class contains public scoped method Export, which converts data passed in the form of datatable to excel.


public static class ExportToExcel

{

///

/// This Method takes DataTable and Page as input parameter and

/// renders the converted excel data to given page instance.

///


/// DataTable instance

/// The Sytem.Web.UI.Page instance.

public static void Export(string fileName, GridView gv, string title)

{

HttpContext.Current.Response.Clear();

HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));

HttpContext.Current.Response.Charset = "";

//HttpContext.Current.Response.ContentType = "application/ms-excel";

HttpContext.Current.Response.ContentType = "application/vnd.xls";

using (StringWriter sw = new StringWriter())

{

HtmlTextWriter htw = new HtmlTextWriter(sw);

try

{

// render the table into the htmlwriter

RenderGrid(gv).RenderControl(htw);

// render the htmlwriter into the response

HttpContext.Current.Response.Write("" + title + "");

HttpContext.Current.Response.Write(sw.ToString());

HttpContext.Current.Response.End();

}

finally

{

htw.Close();

}

}

}
 
More Coding Mehtods:
 
http://blogs.msdn.com/b/erikaehrli/archive/2009/01/30/how-to-export-data-to-excel-from-an-asp-net-application-avoid-the-file-format-differ-prompt.aspx

Thursday, November 3, 2011

Unable to connect to database


hi friends,


You receive a "Cannot connect to the configuration database" error message when you access your Windows SharePoint Services Web site





You receive an "Unable to connect to database" error message when you install SharePoint Portal Server 2003 or Windows SharePoint Services



Troubleshooting Server and Database Connection Problems




Friday, October 28, 2011

DOTNet Sent Mail Coding

protected void SendMail(string FromUserName, string ToUserName, string strContent, string strSubject)
        {
            try
            {
                string mstrContents;
                //Retrives the contact mail ids
                if (FromUserName != null && FromUserName.Trim() != "" && ToUserName != null && ToUserName.Trim() != "")
                {
                    //Retrives the mailing contents

                    string strSiteName = DefaultSettings.SiteID;//ConfigurationManager.AppSettings["siteId"].ToString().Trim(); ;
                    SPSite site = new SPSite(strSiteName);
                    SPWeb web = site.OpenWeb();
                    string ToEmailid = web.AllUsers[ToUserName].Email;
                    string FromEmailId = ConfigurationManager.AppSettings["FromEmailId"].ToString().Trim(); ;
                    SmtpClient objSmtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString().Trim());


                    if (SPUtility.IsEmailServerSet(web))
                    {

                        MailAddress from = new MailAddress(FromEmailId);
                        MailAddress to = new MailAddress(ToEmailid);
                        MailMessage message = new MailMessage(from, to);
                        message.Subject = strSubject;
                        mstrContents = strContent;
                        message.Body = mstrContents;
                        objSmtp.Send(message);
                    }
                    site.Close();
                    site.Dispose();
                    web.Close();
                    web.Dispose();
                }
            }
            catch (Exception ex)
            {
                string strError = ex.Message.ToString();
                objErrorLog.WriteintoLogFile(ex.Message);
                objErrorLog.WriteintoLogFile(ex.StackTrace);
            }
        }

.Net SmtpClient e-mail send with attachments coding

 public void SendMail(string FromUserName, string ToUserName, string strContent, string strSubject, string strAttachmentPath, bool IsAttachment)
        {
            try
            {
                string mstrContents;
                //Retrives the contact mail ids
                if (FromUserName != null && FromUserName.Trim() != "" && ToUserName != null && ToUserName.Trim() != "")
                {
                    //Retrives the mailing contents

                    string strSiteName = DefaultSettings.SiteID;//ConfigurationManager.AppSettings["siteId"].ToString().Trim(); ;
                    SPSite site = new SPSite(strSiteName);
                    SPWeb web = site.OpenWeb();
                    string ToEmailid = web.AllUsers[ToUserName].Email;
                    string FromEmailId = ConfigurationManager.AppSettings["FromEmailId"].ToString().Trim(); ;
                    SmtpClient objSmtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString().Trim());


                    if (SPUtility.IsEmailServerSet(web))
                    {

                        MailAddress from = new MailAddress(FromEmailId);
                        MailAddress to = new MailAddress(ToEmailid);
                        MailMessage message = new MailMessage(from, to);
                        Attachment data = new Attachment(strAttachmentPath, MediaTypeNames.Application.Octet);
                        // Add time stamp information for the file.
                        ContentDisposition disposition = data.ContentDisposition;
                        if(strSubject.Contains("Workflow Status Report"))
                        {
                        disposition.FileName = "WorkflowStatusReport.xls";
                        }
                        if(strSubject.Contains("Live Agreement Report"))
                        {
                        disposition.FileName = "LiveAgreementReport.xls";
                        }
                        disposition.CreationDate = System.IO.File.GetCreationTime(strAttachmentPath);
                        disposition.ModificationDate = System.IO.File.GetLastWriteTime(strAttachmentPath);
                        disposition.ReadDate = System.IO.File.GetLastAccessTime(strAttachmentPath);
                        // Add the file attachment to this e-mail message.
                        message.Attachments.Add(data);

                        message.Subject = strSubject;
                        mstrContents = strContent;
                        message.Body = mstrContents;
                        objSmtp.Send(message);
                        data.Dispose();
                    }
                    site.Close();
                    site.Dispose();
                    web.Close();
                    web.Dispose();
                }
            }
            catch (Exception ex)
            {
                string strError = ex.Message.ToString();
                objErrorLog.WriteintoLogFile(ex.Message);
                objErrorLog.WriteintoLogFile(ex.StackTrace);
            }
        }

Sharepoint Custom Search Coding


using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Query;


        public DataSet getSearchResults(string strSqlString)
        {
            DataSet dsResults = null;
            string strSiteUrl = ConfigurationManager.AppSettings["siteId"].ToString();
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(strSiteUrl))
                    {
                        FullTextSqlQuery query = new FullTextSqlQuery(site);
                        query.QueryText = strSqlString;
                        query.RowLimit = 30000;
                        query.ResultTypes = ResultType.RelevantResults;
                        ResultTableCollection coll = query.Execute();

                        if ((int)ResultType.RelevantResults != 0)
                        {
                            ResultTable tblResult = coll[ResultType.RelevantResults];
                            if (tblResult.TotalRows > 0)
                            {
                                DataTable dtResults = new DataTable("tblResults");
                                dsResults = new DataSet();
                                dsResults.Tables.Add(dtResults);
                                dsResults.Load(coll[ResultType.RelevantResults], LoadOption.OverwriteChanges, dtResults);
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dsResults;
        }

Sharepoint Server 2007 common Errors


You cannot visit any site collection from an Office SharePoint Server 2007 content database after you attach the content database to a SharePoint Server 2010 environment

You receive a "Cannot connect to the configuration database" error message when you connect to  your Windows SharePoint Services 2.0 Web site

The User Profile Synchronization service does not start on a stand-alone installation of SharePoint Server 2010


SharePoint Draft items not crawled


How to add lots of users to a site, to a list, or to a document library in Windows  SharePoint Services 3.0 and in SharePoint Server 2007


You cannot use the Item Updating event to retrieve an updated value in SharePoint  Server 2007 or in Windows SharePoint Services 3.0


Error message when you try to take an external list offline after you uninstall and then reinstall SharePoint Server 2010: "Failed to obtain signing certificate"


You receive a "Service Unavailable" error message  when you browse a Windows SharePoint Services 2.0 Web site


How to rename a computer that is running  SharePoint Portal Server 2003



How to automate the deletion of backups in SharePoint Server 2007 and in Windows SharePoint Services 3.0 by using a Visual Basic script


How to defragment Windows SharePoint Services 3.0  databases and SharePoint Server 2007 databases

Using Microsoft Windows SharePoint Services with a content database  that is configured as read-only in Microsoft SQL Server



Thursday, October 27, 2011

Microsoft Most important Sharepoint Sites

Microsoft Enterprise Search Blog

(Learn about the Enterprise Content Management features in SharePoint and Office 2010 and engage with the people who build and deliver the products)

Microsoft Records Management Team Blog

A blog about the business challenges we are all facing and the opportunities to address these challenges using technology, as we encounter the problems of records keeping, planning, retention, disposition, litigation response, holds, and so on.

Microsoft Project 2010 The official blog of the Microsoft Office product development group. Learn how to manage your work effectively 

Performance Point Services

Microsoft SharePoint Developer Documentation Team Blog
GetThePoint
Enterprise Project management Content

Microsoft Business Connectivity Services Team Blog

The Microsoft MVP Award Program Blog

SQL Server Mail Configuration


After configuring SQL Server database mail and testing it successfully, you could find maintenance plans unable to send e-mails although you have set the recipients correctly.
This is generally due to the setting for the default profile for database mail.
Generally, you need to do the following to configure database mail:
1.       In SQL Server Management Studio, select Management, Database Mail
2.       Select Configure Database Mail
3.       On the Database Mail Configuration Wizard, select setup Database Mail and configure the SMTP settings
Secondly, you need to configure the default profile as follows:
1.       In SQL Server Management Studio, select Management, Database Mail
2.       Select Configure Database Mail
3.       On the Database Mail Configuration Wizard, select Manage Profile Security
4.       Under Public Profiles,  select Yes in the Default Profile to set the default Profile
 

The Parameter Incorrect

          SharePoint 2007 Search Crawl Error " The Parameter Incorrect"

hi,

U r face any Problems, when u configured SharePoint search 2007  search crawling , u got this Error
"The Parameter Incorrect

I have encountered the above implementation issue where my ACL with SharePoint Users/Groups exceeded the said limitation above and my search/indexer failed on those affected sites. I have found the following explanation from MS TechNet:

Security principal
Approximately 2,000 per ACL (Access Control List) on any securable object (scope)
The total size of the ACL on scopes can be no larger than 64kb. Because each security principal is approximately 32 bytes in size, there can be no more than approximately 2,000 security principals or less for each scope.  If this limit is reached, indexing of items in that scope, and all items below that scope, to fail.
Also, because SharePoint Groups are expanded during the indexing process, having more than 2,000 users or Directory Groups in a SharePoint group and using that group for securing scopes may cause indexing of items secured with these groups, and all items below them, to fail.
This limit only occurs when Windows Integrated Authentication is utilized.

What I want to understand is what is the proven workaround or long term solutions for the above mentioned? And also if this limit only occurs when using Windows Integrated Authentication, what do you mean by this and also what are the alternatives?




More Details Check these Links:
Regards,
Prasad Kasireddy.