コード例 #1
0
 public void LoadFromFile()
 {
     using (var cmd = _db.CreateCommand())
     {
         cmd.CommandText = "SELECT path FROM folders";
         using (var dr = cmd.ExecuteReader())
         {
             LogEntries.Clear();
             while (dr.Read())
             {
                 LogEntries.Add(new LogEntry()
                 {
                     MainItem = dr.GetString(0)
                 });
             }
             FolderCount = (uint)LogEntries.Count;
             if (FolderCount > 0)
             {
                 RootFolder = LogEntries[0].MainItem;
             }
         }
         cmd.CommandText = "SELECT COUNT(name) FROM files";
         FileCount       = Convert.ToUInt32(cmd.ExecuteScalar());
         Status          = ComparatorStatus.Ready;
     }
 }
コード例 #2
0
        void LoadEntries()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            LogEntries.Clear();

            try
            {
                _cache.GetAndFetchLatest("entries", async()
                                         => await _tripLogService.GetEntriesAsync())
                .Subscribe(entries
                           => LogEntries = new ObservableCollection <TripLogEntry>(entries));
            }
            catch (Exception e)
            {
                AnalyticsService.TrackError(e,
                                            new Dictionary <string, string>
                {
                    { "Method", "MainViewModel.LoadEntries()" }
                });
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #3
0
        async Task LoadEntries()
        {
            LogEntries.Clear();

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Washington Monument",
                Notes     = "Amazing!",
                Rating    = 3,
                Date      = new DateTime(2017, 2, 5),
                Latitude  = 38.8895,
                Longitude = -77.0352
            });

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Statue of Liberty",
                Notes     = "Inspiring!",
                Rating    = 4,
                Date      = new DateTime(2017, 4, 13),
                Latitude  = 40.6892,
                Longitude = -74.0444
            });

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Golden Gate Bridge",
                Notes     = "Foggy, but beautiful.",
                Rating    = 5,
                Date      = new DateTime(2017, 4, 26),
                Latitude  = 37.8268,
                Longitude = -122.4798
            });
        }
コード例 #4
0
        internal static void UpdateConfig(ConfigData settings)
        {
            DuplicateManager.Settings = settings;
            Dedupper.Stop();
            Dedupper.UpdateConfiguration(settings);

            lock (LogEntriesLock)
            {
                LogEntries.Clear();
                logId = Guid.NewGuid();
            }

            try
            {
                Dedupper.Start();
            }
            catch (InvalidOperationException exc)
            {
                OperationInfo = new OperationInfo
                {
                    ProgressStyle = ProgressStyle.NoProgress,
                    Message       = exc.Message,
                };
                AddLogEntry(exc.Message);
            }
        }
