Saturday, June 30, 2012

questions asked  :

we have a doc template in a content type< when we try to create a
new item from the content type then the  fields in the new
document shoudl get filled up auto.
Hows that possible ?No coding .

You have access to Insure site collection.Now you want to
open Sports site collection in the same farm.You get a
page denied error.How to handle the same
and make sure that the user gets to see a  more custom page
that is helpful.

Site admin roles and stuff ; If after 2 years the site that u created
is hanging and is slow to start etc. Then what to do among first things
t check.
What the Microsoft standard for the size  of a site /collection ?

Content query webpart and the xslt part of it .where you save the
queries and write the filters etc.


List form -- where to customize so that u cab create a lits form with the columns
in a different format i.e horizontal etc.

Connect to a Oracle database . How to do the same from a SPD ?is it possible ?

extending a  sharepoint site ?

questions asked  :

we have a doc template in a content type< when we try to create a
new tem from the content type then the  fields in the new
document shoudl get filled up auto.
Hows that possible ?No coding .

You have access to Insure site collection.Now you want to
open Sports site collection in the same farm.You get a
page denied error.How to handle the same
and make sure that the user gets to see a  more custom page
that is helpful.

Site admin roles and stuff ; If after 2 years the site that u created
is hanging and is slow to start etc. Then what to do among first things
t check.
What the Microsoft standard for the size  of a site /collection ?

Content query webpart and the xslt part of it .where you save the
queries and write the filters etc.


List form -- where to customize so that u cab create a lits form with the columns
in a different format i.e horizontal etc.

Connect to a Oracle database . How to do the same from a SPD ?is it possible ?

extending a  sharepoint site


================= admin parts  ==


recover site from database
control over list sizes
better disaster recovery
easier to manage/host
health manamement


scle of governance :
granular recoverya and mirroring service
resilient and



==========
A day in the life of an admin

plan the site - service, hosting,authentication, mirror
operating  -- throttling .reporting , improveed central admin ui
maintenance -- pweershell,import/export/recovery
optimization -- performance ,health,dev dashboard.



Monday, June 25, 2012

Content Type HUB - CTH

when you are developing enterprise application for large organization some fields are common across all brands such as brand name, brand logo, SEO title, SEO description etc..

How will you handle this common fields across farms?

Scenario (P&G only for reference)

Assume that we are designing architecture for P&G products, normally P&G has lot of products (Pantene, Olay, pampers etc...)but, all these products have some common fields such as Product logo, product name, SEO title, SEO description etc... How will you handle this?

SharePoint 2007

In SharePoint 2007 usually what we do? we go and create separate content type for this called brand content type and deploy this into site collection but, here the problem is we need to go to each and every web application and install site content type feature , there is no central location to place common fields, in future if you want to update particular column, you have to go to each and every web application and update

SharePoint 2010

In SharePoint 2010 there is a new concept called Content Type Hubs, through this you can manage all common fields centrally and publish it to the other web applications, so in 2010 the other web applications can subscribe these content types and pull down the published content types from the CTH and also can get updates when ever changes happened in published content types

Here, mainly you need to concentrate on three things

Site collection to host the content types and act as a Content Type Hubs

Managed metadata service application( to expose content type hub to each and every web application)

Web applications ( to subscribe content type hubs)

Advantages

No need of going to each and every web application and installing the content types and if you want to do updates on particular content type you can simply do it on Content Type Hubs and push it down, so managing the content types easy

In reality the content types changes frequently like adding new fields or creating new content type etc... It's easier to coordinate this from a single location and make sure that xml files are correctly set up across all web applications/farms.

Sunday, June 24, 2012

Event Reciver SharePoint 2010


Remember that the suffix "-ing" indicates that the event is being handled before the action occurs, and the suffix "-ed" indicates that the event is being handled after the action occurs.

