Wednesday, December 21, 2016

Upload Files to SharePoint Document Library in c#

1.Create a seperate class for the SharePoint upload called "SharePointUtil". And include below two methods.

 Connect to the server. Url is the site URL.
 public bool Connect(string Url)  
 {  
 bool bConnected = false;  
 try  
 {  
 SPClientContext = GetSPContext(Url);  
 SPWeb = SPClientContext.Web;  
 SPClientContext.Load(SPWeb);  
 SPClientContext.ExecuteQuery();  
 bConnected = true;  
 }  
 catch (Exception ex)  
 {  
 bConnected = false;  
 SPErrorMsg = ex.Message;  
 }  
 return bConnected;  
 }  
 private ClientContext GetSPContext(string Url)  
 {  
 ClientContext SPClientContext = new ClientContext(Url);  
 SecureString SecSPassWord = new SecureString();  
 foreach (char c in sPPassword)  
 {  
 SecSPassWord.AppendChar(c);  
 }  
 SPClientContext.Credentials = new SharePointOnlineCredentials(sPUserName, SecSPassWord);  
 return SPClientContext;  
 }  

Upload a File to SharePoint
fs means File Stream
sFileName means File Name
sSPSiteRelativeURL means Relative Path
sLibraryName means Document Library Name
fileid means File ID
applicationtype means Type of the Application


 public void UploadFile(Stream fs, string sFileName, string sSPSiteRelativeURL, string fileid, string applicationtype)  
 {  
 string sDocName = string.Empty;  
 string folderpath = string.Empty;  
 try  
 {  
 if (SPWeb != null)  
 {  
 string sLibraryName = "Test";  
 var fullFolderUrl = applicationtype + "/" + fileid;  
 var list = SPWeb.Lists.GetByTitle(sLibraryName);  
 var rootfolder = list.RootFolder;  
 //Here you can create the folders in document library.  
 CreateFolder(fullFolderUrl, rootfolder);  
 var fUrl = sSPSiteRelativeURL + sLibraryName + "/" + fullFolderUrl + "/" + sFileName;  
 Microsoft.SharePoint.Client.File.SaveBinaryDirect(SPClientContext, fUrl, fs, true);  
 }  
 }  
 catch (Exception ex)  
 {  
 sDocName = string.Empty;  
 SPErrorMsg = ex.Message;  
 }  
 }  

Creating a folder and named the file id
fullFolderUrl means Folder Url
parentFolder means parent Folder
CurrentURL means Current URL


 public Folder CreateFolder(string fullFolderUrl, Folder parentFolder)  
 {  
 string folderpath = string.Empty;  
 string UploadUrl = sURL;  
 if (string.IsNullOrEmpty(fullFolderUrl))  
 throw new ArgumentNullException("fullFolderUrl");  
 var folderNames = fullFolderUrl.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);  
 string folderName = folderNames[0];  
 var curfolder = parentFolder.Folders.Add(folderName);  
 SPClientContext.Load(curfolder);  
 SPClientContext.ExecuteQuery();  
 // If we have sub folders  
 if (folderNames.Length > 1)  
 {  
 var subFolderUrl = string.Join("/", folderNames, 1, folderNames.Length - 1);  
 return CreateFolder(subFolderUrl, curfolder);  
 }  
 return curfolder;  
 }  

2.Use the below method where click on the "upload" button.

 private void UploadFilestoSharePoint(Stream fs, string sFileName, Guid id, string filetype)  
 {  
 string fileid = id.ToString();  
 // if you want to specialize the application type  
 string applicationtype = filetype;  
 //This is the SharePoint Web url eg "https://test.sharepoint.com"   
 string UploadUrl = sURL;  
 Uri uri = new Uri(UploadUrl);  
 string sSPSiteRelativeURL = uri.AbsolutePath;  
 SharePointUtil sputil = new SharePointUtil();  
 bool bbConnected = sputil.Connect(UploadUrl);  
 if (bbConnected)  
 {  
 sputil.UploadFile(fs, sFileName, sSPSiteRelativeURL, fileid, applicationtype);  
 }  
 }  

Wednesday, October 12, 2016

How to Remove the "Title" Field from our Forms and the Default View in SharePoint

1. Go to the list and choose Settings | List Settings

2. Click "Advanced settings"

3. Change the first entry, "Allow management of content types?" to Yes

4. In the “Content Types” section that has just appeared, click the "Item" link

5. Click the "Title" field and select “Hidden (will not appear on forms)”

6. Change the management of content types back to “No” (steps 1-2)

Tuesday, May 24, 2016

Display Repeated Events in a Calendar in SharePoint 2013

1.Select the Calendar which you need to show the items. Then select “List Settings” in the calendar tab.


2.Click on the “Create Column”

3.Create two calculated columns which we can use to save the Start Time and the End Time (as below).

*Please create two columns for both Start Time and End Time

4.Now go to the page where display the “What’s on today” web part. Then Click on edit to edit the page.

5.After that edit the “What’s on today” web part.


6.Then set the rules as below.

Here select the calendar which you need to show the events.
Eg : According to yours “Events”



7. Save the changes.

Thursday, November 12, 2015

Business Intelligence with SharePoint

  •    SharePoint -  Excel Service , Visio Service, PerformancePoint Service
  •    Microsoft Excel – Excel, Power view, PowerPivot
  •    SQL Server – Integration with the SQL Reporting Service
  •    Third Party Tool – Power BI 

Comparison Business Intelligence Capabilities in Different Microsoft SharePoint Environments  

Feature
SharePoint On-Premise
SharePoint Online Plan 1
SharePoint Online Plan 2
BI Center
Yes
No
Yes
Excel Services
Yes
No
Yes, if the workbook size less than 10 MB
Visio Services
Yes
No
Yes
PerformancePoint Services
Yes
No
No
PerformancePoint Services (PPS) Dashboard Migration
Yes
No
No
Power View for Excel in SharePoint
Yes
No
Yes
PowerPivot for Excel in SharePoint
Yes
No
Yes
Scorecards & Dashboards
Yes
No
No
PivotTables and Pivot Charts
Yes
No
Yes
Filter Enhancements and Filter Search
Yes
No
Yes
Schedule Data Refresh
Yes
No
No
Usage Monitoring
Yes
No
Yes
Reporting Services integration With SQL
Yes
No
No

Moreover we can use Power BI (Payable app) for office 365.It provides below features.
  • Can create BI sites and called them as “Power BI sites”.
  • Provide data stewardship and query sharing and management.
  • Can schedule Data Refresh.
  • Provide Natural Language Query (Q&A).-(not provide in any other environments)
  • Provide predictive forecasting.(not provide in any other environments)
  • View Microsoft Excel workbooks in a browser.( if the workbook size less than 250 MB)
  • Usage Monitoring.
  • Cannot use for Excel Power view and PowerPivot workbooks.
References
https://msdn.microsoft.com/en-us/library/dn877942%28v=sql.120%29.aspx
https://technet.microsoft.com/en-us/library/sharepoint-online-service-description.aspx#bkmk_tablespo
http://www.sharepoint.co.il/sites/share-point/UserContent/files/Appendix_B.pdf
https://msdn.microsoft.com/en-us/library/dn877942%28v=sql.120%29.aspx