Ejemplo n.º 1
0
        public void SaveAll()
        {
            mustCancel = false;
            byte[] buffer = null;
            for (int i = 0; i < filesToSave.Length; i++)
            {
                fileIndex = i;
                var state = filesToSave[fileIndex];
                OnWritingFile?.Invoke(this, new ModuleSaverWriteEventArgs(state.File, true));

                fileProgress = null;
                switch (state.File.Type)
                {
                case SaveOptionsType.Module:    Save((SaveModuleOptionsVM)state.File); break;

                case SaveOptionsType.Hex:               Save((SaveHexOptionsVM)state.File, ref buffer); break;

                default:                                                throw new InvalidOperationException();
                }
                fileProgress = null;

                OnWritingFile?.Invoke(this, new ModuleSaverWriteEventArgs(state.File, false));
            }

            fileIndex = filesToSave.Length;
            OnProgressUpdated?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 2
0
 internal void UpdateProgress(float _progress)
 {
     progress = _progress;
     if (OnProgressUpdated != null)
     {
         OnProgressUpdated.Invoke(this);
     }
 }
Ejemplo n.º 3
0
        private void UpdateUITimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Console.WriteLine("Timer elapsed in SampleEventRaiser");
            i += 2;
            double time = e.SignalTime.TimeOfDay.TotalMilliseconds;

            if (i == 100)
            {
                updateUITimer.Stop();
                updateUITimer.Dispose();
            }
            OnProgressUpdated?.Invoke(i, time);
        }
        public void PseudonymizeTable(string schema, Table table)
        {
            string sql = $"SELECT * FROM [{schema}].[{table.Name}] ORDER BY {table.Columns.First().ColumnName} ASC OFFSET {{0}} ROWS FETCH NEXT {BulkSize} ROWS ONLY";

            long size = table.BulkBlocks;

            for (long i = 0; i < size; i++)
            {
                using (var dataTable = new DataTable())
                    using (var sqlConn = new SqlConnection(ConnectionString))
                        using (var cmd = new SqlDataAdapter(string.Format(sql, i * BulkSize), sqlConn))
                            using (var sqlCommand = new SqlCommandBuilder(cmd))
                            {
                                try
                                {
                                    cmd.Fill(dataTable);

                                    for (int j = 0; j < dataTable.Rows.Count; j++)
                                    {
                                        foreach (var column in table.Columns)
                                        {
                                            var    pseudonymized = Pseudonymizer.Pseudonymize(dataTable.Rows[j][column.ColumnName].ToString());
                                            string value         = column.MaxLength.HasValue && pseudonymized.Length > column.MaxLength.Value
                                    ? new string(pseudonymized.Take(column.MaxLength.Value).ToArray())
                                    : pseudonymized;
                                            dataTable.Rows[j][column.ColumnName] = value;
                                        }
                                    }

                                    cmd.UpdateCommand   = sqlCommand.GetUpdateCommand();
                                    cmd.UpdateBatchSize = BulkSize;
                                    cmd.Update(dataTable);

                                    int progressPercentage = (int)(((double)(++_currentBulkIndexProcessed) / _bulkSizeExpected) * 100);

                                    OnProgressUpdated?.Invoke(
                                        null,
                                        new ProgressEventArgs()
                                    {
                                        Percetange = progressPercentage
                                    });
                                }
                                catch (Exception ex)
                                {
                                    Logger.Log(ex);
                                }
                            }
            }
        }
Ejemplo n.º 5
0
 void NotifyProgressUpdated() => OnProgressUpdated?.Invoke(this, EventArgs.Empty);
 protected void FireProgressUpdated()
 {
     OnProgressUpdated?.Invoke(this);
 }