Cancel deletion of item :

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace MyEventHandlers
{
    public class SimpleEventHandler : SPItemEventReceiver    {
    }
}
public override void ItemDeleting(SPItemEventProperties properties)
{
    properties.Cancel = true;
    properties.ErrorMessage = "Deleting is not supported.";
}

Adding of  item


public override void ItemAdded(SPItemEventProperties properties)
{
    SPListItem oItem = properties.ListItem;
    oItem["Body"] = "Body text maintained by the system.";
    oItem.Update();
}

---------- Complete example  ----


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;
namespace ERDefinition
{
    public class ItemEvents : SPItemEventReceiver
    {
        public override void ItemAdded(SPItemEventProperties properties)
        {
            SPListItem item = properties.ListItem;
            item["Title"] = item["Title"] + " - " + DateTime.Now;
            item.Update();
        }
    }
}

 

    --------------


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;

namespace BindItemEvents
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://localhost/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Shared Documents"];

                    SPEventReceiverDefinition def = list.EventReceivers.Add();

                    def.Assembly = "ERDefinition, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=704f58d28567dc00";
                    def.Class = "ERDefinition.ItemEvents";
                    def.Name = "ItemAdded Event";
                    def.Type = SPEventReceiverType.ItemAdded;
                    def.SequenceNumber = 1000;
                    def.Synchronization = SPEventReceiverSynchronization.Synchronous;
                    def.Update();
                }
            }
        }
    }
}

 

 

Site Events

Web Events

List Events

List Field Events

Item Events

Business Connectivity Services SharePoint 2010

================= 6 Sep 2012 =================

ECT has the
  1. methods -- create/update/delete
  2. schema
  3. data access capability
  4. permissions

Authentic for users

  1. Revert to Self :
  2. using the process a/c . network Service
  3. Pass thorugh : logged on user.

BDC identity : ie. the customer data i.e. first name /last name / password from the db table.


Single Sign ON  :

using an alias/ for a individual/group for theSQL/ credentials .This was discussed here as
i have seen with the other videos

2 methods that are reqd ; Readitem,ReadList.
   
BCS associations :
relation between the tables  in the database  can be replicated
into relations between entities in ECT.

Supported Associations:
1 to many based on FK

many to many assoc between CTs is not supported

Eg .
 the Salesorder CT is related to
 the Customer CT 
 with the feild customerId.

ULS Viewewer -- download from
http ://code.msdn.com/UlsViewer

For eanabling BCS search :

1> Create Search Content Source : Here you can point the content source to the BCS connection that u created in SPD or

VS2010
  1.  Ensure that  permissions are set on the same .
  2.  create profile page site
  3.  Enable profile pages in BCS CA \
  4. Crawl


WorkFlow :
You cant create WF against Ext List . as the data is in the ext system.
However you can create a SIte level WF and there we  can decide and update a field in an ext list using the WF.

and since the wf runs under process user you have to have a  SSS for the WF to run against.


For Viewing BLOB  data on the Ext list we can do the following :as it cant be done from the SPD
Export the BDC model to desktop and then you can open the same.You can open the same from  a DeskTop
and it will be an xml.It has method / instance/params etc.
you can add some customization to the same  XML for streaming of data
goto CA of the site and then Import the same BDC model in the SP site .

SP server enterprise edition has the Web Parts for BCS.



===================  ===================
Was really confused regarding the .Net Assembly connector from BCS .
aper from .Net there is the WCF  and SQL connectors for connecting to external systesm :

http://msdn.microsoft.com/en-us/library/hh144965.aspx
is real usefull

In scenarios where you need more flexibility than is provided by the SQL and WCF connectors, you will likely build a .NET Assembly Connector instead. A .NET Assembly Connector is a project that you create in Visual Studio 2010 that contains the ECT definition and associated business logic for accessing a specific external system. The .NET Assembly Connector differs from the custom connector because it targets a specific instance of a system, as opposed to all instances of a specific system type. In other words, you can use a .NET Assembly Connector to access a specific folder in Exchange, while a custom connector could be used to access any folder in Exchange.

