public RecordIds(DbBase db, HluDataSet hluDataset, TableAdapterManager hluTableAdapterMgr, ViewModelWindowMain.GeometryTypes gisLayerType) { if (db == null) { throw new ArgumentException("db"); } if (hluDataset == null) { throw new ArgumentException("hluDataset"); } if (hluTableAdapterMgr == null) { throw new ArgumentException("hluTableAdapterMgr"); } _db = db; _hluDataset = hluDataset; _hluTableAdapterMgr = hluTableAdapterMgr; _gisLayerType = gisLayerType; if (_hluDataset.lut_last_incid.IsInitialized && _hluDataset.lut_last_incid.Count == 0) { if (_hluTableAdapterMgr.lut_last_incidTableAdapter == null) { _hluTableAdapterMgr.lut_last_incidTableAdapter = new HluTableAdapter <HluDataSet.lut_last_incidDataTable, HluDataSet.lut_last_incidRow>(_db); } _hluTableAdapterMgr.Fill(_hluDataset, new Type[] { typeof(HluDataSet.lut_last_incidDataTable) }, false); } _incidCurrentNumber = CurrentMaxIncidNumber(false); InitializeIncidChildRecordIds(); }
public ViewModelCompletePhysicalSplit(string reason, string process, HluDataSet.lut_reasonRow[] reasonCodes, HluDataSet.lut_processRow[] processCodes) { _reason = reason; _process = process; _reasonCodes = reasonCodes; _processCodes = processCodes; }
public ViewModelExport(int numberSelected, string layerName, GISApplications gisApp, HluDataSet.exportsDataTable exportFormats) { _selectedNumber = numberSelected; _selectedOnly = _selectedNumber > 0; _layerName = layerName; _gisApp = gisApp; _exportFormats = exportFormats; if (_exportFormats.Count == 1) _exportID = _exportFormats[0].export_id; }
public BapEnvironment(bool bulkUpdateMode, bool additional, HluDataSet.incid_bapRow dataRow) { _bulkUpdateMode = bulkUpdateMode; _additionalBap = additional; HluDataSet.incid_bapDataTable table = (HluDataSet.incid_bapDataTable)dataRow.Table; _bap_id = dataRow.bap_id; _incid = dataRow.incid; _bap_habitat = dataRow.IsNull(table.bap_habitatColumn) ? null : dataRow.bap_habitat; _quality_determination = _additionalBap ? BAPDetQltyUserAdded : dataRow.IsNull(table.quality_determinationColumn) ? null : dataRow.quality_determination; _quality_interpretation = dataRow.IsNull(table.quality_interpretationColumn) ? null : dataRow.quality_interpretation; this.interpretation_comments = dataRow.IsNull(table.interpretation_commentsColumn) ? null : dataRow.interpretation_comments; }
public static bool CreateScratchMdb(HluDataSet.incidDataTable incidTable, HluDataSet.incid_mm_polygonsDataTable incidMMTable) { try { _incidTable = incidTable; _incidMMTable = incidMMTable; _scratchMdbPath = String.Empty; try { _scratchMdbPath = Path.GetTempPath(); } catch { _scratchMdbPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); _scratchMdbPath += Path.DirectorySeparatorChar.ToString(); } _scratchMdbPath += Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".mdb"; OdbcCP32 odbc = new OdbcCP32(); odbc.CreateDatabase(_scratchMdbPath); string connString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", _scratchMdbPath); string defaultSchema = ""; bool promptPwd = false; _scratchDb = new DbOleDb(ref connString, ref defaultSchema, ref promptPwd, Properties.Resources.PasswordMaskString, Settings.Default.UseAutomaticCommandBuilders, true, Settings.Default.DbIsUnicode, Settings.Default.DbUseTimeZone, 255, Settings.Default.DbBinaryLength, Settings.Default.DbTimePrecision, Settings.Default.DbNumericPrecision, Settings.Default.DbNumericScale); return true; } catch { if (File.Exists(_scratchMdbPath)) { try { if ((_scratchDb != null) && (_scratchDb.Connection.State != ConnectionState.Closed)) _scratchDb.Connection.Close(); File.Delete(_scratchMdbPath); } catch { } } return false; } }
public BapEnvironment(bool bulkUpdateMode, bool isSecondary, HluDataSet.incid_bapRow dataRow) { _bulkUpdateMode = bulkUpdateMode; _secondaryPriorityHabitat = isSecondary; HluDataSet.incid_bapDataTable table = (HluDataSet.incid_bapDataTable)dataRow.Table; _bap_id = dataRow.bap_id; _incid = dataRow.incid; _bap_habitat = dataRow.IsNull(table.bap_habitatColumn) ? null : dataRow.bap_habitat; _quality_determination = dataRow.IsNull(table.quality_determinationColumn) ? null : dataRow.quality_determination; _quality_interpretation = dataRow.IsNull(table.quality_interpretationColumn) ? null : dataRow.quality_interpretation; //--------------------------------------------------------------------- // CHANGED: CR2 (Apply button) // Update the _interpretation_comments string directly, rather than via the property, // so that the Changed flag is not set. // //this.interpretation_comments = dataRow.IsNull(table.interpretation_commentsColumn) ? // null : dataRow.interpretation_comments; if (dataRow.IsNull(table.interpretation_commentsColumn)) _interpretation_comments = null; else _interpretation_comments = dataRow.interpretation_comments.Length < 255 ? dataRow.interpretation_comments : dataRow.interpretation_comments.Substring(0, 254); //--------------------------------------------------------------------- }
public static string GetOperationsCode(HluDataSet hluDS, ViewModelWindowMain.Operations modifyOperation) { if ((hluDS == null) || (hluDS.lut_operation == null)) { return(null); } string operationName = Enum.GetName(typeof(ViewModelWindowMain.Operations), modifyOperation); string descriptionPattern = Regex.Matches(operationName, "[A-Z][^A-Z]*").Cast <Match>() .Aggregate(new StringBuilder(), (sb, m) => sb.Append(@"\s*" + operationName.Substring(m.Index, m.Length))) .Append(@"\s*").ToString(); var o = hluDS.lut_operation .Where(r => Regex.IsMatch(r.description, descriptionPattern, RegexOptions.IgnoreCase)); if (o.Count() == 1) { return(o.First().code); } else { return(null); } }
public static HluDataSet.incid_bapRow MakeSecondary(HluDataSet.incid_bapRow r) { return r; }
public ViewModelWindowSelectQuery(HluDataSet hluDataset, DbBase hluDatabase) { HluDatasetStatic = hluDataset; _db = hluDatabase; }
public ViewModelQueryBuilder(HluDataSet hluDataset) { HluDatasetStatic = hluDataset; _hluDataset = hluDataset; }
/// <summary> /// Handles event when Cancel button is clicked /// </summary> /// <param name="param"></param> /// <remarks></remarks> private void CancelCommandClick(object param) { HluDatasetStatic = null; this.RequestClose(null); }
/// <summary> /// Handles event when Ok button is clicked /// </summary> /// <param name="param"></param> /// <remarks></remarks> private void OkCommandClick(object param) { HluDatasetStatic = null; this.RequestClose(_queryItems); }
public ViewModelQueryBuilder(HluDataSet hluDataset) { HluDatasetStatic = hluDataset; _hluDataset = hluDataset; }
/// <summary> /// Handles event when Ok button is clicked /// </summary> /// <param name="param"></param> /// <remarks></remarks> private void OkCommandClick(object param) { HluDatasetStatic = null; this.RequestClose(_queryItems); }
/// <summary> /// Handles event when Cancel button is clicked /// </summary> /// <param name="param"></param> /// <remarks></remarks> private void CancelCommandClick(object param) { HluDatasetStatic = null; this.RequestClose(null); }
private void MergeSynchronizeIncidMMPolygons(HluDataSet.incid_mm_polygonsDataTable selectTable, DataTable resultTable, string newToidFragmentID, List<SqlFilterCondition> resultFeatureWhereClause, List<List<SqlFilterCondition>> mergeFeaturesWhereClause) { // build an update statement for the result feature: lowest toid_fragment_id // in the selection set and sum of shape_length/shape_area of merged features string updateWhereClause = _viewModelMain.DataBase.WhereClause(false, true, true, resultFeatureWhereClause); string updateStatement = null; switch (_viewModelMain.GisLayerType) { case ViewModelWindowMain.GeometryTypes.Point: updateStatement = String.Format("UPDATE {0} SET {1} = {2} WHERE {3}", _viewModelMain.DataBase.QualifyTableName(_viewModelMain.HluDataset.incid_mm_polygons.TableName), _viewModelMain.DataBase.QuoteIdentifier( _viewModelMain.HluDataset.incid_mm_polygons.toid_fragment_idColumn.ColumnName), _viewModelMain.DataBase.QuoteValue(newToidFragmentID), updateWhereClause); break; case ViewModelWindowMain.GeometryTypes.Line: double plineLength = resultTable.Rows[0].Field<double>(ViewModelWindowMain.HistoryGeometry1ColumnName); updateStatement = String.Format("UPDATE {0} SET {1} = {2}, {3} = {4} WHERE {5}", _viewModelMain.DataBase.QualifyTableName(_viewModelMain.HluDataset.incid_mm_polygons.TableName), _viewModelMain.DataBase.QuoteIdentifier( _viewModelMain.HluDataset.incid_mm_polygons.toid_fragment_idColumn.ColumnName), _viewModelMain.DataBase.QuoteValue(newToidFragmentID), _viewModelMain.DataBase.QuoteIdentifier( _viewModelMain.HluDataset.incid_mm_polygons.shape_lengthColumn.ColumnName), plineLength, updateWhereClause); break; case ViewModelWindowMain.GeometryTypes.Polygon: double shapeLength = resultTable.Rows[0].Field<double>(ViewModelWindowMain.HistoryGeometry1ColumnName); double shapeArea = resultTable.Rows[0].Field<double>(ViewModelWindowMain.HistoryGeometry2ColumnName); updateStatement = String.Format("UPDATE {0} SET {1} = {2}, {3} = {4}, {5} = {6} WHERE {7}", _viewModelMain.DataBase.QualifyTableName(_viewModelMain.HluDataset.incid_mm_polygons.TableName), _viewModelMain.DataBase.QuoteIdentifier( _viewModelMain.HluDataset.incid_mm_polygons.toid_fragment_idColumn.ColumnName), _viewModelMain.DataBase.QuoteValue(newToidFragmentID), _viewModelMain.DataBase.QuoteIdentifier( _viewModelMain.HluDataset.incid_mm_polygons.shape_lengthColumn.ColumnName), shapeLength, _viewModelMain.DataBase.QuoteIdentifier( _viewModelMain.HluDataset.incid_mm_polygons.shape_areaColumn.ColumnName), shapeArea, updateWhereClause); break; } bool startTransaction = _viewModelMain.DataBase.Transaction == null; if (startTransaction) _viewModelMain.DataBase.BeginTransaction(true, IsolationLevel.ReadCommitted); try { // delete merged polygons from shadow table in DB List<List<SqlFilterCondition>> cleanList = _viewModelMain.DataBase.JoinWhereClauseLists(mergeFeaturesWhereClause); foreach (List<SqlFilterCondition> oneWhereClause in cleanList) { if (_viewModelMain.DataBase.ExecuteNonQuery(String.Format("DELETE FROM {0} WHERE {1}", _viewModelMain.DataBase.QualifyTableName(_viewModelMain.HluDataset.incid_mm_polygons.TableName), _viewModelMain.DataBase.WhereClause(false, true, true, oneWhereClause)), _viewModelMain.DataBase.Connection.ConnectionTimeout, CommandType.Text) == -1) throw new Exception(String.Format("Failed to delete from table {0}.", _viewModelMain.HluDataset.incid_mm_polygons.TableName)); } // update the result feature if (_viewModelMain.DataBase.ExecuteNonQuery(updateStatement, _viewModelMain.DataBase.Connection.ConnectionTimeout, CommandType.Text) == -1) throw new Exception(String.Format("Failed to update table {0}.", _viewModelMain.HluDataset.incid_mm_polygons.TableName)); if (startTransaction) _viewModelMain.DataBase.CommitTransaction(); } catch { if (startTransaction) _viewModelMain.DataBase.RollbackTransaction(); throw; } }
public static HluDataSet.incid_bapRow MakeAdditional(HluDataSet.incid_bapRow r) { if (r != null) r.quality_determination = BAPDetQltyUserAdded; return r; }
public static bool ValidateRow(bool bulkUpdateMode, bool additionalBap, HluDataSet.incid_bapRow r) { return ValidateRow(bulkUpdateMode, additionalBap, r.bap_id, r.incid, r.bap_habitat, r.quality_determination, r.quality_interpretation) == null; }
public bool IsValid(bool bulkUpdateMode, bool additionalBap, HluDataSet.incid_bapRow r) { return String.IsNullOrEmpty(ValidateRow(bulkUpdateMode, additionalBap, r.bap_id, r.incid, r.bap_habitat, r.quality_determination, r.quality_interpretation)); }
public static bool ValidateRow(bool bulkUpdateMode, bool additionalBap, HluDataSet.incid_bapRow r, IEnumerable<BapEnvironment> bapEnvironmentList) { return ValidateRow(bulkUpdateMode, additionalBap, r.bap_id, r.incid, r.bap_habitat, r.quality_determination, r.quality_interpretation) == null; }