Esempio n. 1
0
		internal static void UpdateDatabaseMetaProperty(string connectionString, string propertyName, string propertyValue)
		{
			System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
			try
			{
				var settings = new nHydrateSetting();
				settings.Load(connectionString);
				switch (propertyName)
				{
					case "dbVersion":
						settings.dbVersion = propertyValue;
						break;
					case "LastUpdate":
						settings.LastUpdate = DateTime.Parse(propertyValue);
						break;
					case "ModelKey":
						settings.ModelKey = new Guid(propertyValue);
						break;
					case "History":
						settings.LoadHistory(propertyValue);
						break;
					default:
						throw new Exception("No property found!");
				}
				settings.Save(connectionString);
			}
			catch (Exception ex)
			{
				throw;
			}
			finally
			{
				if (conn != null)
					conn.Close();
			}

			//We no longer use extended properties
			if (CanUseExtendedProperty(connectionString))
			{
				if (ExtendedPropertyExists(connectionString, propertyName, string.Empty, string.Empty, string.Empty))
				{
					//UpdateExtendedProperty(connectionString, propertyName, propertyValue, string.Empty, string.Empty, string.Empty);
					DeleteExtendedProperty(connectionString, propertyName);
				}
				else
				{
					//InsertExtendedPropery(connectionString, propertyName, propertyValue, string.Empty, string.Empty, string.Empty);
				}
			}

		}
Esempio n. 2
0
		internal static string GetDatabaseMetaProperty(string connectionString, string propertyName)
		{
			if (CanUseExtendedProperty(connectionString))
			{
				return SelectExtendedProperty(connectionString, propertyName, string.Empty, string.Empty, string.Empty);
			}
			else
			{
				var settings = new nHydrateSetting();
				settings.Load(connectionString);
				switch (propertyName)
				{
					case "dbVersion":
						return settings.dbVersion;
					case "LastUpdate":
						return settings.LastUpdate.ToString("yyyy-MM-dd HH:mm:ss");
					case "ModelKey":
						return settings.ModelKey.ToString();
					case "History":
						return settings.ToHistoryString();
					default:
						throw new Exception("No property found!");
				}
			}
		}
Esempio n. 3
0
		internal static List<HistoryItem> GetHistory(string connectionString)
		{
			var retval = new List<HistoryItem>();
			var settings = new nHydrateSetting();
			if (CanUseExtendedProperty(connectionString))
			{
				var historyRow = SqlServers.SelectExtendedProperty(connectionString, "History", string.Empty, string.Empty, string.Empty);
				settings.LoadHistory(historyRow);
				if (settings.History.Count > 0)
					return settings.History;
			}

			if (settings.History.Count == 0)
			{
				settings = new nHydrateSetting();
				settings.Load(connectionString);
			}
			return settings.History;

		}