Wednesday, June 15, 2011

Find the most repeated wordin the string.


public static void findmaximumcharinstring()
string str11 = "my name is ayyappan as as i i am working as an software engineer in hexaware i had two year experianced in microsoft platform";
string str1 = "bayyappppan";
string[] name = new string[str1.Length];
string[] stringval = new string[100];
string[] word = str11.Split(' ');
int cout=0;
foreach (var w in word)Array.FindAll(stringval, val => val != null).ToArray();
 var local =
(from p in stringvalgroup p by p into gselect new { charec = g.Key, chareccount = g.Count() }).OrderByDescending(x => x.chareccount);
int t=0;
foreach (var l in local)
if (t != 0)
if (l.chareccount != t)break;
Console.WriteLine("Maximum repeted string is:{0} and the count is : {1}",
 l.charec, l.chareccount);
}
}

Wednesday, February 16, 2011

Advantages of XsltListViewWebPart in SharePoint 2010

       SharePoint 2010 provides new control to render the Lists - XsltListViewWebPart, that replaces previous controls, such as List Form, List View, DataFormViewPart.         The benefits of the XsltListViewWebPart are summarized in the following table


List View
List Form
Data Form
XSLT List View
Rendering Technology
CAML
ASP.NET
XSLT
XSLT
Render Lists
+

+
+
Render Items

+
+
+
Aggregate Data


+
+
Render External Data


+
+
Browser Editing
+
+

+
SPD Editing


+
+
Parameterizable


+
+
Conditional Formatting


+
+
Performance
+
+

+

SharePoint 2010: Architecture

Well, the final day of the conference came and with it some of the most useful sessions (from my perspective). One of which was the "Architecture Guidance for SharePoint 2010". This hopefully distils some of that information. It's not a be all and end all, but hopefully points you in the right direction so that you can focus your research a little better!


UI Design
·         Entire interface in SharePoint 2010 to be W3C XHTML compliant
·         SharePoint 2010 "more accessible mode" to be WCAG 2.0 AA compliant
·         New ribbon interface replaces toolbars and menus (and considerations for old "CustomAction" commands which may no longer work!)
·         Wiki content allows web parts to be dropped in (removing over-reliance on web part zones)

Lists
There are a whole load of new List capabilities (in addition to the "External List" that BSC brings to the plate!).
·         Lookup to Multiple
This means that when you create a new lookup column, you can now pull down additional fields from the lookup list item and use them for filtering.
·         CAML support for Joins!
You can now perform "JOIN" operations in your CAML queries for linking lists together.
·         Enforced List Relationships
You can now enforce specific relationships for lookup columns with two options:
·         Restrict Delete - cannot delete parent if child items exist.
·         Cascade Delete - If you delete the parent, all child items are automatically deleted (recycle bin aware with "restore" options!)
·         Store-level enforcement
This is code level "required fields", so now you can enforce the requirements even through code !
·         Unique Fields
Specify a unique field, so that no two values can match (e.g. Email addresses in contacts list)
·         Compound Indices
If you want to query by 2 fields, you can now index both at once as a compound index.
·         <In> clause for reverse lookups
This allows a CAML query to do a reverse lookup to get all child items that are associated with the parent!
·         Formula based validation
e.g. Don't allow Field2 to be lower than Field1.

Workflows
·         Out of the box SharePoint 2010 workflows can now be extended in SharePoint Designer 2010.
·         SharePoint Designer 2010 can be used to create "re-usable" workflows
·         Site Workflows - to manage processes across an entire site.
·         You can now import a SharePoint Designer 2010 workflow into Visual Studio 2010!
·         Import/Export workflow using Visio 2010 for visual workflow modeling.

Content & Document Management
·         "Document Sets" allow you to treat a group of documents as a single item (with 1 version history, group executed workflow and policy, and a "download as zip" option).
·         Managed Metadata Service  allows cross-farm Content Type management and a pre-defined enterprise taxonomy structure! This is a killer-app, bringing true enterprise content management to SharePoint 2010.
·         Enterprise Wiki's allow more rapid "in edit" content, as well as Web Parts deployed directly into the rich text editor (no more web part zones?).
·         Spelling check and broken link check when you "check-in" WCM pages.