コード例 #5
0
        public void Reset()
        {
            if (FolderCount == 0 && FileCount == 0)
            {
                return;
            }

            if (_Status == ComparatorStatus.Running)
            {
                throw new InvalidOperationException("Comparator is running. You can not erase the database. Abort processing first.");
            }
            MessageBoxHelper.PrepToCenterMessageBoxOnForm(Application.Current.MainWindow);
            if (MessageBox.Show(Application.Current.MainWindow, "Are you sure?", "Erase database", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            FolderCount = 0;
            FileCount   = 0;
            LogEntries.Clear();
            StatusMessage = _StatusMessageDefaultValue;
            SQLiteCommand cmd = _db.CreateCommand();

            cmd.CommandText = "DELETE FROM folders;";
            cmd.ExecuteNonQuery();
            cmd.CommandText = "DELETE FROM files;";
            cmd.ExecuteNonQuery();
            cmd.CommandText = "VACUUM;";
            cmd.ExecuteNonQuery();
            UpdateStatus();
        }
コード例 #6
0
        private void setupNewLog()
        {
            LogEntries.Clear();
            CollectionIsDirty = true;
            LogOnDisk         = false;

            logName = "New Log";
            setWindowTitle();
        }
コード例 #7
0
        private async void RefreshData()
        {
            LogEntries.Clear();
            IList <LogbookEntry> entries = await _logbookService.GetEntriesWithoutTrackAsync(_aircraft);

            foreach (LogbookEntry logbookEntry in entries)
            {
                LogEntries.Add(logbookEntry);
            }

            CreateSummary();
        }
コード例 #8
0
 private async Task LoadEntries()
 {
     await Task.Factory.StartNew(() =>
     {
         var items = DataService.Instance.GetItems();
         LogEntries.Clear();
         foreach (var item in items)
         {
             LogEntries.Add(item);
         }
         OnPropertyChanged("LogEntries");
     });
 }
コード例 #9
0
ファイル: MainViewModel.cs プロジェクト: jsauve/PlugEVMe
        async Task LoadEntries()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                LogEntries.Clear();

                ReadLibraries readLibraries = new ReadLibraries();
                List <string> libraries     = readLibraries.libraries;

                var tempEntries = new List <PlugEVMeEntry>();

                tempEntries.Add(homeEntry);

                foreach (string library in libraries)
                {
                    PlugEVMeEntry _entry = new PlugEVMeEntry();

                    string[] libs = library.Split(',');

                    _entry.Longitude = Convert.ToDouble(libs[libs.Length - 1]);
                    _entry.Latitude  = Convert.ToDouble(libs[libs.Length - 2]);
                    libs.Take(libs.Length - 1);
                    libs.Take(libs.Length - 2);

                    _entry.Title = libs[0];
                    _entry.Date  = DateTime.Now;
                    _entry.Title = string.Join(" ", libs);
                    _entry.Notes = _entry.Latitude + " " + _entry.Longitude;
                    tempEntries.Add(_entry);
                }

                // AddRange() in ObservableRangeCollection differs from Add() in ObservableCollection in that it fires a single
                // CollectionChanged notification when all the items are added to the collection at once, instead of many individual
                // CollectionChanged notifications from calling Add() over and over.
                LogEntries.AddRange(tempEntries);
            }
            finally
            {
                IsBusy = false;
            }

            await Task.CompletedTask;
        }
コード例 #10
0
        private async void ButtonTestScript_OnClick(object sender, RoutedEventArgs e)
        {
            LogEntries.Clear();

            var jsCommand = JavascriptGrid.SelectedItem as JavaScriptCommand;

            if (jsCommand == null)
            {
                return;
            }

            var inMemoryLog = new InMemoryFeedback {
                Source = "JavaScript Test Window"
            };

            inMemoryLog.LogEntries.CollectionChanged += LogEntries_CollectionChanged;

            var myCollectionViewSource = (CollectionViewSource)Resources["LogEntryViewSource"];

            if (myCollectionViewSource != null)
            {
                myCollectionViewSource.Source = LogEntries;
            }

            await inMemoryLog.ReportInfoAsync("JavaScript test run started...", CancellationToken.None);

            var script = JsEditor.Editor.Text;

            if (string.IsNullOrEmpty(script))
            {
                return;
            }
            TestButton.IsEnabled = false;

            var javaScriptRunner = new JavaScriptRunner(inMemoryLog, new CommandProcessor(_app.ZvsEngine.AdapterManager, _app.EntityContextConnection, inMemoryLog), _app.EntityContextConnection);

            var result = await javaScriptRunner.ExecuteScriptAsync(script, CancellationToken.None);

            if (result.HasError)
            {
                await inMemoryLog.ReportErrorAsync(result.Message, CancellationToken.None);
            }
            else
            {
                await inMemoryLog.ReportInfoAsync(result.Message, CancellationToken.None);
            }

            TestButton.IsEnabled = true;
        }
コード例 #11
0
ファイル: SessionLog.cs プロジェクト: amoydream/RaceLogic
        public void BatchLoad(IEnumerable <object> logEntries)
        {
            LogEntries.Clear();
            LogEntries.AddRange(logEntries);
            var start = LogEntries.OfType <SessionStart>().LastOrDefault();

            if (start != null)
            {
                ApplyStart(start);
            }
            else
            {
                TrackOfCheckpoints = ReloadTrack(StartTime, FinishCriteria);
            }
        }
コード例 #12
0
        private void LogAppender_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                e.NewItems.Cast <LoggingEvent>().ToList().ForEach(x => AddEntry(x));
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                LogEntries.Clear();
                LogEntriesFiltered.Clear();
                App.PrintHeader();
                break;
            }
        }
