AWG Blogs

Thursday, August 23, 2012

Add Change Order Action Menu Item

By default only the Links list type has this menu item in SharePoint 2007. It can be added to any other list though through the web services API, specifically updating the "Ordered" field property to True. See http://msdn.microsoft.com/en-us/library/lists.lists.updatelist(v=office.12)

Once that's done, just edit the View properties (including the anonymous views from any web parts) and set "Allow users to order items in this view." Doing so will change the order shown to that of the built-in Ordered lists property, which is what is updated via the (now shown) Change Order action menu for the view.

Here is an adapted sample console app:

class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Property Editor - v.0.1");
            Console.WriteLine("Enter the URL of the Lists web service");
            string url = Console.ReadLine();
            Console.WriteLine("Enter the Display name of your list, e.g. My List");
            string listname = Console.ReadLine();
            Console.WriteLine("Enter the list property (e.g. Ordered)");
            string property = Console.ReadLine();
            Console.WriteLine("Enter the property value (e.g. TRUE)");
            string propertyValue = Console.ReadLine();

            Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
            listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
            listService.Url = url;

            XmlDocument xmlDoc = new System.Xml.XmlDocument();

            XmlNode ndProperties = xmlDoc.CreateNode(XmlNodeType.Element, "List", 
                "");

            XmlAttribute ndOtherAttrib =
                (XmlAttribute)xmlDoc.CreateNode(XmlNodeType.Attribute,
                property, "");
            ndOtherAttrib.Value = propertyValue;
            ndProperties.Attributes.Append(ndOtherAttrib);

            try
            {
                XmlNode ndReturn =
                    listService.UpdateList(listname, 
                    ndProperties, null, null, null, 
                    null);

                Console.WriteLine(ndReturn.OuterXml);
            }

            catch (Exception ex)
            {
                Console.WriteLine("Message:\n" + ex.Message + "\nStackTrace:\n" + 
                    ex.StackTrace);
            }
            Console.ReadLine();
        }
    }

Saturday, August 18, 2012

Compiling MD5summer in XE2

- Download md5summer.tar.gz from http://md5summer.cvs.sourceforge.net/md5summer/ and extract all
  - Alternately get source (v1.2.0.05) from http://md5summer.cvs.sourceforge.net/viewvc/md5summer/md5summer/Source/
- Download tpshellshock_1_02_2011-09-08.zip from http://sourceforge.net/projects/tpshellshock/
- Perform installation of ShellShock per the readme.txt, i.e.
  - add the tpshellshock_1_02_2011-09-08\source directory to XE2's Tools Options, Delphi Options, Library Path
  - open .packages\Delphi XE2\ShellShock Delphi XE2.groupproj in Delphi XE2
  - Right click on K102_R160.bpl and compile
  - Right click on K102_D160.bpl and install
- If reopening IDE, may need to do Component, Install Packages, then add
c:\Users\Public\Documents\RAD Studio\9.0\Bpl\K102_D160.bpl
- Download and install the author's components at http://luke.pascoe.net.nz/tools.html ; also add library ref.
- Open md5summer.dpr to load project
- Compile and run

Note, if you choose not to install the author's components, you will need to make a few edits:
- To remove About components functionality
  - open u_About.pas and edit code: remove or delete all references to "Maze" and "Rect"
  - right click (RC) md5summer.exe and View Source, then comment out Application.CreateForm(TAbout, About)
- Open u_DoMD5s.pas and comment out these lines:
  - BatchGauge: TGauge;
  - FileGauge: TGauge;
  - Remove "Guage" from uses
- Open u_DoMD5s.dfm
  - drag two TGauge's from Samples in the Tool Palette to the form under Batch and File labels
  - name the top one BatchGauge and the bottom one FileGauge
- in u_DoMD5s.pas, search and replace all "Gauge.Position" with "Gauge.Progess"




Thursday, August 2, 2012

Logic for Viewing 2D Data in 3D

 Logic for Viewing 2D Data in 3D
Do with groupings of a unit (grouping function g) as x axis and observee in y axis. (Note: the fourth dimension would be grouping of groupings, i.e. higher order grouping functions as possible inputs.) Cell(x,y) equals the function of data items h(f(),g(),v,t(y,z,w) where y=y1) -- in our case, given y1 and grouping function g, lookup z for record that matches f(g(w)) -- below, for y1=observee1, 1.1 and 1.2 could be grouped into group with key v=1, i.e. g(v,t)={1.1,1.2}, then f(g(v,t))= max of {1.1,1.2} or 1.2, so return value is b == cell(x,y)

