2010-07-29
Projected Fields with User Profile Properties in Sharepoint 2010
What i eventually had to do in SharePoint 2007, was kind of hacky, and really annoying to implement. Say if the user wanted the Office to be displayed in each row, i would create the Office field in the list definition as a Person field. Then make an event receiver, that on ItemAdding, would update the Office field to be the same user in the normal Person field, but instead of displaying the Name, i would display the user profile field that the stakeholder wanted.
So with multiple columns, i would end up with something like this:
[image]
But with SharePoint 2010 this problem goes away. Enter list joins and projected fields. What this allows is having one list, and showing value from a joined list. Things did not go as smoothly as i hoped though.
So i went into the column create screens and cycled through the different field types. I was disappointed that the person field did not have what i wanted. Only the lookup field type had the projected fields. Well i could live with that, but it would not be the ideal solution. Because you would not be able to make use of the people picker, it would just be a very large dropdown.
But when i went to assign the lookup table to the hidden "User Information List", well, it was hidden. This list if you dont know, holds a copy of the user profile fields marked as replicatable. Sharepoint takes care of keeping it in sync with the values in the SSP or Application Service.
I suspected that while it was hidden, i could still make the join, just not through the interface. So i went hunting from some scripts, preferably powershell to create this projected fields. I found them on msdn, and it looked pretty straight forward. It got me thinking.
Hang on though, a person field is just a lookup field, so i could go back to my orignial plan of joining the custom list to the "User Information List", but using a Person field instead of a lookup.
To my shock, everything work out as i had hoped for since the start. Effectively i have reduced a days work of hassle and deployment, to a few lines of powershell.
Scripts and screen shots to come later.
2007-09-13
Enabled / Disable Network Adapter with Powershell
But unfortunately the easy way only works on Vista, and i needed it in Windows Server 2003. http://blogs.msdn.com/daiken/archive/2007/02/09/enable-disable-network-connection.aspx
I had to go digging around for how you used to have to enable the connection with wsf. http://mcpmag.com/columns/article.asp?EditorialsID=619
And then converted it into something i could use in powershell.
$shell = New-Object -comObject Shell.Application
((($shell.NameSpace(3).Items() | where {$_.Name -eq "Network Connections"}).GetFolder.Items() | where {$_.Name -eq "Local Area Connection"}).Verbs() | where {$_.Name -eq "En&able"}).DoIt()
And to disable.
$shell = New-Object -comObject Shell.Application
At must have had at least 30 tabs open in my browser by the time i got this to work.
2006-12-19
Is DTS dead?
http://msdn2.microsoft.com/en-us/library/ms141026.aspx
But i did find some links about how to create a basic DTS file, possibly that could be run from the command line.
http://www.15seconds.com/Issue/030909.htm
And then what files i would need on the running server
http://www.sqldts.com/default.aspx?225
Webservice Envelope Validation
I have got a extension that just logs soap packets, so its not too hard to plug the validator into that.
ASP.NET 1.1 and 2.0 Working Together
SVN Externals No Good
http://www.brunningonline.net/simon/blog/archives/002031.html
http://svn.haxx.se/dev/archive-2003-07/1617.shtml
A few other people tend to agree, or have found the smae problems that i have.
Its just a nightmare to try and manage them.
I'm actually starting to think that no software configuration information should be stored in the svn repository and that should be maintain by an outside program.
More Automated Software Process
There is maven and lunt build, but both are written in java. And i think they are more similar to cc.net then the linked tool.
If i can't find one written in .net, i might have to build one. A little bit of effort here saves both time and hassel in the future thats for sure.
Server backgrounds
SQL XML Not Required
var objConn = new ActiveXObject("ADODB.Connection");
//Provider=SQLXMLOLEDB.3.0;Data Provider=SQLOLEDB
var objComm = new ActiveXObject("ADODB.Command")
objComm.ActiveConnection = objConn
objComm.CommandText = tSQL
var objStream = new ActiveXObject("ADODB.Stream")
objStream.Open()
objComm.Properties("Output Stream") = objStream
objComm.Execute(null, null, 0x400)
objStream.Position = 0
This turns out not to be the case, you can use this as the connection string:
//Provider=SQLOLEDB;Data Provider=SQLOLEDB
And then you dont need to install the extra component, good for shared hosting!
Handling Nulls in Webservices
So this was where if nulls are passed into a .net 2.0 webservice, then the elements are removed from the soap envelope that is sent.
2006-10-08
Accessing Session in HttpApplication
public class global : System.Web.HttpApplication {
void Application_PreRequestHandlerExecute(object sender, EventArgs e) {
if(User.Identity.IsAuthenticated) {
if(Session != null) {
}
if(Context.Session != null) {
}
}
}
}
The first access to the Session throws this exception:
Session state is not available in this context.
But the second one succeeds, i assume that they would both be accessing the same underlying object. Weird.
2006-09-27
Spring.Net Schema
2006-09-25
Mem Usage vs VM Size
When viewing my task manager, I always make sure that the VM Size column is turned on. This shows the actual memory footprint that the process has, rather than what is currently taken. For instance, if you minimise an application, usually the Mem Usage column will drop, but the VM Size doesnt. Though it didnt matter with my memory leak program, both the numbers filled all my available ram.
Design Time Master Page
GC.Collect not the solution
Many times i have come to situations where the memory usage in my program spirals out of control. Always i think it is a problem with anything but my program. I test the cleanups of the 3rd party libraries, and every other little thing. Then i resort to put GC.Collect statements around, thinky that it will magically free memory.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Then i go searching for how to debug these things:
http://blogs.msdn.com/tess/archive/2006/09/06/742568.aspx
http://blogs.msdn.com/tess/archive/2006/08/11/695268.aspx
Finally i get stuck into reviewing my code with a fine tooth comb, and find one thing that was causing the leak, static array on a singleton, used in temporary processing, that didnt get cleared.
2006-09-23
HttpContext Items Strongly Typed
public abstract class AbstractObjectCacher<T> {
#region IoC
private IObjectCache<T> cache;
public IObjectCache<T> Cache {
set { cache = value; }
get { return cache; }
}
#endregion
public T Get() {
return cache.Get();
}
public void Set(T obj) {
cache.Set(obj);
}
public void Dispose() {
T obj = Get();
if(obj != null) {
Set(default(T));
if(obj is IDisposable) {
((IDisposable)obj).Dispose();
}
obj = default(T);
}
cache.Clear();
}
}
So for instance, the thread store i use for unit testing will look like this:
public class ThreadObjectCache<T> : IObjectCache<T> {
#region IoC
private string key;
public string Key {
set {
key = value;
ThreadStore.Initialise(key);
}
get { return key; }
}
#endregion
public T Get() {
return (T)ThreadStore.Get(key);
}
public void Set(T obj) {
ThreadStore.Set(key, obj);
}
public void Clear() {
ThreadStore.Set(key, null);
}
public void Dispose() {
ThreadStore.Dispose(key);
}
}
And the HttpContext store will look like this:
public class HttpContextCache<T> : IObjectCache<T> {
#region IoC
private string key;
public string Key {
set { key = value; }
get { return key; }
}
#endregion
public T Get() {
return (T)HttpContext.Current.Items[key];
}
public void Set(T obj) {
HttpContext.Current.Items[key] = obj;
}
public void Clear() {
HttpContext.Current.Items[key] = null;
}
public void Dispose() {
HttpContext.Current.Items.Remove(key);
}
}
2006-09-20
Changes are not allowed while code is running

Notice the lock icon next to the filename, showing its read only.
This is a feature of VS that allows you to change the code and continue running with the modified code.
It seems to be only useful for desktop applications, not web apps that we develop.
We know that if we change code in the binary then we will need to recompile anyway, so how do we turn off this annoying message.
To remove the message, turn off Edit and Continue by:
Going to options

Go to Debugging, Edit and Continue and uncheck the top box

By turning off Edit and Continue, you still can create and remove debug points why the process is paused.
And you can still edit aspx’s, ascx’s, and their code besides (in the web application) without problems.
db4o 5.7
2006-09-19
Updating Atlas
The other issue i had was i was gettting a debugger alert client side about
PageRequestManagerID not being an attribute on draggablelistitem. This is a custom drag item i have implemented, so i just went digging through AtlasControlToolkit and found something similar to what i wanted to do DragPanelProperties and it has go this code:
[EditorBrowsable(EditorBrowsableState.Never),
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string PageRequestManagerID {
get { return null; }
set { throw new NotImplementedException(); }
}
So i just copied that into mine, and things worked. Its weird that there is no need to have the "new" keyword on this method. And why didnt it work in the first place.