The .NET Assembly Connector is also useful for aggregating data from multiple sources into a single ECT, which cannot be accomplished using a custom connector. While accessing an external system, the .NET Assembly Connector can also apply business rules to data before it is made available in SharePoint, and facilitate search indexing of a specific external system. The .NET Assembly Connector is covered in detail later in the chapter.

The key thing to note about the .NET Assembly Connector is that it gives complete control over the method implementations. This means you can easily implement additional business rules or security functions when retrieving data from external systems.

Example is that the .net  connector is used to fetch data from  an XML file/storage of data.

Hence after you have coded the same using VS2010 where you can connect to any source like XML/Oracle/SQL etc.  you can deploy the same . Now in the SPD  you select .Net Type and then the deployed  BDC connections/assemblies show up in a list and you can select them .



-------------------------------------------

Was trying to create a connection to a  SQL database and the show that as an ext list in my Sharepoint site . the best is thanks to Fabian Williams for his blog :
http://www.sharepointfabian.com/blog/Lists/Posts/Post.aspx?ID=122

 Now what i did was that i missed the ReadList()  Method and  did everything else .
 . So after the publish and deploy etc   was getting the below error when looking for ECT from Site :



No ECT available .Contact Siyte admion .
 I went to the CA and there i could see the  ECT and gave it the perms required for the user concerned.

So i went ahead and created the ReadList() method and bingo  the ECT shows up.



EXTERNAL CONTENT TYPE 
A core concept of Microsoft Business Connectivity Services (BCS) is the external content type. Used throughout the functionality and services offered by Business Connectivity Services, external content types are reusable metadata descriptions of connectivity information and data definitions plus the behaviors you want to apply to a certain category of external data. External content types enable you to manage and reuse the metadata and behaviors of a business entity such as Customer or Order from a central location, and enable users to interact with that external data and processes in a more meaningful way.
For example, consider a business entity such as Customer. You might want to interact with items of type Customer inside a SharePoint list or work on them offline in Microsoft Outlook. Or, you might want to enable the user to pick a customer from a list of customers in an Orders contract document inside Microsoft Word. You can create an external content type once and then reuse it anywhere you need it.
External content types offer the following benefits:
  • Enable reusability An external content type is a reusable data definition of a business entity. After you create it, you can use it with any of the Presentation Features in BCS to provide a rich user experience to interact with external data.
  • Encapsulate complexities of external systems External content types enable information workers to assemble business solutions without having to handle the complexities of the external systems, for example, without needing to know the connectivity information or learn their programmability interfaces. After an experienced user or a developer creates an external content type, it is available to any user for use in any way they need (provided they have the permissions to perform that operation and access the external data). However, the user does not need to know anything about the location of the external data or how to connect to it.
  • Provide built-in Office and SharePoint behavior External content types provide Office item-type behaviors (such as contacts, tasks, calendars in Microsoft Outlook, documents in Microsoft Word, and lists in Microsoft SharePoint Workspace); SharePoint behaviors (such as lists, Web Parts, and profile pages); and capabilities (such as the ability to search or work offline) to external data and services, so users can work in their familiar work environments without having to hunt for data or learn and interact with different (and proprietary) user interfaces.
  • Ensure secure access External content types adhere to the security put in place by both the external system and SharePoint Products and Technologies. You can have full control of who accesses what data by configuring security in SharePoint.
  • Simplify maintenance. Because external content types can be created once and used by multiple solutions in various scenarios, you can manage them easily. For example, you can manage their access permissions and connection and data definitions in one central location.
  • Enable external data search You can use SharePoint Server search from an intranet portal to look up information about a specific external content type such as a Customer. SharePoint Server search retrieves the data directly from the external system. Consequently, users can get the information they need without having to get approval or install a separate application.
  • Enable working offline You can take external content types offline in Outlook 2010 and SharePoint Workspace 2010. Business Connectivity Services provides rich cache and offline work features, and supports cache-based operations. Users can manipulate external data seamlessly and efficiently, even when they are offline or if the server connectivity is slow, intermittent, or unavailable. The read/write operations performed against cached business entities are synchronized when connection to the server becomes available.
 --------------------

