public int?AddGroup(Group group) { try { var values = new Dictionary <string, object> { { GlobalAppSettings.DbColumns.DB_Group.Name, group.GroupName }, { GlobalAppSettings.DbColumns.DB_Group.Description, group.GroupDescription }, { GlobalAppSettings.DbColumns.DB_Group.Color, group.GroupColor }, { GlobalAppSettings.DbColumns.DB_Group.IsActive, true }, { GlobalAppSettings.DbColumns.DB_Group.ModifiedDate, DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) } }; var output = new List <string> { GlobalAppSettings.DbColumns.DB_Group.GroupId }; var result = _dataProvider.ExecuteScalarQuery(_queryBuilder.AddToTable( GlobalAppSettings.DbColumns.DB_Group.DB_TableName, values, output)); if (result.Status) { return(Convert.ToInt32(result.ReturnValue)); } return(null); } catch (Exception e) { LogExtension.LogError("Error while adding group", e, MethodBase.GetCurrentMethod(), " GroupName - " + group.GroupName + " GroupDescription - " + group.GroupDescription + " GroupColor - " + group.GroupColor); return(null); } }
public bool AddUserInGroup(int userId, int groupId) { try { var values = new Dictionary <string, object> { { GlobalAppSettings.DbColumns.DB_UserGroup.GroupId, groupId }, { GlobalAppSettings.DbColumns.DB_UserGroup.UserId, userId }, { GlobalAppSettings.DbColumns.DB_UserGroup.IsActive, true }, { GlobalAppSettings.DbColumns.DB_UserGroup.ModifiedDate, DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) } }; var result = _dataProvider.ExecuteNonQuery( _queryBuilder.AddToTable(GlobalAppSettings.DbColumns.DB_UserGroup.DB_TableName, values)); return(result.Status); } catch (Exception e) { LogExtension.LogError("Error while add user in group", e, MethodBase.GetCurrentMethod(), " UserId - " + userId + " GroupId - " + groupId); return(false); } }
/// <summary> /// Initialize the Settings for the Server. /// </summary> /// <param name="path">Path of the configuration file</param> public static void InitializeSystemSettings(string path) { var tokenCryptography = new TokenCryptography(); try { SystemSettings = new SystemSettingsSerializer().Deserialize(path); if (SystemSettings != null) { SystemSettings.SqlConfiguration.ConnectionString = tokenCryptography.Decrypt(SystemSettings.SqlConfiguration.ConnectionString); ConnectionString = SystemSettings.SqlConfiguration.ConnectionString; DbSupport = SystemSettings.SqlConfiguration.ServerType; if (DbSupport == DataBaseType.MSSQLCE) { DataProvider = new SqlCeRelationalDataAdapter(ConnectionString); QueryBuilder = new SqlCeQueryBuilder(); } else { QueryBuilder = new SqlQueryBuilder(); DataProvider = new SqlRelationalDataAdapter(ConnectionString); } var globalSettings = new GlobalAppSettings().GetSystemSettings().DataTable.AsEnumerable() .Select(a => new { Key = a.Field <string>(DbColumns.DB_SystemSettings.Key), Value = a.Field <string>(DbColumns.DB_SystemSettings.Value) } ).ToDictionary(a => a.Key, a => a.Value); SystemSettings.OrganizationName = globalSettings[SystemSettingKeys.OrganizationName.ToString()]; SystemSettings.LoginLogo = globalSettings[SystemSettingKeys.LoginLogo.ToString()]; SystemSettings.MainScreenLogo = globalSettings[SystemSettingKeys.MainScreenLogo.ToString()]; SystemSettings.FavIcon = globalSettings[SystemSettingKeys.FavIcon.ToString()]; SystemSettings.WelcomeNoteText = globalSettings[SystemSettingKeys.WelcomeNoteText.ToString()]; SystemSettings.Language = globalSettings[SystemSettingKeys.Language.ToString()]; SystemSettings.TimeZone = globalSettings[SystemSettingKeys.TimeZone.ToString()]; SystemSettings.DateFormat = globalSettings[SystemSettingKeys.DateFormat.ToString()]; SystemSettings.BaseUrl = globalSettings[SystemSettingKeys.BaseUrl.ToString()]; SystemSettings.ActivationExpirationDays = Convert.ToInt32(globalSettings[SystemSettingKeys.ActivationExpirationDays.ToString()]); SystemSettings.MailSettingsAddress = globalSettings[SystemSettingKeys.MailSettingsAddress.ToString()]; SystemSettings.MailSettingsHost = globalSettings[SystemSettingKeys.MailSettingsHost.ToString()]; SystemSettings.MailSettingsSenderName = globalSettings[SystemSettingKeys.MailSettingsSenderName.ToString()]; SystemSettings.MailSettingsPassword = tokenCryptography.Decrypt( globalSettings[SystemSettingKeys.MailSettingsPassword.ToString()]); SystemSettings.MailSettingsPort = Convert.ToInt32(globalSettings[SystemSettingKeys.MailSettingsPort.ToString()]); SystemSettings.MailSettingsIsSecureAuthentication = Convert.ToBoolean( globalSettings[SystemSettingKeys.MailSettingsIsSecureAuthentication.ToString()]); Serializer = new JavaScriptSerializer(); } } catch (Exception e) { LogExtension.LogError("Exception while deserializing system settings", e, MethodBase.GetCurrentMethod(), " Path - " + path + " ConnectionString - " + ConnectionString + " OrganizationName - " + SystemSettings.OrganizationName + " LoginLogo - " + SystemSettings.LoginLogo + " MainScreenLogo - " + SystemSettings.MainScreenLogo + " FavIcon - " + SystemSettings.FavIcon + " WelcomeNoteText - " + SystemSettings.WelcomeNoteText + " Language - " + SystemSettings.Language + " TimeZone - " + SystemSettings.TimeZone + " DateFormat - " + SystemSettings.DateFormat + " BaseUrl - " + SystemSettings.BaseUrl + " ActivationExpirationDays - " + SystemSettings.ActivationExpirationDays + " MailSettingsAddress - " + SystemSettings.MailSettingsAddress + " MailSettingsHost - " + SystemSettings.MailSettingsHost + " MailSettingsSenderName - " + SystemSettings.MailSettingsSenderName + " MailSettingsPassword - " + SystemSettings.MailSettingsPassword + " MailSettingsPort - " + SystemSettings.MailSettingsPort + " MailSettingsIsSecureAuthentication - " + SystemSettings.MailSettingsIsSecureAuthentication); } }