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!
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.
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.
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
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.
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.
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();
}
}
}
}
}