all about ONET.xml file :
http://msdn.microsoft.com/en-us/library/ms474369.aspx

Misc: SPProxyOperations/WorkFlows


-----------------------------------------------------------------------------------------------
Console.ForegroundColor = ConsoleColor.Green;
Console.BufferHeight = 1000;
//Get local farm
SPFarm farm = SPFarm.Local;
Console.Write(farm.Id.ToString("N").ToLower());
//loop Services
foreach (SPService service in farm.Services)
{
    //find WebService
    if (service is SPWebService)
    {
        SPWebService webService = (SPWebService)service;
        //Loop WebApps
        foreach (SPWebApplication webApp in webService.WebApplications)
        {
            Console.Write(webApp.Id.ToString("N").ToLower());
            //Loop Site Collections
            foreach (SPSite site in webApp.Sites)
            {
                Console.Write(site.ID.ToString("N").ToLower());
                //Loop Sites
                foreach (SPWeb web in site.AllWebs)
                {
                    Console.Write(web.ID.ToString("N").ToLower());
                    //Loop Lists
                    foreach (SPList list in web.Lists)
                    {
                        Console.Write(list.ID.ToString("N").ToLower());
                        //Loop Items
                        foreach (SPListItem item in list.Items)
                        {
                            Console.Write(item.UniqueId.ToString("N").ToLower());
                        }
                    }
                    web.Dispose();
                }
                site.Dispose();
            }
        }
    }
}

-----------------------------------------------------------------
For WorkFlows in SHArepoint we have
List Wf  : attach the workflow to any existing list in the site.
Reusable wf - apply it to a Content Type
Example it can be applied to Announcements etc.
Item Content type . Every Doc/item get created from an Item .Henc the WF gets attached to any item /document in the site collection.
Also, the Save as Template command can be used to create a WSP file containing a reusable workflow which can be moved to another SharePoint server or to Visual Studio 2010. In SharePoint Designer, this means you don’t have access to the list fields to access data since no specific list structure is connected.
Hence whenever  a list gets created
Site WF :THE WF is not associated with any list or Doc.After publishing the WF
You can get to the activated site workflows by choosing Site Workflows from the Site Actions menu in SharePoint. It shows you new workflows you can start, any running site workflows and completed workflows. Since site workflows don’t have a list item or document to start from, they must be started manually through the SharePoint user interface or via the SharePoint API.
==================================
Modules (not to be confused with Visual Basic modules) contain any files that you want to accompany the SharePoint project, such as development notes or a Readme file. Some SharePoint projects also use modules to include files they require. The module project template creates an Empty SharePoint Project that contains a Module node. The Module node contains two project item templates: an XML definition file, which acts as a manifest for the module, and a sample.txt file, a file included for example purposes. For more information, see Using Modules to Include Files in the Solution and Modules.



Site collection administrators now have the authority to upload, activate, delete, and manage sandboxed solutions using the new Solution Gallery, which is a repository of sandboxed solutions. The gallery also enables a site collection administrator to monitor a solution’s usage against a resource quota. (You will see how in detail later in the article.) The Solution Gallery is simply a standard SharePoint list that stores the .wsp file. It is located under the _catalogs folder at _catalogs/solutions

But what you can do is read and write to lists and libraries within the same site collection. The sandbox provides enough functionality to build most of the applications that are required at a site level.
The best way to reach out of the sandbox is by using the Business Connectivity Services (BCS) to create an external content type. You can then read and write to the data source from the sandboxed solution.
Another, more advanced, way to reach outside the sandbox is to create a class that runs in a full-trust process outside the sandboxed worker process to proxy calls.  
To enable the same we can follow the following steps :

     http://msdn.microsoft.com/en-us/library/ff798476

