public string FillEventType() { string strEventTypes = string.Empty; try { strEventTypes = CommonDataAccess.GetSettingValue("EVENTTYPELIST"); } catch (Exception ex) { ExceptionManager.Publish(ex); strEventTypes = string.Empty; } return(strEventTypes); }
public string FillSettingsToBeSkipped() { string strSettings = string.Empty; try { strSettings = CommonDataAccess.GetSettingValue("SETTING_NAMES_HIDDEN"); } catch (Exception ex) { ExceptionManager.Publish(ex); strSettings = string.Empty; } return(strSettings); }
/// <summary> /// Create database back up in Zip format and kept in path /// </summary> /// <returns>int 0 -not success, 1- success, 2 - already backkup available</returns> public int CreateSqlDatabaseBackUp(FactoryReset oFactoryResetEntity) { SqlConnection SqlConn = null; ServerConnection svrConnServerConnection = null; Server SqlSever = null; Backup bak = null; BackupDeviceItem bkpitem = null; DateTime dt = DateTime.Now; int iResult = 0; String[] format = { "ddMMMyyyyHHmm" }; string bkpFileName = ""; string Backuppath = ""; string date = ""; string zipFileName = ""; try { date = dt.ToString(format[0], DateTimeFormatInfo.InvariantInfo); Backuppath = oFactoryResetEntity.strBackupPath; bkpFileName = Backuppath + "\\" + "[" + date + "]" + "_BAK_" + "[" + CommonDataAccess.GetSettingValue("TICKET_LOCATION_CODE") + "]" + "[" + BMC.Transport.Settings.SiteName + "]" + "_" + oFactoryResetEntity.BackUpDataBase + ".BAK"; oFactoryResetEntity.strBackupFileName = bkpFileName; if (Directory.Exists(Backuppath)) { if (File.Exists(bkpFileName) == false) { try { SqlConn = new SqlConnection(CommonDataAccess.ExchangeConnectionString); svrConnServerConnection = new ServerConnection(SqlConn); SqlSever = new Server(svrConnServerConnection); if (SqlSever != null) { bak = new Microsoft.SqlServer.Management.Smo.Backup(); bak.Action = BackupActionType.Database; bkpitem = new BackupDeviceItem(bkpFileName, DeviceType.File); bak.Devices.Add(bkpitem); bak.Database = oFactoryResetEntity.BackUpDataBase; bak.SqlBackup(SqlSever); } } catch (SqlException sqlex) { ExceptionManager.Publish(sqlex); iResult = 0; } catch (TimeoutException tex) { ExceptionManager.Publish(tex); iResult = 0; } zipFileName = Backuppath + "\\" + "bkp" + oFactoryResetEntity.BackUpDataBase + date + ".ZIP"; zipFileName = Backuppath + "\\" + "[" + date + "]" + "_BAK_" + "[" + CommonDataAccess.GetSettingValue("TICKET_LOCATION_CODE") + "]" + "[" + BMC.Transport.Settings.SiteName + "]" + "_" + oFactoryResetEntity.BackUpDataBase + ".ZIP"; oFactoryResetEntity.strZipFileName = zipFileName; iResult = 1; } else { iResult = 2; } } else { Directory.CreateDirectory(Backuppath); try { SqlConn = new SqlConnection(CommonDataAccess.ExchangeConnectionString); svrConnServerConnection = new ServerConnection(SqlConn); SqlSever = new Server(svrConnServerConnection); if (SqlSever != null) { bak = new Microsoft.SqlServer.Management.Smo.Backup(); bak.Action = BackupActionType.Database; bkpitem = new BackupDeviceItem(bkpFileName, DeviceType.File); bak.Devices.Add(bkpitem); bak.Database = oFactoryResetEntity.BackUpDataBase; bak.SqlBackup(SqlSever); } } catch (SqlException sqlex) { ExceptionManager.Publish(sqlex); iResult = 0; } catch (TimeoutException tex) { ExceptionManager.Publish(tex); iResult = 0; } zipFileName = Backuppath + "bkp" + oFactoryResetEntity.BackUpDataBase + date + ".zip"; oFactoryResetEntity.strZipFileName = zipFileName; iResult = 1; } } catch (FileNotFoundException fex) { ExceptionManager.Publish(fex); iResult = 0; } catch (FileLoadException flx) { ExceptionManager.Publish(flx); iResult = 0; } catch (Exception ex) { ExceptionManager.Publish(ex); iResult = 0; } return(iResult); }
public string GetSetting(string strSettingName, string defaultValue) { return(CommonDataAccess.GetSettingValue(strSettingName, defaultValue)); }