コード例 #13
0
        async Task LoadEntries()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            LogEntries.Clear();

            // TODO: Remove this in chapter 6
            await Task.Delay(3000);

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Washington Monument",
                Notes     = "Amazing!",
                Rating    = 3,
                Date      = new DateTime(2017, 2, 5),
                Latitude  = 38.8895,
                Longitude = -77.0352
            });

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Statue of Liberty",
                Notes     = "Inspiring!",
                Rating    = 4,
                Date      = new DateTime(2017, 4, 13),
                Latitude  = 40.6892,
                Longitude = -74.0444
            });

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Golden Gate Bridge",
                Notes     = "Foggy, but beautiful.",
                Rating    = 5,
                Date      = new DateTime(2017, 4, 26),
                Latitude  = 37.8268,
                Longitude = -122.4798
            });

            IsBusy = false;
        }
コード例 #14
0
        public void FindDuplicates()
        {
            StatusMessage = "Searching for duplicates...";
            SQLiteCommand cmd = _db.CreateCommand();

            //cmd.CommandText = "SELECT name, path, size, date_mod, date_created, COUNT(*) as c FROM files INNER JOIN folders ON files.parent_folder_id = folders.rowid GROUP BY md5 HAVING c > 1";
            cmd.CommandText = @"
                SELECT files.rowid, files.name, folders.path, f.c, files.md5, files.size FROM files
                INNER JOIN folders ON files.parent_folder_id = folders.rowid
                JOIN ( SELECT rowid, md5, COUNT(*) as c FROM files GROUP BY md5 HAVING c > 1) f ON files.md5 = f.md5 ORDER BY files.size DESC";
            var dr = cmd.ExecuteReader();

            if (!dr.HasRows)
            {
                StatusMessage = "No duplicates found.";
                return;
            }
            LogEntries.Clear();
            string   md5  = String.Empty;
            LogEntry item = null;

            while (dr.ReadAsync().Result)
            {
                if (md5 != dr.GetString(4))
                {
                    if (item != null)
                    {
                        LogEntries.Add(item);
                    }
                    item = new LogEntry()
                    {
                        Rowid = (uint)dr.GetInt32(0), MainItem = Path.Combine(dr.GetString(2), dr.GetString(1)), DuplicatesCount = (uint)dr.GetInt32(3), FileSize = dr.GetInt32(5), Duplicates = new System.Collections.Generic.List <ItemDuplicates>()
                    };
                    md5 = dr.GetString(4);
                }
                else
                {
                    item.Duplicates.Add(new ItemDuplicates()
                    {
                        Rowid = (uint)dr.GetInt32(0), FilePath = Path.Combine(dr.GetString(2), dr.GetString(1)), IsSelected = false
                    });
                }
            }
            StatusMessage = String.Format("Found {0} duplicates.", LogEntries.Count);
        }
コード例 #15
0
        private void UpdateLog(string text)
        {
            var log = new LogEntry(text);

            LogEntries.Add(log);
            if (string.IsNullOrEmpty(SearchString) || text.ToLower().Contains(SearchString.ToLower()))
            {
                FilteredLogEntries.Add(log);
            }
            if (LogEntries.Count > 1000)
            {
                LogEntries.Clear();
                FilteredLogEntries.Clear();
            }
            if (IsUserScrollingLog == false)
            {
                LogScrollViewer.ScrollToEnd();
            }
        }
コード例 #16
0
 private void LoadEntries()
 {
     if (IsBusy)
     {
         return;
     }
     IsBusy = true;
     LogEntries.Clear();
     try
     {
         _cache.GetAndFetchLatest("entries", async() => await _tripLogService.GetEntriesAsync())
         .Subscribe(x => LogEntries = new ObservableCollection <TripLogEntry>(x),
                    ex => System.Diagnostics.Debug.WriteLine("No Key"));
     }
     finally
     {
         IsBusy = false;
     }
 }
コード例 #17
0
        private void JavascriptGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LogEntries.Clear();

            var jsCommand = JavascriptGrid.SelectedItem as JavaScriptCommand;

            if (jsCommand == null)
            {
                return;
            }

            JsEditor.Editor.ResetText();

            if (jsCommand.Script != null)
            {
                JsEditor.Editor.AppendText(jsCommand.Script);
            }

            EvaluateSaveButton();
        }