The ExecutionModels.Sandboxed.Proxy solution illustrates everything you need to know to create and deploy a full-trust proxy. At a high level, you must complete three key tasks to make a full-trust proxy available to sandboxed solutions:
  • Create a proxy operation arguments class that represents the data that you want to pass to your full-trust proxy. This class should inherit from the SPProxyOperationArgs base class. The proxy operation arguments class is essentially a serializable collection of user-defined public properties.
  • Create a proxy operations class that implements your full-trust logic. This class should inherit from the SPProxyOperations base class. The base class defines a single method named Execute that requires a single argument of type SPProxyOperationsArgs and returns a value of type Object.
  • Register your full-trust proxy with the user code service. This is best accomplished through the use of a feature receiver class. The registration process makes your proxy operation arguments class available in the sandbox environment, and it enables you to invoke your proxy logic through the SPUtility.ExecuteRegisteredProxyOperation method.

Client Side OM updated



in CSOM

we create a batch of commands and then fire them
at one go .helps increase  efficiency.

the server will process the task at on go and send the results back to the client

side..instead of one postback after another.

Communication is done send commands with XML ---> the result/response is returned  back with

JSON .

there is a free tool in u2u.be site which can be used for writing CAML queries.
SP.js is a  minified version  of SP.debug.js . In the debug mode the SP.debug.js is use
whereas the SP.js is used in the production version of the Sharepoint.

1>JSOm can be used for any used for any HTML  in the conrext of a sharepoint site
app/web page.
2>web Parts
3> Dialof framwork -- popup etc  in the browser.

You can use the JQuery that is there for SP site throgh the concept fo CSOM .
Here we get the context of the site  ctx(say).
then we use the
ctx.executequeryasynch(onSucces,onFail)


in jquery its always executequeryasynch as the UI is left un touched and the querying

happens asych without depending on whether postbacjk is happning or not.

onSucces,onFail methods are the ones that get called after the ctx has been able to or

unable to fire the query and fetch results .



------------------------------

inside the Sharepoint we get the file to be hosted  in the :

Jquery files can be uploaded and deployed at the physical file system

Virtaul FS (content db).
hence whenever we upload stuff using the web user interface like the SPD  its gets
loaded into the VFS.
scoped to the level of a site.Hence JQuery needs to be deployed at all the sites.
The advantage here the SandBox Sol can be used to deploy at this VFS.
without the need of a admin

Physical FS i.e /_layout/ folder -- Content  is palced on the  fron end serever at he
14 hive
c:/prog files/common files/microsoft shared /web server extesions/14/
hive
Here the JQuery can be placed once in the Phuscial file system and we can just reeference

the same frome verywhere else.

Choose between the two.

Custom Action is a small XML wrapped inside a feature that references JQuery .
Advantages : its a techniq that will work with SandBox sol/Office 365 in cloud etc.
 


=====================================

JSOM is intended for accessing and manipulating SharePoint objects by using JavaScript (ECMAScript) in an asynchronous fashion. It is very useful in situations where you want to access SharePoint data or make manipulations to the data after the page has been loaded on the client.

JSOM provides a comprehensive set of APIs that can be used to perform operations on most
SharePoint objects such as Site, Web, List, ContentTypes, User Permission and so forth. The API is simple to use and allows the developer to focus on the business scenario with a minimum amount of infrastructure required. JSOM fully supports JQuery and both can be used in conjunction with the other
SUPPORTED ON :
•Microsoft Internet Explorer 7.0 or greater

