Sunday, June 24, 2012

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.

No comments:

Post a Comment