public static ArrayList FillUserCollection(int portalId, IDataReader dr) { //Note: the DataReader returned from this method should contain 2 result sets. The first set // contains the TotalRecords, that satisfy the filter, the second contains the page // of data var arrUsers = new ArrayList(); try { while (dr.Read()) { //fill business object UserInfo user = FillUserInfo(portalId, dr, false); //add to collection arrUsers.Add(user); } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return(arrUsers); }
public override Stream GetFileStream(IFolderInfo folder, string fileName) { Requires.NotNull("folder", folder); Requires.NotNullOrEmpty("fileName", fileName); var file = FileManager.Instance.GetFile(folder, fileName); if (file != null) { byte[] bytes = null; IDataReader dr = null; try { dr = DataProvider.Instance().GetFileContent(file.FileId); if (dr.Read()) { bytes = (byte[])dr["Content"]; } } finally { CBO.CloseDataReader(dr, true); } if (bytes != null) { return(new MemoryStream(bytes)); } } return(null); }
/// <inheritdoc/> public override ArrayList GetLogTypeConfigInfo() { var list = (ArrayList)DataCache.GetCache(LogTypeInfoCacheKey); if (list == null) { IDataReader dr = null; try { dr = DataProvider.Instance().GetLogTypeConfigInfo(); list = CBO.FillCollection(dr, typeof(LogTypeConfigInfo)); DataCache.SetCache(LogTypeInfoCacheKey, list); FillLogTypeConfigInfoByKey(list); } finally { if (dr == null) { list = new ArrayList(); } else { CBO.CloseDataReader(dr, true); } } } return(list); }
public IList <MessageFileView> GetMessageAttachmentsByMessage(int messageId) { var attachments = new List <MessageFileView>(); var dr = _provider.ExecuteReader("CoreMessaging_GetMessageAttachmentsByMessage", messageId); try { while (dr.Read()) { var fileId = Convert.ToInt32(dr["FileID"]); var file = FileManager.Instance.GetFile(fileId); if (file == null) { continue; } var attachment = new MessageFileView { Name = file.FileName, Size = file.Size.ToString(CultureInfo.InvariantCulture), Url = FileManager.Instance.GetUrl(file) }; attachments.Add(attachment); } } finally { CBO.CloseDataReader(dr, true); } return(attachments); }
private Dictionary <string, ListInfo> FillListInfoDictionary(IDataReader dr) { Dictionary <string, ListInfo> dic = new Dictionary <string, ListInfo>(); try { ListInfo obj; while (dr.Read()) { obj = FillListInfo(dr, false); if (!dic.ContainsKey(obj.Key)) { dic.Add(obj.Key, obj); } } } catch (Exception exc) { CommonLibrary.Services.Exceptions.Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return(dic); }
private static EventMessageCollection FillMessageCollection(IDataReader dr) { var arr = new EventMessageCollection(); try { EventMessage obj; while (dr.Read()) { //fill business object obj = FillMessage(dr, false); //add to collection arr.Add(obj); } } catch (Exception exc) { Exceptions.Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return(arr); }
public void UpdateHostSetting(string SettingName, string SettingValue, bool SettingIsSecure, bool clearCache) { IDataReader dr = null; try { dr = DataProvider.Instance().GetHostSetting(SettingName); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); if (dr.Read()) { DataProvider.Instance().UpdateHostSetting(SettingName, SettingValue, SettingIsSecure, UserController.GetCurrentUserInfo().UserID); objEventLog.AddLog(SettingName.ToString(), SettingValue.ToString(), PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.HOST_SETTING_UPDATED); } else { DataProvider.Instance().AddHostSetting(SettingName, SettingValue, SettingIsSecure, UserController.GetCurrentUserInfo().UserID); objEventLog.AddLog(SettingName.ToString(), SettingValue.ToString(), PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.HOST_SETTING_CREATED); } } catch (Exception ex) { Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } if (clearCache) { DataCache.ClearHostCache(false); } }
private static List <ProfilePropertyDefinition> FillPropertyDefinitionInfoCollection(IDataReader dr) { var arr = new List <ProfilePropertyDefinition>(); try { while (dr.Read()) { //fill business object ProfilePropertyDefinition definition = FillPropertyDefinitionInfo(dr, false); //add to collection arr.Add(definition); } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } return(arr); }
public static Dictionary <string, string> GetHostSettingsDictionary() { Dictionary <string, string> dicSettings = DataCache.GetCache <Dictionary <string, string> >(DataCache.HostSettingsCacheKey); if (dicSettings == null) { dicSettings = new Dictionary <string, string>(); IDataReader dr = DataProvider.Instance().GetHostSettings(); try { while (dr.Read()) { if (!dr.IsDBNull(1)) { dicSettings.Add(dr.GetString(0), dr.GetString(1)); } } } finally { CBO.CloseDataReader(dr, true); } CacheDependency objDependency = null; //DataCache.SetCache(DataCache.HostSettingsCacheKey, dicSettings, objDependency, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(DataCache.HostSettingsCacheTimeOut), DataCache.HostSettingsCachePriority, null); } return(dicSettings); }
public override object GetSingleLog(LogInfo logInfo, ReturnType returnType) { IDataReader dr = DataProvider.Instance().GetSingleLog(logInfo.LogGUID); LogInfo log = null; try { if (dr != null) { dr.Read(); log = FillLogInfo(dr); } } finally { CBO.CloseDataReader(dr, true); } if (returnType == ReturnType.LogInfoObjects) { return(log); } var xmlDoc = new XmlDocument(); if (log != null) { xmlDoc.LoadXml(log.Serialize()); } return(xmlDoc.DocumentElement); }
private static object GetSecureHostSettingsDictionaryCallBack(CacheItemArgs cacheItemArgs) { Dictionary <string, string> dicSettings = new Dictionary <string, string>(); IDataReader dr = DataProvider.Instance().GetHostSettings(); try { while (dr.Read()) { if (Convert.ToInt32(dr[2]) < 1) { string settingName = dr.GetString(0); if (settingName.ToLower().IndexOf("password") == -1) { if (!dr.IsDBNull(1)) { dicSettings.Add(settingName, dr.GetString(1)); } else { dicSettings.Add(settingName, ""); } } } } } finally { CBO.CloseDataReader(dr, true); } return(dicSettings); }
/// <inheritdoc/> public override void SendLogNotifications() { List <LogTypeConfigInfo> configInfos = CBO.FillCollection <LogTypeConfigInfo>(DataProvider.Instance().GetEventLogPendingNotifConfig()); foreach (LogTypeConfigInfo typeConfigInfo in configInfos) { IDataReader dr = DataProvider.Instance().GetEventLogPendingNotif(Convert.ToInt32(typeConfigInfo.ID)); string log = string.Empty; try { while (dr.Read()) { LogInfo logInfo = FillLogInfo(dr); log += logInfo.Serialize() + Environment.NewLine + Environment.NewLine; } } finally { CBO.CloseDataReader(dr, true); } Mail.Mail.SendEmail(typeConfigInfo.MailFromAddress, typeConfigInfo.MailToAddress, "Event Notification", string.Format("<pre>{0}</pre>", HttpUtility.HtmlEncode(log))); DataProvider.Instance().UpdateEventLogPendingNotif(Convert.ToInt32(typeConfigInfo.ID)); } }
public Hashtable GetModuleSettings(int ModuleId) { var settings = new Hashtable(); IDataReader dr = null; try { dr = dataProvider.GetModuleSettings(ModuleId); while (dr.Read()) { if (!dr.IsDBNull(1)) { settings[dr.GetString(0)] = dr.GetString(1); } else { settings[dr.GetString(0)] = string.Empty; } } } catch (Exception ex) { Exceptions.LogException(ex); } finally { // Ensure DataReader is closed CBO.CloseDataReader(dr, true); } return(settings); }
/// <summary> /// Gets all settings from the databse /// </summary> /// <returns><see cref="Dictionary"/><<see cref="string"/>, <see cref="ConfigurationSetting"/>></returns> private static Dictionary <string, ConfigurationSetting> GetSettingsFromDatabase() { var dicSettings = new Dictionary <string, ConfigurationSetting>(); IDataReader dr = null; try { dr = DataProvider.Instance().GetHostSettings(); while (dr.Read()) { string key = dr.GetString(0); var config = new ConfigurationSetting { Key = key, IsSecure = Convert.ToBoolean(dr[2]), Value = dr.IsDBNull(1) ? string.Empty : dr.GetString(1) }; dicSettings.Add(key, config); } } catch (Exception ex) { Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } return(dicSettings); }
public ListInfo GetListInfo(string ListName, string ParentKey, int PortalID) { ListInfo list = null; string key = Null.NullString; if (!string.IsNullOrEmpty(ParentKey)) { key = ParentKey + ":"; } key += ListName; Dictionary <string, ListInfo> dicLists = GetListInfoDictionary(PortalID); if (!dicLists.TryGetValue(key, out list)) { IDataReader dr = DataProvider.Instance().GetList(ListName, ParentKey, PortalID); try { list = FillListInfo(dr, true); } finally { CBO.CloseDataReader(dr, true); } } return(list); }
private Dictionary <string, ListInfo> FillListInfoDictionary(IDataReader dr) { var dic = new Dictionary <string, ListInfo>(); try { ListInfo obj; while (dr.Read()) { // fill business object obj = FillListInfo(dr, false); if (!dic.ContainsKey(obj.Key)) { dic.Add(obj.Key, obj); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { // close datareader CBO.CloseDataReader(dr, true); } return(dic); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchSettings gets the search settings for a single module. /// </summary> /// <remarks> /// </remarks> /// <param name="ModuleId">The Id of the Module.</param> /// <returns></returns> /// ----------------------------------------------------------------------------- public static Dictionary <string, string> GetSearchSettings(int ModuleId) { var dicSearchSettings = new Dictionary <string, string>(); IDataReader dr = null; try { dr = DataProvider.Instance().GetSearchSettings(ModuleId); while (dr.Read()) { if (!dr.IsDBNull(1)) { dicSearchSettings[dr.GetString(0)] = dr.GetString(1); } else { dicSearchSettings[dr.GetString(0)] = string.Empty; } } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } return(dicSearchSettings); }
private static void UpdateFolderMappingSetting(int folderMappingID, string settingName, string settingValue) { IDataReader dr = null; try { dr = dataProvider.GetFolderMappingSetting(folderMappingID, settingName); if (dr.Read()) { dataProvider.UpdateFolderMappingSetting(folderMappingID, settingName, settingValue, UserController.Instance.GetCurrentUserInfo().UserID); } else { dataProvider.AddFolderMappingSetting(folderMappingID, settingName, settingValue, UserController.Instance.GetCurrentUserInfo().UserID); } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } finally { // Ensure DataReader is closed CBO.CloseDataReader(dr, true); } }
public ListInfo GetListInfo(string listName, string parentKey, int portalId) { ListInfo list = null; string key = Null.NullString; if (!string.IsNullOrEmpty(parentKey)) { key = parentKey + ":"; } key += listName; Dictionary <string, ListInfo> dicLists = this.GetListInfoDictionary(portalId); if (!dicLists.TryGetValue(key, out list)) { IDataReader dr = DataProvider.Instance().GetList(listName, parentKey, portalId); try { list = this.FillListInfo(dr, true); } finally { CBO.CloseDataReader(dr, true); } } return(list); }
private static object GetCachedUserPersonalizationCallback(CacheItemArgs cacheItemArgs) { var portalId = (int)cacheItemArgs.ParamList[0]; var userId = (int)cacheItemArgs.ParamList[1]; var returnValue = Null.NullString; // Default is no profile IDataReader dr = null; try { dr = DataProvider.Instance().GetProfile(userId, portalId); if (dr.Read()) { returnValue = dr["ProfileData"].ToString(); } else // does not exist { DataProvider.Instance().AddProfile(userId, portalId); } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } return(returnValue); }
public virtual MessageThreadsView GetMessageThread(int conversationId, int userId, int afterMessageId, int numberOfRecords, string sortColumn, bool sortAscending, ref int totalRecords) { var messageThreadsView = new MessageThreadsView(); var dr = _dataService.GetMessageThread(conversationId, userId, afterMessageId, numberOfRecords, sortColumn, sortAscending, ref totalRecords); try { while (dr.Read()) { var messageThreadView = new MessageThreadView { Conversation = new MessageConversationView() }; messageThreadView.Conversation.Fill(dr); if (messageThreadView.Conversation.AttachmentCount > 0) { messageThreadView.Attachments = _dataService.GetMessageAttachmentsByMessage(messageThreadView.Conversation.MessageID); } if (messageThreadsView.Conversations == null) { messageThreadsView.Conversations = new List <MessageThreadView>(); } messageThreadsView.Conversations.Add(messageThreadView); } } finally { CBO.CloseDataReader(dr, true); } return(messageThreadsView); }
private static Dictionary <int, DesktopModulePermissionCollection> FillDesktopModulePermissionDictionary(IDataReader dr) { Dictionary <int, DesktopModulePermissionCollection> dic = new Dictionary <int, DesktopModulePermissionCollection>(); try { DesktopModulePermissionInfo obj; while (dr.Read()) { obj = CBO.FillObject <DesktopModulePermissionInfo>(dr, false); if (dic.ContainsKey(obj.PortalDesktopModuleID)) { dic[obj.PortalDesktopModuleID].Add(obj); } else { DesktopModulePermissionCollection collection = new DesktopModulePermissionCollection(); collection.Add(obj); dic.Add(obj.PortalDesktopModuleID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return(dic); }
private object GetTabPermissionsCallBack(CacheItemArgs cacheItemArgs) { int portalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetTabPermissionsByPortal(portalID); Dictionary <int, TabPermissionCollection> dic = new Dictionary <int, TabPermissionCollection>(); try { TabPermissionInfo obj; while (dr.Read()) { obj = CBO.FillObject <TabPermissionInfo>(dr, false); if (dic.ContainsKey(obj.TabID)) { dic[obj.TabID].Add(obj); } else { TabPermissionCollection collection = new TabPermissionCollection(); collection.Add(obj); dic.Add(obj.TabID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return(dic); }
public PersonalizationInfo LoadProfile(int UserId, int PortalId) { PersonalizationInfo objPersonalization = new PersonalizationInfo(); objPersonalization.UserId = UserId; objPersonalization.PortalId = PortalId; objPersonalization.IsModified = false; string profileData = Null.NullString; if (UserId > Null.NullInteger) { IDataReader dr = null; try { dr = DataProvider.Instance().GetProfile(UserId, PortalId); if (dr.Read()) { profileData = dr["ProfileData"].ToString(); } else { try { DataProvider.Instance().AddProfile(UserId, PortalId); } catch { } } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } } else { HttpContext context = HttpContext.Current; if (context != null && context.Request != null && context.Request.Cookies["Personalization"] != null) { profileData = context.Request.Cookies["Personalization"].Value; } } if (string.IsNullOrEmpty(profileData)) { objPersonalization.Profile = new Hashtable(); } else { objPersonalization.Profile = Globals.DeserializeHashTableXml(profileData); } return(objPersonalization); }
//override allows for manipulation of PersonalizationInfo outside of HTTPContext public PersonalizationInfo LoadProfile(int userId, int portalId) { var personalization = new PersonalizationInfo { UserId = userId, PortalId = portalId, IsModified = false }; string profileData = Null.NullString; if (userId > Null.NullInteger) { IDataReader dr = null; try { dr = DataProvider.Instance().GetProfile(userId, portalId); if (dr.Read()) { profileData = dr["ProfileData"].ToString(); } else //does not exist { DataProvider.Instance().AddProfile(userId, portalId); } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } } else { //Anon User - so try and use cookie. HttpContext context = HttpContext.Current; if (context != null && context.Request.Cookies["DNNPersonalization"] != null) { profileData = context.Request.Cookies["DNNPersonalization"].Value; } } if (string.IsNullOrEmpty(profileData)) { personalization.Profile = new Hashtable(); } else { personalization.Profile = Globals.DeserializeHashTableXml(profileData); } return(personalization); }
private object GetFolderPermissionsCallBack(CacheItemArgs cacheItemArgs) { var PortalID = (int)cacheItemArgs.ParamList[0]; IDataReader dr = dataProvider.GetFolderPermissionsByPortal(PortalID); var dic = new Dictionary <string, FolderPermissionCollection>(); try { while (dr.Read()) { //fill business object var folderPermissionInfo = CBO.FillObject <FolderPermissionInfo>(dr, false); string dictionaryKey = folderPermissionInfo.FolderPath; if (string.IsNullOrEmpty(dictionaryKey)) { dictionaryKey = "[PortalRoot]"; } //add Folder Permission to dictionary if (dic.ContainsKey(dictionaryKey)) { //Add FolderPermission to FolderPermission Collection already in dictionary for FolderPath dic[dictionaryKey].Add(folderPermissionInfo); } else { //Create new FolderPermission Collection for TabId var collection = new FolderPermissionCollection { folderPermissionInfo }; //Add Permission to Collection //Add Collection to Dictionary dic.Add(dictionaryKey, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { CBO.CloseDataReader(dr, true); } return(dic); }
private static ProfilePropertyDefinition FillPropertyDefinitionInfo(IDataReader dr) { ProfilePropertyDefinition definition = null; try { definition = FillPropertyDefinitionInfo(dr, false); } catch { } finally { CBO.CloseDataReader(dr, true); } return(definition); }
private Stream GetFileStreamInternal(IDataReader dr) { byte[] bytes = null; try { if (dr.Read()) { bytes = (byte[])dr["Content"]; } } finally { CBO.CloseDataReader(dr, true); } return(bytes != null ? new MemoryStream(bytes) : null); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetTabPermissionsCallBack gets a Dictionary of TabPermissionCollections by /// Tab from the the Database. /// </summary> /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters /// needed for the database call</param> /// <history> /// [cnurse] 04/15/2009 Created /// </history> /// ----------------------------------------------------------------------------- private object GetTabPermissionsCallBack(CacheItemArgs cacheItemArgs) { var portalID = (int)cacheItemArgs.ParamList[0]; var dic = new Dictionary <int, TabPermissionCollection>(); if (portalID > -1) { IDataReader dr = dataProvider.GetTabPermissionsByPortal(portalID); try { while (dr.Read()) { //fill business object var tabPermissionInfo = CBO.FillObject <TabPermissionInfo>(dr, false); //add Tab Permission to dictionary if (dic.ContainsKey(tabPermissionInfo.TabID)) { //Add TabPermission to TabPermission Collection already in dictionary for TabId dic[tabPermissionInfo.TabID].Add(tabPermissionInfo); } else { //Create new TabPermission Collection for TabId var collection = new TabPermissionCollection { tabPermissionInfo }; //Add Collection to Dictionary dic.Add(tabPermissionInfo.TabID, collection); } } } catch (Exception exc) { Exceptions.LogException(exc); } finally { //close datareader CBO.CloseDataReader(dr, true); } } return(dic); }
private static ProfilePropertyDefinition FillPropertyDefinitionInfo(IDataReader dr) { ProfilePropertyDefinition definition = null; try { definition = FillPropertyDefinitionInfo(dr, true); } catch (Exception ex) { Logger.Error(ex); } finally { CBO.CloseDataReader(dr, true); } return(definition); }