public CustomFieldDataPreDefinitionData GetData(Guid objectCustomFieldId)
        {
            CustomFieldDataPreDefinitionData ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();

                ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId);

                if (objectCustomField.ObjectCustomFieldDatas != null)
                {
                    ret = new CustomFieldDataPreDefinitionData();

                    foreach (var data in objectCustomField.ObjectCustomFieldDatas)
                    {
                        PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId;

                        NAS.DAL.Inventory.Command.InventoryCommand Command =
                            session.GetObjectByKey <NAS.DAL.Inventory.Command.InventoryCommand>(predefinitionData.RefId);

                        if (Command != null)
                        {
                            CustomFieldDataPreDefinitionDataItem item = new CustomFieldDataPreDefinitionDataItem()
                            {
                                CustomFieldDataId = predefinitionData.CustomFieldDataId,
                                PredefinitionType = predefinitionData.PredefinitionType,
                                RefId             = predefinitionData.RefId,
                                DisplayText       = Command.Name
                            };
                            ret.Add(item);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }
        public CustomFieldDataPreDefinitionData GetData(Guid objectCustomFieldId)
        {
            CustomFieldDataPreDefinitionData ret = null;
            Session session = null;

            try
            {
                session = XpoHelper.GetNewSession();

                ObjectCustomField objectCustomField = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId);

                if (objectCustomField.ObjectCustomFieldDatas != null)
                {
                    ret = new CustomFieldDataPreDefinitionData();

                    foreach (var data in objectCustomField.ObjectCustomFieldDatas)
                    {
                        PredefinitionData predefinitionData = (PredefinitionData)data.CustomFieldDataId;

                        Item itemData = session.GetObjectByKey <Item>(predefinitionData.RefId);

                        if (itemData != null)
                        {
                            CustomFieldDataPreDefinitionDataItem item = new CustomFieldDataPreDefinitionDataItem()
                            {
                                CustomFieldDataId = predefinitionData.CustomFieldDataId,
                                PredefinitionType = predefinitionData.PredefinitionType,
                                RefId             = predefinitionData.RefId,
                                DisplayText       = String.Format("{0} - {1}", itemData.Code, itemData.Name)
                            };
                            ret.Add(item);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }