private void Run(CancellationToken cancellationToken) { LocalizationHelper.InitThread(); try { using (QueryRequest.QueryLock.GetReadLock()) { var queryResults = QueryResults.Empty .SetParameters(QueryRequest.QueryParameters) .SetSourceRows(RowSource.ListRowItems()); queryResults = RunAll(cancellationToken, queryResults); QueryRequest.SetFinalQueryResults(queryResults); } } catch (OperationCanceledException) { } catch (Exception e) { if (!(e.InnerException is OperationCanceledException)) { QueryRequest.OnUnhandledException(e); } } }
private void Reset() { lock (this) { Stop(); SourceRowItems = ImmutableList.ValueOf(RowSource.ListRowItems()); EnsureRunning(); } }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RowSource != null ? RowSource.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Rules != null ? Rules.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { int result = (Name != null ? Name.GetHashCode() : 0); result = result * 397 ^ (RowSource != null ? RowSource.GetHashCode() : 0); result = (result * 397) ^ CollectionUtil.GetHashCodeDeep(Columns); result = (result * 397) ^ CollectionUtil.GetHashCodeDeep(Filters); result = (result * 397) ^ SublistId.GetHashCode(); return(result); } }
public StreamedBinaryTableHDU(RowSource rs, int bufSize, StringWriteMode writeMode, int stringTruncationLength, bool padLeft, char padChar) { _writerMap = CreateWriterMap(); _rs = rs; _buf = new byte[bufSize]; _byteRenderers = new ByteRenderer[_rs.ModelRow.Length]; _writeMode = writeMode; _stringTruncationLength = stringTruncationLength; _padLeft = padLeft; _padChar = padChar; SetupRenderers(); }
private void Add(object obj) { var ank = new AnketaViewModel(new Anketa()) { FileId = SelectedFile.ID }; // Stable dependency var ieditView = Facade.GetEditView(ank); ieditView.ShowAction(); if (!ank.HasErrors) { RowSource.Add(ank); } }
public void Start() { lock (this) { if (null != _cancellationTokenSource) { throw new InvalidOperationException(); } RowSource.RowSourceChanged += RowSourceChanged; _rootCancellationToken.Register(() => RowSource.RowSourceChanged -= RowSourceChanged); SourceRowItems = ImmutableList.ValueOf(RowSource.ListRowItems()); EnsureRunning(); } }
protected void ImportCurrentRow(int rowId, System.Data.Common.DbConnection connection) { try { User.BeginTransaction(connection); ImportRowImpl(rowId, connection); // If we get here we can commit the transacton.... User.CommitTransaction(); _successCount++; } catch (Exception ex) { Error("Error on Row {0}: {1}", rowId, ex.Message); // Roll back the transaction.... User.RollbackTransaction(); // Mark the import row as failed RowSource.CopyToErrorTable(ex.Message); _errorCount++; } }
private void Run() { try { var queryResults = QueryResults.Empty .SetParameters(QueryRequest.QueryParameters) .SetSourceRows(RowSource.ListRowItems()); queryResults = RunAll(QueryRequest.CancellationToken, queryResults); QueryRequest.SetFinalQueryResults(queryResults); } catch (OperationCanceledException) { // ignore } catch (Exception ex) { QueryRequest.OnUnhandledException(ex); } }
public override int GetHashCode() { unchecked { var hashCode = PropMask?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Tag?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Id; hashCode = (hashCode * 397) ^ HelpContextId; hashCode = (hashCode * 397) ^ (int)BitFlags; hashCode = (hashCode * 397) ^ (int)ObjectStreamSize; hashCode = (hashCode * 397) ^ TabIndex.GetHashCode(); hashCode = (hashCode * 397) ^ ClsidCacheIndex.GetHashCode(); hashCode = (hashCode * 397) ^ GroupId.GetHashCode(); hashCode = (hashCode * 397) ^ (ControlTipText?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (RuntimeLicKey?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (ControlSource?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (RowSource?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (SitePosition?.GetHashCode() ?? 0); return(hashCode); } }
private void CreateColumnIndexes() { LogMsg("Caching column mappings..."); _fieldIndex.Clear(); foreach (ImportFieldMapping mapping in Mappings) { if (mapping.TargetColumn == null) { continue; } string target = mapping.TargetColumn.ToLower(); int index = -1; for (int i = 0; i <= RowSource.ColumnCount - 1; ++i) { var sourceColumnName = RowSource.ColumnName(i); if (sourceColumnName.Equals(mapping.SourceColumn, StringComparison.CurrentCultureIgnoreCase)) { index = i; break; } } if (index >= 0) { _fieldIndex[target] = index; if (!string.IsNullOrWhiteSpace(mapping.TargetColumn)) { LogMsg("{0} mapped to {1} (index {2})", mapping.TargetColumn, mapping.SourceColumn, index); } else { LogMsg("Source column {1} (index {2}) is not mapped to a target column.", mapping.TargetColumn, mapping.SourceColumn, index); } } } }
private async void ReloadGridData() { ComboEnabed = false; RowSource.Clear(); if (SelectedFile != null) { var anketas = await Facade.Keeper.GetAnketasAsync(_selectedFile.ID); foreach (var row in anketas) { var ankview = new AnketaViewModel(row); // Stable dependency RowSource.Add(ankview); } } if (RowSource.Count > 0) { AllowDeploy = true; } else { AllowDeploy = false; } ComboEnabed = true; }
public StreamedBinaryTableHDU(RowSource rs, int bufSize, StringWriteMode writeMode, int stringTruncationLength) : this(rs, bufSize, writeMode, stringTruncationLength, true, ' ') { }
public StreamedBinaryTableHDU(RowSource rs, int bufSize) : this(rs, bufSize, DEFAULT_STRING_WRITE_MODE, DEFAULT_STRING_TRUNCATION_LENGTH) { }
public StreamedBinaryTableHDU(RowSource rs) : this(rs, DEFAULT_BUFFER_SIZE) { }
public void Import(Window parentWindow, ImportWizardContext context, IProgressObserver progress, Action <ImportStatusLevel, string> logFunc) { this.ParentWindow = parentWindow; this.Importer = context.Importer; this.Mappings = context.FieldMappings; this.Progress = progress; this.LogFunc = logFunc; if (Progress != null) { Progress.ProgressStart("Initialising..."); } if (!InitImport()) { return; } ProgressMsg("Importing data - Stage 1", 0); if (!DoStage1()) { return; } CreateColumnIndexes(); Cancelled = false; var connection = User.GetConnection(); LogMsg("Importing data - Stage 2", 10); int rowCount = 0; int lastPercent = 0; DateTime timeStarted = DateTime.Now; DateTime lastCheck = timeStarted; RowSource.Reset(); while (RowSource.MoveNext() && !Cancelled) { ImportCurrentRow(rowCount++, connection); var dblPercent = (double)((double)rowCount / (double)RowSource.RowCount) * 90; int percent = ((int)dblPercent) + 10; var timeSinceLastUpdate = DateTime.Now - lastCheck; if (percent != lastPercent || timeSinceLastUpdate.Seconds > 5) { var timeSinceStart = DateTime.Now - timeStarted; var avgMillisPerRow = (double)(timeSinceStart.TotalMilliseconds == 0 ? 1 : timeSinceStart.TotalMilliseconds) / (double)(rowCount == 0 ? 1 : rowCount); var rowsLeft = RowSource.RowCount - rowCount; var secondsLeft = (int)((double)(rowsLeft * avgMillisPerRow) / 1000.0); lastCheck = DateTime.Now; TimeSpan ts = new TimeSpan(0, 0, secondsLeft); var message = string.Format("Importing rows - Stage 2 ({0} of {1}). {2} remaining.", rowCount, RowSource.RowCount, ts.ToString()); ProgressMsg(message, percent); lastPercent = percent; } } ProgressMsg("Importing rows - Stage 2 Complete", 100); LogMsg("{0} Rows successfully imported, {1} rows failed with errors", _successCount, _errorCount); LogMsg("Cleaning up staging database..."); if (RowSource.Service.GetErrorCount() > 0) { if (ParentWindow.Question("Errors were encountered during the import. Rejected rows can be corrected and re-imported by re-running the import wizard and selecting the 'Import Error Database' option. Would you like to save the rejected rows so that they can be corrected and re-imported?", "Save rejected rows?", System.Windows.MessageBoxImage.Exclamation)) { // Clean out just the imported records, leaving just the error rows... LogMsg("Purging successfully imported rows from staging database..."); RowSource.Service.PurgeImportedRecords(); LogMsg("Saving mapping information to staging database..."); RowSource.Service.SaveMappingInfo(Importer, Mappings); LogMsg("Disconnecting from staging database..."); RowSource.Service.Disconnect(); var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = "SQLite database files|*.sqlite|All files (*.*)|*.*"; dlg.Title = "Save error database file"; if (dlg.ShowDialog().ValueOrFalse()) { LogMsg("Copying staging database from {0} to {1}", RowSource.Service.FileName, dlg.FileName); System.IO.File.Copy(RowSource.Service.FileName, dlg.FileName, true); } } } connection.Close(); }
private void Remove(object obj) { Facade.Keeper.Remove(SelectedRow.TheAnketa); RowSource.Remove(SelectedRow); }