GetDataSet() public method

Gets all Data values of an UDT table (module) from the Database as DataSet
public GetDataSet ( ) : DataSet
return System.Data.DataSet
Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                PortalController.Instance.GetCurrentPortalSettings();

                if ((context.Request.QueryString["tabid"] == null || context.Request.QueryString["mid"] == null) ||
                    !(context.Request.IsAuthenticated))
                {
                    return;
                }
                // get TabId
                var tabId = Convert.ToInt32(-1);
                if (context.Request.QueryString["tabid"] != null)
                {
                    tabId = int.Parse(context.Request.QueryString["tabid"]);
                }

                // get ModuleId
                var moduleId = Convert.ToInt32(-1);
                if (context.Request.QueryString["mid"] != null)
                {
                    moduleId = int.Parse(context.Request.QueryString["mid"]);
                }

                var userInfo = UserController.Instance.GetCurrentUserInfo();
                var mc       = new ModuleController();

                var moduleInfo = new ModuleController().GetModule(moduleId, tabId);
                var settings   = moduleInfo.ModuleSettings;

                if (ModulePermissionController.CanManageModule(moduleInfo))
                {
                    var udt = new UserDefinedTableController(moduleId, tabId, userInfo);
                    var ds  = udt.GetDataSet(true);

                    ds.Tables.Add(udt.Context(moduleInfo, userInfo,
                                              context.Request[Definition.QueryStringParameter].AsString(),
                                              settings[SettingName.SortField].AsString(),
                                              settings[SettingName.SortOrder].AsString(),
                                              settings[SettingName.Paging].AsString()));
                    context.Response.ContentType = "Text/Xml";
                    ds.WriteXml(context.Response.OutputStream);
                }
            }
            catch (Exception)
            {
                context.Response.Write("Not defined");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                PortalController.GetCurrentPortalSettings();

                if ((context.Request.QueryString["tabid"] == null || context.Request.QueryString["mid"] == null) ||
                    !(context.Request.IsAuthenticated))
                {
                    return;
                }
                // get TabId
                var tabId = Convert.ToInt32(-1);
                if (context.Request.QueryString["tabid"] != null)
                {
                    tabId = int.Parse(context.Request.QueryString["tabid"]);
                }

                // get ModuleId
                var moduleId = Convert.ToInt32(-1);
                if (context.Request.QueryString["mid"] != null)
                {
                    moduleId = int.Parse(context.Request.QueryString["mid"]);
                }

                var userInfo = UserController.GetCurrentUserInfo();
                var mc = new ModuleController();
                var settings = mc.GetModuleSettings(moduleId);
                var moduleInfo = new ModuleController().GetModule(moduleId, tabId);

                if (ModulePermissionController.CanManageModule(moduleInfo))
                {
                    var udt = new UserDefinedTableController(moduleId, tabId, userInfo);
                    var ds = udt.GetDataSet(true);

                    ds.Tables.Add(udt.Context(moduleInfo, userInfo,
                                                 context.Request[Definition.QueryStringParameter].AsString(),
                                                 settings[SettingName.SortField].AsString(),
                                                 settings[SettingName.SortOrder].AsString(),
                                                 settings[SettingName.Paging].AsString()));
                    context.Response.ContentType = "Text/Xml";
                    ds.WriteXml(context.Response.OutputStream);
                }
            }
            catch (Exception)
            {
                context.Response.Write("Not defined");
            }
        }
        public DataSet ExportModuleDataSet(int moduleId, int tabId)
        {
            DataSet ds;

            if (tabId == Null.NullInteger)
            {
                var udtController = new UserDefinedTableController(moduleId);
                ds = udtController.GetDataSet(false);
                ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
            }
            else
            {
                var moduleInfo    = new ModuleController().GetModule(moduleId, tabId);
                var udtController = new UserDefinedTableController(moduleInfo);
                ds = udtController.GetDataSet(false);
                ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
                ds.Tables.Add(GetSettingsTable(moduleInfo.TabModuleID, SettingsType.TabModuleSettings));
                ds.Tables.Add(GetStylesheetTable(udtController.Settings, moduleInfo.PortalID));
            }
            return(ds);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Implements the search interface for DotNetNuke
        /// </summary>
        /// -----------------------------------------------------------------------------
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            var searchItemCollection = new SearchItemInfoCollection();
            var udtController        = new UserDefinedTableController(modInfo);

            try
            {
                var dsUserDefinedRows = udtController.GetDataSet(withPreRenderedValues: false);

                //Get names of ChangedBy and ChangedAt columns
                var colnameChangedBy = udtController.ColumnNameByDataType(dsUserDefinedRows,
                                                                          DataTypeNames.UDT_DataType_ChangedBy);
                var colnameChangedAt = udtController.ColumnNameByDataType(dsUserDefinedRows,
                                                                          DataTypeNames.UDT_DataType_ChangedAt);

                var moduleController = new ModuleController();
                var settings         = moduleController.GetModuleSettings(modInfo.ModuleID);
                var includeInSearch  = !(settings[SettingName.ExcludeFromSearch].AsBoolean());

                if (includeInSearch)
                {
                    foreach (DataRow row in dsUserDefinedRows.Tables[DataSetTableName.Data].Rows)
                    {
                        var changedDate     = DateTime.Today;
                        var changedByUserId = 0;

                        if (colnameChangedAt != string.Empty && !Information.IsDBNull(row[colnameChangedAt]))
                        {
                            changedDate = Convert.ToDateTime(row[colnameChangedAt]);
                        }
                        if (colnameChangedBy != string.Empty && !Information.IsDBNull(row[colnameChangedBy]))
                        {
                            changedByUserId = ModuleSecurity.UserId(row[colnameChangedBy].ToString(), modInfo.PortalID);
                        }

                        var desc = string.Empty;
                        foreach (DataRow col in dsUserDefinedRows.Tables[DataSetTableName.Fields].Rows)
                        {
                            var fieldType  = col[FieldsTableColumn.Type].ToString();
                            var fieldTitle = col[FieldsTableColumn.Title].ToString();
                            var visible    = Convert.ToBoolean(col[FieldsTableColumn.Visible]);
                            if (visible &&
                                (fieldType.StartsWith("Text") || fieldType == DataTypeNames.UDT_DataType_String))
                            {
                                desc += string.Format("{0} &bull; ", Convert.ToString(row[fieldTitle]));
                            }
                        }
                        if (desc.EndsWith("<br/>"))
                        {
                            desc = desc.Substring(0, Convert.ToInt32(desc.Length - 5));
                        }
                        var searchItem = new SearchItemInfo(modInfo.ModuleTitle, desc, changedByUserId, changedDate,
                                                            modInfo.ModuleID, row[DataTableColumn.RowId].ToString(),
                                                            desc);
                        searchItemCollection.Add(searchItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }

            return(searchItemCollection);
        }
Beispiel #5
0
        private void LoadFnL()
        {
            EnsureConfigurationIsLoaded();

            // Preferred way in Form and List
            var udt = new UserDefinedTableController();
            var ds = udt.GetDataSet(ModuleId);
            DtDs = DataSource.GetDataSource<DataTableDataSource>(valueCollectionProvider: ConfigurationProvider);
            DtDs.Source = ds.Tables["Data"];
            DtDs.EntityIdField = "UserDefinedRowId";         // default column created by UDT
            DtDs.ContentType = ContentType;

            // clean up column names if possible, remove spaces in the column-names
            for (var i = 0; i < DtDs.Source.Columns.Count; i++)
                DtDs.Source.Columns[i].ColumnName = DtDs.Source.Columns[i].ColumnName
                    .Replace(" ", "");

            // Set the title-field - either the configured one, or if missing, just the first column we find
            if (string.IsNullOrWhiteSpace(TitleField))
                TitleField = DtDs.Source.Columns[1].ColumnName;
            DtDs.TitleField = TitleField;
        }
        public DataSet ExportModuleDataSet(int moduleId, int tabId)
        {
            DataSet ds;

            if (tabId == Null.NullInteger)
            {
                var udtController = new UserDefinedTableController(moduleId);
                ds = udtController.GetDataSet(false);
                ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
            }
            else
            {
                var moduleInfo = new ModuleController().GetModule(moduleId, tabId);
                var udtController = new UserDefinedTableController(moduleInfo);
                ds = udtController.GetDataSet(false);
                ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
                ds.Tables.Add(GetSettingsTable(moduleInfo.TabModuleID, SettingsType.TabModuleSettings));
                ds.Tables.Add(GetStylesheetTable(udtController.Settings, moduleInfo.PortalID));
            }
            return (ds);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Implements the search interface for DotNetNuke
        /// </summary>
        /// -----------------------------------------------------------------------------
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            var searchItemCollection = new SearchItemInfoCollection();
            var udtController = new UserDefinedTableController(modInfo);

            try
            {
                var dsUserDefinedRows = udtController.GetDataSet(withPreRenderedValues: false);

                //Get names of ChangedBy and ChangedAt columns
                var colnameChangedBy = udtController.ColumnNameByDataType(dsUserDefinedRows,
                                                                          DataTypeNames.UDT_DataType_ChangedBy);
                var colnameChangedAt = udtController.ColumnNameByDataType(dsUserDefinedRows,
                                                                          DataTypeNames.UDT_DataType_ChangedAt);

                var moduleController = new ModuleController();
                var settings = moduleController.GetModuleSettings(modInfo.ModuleID);
                var includeInSearch = !(settings[SettingName.ExcludeFromSearch].AsBoolean());

                if (includeInSearch)
                {
                    foreach (DataRow row in dsUserDefinedRows.Tables[DataSetTableName.Data].Rows)
                    {
                        var changedDate = DateTime.Today;
                        var changedByUserId = 0;

                        if (colnameChangedAt != string.Empty && ! Information.IsDBNull(row[colnameChangedAt]))
                        {
                            changedDate = Convert.ToDateTime(row[colnameChangedAt]);
                        }
                        if (colnameChangedBy != string.Empty && ! Information.IsDBNull(row[colnameChangedBy]))
                        {
                            changedByUserId = ModuleSecurity.UserId(row[colnameChangedBy].ToString(), modInfo.PortalID);
                        }

                        var desc = string.Empty;
                        foreach (DataRow col in dsUserDefinedRows.Tables[DataSetTableName.Fields].Rows)
                        {
                            var fieldType = col[FieldsTableColumn.Type].ToString();
                            var fieldTitle = col[FieldsTableColumn.Title].ToString();
                            var visible = Convert.ToBoolean(col[FieldsTableColumn.Visible]);
                            if (visible &&
                                (fieldType.StartsWith("Text") || fieldType == DataTypeNames.UDT_DataType_String))
                            {
                                desc += string.Format("{0} &bull; ", Convert.ToString(row[fieldTitle]));
                            }
                        }
                        if (desc.EndsWith("<br/>"))
                        {
                            desc = desc.Substring(0, Convert.ToInt32(desc.Length - 5));
                        }
                        var searchItem = new SearchItemInfo(modInfo.ModuleTitle, desc, changedByUserId, changedDate,
                                                            modInfo.ModuleID, row[DataTableColumn.RowId].ToString(),
                                                            desc);
                        searchItemCollection.Add(searchItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }

            return searchItemCollection;
        }