Event Handlers
Three new event handlers added (at last!!)
·         WebAdded - Fired every time a child site is created in the web.
·         ListAdded - Fired every time a list is created in the web.
·         Feature Upgrading  - Fired when a feature has it's "upgrade" method called (more on this in a future blog post).

Security
·         Editing of ASPX pages now required "Designer" permissions (instead of contribute).
·         XSS (Cross Site Scripting) protection for pages and web parts.
·         HTML pages will now "force download" by default. This stops people from uploading HTML files with malicious scripts, so if you click on an HTML file in a document library you will get a download dialog instead of the file opening in the browser!
·         There are still no field level permissions (it was estimated that this would add a 30% overhead to performance! Maybe in a future release)

BI and Connectivity
·         New Business Connectivity Services (BCS) allows no-code connections of databases and LOB systems to content types and lists with two-way synchronization of data  and full CRUD support.
·         BCS interactivity from within Office clients, allowing LOB system data to be edited directly from desktop applications (such as Outlook and Word).
·         Power Pivot for Excel allows upwards of 100 million rows into an excel workbook with phenomenal performance.

Office Application Support
·         New web level services for applications (Excel / Visio with JavaScript events!)
·         SharePoint Workspace to replace "Groove" for offline file support and editing.
·         Office Web Applications to allow for direct opening and editing of documents from within the browser!
·         InfoPath 2010 can now be used to edit the List forms out of the box!

Databases
·         Still a 100GB "limit" for content databases.
·         Still cannot have site collections spanning multiple databases.
·         New support for "Failover" databases, SharePoint 2010 is now SQL mirror aware!
·         All "Service Applications" have their own SQL database, along with many other new databases (e.g. Feed Activity, Social Data, Usage Logs).
·         New "read only content databases" open the door for simple content deployment (utilising SQL log shipping or database replication).

Content Deployment
·         All execution now in Timer Jobs.
·         Performance (and memory usage) improved.
·         Export routine now creates database snapshot to improve data integrity!

Sandboxed Solutions
·         Ability to upload WSPs directly into the content database to execute in minimal permissions using "virtual files" (no impact on the file system!)
·         Resource throttling, code performance checking and "bad routine" blocking
·         Provides new best practice for code development and deployment!

Search
·         New FAST search with thumbnail views (and navigation!) for office documents
·         Improved relevancy and non-query searching
·         2 new search products (FAST based)
·         New refinement panel for advanced sorting and filtering "on the fly"
·         Multi-lingual support with over 80 languages built-in.

Social Networking
·         New My Sites structure
·         Activity Feeds to provide updates on user activity with an extensible architecture!
·         "Social Feedback" functions akin to Delicious and Dig allowing tagging of any URL based content, and subsequent discussions around items that have been "tagged".
·         Ratings mechanism distributed throughout the product.

I'm sure there are many other things, so please let me know if there's anything else you think should "make the grade" and I'll see if I can add it in :)

Using Elevated Privileges and AllowSafeUpdates Method - A Potential Security Risks

Although not recommended, there may be times when you need your code to perform certain functions that the current user does not have the necessary permissions to perform. I have such situation in one of our project, suppose that you wanted to provide add, edit or delete capability to all users who use your application, regardless of their permissions on the list. So how this would be achieved?

By using the SPSecurity class, it provides a method RunWithElevatedPrivileges that allows you to run a subset of code in the context of an account with higher privileges than the current user. You need to wrap the RunWithElevatedPrivileges method around your code, as shown below:    
<code>
    protected void btnAddListItem_Click(object sender, EventArgs e)

    {
        using (SPSite oSite = SPContext.Current.Site)  {

        // Run with an account with higher privileges than the current user

         SPSecurity.RunWithElevatedPrivileges(delegate(){

//code               

 }

});
}
}

Friday, December 24, 2010