Unified · Split
| @@ -106,18 +106,21 @@ namespace GSF.Web.Security · 105 unmodified lines | ||
| 106 | 106 | DefaultNodeID = Guid.Parse(systemSettings["NodeID"].Value.ToNonNullString(Guid.NewGuid().ToString())); |
| 107 | 107 | |
| 108 | 108 | // Determine whether the node exists in the database and create it if it doesn't |
| 109 | − using (AdoDataConnection connection = new AdoDataConnection("securityProvider")) | |
| 109 | + if (DefaultNodeID != Guid.Empty) | |
| 110 | 110 | { |
| 111 | − const string NodeCountFormat = "SELECT COUNT(*) FROM Node"; | |
| 112 | − const string NodeInsertFormat = "INSERT INTO Node(Name, Description, Enabled) VALUES('Default', 'Default node', 1)"; | |
| 113 | − const string NodeUpdateFormat = "UPDATE Node SET ID = {0}"; | |
| 111 | + using (AdoDataConnection connection = new AdoDataConnection("securityProvider")) | |
| 112 | + { | |
| 113 | + const string NodeCountFormat = "SELECT COUNT(*) FROM Node"; | |
| 114 | + const string NodeInsertFormat = "INSERT INTO Node(Name, Description, Enabled) VALUES('Default', 'Default node', 1)"; | |
| 115 | + const string NodeUpdateFormat = "UPDATE Node SET ID = {0}"; | |
| 114 | 116 | |
| 115 | − int nodeCount = connection.ExecuteScalar<int?>(NodeCountFormat) ?? 0; | |
| 117 | + int nodeCount = connection.ExecuteScalar<int?>(NodeCountFormat) ?? 0; | |
| 116 | 118 | |
| 117 | − if (nodeCount == 0) | |
| 118 | − { | |
| 119 | − connection.ExecuteNonQuery(NodeInsertFormat); | |
| 120 | − connection.ExecuteNonQuery(NodeUpdateFormat, connection.Guid(DefaultNodeID)); | |
| 119 | + if (nodeCount == 0) | |
| 120 | + { | |
| 121 | + connection.ExecuteNonQuery(NodeInsertFormat); | |
| 122 | + connection.ExecuteNonQuery(NodeUpdateFormat, connection.Guid(DefaultNodeID)); | |
| 123 | + } | |
| 121 | 124 | } |
| 122 | 125 | } |
| 123 | 126 | } |