/// <summary>
        /// Initializes the control, this looks to see if the Binding Object type is of type IOrderableBaseInfo and IBindingBaseInfo
        /// </summary>
        public override void OnInit()
        {
            if (!string.IsNullOrWhiteSpace(BindingObjectType))
            {
                // Get the Binding and base Object so we can detect if they are orderable or not.
                var BindingObjectFactory   = new InfoObjectFactory(BindingObjectType);
                var BindingObjectSingleton = (BindingObjectFactory != null && BindingObjectFactory.Singleton != null ? BindingObjectFactory.Singleton : null);

                var ObjectFactory   = new InfoObjectFactory(ObjectType);
                var ObjectSingleton = (ObjectFactory != null && ObjectFactory.Singleton != null ? ObjectFactory.Singleton : null);

                if (BindingObjectSingleton != null && ObjectSingleton != null && BindingObjectSingleton is IOrderableBaseInfo && BindingObjectSingleton is IBindingBaseInfo)
                {
                    // Set the new Grid with actions
                    Control.GridName         = "~/CMSModules/RelationshipsExtended/Grids/ControlItemList.xml";
                    Control.UniGrid.GridName = "~/CMSModules/RelationshipsExtended/Grids/ControlItemList.xml";
                    Control.UniGrid.LoadXmlConfiguration();

                    // Add the ordering to the DataSet's Table, then use a TableView to order by that.  Hacky but works.
                    Control.UniGrid.OnAfterRetrieveData += UniGrid_OnAfterRetrieveData;
                    // Ensures that it retrieves all the rows found so it can order them manually
                    Control.UniGrid.ApplyPageSize = false;

                    // Ensure no sorting.
                    if (Control.UniGrid.GridOptions == null)
                    {
                        Control.UniGrid.GridOptions = new UniGridOptions();
                    }
                    Control.UniGrid.GridOptions.AllowSorting = false;

                    // Catch the Move events
                    Control.UniGrid.OnAction += UniGrid_OnAction;

                    // Get ColumnID of Object it's referencing for the Grid Actions at various points in the rendering, since this seems to get lost frequently.
                    SetActions();
                    Control.UniGrid.PreRender         += UniGrid_PreRender;
                    Control.UniGrid.Load              += UniGrid_Load;
                    Control.UniGrid.OnAfterDataReload += UniGrid_OnAfterDataReload;

                    // Setup Field and Script for Move command.
                    AddCustomMoveHiddenField();
                    RegisterCmdScripts();

                    // Handle current page and size if in URL parameter
                    if (!Control.Page.IsPostBack && !string.IsNullOrWhiteSpace(URLHelper.GetUrlParameter(RequestContext.RawURL, "OrderableUniPage")))
                    {
                        int CurrentPage     = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(RequestContext.RawURL, "OrderableUniPage"), 1);
                        int CurrentPageSize = ValidationHelper.GetInteger(URLHelper.GetUrlParameter(RequestContext.RawURL, "OrderableUniPageSize"), -1);
                        if (Control.UniGrid.Pager != null)
                        {
                            Control.UniGrid.Pager.CurrentPage = CurrentPage;
                            if (CurrentPageSize > 0)
                            {
                                Control.UniGrid.Pager.CurrentPageSize = CurrentPageSize;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// If actions exist, make sure the Command Argument is set to the Object's ID Column Name so it properly renders the ID value
        /// </summary>
        private void SetActions()
        {
            if (Control.UniGrid.GridActions != null)
            {
                var ObjectFactory   = new InfoObjectFactory(ObjectType);
                var ObjectSingleton = (ObjectFactory != null && ObjectFactory.Singleton != null ? ObjectFactory.Singleton : null);

                Control.UniGrid.GridActions.Parameters = ((BaseInfo)ObjectSingleton).TypeInfo.IDColumn;
                foreach (Action action in Control.UniGrid.GridActions.Actions)
                {
                    action.CommandArgument = ((BaseInfo)ObjectSingleton).TypeInfo.IDColumn;
                }
            }
        }
    /// <summary>
    /// Figure out using the Join Table which categories need to be removed and which added
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void SaveToJoinTable()
    {
        SetPossibleAndSelectedCategories();

        // Do check of min/max here
        if (MinimumCategories > 0 && SelectedCategories.Count() < MinimumCategories)
        {
            AddError("Must select at least " + MinimumCategories + " " + (MinimumCategories == 1 ? "category" : "categories"));
            return;
        }
        if (MaximumCategories > 0 && SelectedCategories.Count() > MaximumCategories)
        {
            AddError("Can select no more than " + MaximumCategories + " " + (MaximumCategories == 1 ? "category" : "categories"));
            return;
        }

        // filter with only the possible categories
        DataClassInfo JoinTableClassInfo = DataClassInfoProvider.GetDataClassInfo(JoinTableName);

        if (JoinTableClassInfo != null)
        {
            List <int> DocumentCategoryIds = new List <int>();

            // Get all the categories the current entity has
            int          totalRecords        = 0;
            var          currentCategoriesDS = ConnectionHelper.ExecuteQuery(JoinTableName + ".selectall", null, string.Format("{0} = '{1}'", JoinTableLeftFieldName, CurrentItemIdentification), null, -1, null, -1, -1, ref totalRecords);
            CategoryInfo catObject           = null;
            string       FieldSaveColumnName = "";
            // Convert to CategoryID
            switch (FieldSaveModeVal)
            {
            case FieldSaveType.ID:
                FieldSaveColumnName = "CategoryID";
                break;

            case FieldSaveType.GUID:
                FieldSaveColumnName = "CategoryGUID";
                break;

            case FieldSaveType.CategoryName:
                FieldSaveColumnName = "CategoryName";
                break;
            }

            foreach (DataRow dr in currentCategoriesDS.Tables[0].Rows)
            {
                // Convert to CategoryID
                switch (FieldSaveModeVal)
                {
                case FieldSaveType.ID:
                    catObject = CategoryInfo.Provider.Get(ValidationHelper.GetInteger(dr[JoinTableRightFieldName], 0));
                    if (catObject != null)
                    {
                        DocumentCategoryIds.Add(catObject.CategoryID);
                    }
                    break;

                case FieldSaveType.GUID:
                    var ClassObject = CategoryInfo.Provider.Get().WhereEquals("CategoryGUID", ValidationHelper.GetGuid(dr[JoinTableRightFieldName], new Guid())).FirstOrDefault();
                    if (ClassObject != null)
                    {
                        DocumentCategoryIds.Add(ValidationHelper.GetInteger(ClassObject["CategoryID"], 0));
                    }
                    break;

                case FieldSaveType.CategoryName:
                    catObject = CategoryInfo.Provider.Get(ValidationHelper.GetString(dr[JoinTableRightFieldName], ""), SiteContext.CurrentSiteID);
                    if (catObject != null)
                    {
                        DocumentCategoryIds.Add(catObject.CategoryID);
                    }
                    break;
                }
            }

            // Find IDs we need to add and remove.
            List <int> NotSelectedIds = PossibleCategoryIDs.Except(SelectedCategoryIDs).ToList();
            List <int> DeselectIds    = DocumentCategoryIds.Intersect(NotSelectedIds).ToList();
            List <int> SelectIds      = SelectedCategoryIDs.Except(DocumentCategoryIds).ToList();

            if (DeselectIds.Count > 0)
            {
                foreach (int DeselectId in DeselectIds)
                {
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItemProvider.GetItems(JoinTableClassInfo.ClassName).WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, CategoryInfo.Provider.Get(DeselectId).GetValue(FieldSaveColumnName))
                        .ToList().ForEach(x => ((CustomTableItem)x).Delete());
                    }
                    else
                    {
                        new ObjectQuery(JoinTableClassInfo.ClassName)
                        .WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, CategoryInfo.Provider.Get(DeselectId).GetValue(FieldSaveColumnName))
                        .ToList().ForEach(x => x.Delete());
                    }
                }
            }
            if (SelectIds.Count > 0)
            {
                foreach (int SelectId in SelectIds)
                {
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItem newCustomTableItem = CustomTableItem.New(JoinTableName);
                        SetBaseInfoItemValues(newCustomTableItem, CategoryInfo.Provider.Get(SelectId).GetValue(FieldSaveColumnName), JoinTableClassInfo.ClassName);
                        InsertObjectHandler(newCustomTableItem);
                    }
                    else
                    {
                        // Create a dynamic BaseInfo object of the right type.
                        var JoinTableClassFactory = new InfoObjectFactory(JoinTableClassInfo.ClassName);
                        if (JoinTableClassFactory.Singleton == null)
                        {
                            AddError("Class does not have TypeInfo and TypeInfoProvider generated.  Must generate " + JoinTableClassInfo.ClassName + " Code before can bind.");
                            return;
                        }
                        BaseInfo newJoinObj = ((BaseInfo)JoinTableClassFactory.Singleton);
                        SetBaseInfoItemValues(newJoinObj, CategoryInfo.Provider.Get(SelectId).GetValue(FieldSaveColumnName), JoinTableClassInfo.ClassName);
                        InsertObjectHandler(newJoinObj);
                    }
                }
            }

            AddConfirmation(string.Format("{0} Categories Added, {1} Categories Removed.", SelectIds.Count, DeselectIds.Count));
        }
    }
        /// <summary>
        /// Since the normal Binding UniGrid only shows a summary of the Object that is bound, it does nto have the built in
        /// Order that would be on the Binding Object.  So I'm programatically adding on an Order Column, then returning the
        /// Items in that order using a Table View.
        /// </summary>
        /// <param name="ds">The Dataset</param>
        /// <returns>The ordered data set</returns>
        private DataSet UniGrid_OnAfterRetrieveData(DataSet ds)
        {
            // Get the object and binding object's information (typeinfo) and their referencing column names.
            var BindingObjectFactory   = new InfoObjectFactory(BindingObjectType);
            var BindingObjectSingleton = (BindingObjectFactory != null && BindingObjectFactory.Singleton != null ? BindingObjectFactory.Singleton : null);

            var ObjectFactory   = new InfoObjectFactory(ObjectType);
            var ObjectSingleton = (ObjectFactory != null && ObjectFactory.Singleton != null ? ObjectFactory.Singleton : null);

            string ParentObjectReference = ((IBindingBaseInfo)BindingObjectSingleton).ParentObjectReferenceColumnName();
            string BoundObjectReference  = ((IBindingBaseInfo)BindingObjectSingleton).BoundObjectReferenceColumnName();
            string ObjectIDColumn        = ((BaseInfo)ObjectSingleton).TypeInfo.IDColumn;
            string OrderColumn           = ((BaseInfo)BindingObjectSingleton).TypeInfo.OrderColumn;
            string DisplayNameColumn     = ((BaseInfo)BindingObjectSingleton).TypeInfo.DisplayNameColumn;

            // Just sort the data by the order
            if (!ds.Tables[0].Columns.Contains("OrderableObjectUniSelector_Order"))
            {
                ds.Tables[0].Columns.Add("OrderableObjectUniSelector_Order", typeof(int));
            }

            // Go through each entry and find the proper Order and assign it.
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                var OrderItem = new ObjectQuery(BindingObjectType)
                                .WhereEquals(ParentObjectReference, CorrectObjectID)
                                .WhereEquals(BoundObjectReference, dr[ObjectIDColumn])
                                .FirstOrDefault();
                if (OrderItem != null)
                {
                    dr["OrderableObjectUniSelector_Order"] = ValidationHelper.GetInteger(OrderItem.GetValue(OrderColumn), 0);
                }
                else
                {
                    dr["OrderableObjectUniSelector_Order"] = 999999999;
                }
            }

            // Sort by the Order and return the new table, now sorted properly.
            DataView DV = new DataView(ds.Tables[0]);

            DV.Sort = "[OrderableObjectUniSelector_Order] asc";
            DataTable dt = DV.ToTable();

            // Now that the items are ordered, we need to limit the results to the Page and Page Size
            // Get the current Page and page size, adjusting if that page no longer exists due to record deletion
            int PageSize    = 10;
            int CurrentPage = 1;

            if (Control.UniGrid.Pager != null)
            {
                PageSize    = Control.UniGrid.Pager.CurrentPageSize;
                CurrentPage = Control.UniGrid.Pager.CurrentPage;
            }
            DataTable newDT = dt.Clone();

            if (dt.Rows.Count > 0)
            {
                while (CurrentPage > 1 && dt.Rows.Count <= (CurrentPage - 1) * PageSize)
                {
                    CurrentPage--;
                }
            }
            // This event triggers twice, once on the full data, and once on the page-only data.  If page-only data, do NOT reset the page (unless the count is 0)
            if (Control.UniGrid.Pager != null && (ds.Tables[0].Rows.Count == Control.UniGrid.PagerForceNumberOfResults || ds.Tables[0].Rows.Count == 0))
            {
                Control.UniGrid.Pager.CurrentPage = CurrentPage;
            }

            // Now remove any records that are not in the current page
            int LowerBound = (CurrentPage - 1) * PageSize;
            int UpperBound = LowerBound + PageSize;

            for (int r = 0; r < dt.Rows.Count; r++)
            {
                if (r >= LowerBound && r < UpperBound)
                {
                    newDT.ImportRow(dt.Rows[r]);
                }
            }

            // Lastly add this new sorted and 'trimmed' table to the results.
            ds.Tables.Remove(ds.Tables[0]);
            ds.Tables.Add(newDT);
            return(ds);
        }
        /// <summary>
        /// Handles the Grid Actions, sadly can't use the default #move #moveup and #movedown because this is technically displaying the Object, not the binding object.
        /// </summary>
        /// <param name="actionName"></param>
        /// <param name="actionArgument"></param>
        private void UniGrid_OnAction(string actionName, object actionArgument)
        {
            var BindingObjectFactory   = new InfoObjectFactory(BindingObjectType);
            var BindingObjectSingleton = BindingObjectFactory.Singleton;
            var BindingObj             = new ObjectQuery(BindingObjectType)
                                         .WhereEquals(((IBindingBaseInfo)BindingObjectSingleton).ParentObjectReferenceColumnName(), CorrectObjectID)
                                         .WhereEquals(((IBindingBaseInfo)BindingObjectSingleton).BoundObjectReferenceColumnName(), actionArgument).FirstOrDefault();

            var ObjectFactory   = new InfoObjectFactory(ObjectType);
            var ObjectSingleton = (ObjectFactory != null && ObjectFactory.Singleton != null ? ObjectFactory.Singleton : null);

            bool RefreshData = false;

            switch (actionName)
            {
            case "custom_move":
                // Get Custom Move Hidden Field value
                foreach (HiddenField hidField in GetControlsOfType <HiddenField>(Control.UniGrid))
                {
                    if (hidField.ID == "hdnCustomMoveArgs")
                    {
                        string[] Values = hidField.Value.Split(':');
                        if (Values.Length == 3)
                        {
                            int ObjectID     = ValidationHelper.GetInteger(Values[0], 0);
                            int OrigPosition = ValidationHelper.GetInteger(Values[1], 0);
                            int NewPosition  = ValidationHelper.GetInteger(Values[2], 0);
                            BindingObj = new ObjectQuery(BindingObjectType)
                                         .WhereEquals(((IBindingBaseInfo)BindingObjectSingleton).ParentObjectReferenceColumnName(), CorrectObjectID)
                                         .WhereEquals(((IBindingBaseInfo)BindingObjectSingleton).BoundObjectReferenceColumnName(), ObjectID).FirstOrDefault();
                            ((IOrderableBaseInfo)BindingObj).SetObjectOrderRelative(NewPosition - OrigPosition);
                        }
                    }
                }
                break;

            case "custom_moveup":
                ((IOrderableBaseInfo)BindingObj).MoveObjectUp();
                try
                {
                    // If the current item is the "first" item on the current page, refresh as it may now be on another page
                    var UpRows = ((DataSet)Control.UniGrid.DataSource).Tables[0].Rows;
                    if (ValidationHelper.GetInteger(UpRows[0][((BaseInfo)ObjectSingleton).TypeInfo.IDColumn], -1) == ValidationHelper.GetInteger(actionArgument, -1))
                    {
                        RefreshData = true;
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("OrderableBindingEditorUniSelectorExtender", "ActionRefreshError", ex, additionalMessage: "Something went wrong trying to detect if binding UI should be refreshed, please ensure both Binding Object and Bound Object types are properly set.");
                }
                break;

            case "custom_movedown":
                ((IOrderableBaseInfo)BindingObj).MoveObjectDown();
                try
                {
                    // If the current item is the "last" item on the current page, refresh as it may now be on another page
                    var DownRows = ((DataSet)Control.UniGrid.DataSource).Tables[0].Rows;
                    if (ValidationHelper.GetInteger(DownRows[DownRows.Count - 1][((BaseInfo)ObjectSingleton).TypeInfo.IDColumn], -1) == ValidationHelper.GetInteger(actionArgument, -1))
                    {
                        RefreshData = true;
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("OrderableBindingEditorUniSelectorExtender", "ActionRefreshError", ex, additionalMessage: "Something went wrong trying to detect if binding UI should be refreshed, please ensure both Binding Object and Bound Object types are properly set.");
                }
                break;
            }

            // If an element is moved off the current page, the grid needs to be refreshed, and the only way to seem to get the UI to update is to totally refresh the page
            if (RefreshData)
            {
                string Url = RequestContext.RawURL;
                if (Control.UniGrid.Pager != null)
                {
                    int CurrentPage     = Control.UniGrid.Pager.CurrentPage;
                    int CurrentPageSize = Control.UniGrid.Pager.CurrentPageSize;
                    Url = URLHelper.AddParameterToUrl(Url, "OrderableUniPage", CurrentPage.ToString());
                    Url = URLHelper.AddParameterToUrl(Url, "OrderableUniPageSize", CurrentPageSize.ToString());
                }
                URLHelper.ResponseRedirect(Url, true);
            }
        }
    /// <summary>
    /// Figure out using the Join Table which categories need to be removed and which added
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Form_OnAfterSaveJoinTable(object sender, EventArgs e)
    {
        //dont save data for filter forms
        if (sender is CMS.FormEngine.Web.UI.FilterForm)
        {
            return;
        }

        // Add key so it will load the new data even though it is a 'postback' after this.
        DataClassInfo JoinTableClassInfo = DataClassInfoProvider.GetDataClassInfo(JoinTableName);

        if (JoinTableClassInfo != null)
        {
            List <string> SelectedObjectRefIDs = GetSelectedObjects();
            List <string> CurrentObjectRefIDs  = GetCurrentObjects();

            List <string> ObjectsToAdd    = SelectedObjectRefIDs.Where(x => !CurrentObjectRefIDs.Contains(x)).ToList();
            List <string> ObjectsToRemove = CurrentObjectRefIDs.Where(x => !SelectedObjectRefIDs.Contains(x)).ToList();

            if (ObjectsToAdd.Count > 0)
            {
                foreach (string ObjectToAdd in ObjectsToAdd)
                {
                    // Custom Tables
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItem newCustomTableItem = CustomTableItem.New(JoinTableName);
                        SetBaseInfoItemValues(newCustomTableItem, GetProperObjectValue(ObjectToAdd), JoinTableClassInfo.ClassName);
                        newCustomTableItem.Insert();
                    }
                    else
                    {
                        // Create a dynamic BaseInfo object of the right type.
                        var JoinTableClassFactory = new InfoObjectFactory(JoinTableClassInfo.ClassName);
                        if (JoinTableClassFactory.Singleton == null)
                        {
                            AddError("Class does not have TypeInfo and TypeInfoProvider generated.  Must generate " + JoinTableClassInfo.ClassName + " Code before can bind.");
                            return;
                        }
                        BaseInfo newJoinObj = ((BaseInfo)JoinTableClassFactory.Singleton);
                        SetBaseInfoItemValues(newJoinObj, GetProperObjectValue(ObjectToAdd), JoinTableClassInfo.ClassName);
                        InsertObjectHandler(newJoinObj);
                    }
                }
            }
            if (ObjectsToRemove.Count > 0)
            {
                foreach (string ObjectToRemove in ObjectsToRemove)
                {
                    // Custom Table logic
                    if (JoinTableClassInfo.ClassIsCustomTable)
                    {
                        CustomTableItemProvider.GetItems(JoinTableClassInfo.ClassName).WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, GetProperObjectValue(ObjectToRemove))
                        .ToList().ForEach(x => ((CustomTableItem)x).Delete());
                    }
                    else
                    {
                        new ObjectQuery(JoinTableClassInfo.ClassName)
                        .WhereEquals(JoinTableLeftFieldName, CurrentItemIdentification)
                        .WhereEquals(JoinTableRightFieldName, GetProperObjectValue(ObjectToRemove))
                        .ToList().ForEach(x => x.Delete());
                    }
                }
            }
        }
    }
