CreateDate for List Items in Manage Site Content and Structure

Just discovered that when you Copy or Move content using Manage Site Content and Structure the target content has the EXACT same CreateDate +1 second. Not sure why this is but since the GUIDs are not preserved for either move or copy this could end up being very useful if you have data in SQL outside of SharePoint that references the ObjectID.

 
 

 
 

Screen clipping taken: 1/29/2009, 1:01 PM

 
 

Move or Copy

 
 

 
 

Screen clipping taken: 1/29/2009, 1:02 PM

 
 

Select destination

 
 

 
 

Screen clipping taken: 1/29/2009, 1:02 PM

 
 

Copy in progress

 
 

 
 

Screen clipping taken: 1/29/2009, 1:04 PM

 
 

CreateDate before Copy/Move

&

 
 

 
 

Screen clipping taken: 1/29/2009, 1:05 PM

 
 

Target is CreateDate is exactly the same +1 second.

o

Art Vandelay – Import/Export SharePoint Content in C#

Here is some handy dandy code for Exporting content from a SharePoint site and importing into another.

 
 

 
 

using System;

using System.Collections.Generic;

using System.Text;

 
 

namespace ContentMoveTest

{

class
Program

{

static
void Main(string[] args)

{

ExportImport(http://www.source.com, http://www.target.com);

}

 
 

 
 

static
void ExportImport(string sourceUrl, string destinationUrl)

{

string fileName = Export(sourceUrl);

Console.WriteLine(“Local filename for this export/import is {0}”, fileName);

Import(destinationUrl, fileName);

}

 
 

static
string Export(string siteURL)

{

Microsoft.SharePoint.Deployment.SPExportSettings exportSettings = new Microsoft.SharePoint.Deployment.SPExportSettings();

 
 

exportSettings.AutoGenerateDataFileName = true;

exportSettings.ExportMethod = Microsoft.SharePoint.Deployment.SPExportMethodType.ExportAll;

//exportSettings.ExportMethod = Microsoft.SharePoint.Deployment.SPExportMethodType.ExportChanges;

exportSettings.CommandLineVerbose = true;

exportSettings.SiteUrl = siteURL;

exportSettings.IncludeSecurity = Microsoft.SharePoint.Deployment.SPIncludeSecurity.All;

exportSettings.IncludeVersions = Microsoft.SharePoint.Deployment.SPIncludeVersions.All;

Microsoft.SharePoint.Deployment.SPExport export = new Microsoft.SharePoint.Deployment.SPExport(exportSettings);

Console.WriteLine(“Starting export of URL {0}”, siteURL);

export.Run();

return exportSettings.FileLocation + “\\” + exportSettings.BaseFileName;

}

 
 

static
void Import(string siteURL, string fileToImport)

{

Microsoft.SharePoint.Deployment.SPImportSettings importSettings = new Microsoft.SharePoint.Deployment.SPImportSettings();

 
 

importSettings.BaseFileName = System.IO.Path.GetFileName(fileToImport);

importSettings.FileLocation = System.IO.Path.GetDirectoryName(fileToImport);

importSettings.CommandLineVerbose = true;

importSettings.SiteUrl = siteURL;

importSettings.RetainObjectIdentity = true;

importSettings.IncludeSecurity = Microsoft.SharePoint.Deployment.SPIncludeSecurity.All;

importSettings.UpdateVersions = Microsoft.SharePoint.Deployment.SPUpdateVersions.Append;

importSettings.UserInfoDateTime = Microsoft.SharePoint.Deployment.SPImportUserInfoDateTimeOption.ImportAll;

Microsoft.SharePoint.Deployment.SPImport import = new Microsoft.SharePoint.Deployment.SPImport(importSettings);

Console.WriteLine(“Starting import to URL {0}”, siteURL);

import.Run();

}

 
 

}

}

Extending VariationRoot.aspx Redirection in SharePoint

Some code used to extend variation redirection logic based on a preferred locale setting in the users profile. If the property is not present or blank it falls back to default variations logic. A locale picker to set this value will be posted soon.

 
 

using System;

using Microsoft.SharePoint;

using CCE.SharePoint.UserControls;

using CCE.SharePoint.Utility;

using Microsoft.Office.Server.UserProfiles;

using Microsoft.SharePoint.Utilities;

 
 

namespace CCE.SharePoint.UserControls

{

public class VariationsRootLanding : CCEBaseUserControl

{

 
 

protected override void OnLoad(EventArgs e)

{

string targetUrl = this.GetRedirectTargetUrl();

 

if (!string.IsNullOrEmpty(targetUrl))

{

SPUtility.Redirect(targetUrl, SPRedirectFlags.Default, Context);

}

else

{

SPUtility.Redirect(“VariationRoot.aspx”, SPRedirectFlags.Default, Context);

}

}

 
 

private string GetRedirectTargetUrl()

{

String url = “”;

 
 

try

{

String loginName = SPContext.Current.Web.CurrentUser.LoginName;

 
 

UserProfile currentUserProfile = Utility.UserProfiles.GetUserProfile(loginName);

String preferredLocale = Utility.UserProfiles.GetSinglePropertyValue(currentUserProfile, “preferredLocale”);

 
 

using (SPSite _SPSite = new SPSite(SPContext.Current.Site.ID))

{

using (SPWeb rootWeb = _SPSite.RootWeb)

{

foreach (SPWeb subWeb in rootWeb.Webs)

{

if (subWeb.Locale.ToString() == preferredLocale)

{

url = “/” + subWeb.Name;

}

}

}

}

}

catch (Exception)

{

//Log error

}

 
 

return url;

}

}

}