コード例 #18
0
        private void OnCmdDuplicatCheck()
        {
            DuplicateChecker dupChecker = new DuplicateChecker();
            var dupList = dupChecker.FindDuplicates(LogEntries);

            if (dupList.Any())
            {
                var newEntities = new List <IEntity>();
                foreach (DuplicateCheckerLib.IEntity d in dupList)
                {
                    newEntities.Add(d as IEntity);
                }

                LogEntries.Clear();
                LogEntries = newEntities;
            }
            else
            {
                MessageBox.Show("There are no duplicated Log Entries");
            }
        }
コード例 #19
0
        void LoadEntries()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = false;
            LogEntries.Clear();

            try
            {
                ReadLibraries readLibraries = new ReadLibraries();
                List <string> libraries     = readLibraries.libraries;

                // Load the current position homeentry and test values
                LogEntries.Insert(0, homeEntry);
                foreach (string library in libraries)
                {
                    PlugEVMeEntry _entry = new PlugEVMeEntry();

                    string[] libs = library.Split(',');

                    _entry.Longitude = Convert.ToDouble(libs[libs.Length - 1]);
                    _entry.Latitude  = Convert.ToDouble(libs[libs.Length - 2]);
                    libs.Take(libs.Length - 1);
                    libs.Take(libs.Length - 2);

                    _entry.Title = libs[0];
                    _entry.Date  = DateTime.Now;
                    _entry.Title = string.Join(" ", libs);
                    _entry.Notes = _entry.Latitude + " " + _entry.Longitude;
                    LogEntries.Add(_entry);
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #20
0
ファイル: MainViewModel.cs プロジェクト: yavaka/TripLog
        void LoadEntries()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            LogEntries.Clear();

            try
            {
                //Load data from the cache and then get entries from azure database
                _cache.GetAndFetchLatest("entries", async() => await _tripLogDataService.GetEntriesAsync())
                .Subscribe(entries => LogEntries = new ObservableCollection <TripLogEntry>(entries));
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #21
0
        void LoadEntries()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            LogEntries.Clear();

            try
            {
                // Load from local cache and then immediately load from API
                _cache.GetAndFetchLatest("entries", async() => await _tripLogService.GetEntriesAsync())
                .Subscribe(entries => LogEntries = new ObservableCollection <TripLogEntry>(entries));
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #22
0
        private void loadLogEntries(String filename)
        {
            Tuple <ObservableCollection <LogEntryDataModel>, String> loadResultTuple;

            if (!CollectionIsDirty)
            {
                loadResultTuple = FileIO.LoadLog(filename);

                ObservableCollection <LogEntryDataModel> logColl = loadResultTuple.Item1;
                if (logColl != null)
                {
                    LogEntries.Clear();

                    foreach (var logEntry in logColl)
                    {
                        LogEntries.Add(logEntry);
                    }
                    LogOnDisk             = true;
                    CollectionIsDirty     = false;
                    ListViewSelectedIndex = 0;
                    logName = loadResultTuple.Item2;
                    setWindowTitle();
                    UpdateStatusAsync("Successfully opened " + logName);
                }
                else if (loadResultTuple.Item2.Equals("BADFILE"))
                {
                    MessageBox.Show("The file is either from an older version or invalid and cannot be opened.", "SSLog");
                }
            }
            else
            {
                // Prompt for save
                if (PromptToSave() != MessageBoxResult.Cancel)
                {
                    CollectionIsDirty = false;
                    loadLogEntries();
                }
            }
        }
コード例 #23
0
ファイル: CentricityModule.cs プロジェクト: lulzzz/iRadiate
 private void GetLogEntries()
 {
     LogEntries.Clear();
     if (LogEndDate <= LogStartDate)
     {
         DesktopApplication.ShowDialog("Error", "Start date must be earlier than end date");
         return;
     }
     using (SqlConnection tmpCon = new SqlConnection(Properties.Settings.Default.InterfaceConnString))
     {
         tmpCon.Open();
         SqlCommand command = new SqlCommand("SELECT * FROM system_logging WHERE entered_date > '" + LogStartDate.ToString("yyyy-MM-dd HH:mm:ss") + "' AND log_date < '" + LogEndDate.ToString("yyyy-MM-dd HH:mm:ss") + "'", tmpCon);
         //command.Parameters.AddWithValue("@StartDate", LogStartDate);
         //SqlParameter startDateParam = new SqlParameter("@StartDate", SqlDbType.DateTime);
         //startDateParam.Value = LogStartDate;
         // SqlParameter endDateParam = new SqlParameter("@EndDate", SqlDbType.DateTime);
         //endDateParam.Value = endDateParam;
         //command.Parameters.Add(startDateParam);
         //command.Parameters.Add(endDateParam);
         //command.Parameters.AddWithValue("@EndDate", LogEndDate);
         SqlDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             //reader.Read();
             LogEntry entry = new LogEntry();
             entry.LogCallSite = reader["log_call_site"].ToString();
             entry.LogDate     = reader["log_date"].ToString();
             //entry.LogDate= reader.GetDateTime(reader.GetOrdinal("log_date"));
             entry.LogException  = reader["log_exception"].ToString();
             entry.LogLevel      = reader["log_level"].ToString();
             entry.LogLogger     = reader["log_logger"].ToString();
             entry.LogMessage    = reader["log_message"].ToString();
             entry.LogStackTrace = reader["log_stacktrace"].ToString();
             LogEntries.Add(entry);
         }
     }
 }
コード例 #24
0
 private void ClearHistory_Click(object sender, RoutedEventArgs e)
 {
     LogEntries.Clear();
 }
コード例 #25
0
ファイル: LogUI.cs プロジェクト: psryland/rylogic_code
 /// <summary>Reset the error log to empty</summary>
 public void Clear()
 {
     LogEntries.Clear();
 }
コード例 #26
0
 private void Clear()
 {
     LogEntries.Clear();
 }
コード例 #27
0
ファイル: LogPanelViewModel.cs プロジェクト: treverson/prime
 private void Clear()
 {
     LogEntries.Clear();
     Count = LogEntries.Count;
 }
コード例 #28
0
 public void Clear()
 {
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => LogEntries.Clear()));
 }
コード例 #29
0
        public string Execute(string input = null)
        {
            // Clear the debug data
            LogEntries.Clear();

            // Have any commandFactories been defined?
            if (commandFactories != null)
            {
                // We need to execute any command factories and modify the command list
                // We can't do a foreach, because we're going to modify this list
                // Also: _this does not account for recursion or circular inclusions!!!!_
                // The GetLogicHashCode method can be used to compare command logic to ensure uniqueness

                for (var i = 0; i < commands.Count(); i++)
                {
                    var thisCommand    = commands[i];
                    var factoryCommand = commandFactories.FirstOrDefault(c => Regex.IsMatch(thisCommand.NormalizedCommandName, StringUtilities.ConvertWildcardToRegex(c.Key), RegexOptions.IgnoreCase));

                    if (factoryCommand.Value != null) // This test is a little weird. KeyValue is a struct, so a normal null check doesn't work, so I do the null check against the Value...
                    {
                        // Run the factory, passing the entire command
                        var commandsToInclude = factoryCommand.Value(thisCommand);

                        // Include the source, for logging
                        commandsToInclude.ToList().ForEach(c =>
                        {
                            c.CommandFactorySource = thisCommand.OriginalText;
                        });

                        // Insert these commands AFTER the factory command
                        commands.InsertRange(i + 1, commandsToInclude);

                        // Delete the factory command
                        commands.Remove(thisCommand);

                        // Inserted commands will also be processed for command factories, since the next iteration of this loop will pickup at the first inserted command
                    }
                }
            }
            // At this point, all command factories should be resolved for this and subsequent executions

            // Add a pass-through command at the end just to hold a label called "end".
            if (commands.Any(c => c.Label == FINAL_COMMAND_LABEL))
            {
                commands.Remove(commands.First(c => c.Label == FINAL_COMMAND_LABEL));
            }
            commands.Add(
                new PipelineCommand()
            {
                FullyQualifiedCommandName = LABEL_COMMAND,
                Label       = FINAL_COMMAND_LABEL,
                CommandArgs = new Dictionary <object, string>()
                {
                    { 0, FINAL_COMMAND_LABEL }
                }
            }
                );

            // We set the global variable to the incoming string. It will be modified and eventually returned from this variable slot.
            SetVariable(GLOBAL_VARIABLE_NAME, input);

            // We're going to set up a linked list of commands. Each command holds a reference to the next command in its SendToLabel property. The last command is NULL.
            var commandQueue = new Dictionary <string, PipelineCommand>();

            for (var index = 0; index < commands.Count; index++)
            {
                var thisCommand = commands[index];

                // If this is a "Label" command, then we need to get the label "out" to a property
                if (thisCommand.NormalizedCommandName == LABEL_COMMAND)
                {
                    thisCommand.Label = thisCommand.DefaultArgument;
                }

                // If (1) this command doesn't already have a SendToLabel (it...shouldn't...I don't think), and (2) we're not on the last command, then set the SendToLabel of this command to the Label of the next command
                if (thisCommand.SendToLabel == null && index < commands.Count - 1)
                {
                    thisCommand.SendToLabel = commands[index + 1].Label;
                }

                // Add this command to the queue, keyed to its Label
                commandQueue.Add(thisCommand.Label.ToLower(), thisCommand);
            }

            // We're going to stay in this loop, resetting "command" each iteration, until SendToLabel is NULL
            NextCommandLabel = commandQueue.First().Value.Label;
            while (true)
            {
                // Do we have a next command?
                if (NextCommandLabel == null)
                {
                    // Stick a fork in us, we're done
                    break;
                }

                // Does the specified next command exist?
                if (!commandQueue.ContainsKey(NextCommandLabel.ToLower()))
                {
                    throw new Exception(string.Format("Specified command label \"{0}\" does not exist in the command queue.", NextCommandLabel));
                }

                // Get the next command
                var command = commandQueue[NextCommandLabel.ToLower()];

                // Create the debug entry
                var executionLog = new ExecutionLog(command, Variables);

                // Are we writing to a variable?
                if (command.NormalizedCommandName == WRITE_TO_VARIABLE_COMMAND)
                {
                    // Get the active text and copy it to a different variable
                    SetVariable(command.OutputVariable, GetVariable(GLOBAL_VARIABLE_NAME));
                    NextCommandLabel = command.SendToLabel;
                    continue;
                }

                // Are we reading from a variable?
                if (command.NormalizedCommandName == READ_FROM_VARIABLE_COMMAND)
                {
                    // Get the variable and copy it into the active text
                    SetVariable(GLOBAL_VARIABLE_NAME, GetVariable(command.InputVariable));
                    NextCommandLabel = command.SendToLabel;
                    continue;
                }

                // Is this a label?
                if (command.NormalizedCommandName == LABEL_COMMAND)
                {
                    NextCommandLabel = command.SendToLabel;
                    continue;
                }

                // Note that the above commands will never actually execute. This is why their methods are just empty shells...

                // Do we a method for this command?
                if (!CommandMethods.ContainsKey(command.NormalizedCommandName))
                {
                    // This command doesn't exist. We're going to try to be helpful and let the user know if it's becaue of a missing dependency.
                    var errorString = hiddenCommandMethods.ContainsKey(command.NormalizedCommandName)
                        ? string.Format(hiddenCommandMethods[command.NormalizedCommandName])  // This should be the reason the command is hidden
                        : string.Format(@"No command loaded for ""{0}""", command.FullyQualifiedCommandName);

                    throw new DeninaException(errorString);
                }

                // Set a pipeline reference which can be accessed inside the filter method
                command.Pipeline = this;

                // Resolve any arguments that are actually variable names
                command.ResolveArguments();

                // Execute
                var method = CommandMethods[command.NormalizedCommandName];
                try
                {
                    timer.Reset();
                    timer.Start();

                    // Get the input from the designated variable
                    var filterInput = (string)GetVariable(command.InputVariable);

                    // Process the input through the event
                    var executingFilterEventArgs = new FilterEventArgs(command, filterInput, null);
                    OnFilterExecuting(executingFilterEventArgs);
                    filterInput = executingFilterEventArgs.Input;
                    command     = executingFilterEventArgs.Command; // I'm not sure I need to do this, but just to be explicit...

                    // TO DO: How do we track changes made to the input in an event?
                    executionLog.InputValue = GetVariable(command.InputVariable).ToString();

                    // This is where we make the actual method call. We get the text out of the InputVariable slot, and we put it back into the OutputVariable slot. (These are usually the same slot...)
                    // We create a delete so that we can use anonymous functions. Since non-anonymous functions are static, and anonymous functions aren't static, we have to create a
                    // delegate so we can handle both
                    var filter       = (FilterDelegate)Delegate.CreateDelegate(typeof(FilterDelegate), null, method);
                    var filterOutput = filter(filterInput, command, executionLog);

                    // Process the output through the event
                    var executedFilterEventArgs = new FilterEventArgs(command, null, filterOutput);
                    OnFilterExecuted(executedFilterEventArgs);
                    filterOutput = executedFilterEventArgs.Output;

                    // TO DO: How do we track changes made to the output in an event?
                    executionLog.OutputValue = filterOutput.ToString();

                    // If we're appending, tack this onto what was passed in (really, prepend was was passed in)
                    if (command.AppendToOutput)
                    {
                        filterOutput = string.Concat(GetVariable(command.OutputVariable), filterOutput);
                    }

                    // We're going to "SafeSet" this, so they can't pipe output to a read-only variable
                    SafeSetVariable(command.OutputVariable, filterOutput);

                    executionLog.ElapsedTime = timer.ElapsedMilliseconds;

                    // If we got here with no exception
                    executionLog.SuccessfullyExecuted = true;
                }
                catch (DeninaException e)
                {
                    e.CurrentCommandText = command.OriginalText;
                    e.CurrentCommandName = command.NormalizedCommandName;
                    throw;
                }
                // We are not going to handle a non-DeninaException. We'll just let that bubble up to the implementation's error handler

                // Set the pointer to the next command
                NextCommandLabel = command.SendToLabel;

                LogEntries.Add(executionLog);
            }

            var finalOutput = GetVariable(GLOBAL_VARIABLE_NAME).ToString();

            // Raise the PipelineCompleted event
            var eventArgs = new PipelineEventArgs(this, finalOutput);

            OnPipelineComplete(eventArgs);
            finalOutput = eventArgs.Value;

            return(finalOutput);
        }
コード例 #30
0
        private void StatusTimerCallback(object param)
        {
            try
            {
                var status = WcfProxy.GetCurrentStatus();

                this.InvokeIfRequired(() =>
                {
                    if (logToken != status.LogToken)
                    {
                        // Has to be in this order
                        // Otherwise clearing the DGV causes cell value requests
                        // in this thread before continuing here.
                        // Which has a high chance of adding items in the
                        // LogEntries list, which are subsequently cleared,
                        // leaving empty cells in the DGV that won't be filled.
                        DgvLog.RowCount = 0;
                        LogEntries.Clear();
                    }
                    logToken = status.LogToken;

                    // If we are scrolled down, we auto scroll
                    var prevRowCount = DgvLog.RowCount;
                    DgvLog.RowCount  = status.LogCount;
                    if (DgvLog.GetLastDisplayedScrollingRowIndex(false) + 1
                        >= prevRowCount)
                    {
                        DgvLog.FirstDisplayedScrollingRowIndex =
                            DgvLog.RowCount - 1;
                    }

                    UpdateOperation(status.Operation);

                    DuplicateCount         = status.DuplicateCount;
                    LblDuplicateCount.Text = string.Format(
                        StatusInfoDuplicateCount,
                        DuplicateCount);
                    BtnResolveDuplicates.Enabled = DuplicateCount > 0;
                    BtnDiscardDuplicates.Enabled = DuplicateCount > 0;
                });
            }
            catch (Exception ex) when(
                ex is EndpointNotFoundException ||
                ex is CommunicationException ||
                ex is TimeoutException)
            {
                Debug.Print("Status request failed with: " + ex.Message);
                this.InvokeIfRequired(() =>
                {
                    BtnResolveDuplicates.Enabled = false;
                    UpdateOperation(new OperationInfo
                    {
                        Message       = "Connecting...",
                        ProgressStyle = ProgressStyle.Marquee,
                    });
                });
            }
            finally
            {
                _ = StatusTimer.StartSingle(Settings.StatusRequestInterval);
            }
        }