Exemplo n.º 7
0
        /// <summary>
        /// Gets a Class Object Summary based on the class name.
        /// </summary>
        /// <param name="ClassName">The Class Name</param>
        /// <returns>The Class Object Summary</returns>
        private static ClassObjSummary GetClassObjSummary(string ClassName)
        {
            return(CacheHelper.Cache <ClassObjSummary>(cs =>
            {
                ClassObjSummary summaryObj = new ClassObjSummary(ClassName);
                DataClassInfo ClassObj = DataClassInfoProvider.GetDataClassInfo(ClassName);
                if (ClassObj != null)
                {
                    summaryObj.ClassIsCustomTable = ClassObj.ClassIsCustomTable;
                    summaryObj.ClassIsDocumentType = ClassObj.ClassIsDocumentType;
                    summaryObj.ClassIsForm = ClassObj.ClassIsForm;
                }
                else
                {
                    summaryObj.ClassIsCustomTable = false;
                    summaryObj.ClassIsDocumentType = false;
                    summaryObj.ClassIsForm = false;
                }
                // now get GUID and Code Name if possible.
                var ObjectClassFactoryObj = new InfoObjectFactory(ClassName);
                if (ObjectClassFactoryObj != null && ObjectClassFactoryObj.Singleton != null)
                {
                    ObjectTypeInfo typeInfoObj = ((BaseInfo)ObjectClassFactoryObj.Singleton).TypeInfo;
                    summaryObj.IDColumn = ValidationHelper.GetString(typeInfoObj.IDColumn, "").Replace(ObjectTypeInfo.COLUMN_NAME_UNKNOWN, "");
                    summaryObj.GUIDColumn = ValidationHelper.GetString(typeInfoObj.GUIDColumn, "").Replace(ObjectTypeInfo.COLUMN_NAME_UNKNOWN, "");
                    summaryObj.CodeNameColumn = ValidationHelper.GetString(typeInfoObj.CodeNameColumn, "").Replace(ObjectTypeInfo.COLUMN_NAME_UNKNOWN, "");
                }
                else
                {
                    // handle unique cases
                    switch (ClassName.ToLower())
                    {
                    case "cms.tree":
                    case "cms.node":
                    case "cms.root":
                        summaryObj.IDColumn = "NodeID";
                        summaryObj.CodeNameColumn = "NodeAliasPath";
                        summaryObj.GUIDColumn = "NodeGUID";
                        break;

                    case "cms.document":
                        summaryObj.IDColumn = "DocumentID";
                        summaryObj.GUIDColumn = "DocumentGUID";
                        break;

                    case "om.contactgroupmember":
                        summaryObj.IDColumn = "ContactGroupMemberID";
                        break;

                    case "om.membership":
                        summaryObj.IDColumn = "MembershipID";
                        summaryObj.GUIDColumn = "MembershipGUID";
                        break;
                    }

                    // if still missing fields, try parsing XML
                    if (string.IsNullOrWhiteSpace(summaryObj.CodeNameColumn) || string.IsNullOrWhiteSpace(summaryObj.GUIDColumn) || string.IsNullOrWhiteSpace(summaryObj.IDColumn))
                    {
                        XmlDocument classXML = new XmlDocument();
                        classXML.LoadXml(ClassObj.ClassFormDefinition);
                        if (string.IsNullOrWhiteSpace(summaryObj.IDColumn))
                        {
                            try
                            {
                                summaryObj.IDColumn = classXML.SelectNodes("/form/field[@columntype='integer' and @isPK='true']").Item(0).Attributes["column"].Value;
                            }
                            catch (Exception)
                            {
                                // can't figure out that code name
                            }
                        }
                        if (string.IsNullOrWhiteSpace(summaryObj.CodeNameColumn))
                        {
                            try
                            {
                                summaryObj.CodeNameColumn = classXML.SelectNodes("/form/field[@columntype='text' and contains(@column, 'CodeName')]").Item(0).Attributes["column"].Value;
                            }
                            catch (Exception)
                            {
                                // can't figure out that code name
                            }
                        }
                        if (string.IsNullOrWhiteSpace(summaryObj.GUIDColumn))
                        {
                            try
                            {
                                summaryObj.GUIDColumn = classXML.SelectNodes("/form/field[@publicfield='false' and @columntype='guid' and system='true']").Item(0).Attributes["column"].Value;
                            }
                            catch (Exception)
                            {
                                // Can't figure out GUID
                            }
                        }
                    }
                }
                if (cs.Cached)
                {
                    cs.CacheDependency = CacheHelper.GetCacheDependency("cms.class|byname|" + ClassName);
                }
                return summaryObj;
            }, new CacheSettings(CacheMinutes, "GetClassObjSummary", ClassName)));
        }