Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.

Development

Merry Christmas – HTML5, JS, and CSS3

I wanted to thank all of you for reading my blog and wishing you a Happy Holiday season.   After passing exam 070-480 about HTML5, it seemed like a great time to practice new skills and draw a <CANVAS> based Christmas Tree here.   Enjoy!  

Smile

 

Screenshot of what it should look like:

image

Code behind:


 

Live working demo:



Merry Christmas!

Say Happy Birthday with Code!

Most people just say “Happy Birthday” to each other over social networks like Facebook and Twitter with the same 14 predictable letters.   Why not say it with code?   If you’re a developer you already understand.  

Smile

   Before you ask … Yes, I really did write and run the QBasic 4.5 version in 16-bit mode running www.DosBox.com on Windows 7 x64.   Oh, and no it’s not my birthday.

 

With PowerShell

1..4 | % {if ($_ -ne 3) {Write-Host "Happy Birthday to You!"} else {"Happy Birthday Dear Jeff"}}

With C# Console Application

for (int i = 0; i <= 3; i++) { Console.WriteLine(((i == 2) ? "Happy Birthday dear Jeff" : "Happy Birthday to You!")); }

With JavaScript

With Command Prompt

@ECHO OFF
FOR %%A IN (1 1 2 1)
DO (
IF %%A == 1 ECHO "Happy Birthday to You!"
IF %%A == 2 ECHO "Happy Birthday dear Jeff"
) 
:EOF

With QBasic 4.5  (oh yes I did!)

CLS
FOR x = 1 TO 4
        IF x = 3 THEN
                PRINT "Happy Birthday dear Jeff!"
        ELSE
                PRINT "Happy Birthday to You!"
        END IF
NEXT x
FOR x = 37 TO 1000
        SOUND x, 1
NEXT x

 

image
image
image
image

An Unhandled exception CryptographicException occurred in OWSTIMER.EXE

I recently saw this error while patching SharePoint with a Cumulative Update.   Most people will never see this.  However, you are not most people.  You run Visual Studio. 

Smile

Visual Studio is trying to help us out with an unhandled exception by asking about launching debug.  That’s all well and good but I didn’t write the code and have no plans to change it.

Best way to work with this is to disable the JIT (Just-In-time Debugger) by following a few simple Registry Key changes:  http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/9e6cb3fb-f8fb-4c22-8608-e521e13260ff

 

image

Visual Studio Just-In-Time Debugger

An unhandled exception (‘System.Security.Cryptography.CryptographicException’) occurred in OWSTIMER.EXE [1344]

Programmatically enabling Records Management

Recently I had someone ask about how In-Place Records Management could be enabled in SharePoint 2010 for a given document with C# object model code.  The method ConfigureListForAutoDeclaration() was key to making everything work.  This would allow for easily enabling on many sites all at once.  Below I’ve included C# code and screenshots from the test site where it was enabled.  Please feel free to leave any questions below with a comment.

  • Open site
  • Enable “In-Place Records Management” site collection feature  (da2e115b-07e4-49d9-bb2c-35e93bb9fca9)
  • Open document library
  • Open “Record declaration settings”
  • Enable “Automatic Declaration” with [Microsoft.Office.Policy.dll]
  • Upload test files
  • Confirmed:  see padlock icon and unable to delete document library

 

C# – Visual Studio 2010 Console Application

Add assembly reference to [C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14ISAPIMicrosoft.Office.Policy.dll]

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft;
using Microsoft.SharePoint;
namespace SharePointConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteURL = "http://sp2010";
            using (SPSite site = new SPSite(siteURL))
            {
                SPWeb w = site.OpenWeb();
                SPList dl;
                bool needToCreate = false;
                try
                {
                    dl = w.Lists["Records"];
                    Console.WriteLine("found");
                }
                catch (System.ArgumentException)
                {
                    needToCreate = true;
                }
                if (needToCreate)
                {
                    //missing so create it
                    Console.WriteLine("Records DL missing on " + w.Url);
                    Guid g = w.Lists.Add("Records", "** Coporate Records Management **", SPListTemplateType.DocumentLibrary);
                    w.Update();
                    dl = w.Lists[g];
                    //enable auto-Record for uploads
                    Microsoft.Office.RecordsManagement.RecordsRepository.Records.ConfigureListForAutoDeclaration(dl, true);
                    //add CEWP to default view
                    dl = w.Lists[g];
                    //show on QuickLaunch
                    if (!dl.OnQuickLaunch)
                    {
                        dl.OnQuickLaunch = true;
                        dl.Update();
                    }
                    //disable folders
                    if (dl.EnableFolderCreation)
                    {
                        dl.EnableFolderCreation = false;
                        dl.Update();
                    }
                    //enable Content Types
                    if (!dl.ContentTypesEnabled)
                    {
                        dl.ContentTypesEnabled = true;
                        dl.Update();
                    }
                    //disable Required Check Out
                    if (dl.ForceCheckout)
                    {
                        dl.ForceCheckout = false;
                        dl.Update();
                    }
                    //add Content Type to default view
                    Console.WriteLine("CT");
                    SPField ctField = dl.Fields["Content Type"];
                    SPView defaultView = dl.Views[dl.DefaultView.ID];
                    defaultView.ViewFields.Add(ctField);
                    defaultView.Update();
                    dl.Update();
                }
            }
        }
    }
}

Screenshots

image

DisplayName

Id

Scope

RecordResource

5bccb9a4-b903-4fd1-8620-b795fa33c9ba

Site

RecordsManagement

6d127338-5e7d-4391-8f62-a11e43b1d404

Farm

InPlaceRecords

da2e115b-07e4-49d9-bb2c-35e93bb9fca9

Site

RecordsCenter

e0a45587-1069-46bd-bf05-8c8db8620b08

Web

image
image
image
image
image

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