•Firefox 3.5 or greater
•Safari 4.0 and greater
The client object model acts as a proxy to connect to a WCF service (Client.svc) for the processing of the request. The Client.svc service is the protocol server responsible for performing all of the operations requested by the client object model. The service is located at /_vti_bin/client.svc on the server. The protocol server endpoint appends /_vti_bin/client.svc/ProcessQuery to process a request and requires a formatted Xml Request message based on the client protocol specifications.
Client.svc is an internal WCF service; it is reserved for SharePoint usage and is not intended to be used directly in client code. If you attempt to add a service reference to this service, no proxy will be generated. Internally, the Client.svc leverages the server-side object model to handle all client requests and return a JSON response.
The new ECMAScript (JavaScript, JScript), .NET managed, and Silverlight client object models each provide a subset of the server object model that is defined in Microsoft.SharePoint.dll, including objects that correspond to major objects at the site-collection level or lower in the SharePoint Foundation hierarchy. To improve security and performance, the client object models focus on the most relevant APIs for client-side development, and do not contain all the types and members that are represented in the server object model

 All operations are inherently asynchronous,and commands are serialized into XML and sent to the server in a single HTTP request. For every command, a corresponding server object model call is made, and the server returns a response to the client in compacted JavaScript Object Notation (or JSON) format, which the proxy parses and associates with appropriate objects.
\
===============================================
In SharePoint 2010 we can access all SharePoint List  via Restful Service.  Here is the URL to access List REST Service.
/_vti_bin/ListData.svc/
will give us all the list data.
http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts ( REST Query to get all Contacts from SharePoint List called SreeniContacts.)
The Below screenshots shows my site Lists REST Service Entities.  
-----------------------------------------------
Connecting and displaying WCF service data as External List in the sp site
---------------------------------------------------------------------
BDC  ----
Client O Model :
Before actually executing a query, you use the objects that are returned through the client context to define the actions to perform. The ClientContext class (JavaScript: ClientContext) inherits the Load<T>(T, Expression<Func<T, Object>>[]) (JavaScript: load(clientObject)) and LoadQuery() (JavaScript: loadQuery(clientObjectCollection, exp)) methods from the ClientRuntimeContext class (JavaScript: ClientRuntimeContext). You define a query to perform specific actions and return specific objects or properties, and then you call one of these methods to load the query.
After you load a query, call the ExecuteQuery() or ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler) method (JavaScript: executeQueryAsync(succeededCallback, failedCallback)) of the ClientContext object (JavaScript: ClientContext) to send the query to the server. The Silverlight client object model provides both an ExecuteQuery() method, which can be called synchronously from threads that do not modify the user interface (UI), and an asynchronous ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler) method for cases where threads do modify the UI. These methods for executing queries formulate XML that represents the actions taken on the client, and send the XML to the server.
  • In the managed object model, this call is synchronous, which means that code execution is blocked until a response is received from the server.
  • This call can be either synchronous or asynchronous in the Silverlight object model,
  • but it is always asynchronous in the JavaScript object model.
  • In an asynchronous call, code continues to execute and does not wait for the server response.

In the Silverlight and JavaScript object models, you can implement a callback function that is invoked when the server response is received.
 

Data Query in the client object model ;
Two points to keep in mind when using LINQ to query against the client object model:
  • When you use LINQ to create queries against the client object model, you are using LINQ to Objects, not the LINQ to SharePoint provider, which can only be used when you write code against the server object model.
  • When your query is designed to return a subset of list items from a list, it is more efficient to use a CAML query than a LINQ query. This is because all the list items are sent from the content database to the front-end web server and loaded into memory. Only then is the LINQ filter is applied. With a CAML query, the filtering is done on the database server. This point applies only to queries that filter the items on a list. Other kinds of LINQ queries, such as returning a subset of the lists from a web site, are more efficient.
 Note 

Two points to keep in mind when using LINQ to query against the client object model:
When you use LINQ to create queries against the client object model, you are using LINQ to Objects, not the LINQ to SharePoint provider, which can only be used when you write code against the server object model.
When your query is designed to return a subset of list items from a list, it is more efficient to use a CAML query than a LINQ query. This is because all the list items are sent from the content database to the front-end web server and loaded into memory. Only then is the LINQ filter is applied.
With a CAML query, the filtering is done on the database server. This point applies only to queries that filter the items on a list. Other kinds of LINQ queries, such as returning a subset of the lists from a web site, are more efficient.