sample data:
(y)                (z)   (w)
observee1     a     1.1
observee1     b     1.2
observee1     c     2.1
observee2     a     2.1
observee2     a     1.1

Friday, July 6, 2012

"Specified view is invalid" error when transferring .webpart

I couldn't figure out why SharePoint would produce ASP.NET error when importing a previously exported .webpart. The quick way to resolve it is to remove the ViewFlag element or set it to 0 in the .webpart file. But I found that when I do this the web part does not set ctx values, such as httpvdir. One workaround is to use Server variables rather than CAML variables in the .webpart's ParameterBinding value. I could also open the page in SPD, and make a minor change and save it, which fixes the problem. But I still need to determine what is causing the issue. (BTW, what does ViewFlag, or its absence, have to do with the issue, and what do the ViewFlag values mean anyways? No-one knows apparently).

I finally reproduced the issue in a simple case:
In SourceSiteCol, create a plain doc library and set ContentTypesEnabled to true ("Allow management of content types").
Save as list template. Copy this to DestSiteCol List template gallery.
On DestSiteCol subsite, create a list based on the uploaded list template.
In a web part page on this subsite, add a ListViewWebPart based on the created list. In SPD, convert it to a DataFormWebPart.
Export it as a .webpart. Then import into another web part page on the same site; the error occurs. Disabling Content type management for the created list makes the error go away. So the problem has something to do with Content Types...

At any rate, when transferring lists and their web parts to other sites, can edit the .webpart as follows:
Look for SelectParameters and change the Parameter with ListID to have ListName, and set its DefaultValue to the current display name of the target list (note, if the display name changes, your web part will break, and you'll have to fix the name in the XSLT).
Remove the  Update, Insert, and Delete params see (http://blogs.msdn.com/b/joshuag/archive/2008/11/10/easily-making-the-data-form-web-part-reusable.aspx).
Set TitleUrl property to the URL of the default view
Set the Title property to the intended title of the web part

Friday, June 15, 2012

Biological Architecture of Software Applications

Organs communicate through the medium of interstitial fluids, i.e. the environment of the body. The sun communicates with the open system of Planet Earth through an environment of space. When you look around self-sustaining systems communicate through indirect mediums. Why should software architecture be any different?

The easiest-to-develop and most self-sustaining software is done, I propose, through a combination of the Observer design pattern and Environments. These Environments are the Observables that trigger events whenever properties are set; Observers (like cells and enzymes) subscribe to those property initializations of interest and may set further properties on their Environment. Environments may subscribe to the property change events of other Environments and so forth. This is a more natural way to design implement software. DCI on steroids if you will. Makes DDD look rather stodgy by comparison....

Monday, May 21, 2012

Secondary Lookup Column in SP2007?

There's UI support in 2010

Stefan Stanev found out it's possible to rig SP2007 to do the same thing, sort of (see http://stefan-stanev-sharepoint-blog.blogspot.com/2010/11/sharepoint-2007-associated-lookup.html).

The catch is deleting the field will give error Exception calling "Delete" with "0" argument(s): "One or more field types are not installed properly. Go to the list settings page to delete these fields."

I noticed you get the same error if attempting to delete Created_x0020_Date once AllowDeletion is set to True. So it appears the issue is widespread with regard to lookup columns that contain the FieldRef attribute.

My only concern is what happens when upgrade occurs.

Monday, April 30, 2012

Middleman Pattern

The DCI paradigm, specifically the canonical example of the account transfer seems unnatural. If I'm not mistaken, in most business domains the act of transferring resources between entities is performed by a middleman entity. Behavior is no more injected into entities than are entry-level checking account clerks trained on the spot to make transfers to investment accounts (imagine this is a bank in the pre-computing days).

So I propose the "Middleman Pattern." The following is an example. Note: the example could be abstracted in that concrete classes could be decoupled via interface implementation and dependency injection.



Edit: See also suggestion of "money transferrer" at http://pettermahlen.com/2010/09/10/dci-architecture-good-not-great-or-both/