Monday, November 10, 2014

Generate Documentation For SharePoint Farm

To Generate documentation for SP farm, just follow the following steps:

- Download the this script from: https://gallery.technet.microsoft.com/office/Inventory-SharePoint-Farm-dc11fc28

- Open the SP server, then open PowerShell as administrator.

- Open downloaded script in PoweShell.


- Go to the script location to import the script


- Create directory to save reports in


- Now, if you go to C drive, you will find folder named 'Report'.

- Just execute the following command in PowerShell:
Run-FullInventory -DestinationFolder "C:\Report" -LogFilePrefix "YOURProjectName"


Now, you can go to C:\Report to view reports generated:



Then you can convert csv files to excel files to make it readable.



Note that, if you have more than one server in your farm, you should generate reports in all nodes. Because some reports like TimerJobs is depending on specific node.



Saturday, November 8, 2014

SharePoint Error: Distributed cache service is not enabled in this deployment

Sometimes you get the following error message in SP log:
"Distributed cache service is not enabled in this deployment"

To solve this issue, just enable windows service 'AppFabric Caching Service'.



Note that, if you have more than node in your farm, you should enable the service in all nodes.

Friday, July 25, 2014

iTextSharp - Make the PDF file secure

When you use iTextSharp, which is a tool used to generate PDF, using C#, you can make the PDF secure. I mean by secure, you can modify the security properities of the PDF like printing, allow modification, allow copying...etc










You have just to write the following fragment: 

            // define the document
            Document document = new Document(PageSize.A4);
            document.SetMargins(0, 0, 20, 10);

            // create memory stream to save the file
            MemoryStream ms = new MemoryStream();
            PdfWriter p = PdfWriter.GetInstance(document, ms);

            // set security properties
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            p.SetEncryption(null, encoding.GetBytes("12"), PdfWriter.AllowPrinting, 
            PdfWriter.STRENGTH40BITS);

            // open the document
            document.Open();

            // generate the document content
            document.Add(PDF_FinanceCertificate(item, p, document));

            // close the final PDF document
            document.Close();

            byte[] pdfFile = ms.ToArray();

            return pdfFile;


Note that, because we implement security issue in the PDF, the generation operation will take more time more than usual.


Thursday, January 9, 2014

How To Add Twitter (Tweet Button) To Web Page

To add twitter button to tweet your page URL just do the following:

* add this line to HTML to show tweet button:

<a href="https://twitter.com/share" class="twitter-share-button" data-url="YOUR PAGE URL" data-text="PAGE TITLE OR DESCRIPTION OF THE TWEET" data-lang="en" data-size="small" data-count="none" data-hashtags="HASHTAG YOU WANT TO TWEET FOR">TWEET</a>


* add the following script in master page or your page:

<script>!function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https'; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = p + '://platform.twitter.com/widgets.js'; fjs.parentNode.insertBefore(js, fjs); } }(document, 'script', 'twitter-wjs');</script>

The result will be like this:


Notes:
- URL should be published, this means you can't share localhost or internal URL if you create javascript to get the current page URL.

- You can create javascript to get the current page title.

- You can remove the section data-hashtags if you want.

- You can change the value of data-lang to your specific language like ar for Arabic language.

- You can change the value of data-size to big to show bigger icon.