Exemple #1
0
        static void Main(string[] args)
        {
            Init();
            bool menuRunning = true;

            //Menu
            while (menuRunning)
            {
                int userChoice = Prompts.Menu();
                switch (userChoice)
                {
                case 1:
                    CreateBasicCrud();
                    break;

                case 2:
                    GenerateLayers();
                    break;

                case 3:
                    GenerateModels();
                    break;

                case 4:
                    menuRunning = false;
                    break;

                default:
                    Console.WriteLine("I'm sorry, but that has not been implemented yet.");
                    break;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Due to some performance issues with version of EBO prior to 2.0, we will limit the amount of points that can be consumed out of EBO versions
        /// prior to 2.0 to 100. No limit for point count in version 2.0 and above.
        /// </summary>
        private bool EvaluatePerformanceImpact(List <Signal> signals)
        {
            try
            {
                // We save this right away so we can execute this setup processor from the value push processor if it is not running
                Cache.AddOrUpdateItem(this.ConfigurationId, "SetupProcessorConfigurationId", this.CacheTenantId, 0);
                var response   = ManagedEwsClient.GetWebServiceInformation(EboEwsSettings);
                var eboVersion = new Version(response.GetWebServiceInformationSystem.Version);
                if (eboVersion.Major > 1)
                {
                    _signalsToUse = signals;
                }
                else
                {
                    if (signals.Count > 100)
                    {
                        Prompts.Add(new Prompt
                        {
                            Severity = PromptSeverity.MayContinue,
                            Message  = $"Due to performance concerns, only 100 points out of {signals.Count} can be consumed when using EBO versions prior to 2.0. Please update your EBO to version 2.0 or greater to get the full functionality of the EBO IoT Edge Smart Connector Extension."
                        });
                    }

                    _signalsToUse = signals.Take(100).ToList();
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogError(LogCategory.Processor, this.Name, ex.ToString());
                return(false);
            }
        }
 public void SetPromptsAndGameManager(Prompts prompts1, GameManager gameManager1, ScoreScript s)
 {
     prompts     = prompts1;
     gameManager = gameManager1;
     scoreScript = s;
     UpdateInstructions();
 }
Exemple #4
0
        protected override IEnumerable <Prompt> Execute_Subclass()
        {
            ResetSubscriptionCache();
            var signals = SignalFileParser.Parse(SignalFileLocation);

            try
            {
                if (!EvaluatePerformanceImpact(signals))
                {
                    Prompts.Add(new Prompt
                    {
                        Message  = "Could not successfully evaluate performance, cannot continue.",
                        Severity = PromptSeverity.MayNotContinue
                    });
                    return(Prompts);
                }

                GetAndUpdateInitialPropertiesForSignals(_signalsToUse);
            }
            catch (Exception ex)
            {
                Prompts.Add(ex.ToPrompt());
                return(Prompts);
            }

            return(Prompts);
        }
Exemple #5
0
        /// <summary>
        /// Sends the Observations to the MQTT broker
        /// </summary>
        /// <param name="sendAdditionalProperties">If true, the 'Writeable' and 'Forceable' properties will be sent in the Observation</param>
        /// <returns></returns>
        private async Task <bool> UpdateValues(SubscriptionReader si, ReadResult <SubscriptionResultItem> results, bool sendAdditionalProperties = false)
        {
            if (!results.Success)
            {
                Prompts.AddRange(results.Prompts);
                return(false);
            }

            var devices = results.DataRead.GroupBy(a => a.ValueItemChangeEvent.Id.Remove(a.ValueItemChangeEvent.Id.LastIndexOf('/')).Remove(0, 2));

            foreach (var device in devices)
            {
                var observations  = new List <Observation>();
                var deviceMessage = new IotEdgeMessage
                {
                    Format       = "rec2.3",
                    Observations = observations,
                    DeviceId     = device.Key
                };

                AddUpdatedValuesToMessage(observations, device.Key, device.ToList(), si.CachedSubscribedItems, sendAdditionalProperties);

                var messageBuilder = new MqttApplicationMessageBuilder();
                var message        = messageBuilder.WithRetainFlag().WithAtLeastOnceQoS().WithTopic(ValuePushTopic).WithPayload(deviceMessage.ToJson()).Build();
                Logger.LogTrace(LogCategory.Processor, this.Name, $"Sending Message to MQTT Broker: {deviceMessage.ToJson()}");
                await ManagedMqttClient.PublishAsync(message);
            }

            return(true);
        }
Exemple #6
0
 /// <summary>
 /// Prints message for when Administrator is not logged in
 /// </summary>
 public static void AdminNotLoggedIn()
 {
     Console.Clear();
     Console.WriteLine("Session limit reached!\n" +
                       "Please login again");
     Prompts.ClearAndContinue();
 }
        public override void ExecuteConsole(Invoker command, ICalculatorComponent calculator, ILogger <CalculatorManager> logger)
        {
            bool check = UserChoiceCheck(command);

            while (check)
            {
                Prompts.Addition();

                double a, b;
                double result;

                Prompts.FirstNumber();
                a = Convert.ToDouble(Console.ReadLine());
                Prompts.SecondNumber();
                b = Convert.ToDouble(Console.ReadLine());

                calculator.Operations["addition"].CreateCalculation(calculator, a, b);
                result = calculator.Operations["addition"].GetResult(calculator);

                Prompts.Result(result);

                calculator.UserOperations.Add("+");
                calculator.CalculatorState.Add(new Context(new Unmodified()));
                check = false;
            }
        }
Exemple #8
0
        static void Main(string[] args)
        {
            int threadHashCode = Thread.CurrentThread.GetHashCode();

            Console.WriteLine("Main() in Thread {0}", threadHashCode);

            Calculator calculator = new Calculator(0);

            while (true)
            {
                char    operationSymbol = Prompts.PromptOperationSymbol();
                var     mathOperation   = Calculator.GetOperation(operationSymbol);
                decimal value           = Prompts.PromtDecimalValue();
                decimal prevSum         = calculator.Sum;

                string statusMessage = String.Format("{0} {1} {2}",
                                                     prevSum, operationSymbol, value);
                CalculatorDelagate delagate = calculator.MakeOperation;

                delagate.BeginInvoke(
                    mathOperation, value,
                    CalculatorCallback, statusMessage
                    );
            }
        }
Exemple #9
0
        protected override IEnumerable <Prompt> Execute_Subclass()
        {
            if (Signals == null || !Signals.Any())
            {
                GetSignalNullReason();
                return(Prompts);
            }

            try
            {
                StartMqttClient().Wait();
            }
            catch (Exception ex)
            {
                Logger.LogError(LogCategory.Processor, this.Name, $"Starting MQTT Client failed");
                Prompts.Add(ex.ToPrompt());
                return(Prompts);
            }

            _tempSignals = Signals.ToList();
            // Read existing subscriptions
            if (!ReadExistingSubscriptions(_tempSignals).Result)
            {
                Prompts.Add(new Prompt {
                    Message = $"Did not successfully read all existing subscriptions."
                });
            }

            // Subscribe and read new subscriptions
            if (!SubscribeAndReadNew(_tempSignals).Result)
            {
                Prompts.Add(new Prompt {
                    Message = $"Did not successfully read all new subscriptions."
                });
            }

            Logger.LogTrace(LogCategory.Processor, this.Name, "Waiting for all messages be be published...");
            while (ManagedMqttClient.PendingApplicationMessagesCount > 0)
            {
                Logger.LogTrace(LogCategory.Processor, this.Name, $"{ManagedMqttClient.PendingApplicationMessagesCount} messages left waiting to be published..");
                if (this.IsCancellationRequested)
                {
                    return(new List <Prompt>());
                }
                Task.Delay(1000).Wait();
            }

            Logger.LogTrace(LogCategory.Processor, this.Name, "Stopping Managed MQTT Client..");
            ManagedMqttClient.StopAsync().Wait();
            while (ManagedMqttClient.IsStarted)
            {
                Logger.LogTrace(LogCategory.Processor, this.Name, "Still waiting for MQTT Client to Stop...");
                Task.Delay(1000).Wait();
            }

            // Update the cache with new values..
            Signals = _tempSignals;
            return(Prompts);
        }
Exemple #10
0
        private void GetAndUpdateInitialPropertiesForSignals(List <Signal> signals)
        {
            var newSignals = new List <Signal>();

            Logger.LogTrace(LogCategory.Processor, this.Name, $"Getting units for all signals.. {signals.Count} total.");
            // Get list of signals that have not been previously discovered
            var newSignalsLeftToAdd = signals.Where(a => !Signals.Select(b => b.EwsId).Contains(a.EwsId)).ToList();

            Logger.LogTrace(LogCategory.Processor, this.Name, $"Found, {newSignalsLeftToAdd.Count} total to add.");
            while (newSignalsLeftToAdd.Any())
            {
                Logger.LogTrace(LogCategory.Processor, this.Name, $"Found, {newSignalsLeftToAdd.Count} left to add.");
                if (IsCancellationRequested)
                {
                    return;
                }
                try
                {
                    var response         = ManagedEwsClient.GetItems(EboEwsSettings, newSignalsLeftToAdd.Take(100).Select(a => a.EwsId).ToArray());
                    var successfulValues = response.GetItemsItems.ValueItems?.ToList();
                    AddSuccessfulSignalsToCache(signals, successfulValues, newSignals);

                    // The below code is a workaround for EBO timing out on GetItems for many values, and returning either an INVALID_ID or TIMEOUT error when the values are in fact valid. We need to make sure we discover as many as possible, so let's loop until we do.
                    // We will do this as long as at least 1 value from the request was successful.
                    while (successfulValues != null && successfulValues.Any() && response.GetItemsErrorResults != null && response.GetItemsErrorResults.Any(a => a.Message == "INVALID_ID" || a.Message == "TIMEOUT"))
                    {
                        response         = ManagedEwsClient.GetItems(EboEwsSettings, response.GetItemsErrorResults.Where(a => a.Message == "INVALID_ID" || a.Message == "TIMEOUT").Select(a => a.Id).ToArray());
                        successfulValues = response.GetItemsItems.ValueItems?.ToList();
                        AddSuccessfulSignalsToCache(signals, successfulValues, newSignals);
                    }

                    var valuesToRetry = UpdateInvalidEwsIdsForRetry(signals, response);

                    response         = ManagedEwsClient.GetItems(EboEwsSettings, valuesToRetry.Select(a => a.EwsId).ToArray());
                    successfulValues = response.GetItemsItems.ValueItems?.ToList();
                    AddSuccessfulSignalsToCache(signals, successfulValues, newSignals);

                    foreach (var value in response.GetItemsErrorResults.ToList())
                    {
                        Prompts.Add(new Prompt {
                            Message = $"Error getting value, this value will not be pushed: {value.Id} - {value.Message}", Severity = PromptSeverity.MayNotContinue
                        });
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(LogCategory.Processor, this.Name, ex.ToString());
                    Prompts.Add(ex.ToPrompt());
                    // We will let it continue and see if everything else fails... Maybe some will work..
                }

                newSignalsLeftToAdd = newSignalsLeftToAdd.Skip(100).ToList();
            }

            signals.AddRange(newSignals);
            Signals = signals;

            SeedProcessorValues(signals);
        }
Exemple #11
0
 public void DeletePrompt(TypePromptKey key)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     Prompts.RemoveAll(k => k.TextKey == key.ToString());
 }
Exemple #12
0
    public void SetPrompt(int index, Prompts prompts, bool quickSpin)
    {
        var prompt = prompts.GetPrompt(index);

        for (var i = 0; i < 6; i++)
        {
            buttonManagers[i].SetText(prompt[i], quickSpin); // Object reference not set error
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     if (text == null)
     {
         text = GetComponentInChildren <Text>();
     }
     prompts = FindObjectOfType <Prompts>();
     current = prompts.GetRandomPrompt();
     //text.text = current;
 }
        private void EvaluateCanMovePrevious()
        {
            var newCanMovePrevious = Prompts.IndexOf(SelectedPrompt) == 0 ? false : true;

            if (newCanMovePrevious != _canMovePrevious)
            {
                _canMovePrevious = newCanMovePrevious;
                MovePrevious.RaiseCanExecuteChanged();
            }
        }
        private void GetAndUpdateInitialPropertiesForSignals(List <Signal> signals)
        {
            var newSignals = new List <Signal>();

            Logger.LogTrace(LogCategory.Processor, this.Name, "Getting units for all signals..");
            while (signals.Any())
            {
                if (IsCancellationRequested)
                {
                    return;
                }
                try
                {
                    var response         = ManagedEwsClient.GetItems(EboEwsSettings, signals.Take(500).Select(a => a.EwsId).ToArray());
                    var successfulValues = response.GetItemsItems.ValueItems.ToList();

                    foreach (var value in successfulValues)
                    {
                        var deviceSignal = signals.FirstOrDefault(a => a.EwsId == value.Id);
                        if (deviceSignal == null)
                        {
                            Logger.LogInfo(LogCategory.Processor, this.Name, $"Returned value does not exist in the list known signals..");
                        }
                        else
                        {
                            Enum.TryParse(value.Type, true, out EwsValueTypeEnum type);
                            Enum.TryParse(value.Writeable, true, out EwsValueWriteableEnum writeable);
                            Enum.TryParse(value.Forceable, true, out EwsValueForceableEnum forceable);
                            deviceSignal.Type      = type;
                            deviceSignal.Unit      = value.Unit;
                            deviceSignal.Writeable = writeable;
                            deviceSignal.Forceable = forceable;
                            newSignals.Add(deviceSignal);
                        }
                    }

                    foreach (var value in response.GetItemsErrorResults.ToList())
                    {
                        Prompts.Add(new Prompt {
                            Message = $"Error getting value, this value will not be pushed: {value.Id} - {value.Message}", Severity = PromptSeverity.MayNotContinue
                        });
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(LogCategory.Processor, this.Name, ex.ToString());
                    Prompts.Add(ex.ToPrompt());
                    // We will let it continue and see if everything else fails... Maybe some will work..
                }

                signals = signals.Skip(500).ToList();
            }

            Signals = newSignals;
        }
Exemple #16
0
        //  request info from user and setup file for processing..keeping it DRY.
        private void prepareForFile(Prompts p)
        {
            //Prompt for file name;
            Util.sendPrompts(p);

            // Get user input
            _sourceFileName = Util.getInput();

            // Build full path to file.
            buildFilePath();
        }
Exemple #17
0
        public DisplayPeople_GS(
            Lobby lobby,
            string title,
            IReadOnlyList <Person> peopleList,
            Func <Person, Color?> backgroundColor = null,
            Func <Person, string> imageIdentifier = null,
            Func <Person, string> imageTitle      = null,
            Func <Person, string> imageHeader     = null)
            : base(
                lobby: lobby,
                exit: new WaitForPartyLeader_StateExit(
                    lobby: lobby,
                    partyLeaderPromptGenerator: Prompts.PartyLeaderSkipRevealButton(),
                    waitingPromptGenerator: Prompts.DisplayText()
                    )
                )
        {
            if (peopleList == null || peopleList.Count == 0)
            {
                throw new ArgumentException("PeopleList cannot be empty");
            }

            this.Entrance.Transition(this.Exit);

            backgroundColor ??= (person) => null;
            imageIdentifier ??= (person) => null;
            imageTitle ??= (person) => null;
            imageHeader ??= (person) => null;
            var unityImages = new List <Legacy_UnityImage>();

            foreach (Person person in peopleList)
            {
                unityImages.Add(person.GetUnityImage(
                                    backgroundColor: backgroundColor(person),
                                    imageIdentifier: imageIdentifier(person),
                                    title: imageTitle(person),
                                    header: imageHeader(person)
                                    ));
            }

            this.Legacy_UnityView = new Legacy_UnityView(this.Lobby)
            {
                ScreenId = new StaticAccessor <TVScreenId> {
                    Value = TVScreenId.ShowDrawings
                },
                UnityImages = new StaticAccessor <IReadOnlyList <Legacy_UnityImage> > {
                    Value = unityImages
                },
                Title = new StaticAccessor <string> {
                    Value = title
                },
            };
        }
 private void EvaluateCanMoveNext()
 {
     if (Prompts.Count != 0)
     {
         var newCanMoveNext = Prompts.IndexOf(SelectedPrompt) == Prompts.Count - 1 ? false : true;
         if (newCanMoveNext != _canMoveNext)
         {
             _canMoveNext = newCanMoveNext;
             MoveNext.RaiseCanExecuteChanged();
         }
     }
 }
Exemple #19
0
 /// <summary>
 /// Creates and prints Category object table
 /// </summary>
 /// <param name="categoryData"></param>
 /// <returns>List of List of base class objects</returns>
 public static List <List <object> > CategoryListReader(List <List <object> > categoryData)
 {
     Console.Clear();
     Console.WriteLine();
     ConsoleTableBuilder.From(categoryData)
     .WithCharMapDefinition(CharMapDefinition.FramePipDefinition)
     .WithTitle("Categories", ConsoleColor.Black, ConsoleColor.White, TextAligntment.Center)
     .WithColumn("Id", "Name")
     .ExportAndWriteLine(TableAligntment.Center);
     Prompts.ClearAndContinue();
     return(categoryData);
 }
Exemple #20
0
 /// <summary>
 /// Creates and prints SoldBook object table
 /// </summary>
 /// <param name="soldBooksData"></param>
 /// <returns>List of List of base class objects</returns>
 public static List <List <object> > SoldBooksListReader(List <List <object> > soldBooksData)
 {
     Console.Clear();
     Console.WriteLine();
     ConsoleTableBuilder.From(soldBooksData)
     .WithCharMapDefinition(CharMapDefinition.FramePipDefinition)
     .WithTitle("Sold books", ConsoleColor.Black, ConsoleColor.White, TextAligntment.Center)
     .WithColumn("Id", "Title", "Author", "Price", "Amount", "Category Id")
     .ExportAndWriteLine(TableAligntment.Center);
     Prompts.ClearAndContinue();
     return(soldBooksData);
 }
        public static void Activate(ICalculatorComponent calculator, Publisher publisher)
        {
            bool repeat = true;

            while (repeat)
            {
                Prompts.Functionality();

                String Done           = "";
                string operationInput = Console.ReadLine();

                while ((!operationInput.Equals("addition")) && (!operationInput.Equals("subtraction")) && (!operationInput.Equals("multiplication")) && (!operationInput.Equals("division") && (!operationInput.Equals("square root") && (!operationInput.Equals("square")) && (!operationInput.Equals("DONE")))))
                {
                    Prompts.NotAvailable();
                    operationInput = Console.ReadLine();
                }

                while (!Done.Equals("DONE"))
                {
                    Invoker command1 = new Invoker(operationInput);
                    calculator.Commands.Add(command1);
                    Prompts._Functionality();
                    operationInput = Console.ReadLine();
                    while ((!operationInput.Equals("addition")) && (!operationInput.Equals("subtraction")) && (!operationInput.Equals("multiplication")) && (!operationInput.Equals("division") && (!operationInput.Equals("square root") && (!operationInput.Equals("square")) && (!operationInput.Equals("DONE")))))
                    {
                        Prompts.NotAvailable();
                        operationInput = Console.ReadLine();
                    }
                    Done   = operationInput;
                    repeat = false;
                }

                Prompts.Divider();
            }

            Invoker finalCommand = new Invoker("Final Command");

            calculator.Commands.Add(finalCommand);

            // Handle User Input
            foreach (Invoker command in calculator.Commands)
            {
                string op = command.OperationString;

                while (op != "Final Command")
                {
                    // Event
                    calculator = publisher.AddFunctionality(command, calculator);
                    op         = "Final Command";
                }
            }
        }
Exemple #22
0
        private void AddToolBtn_Click(object sender, RoutedEventArgs e)
        {
            string newID = Prompts.ShowDialog_Text("New Tool", "New tool control id", "");
            Tool   t     = HWC.GetTool(newID);

            if (t != null)
            {
                return;
            }
            t = HWC.NewTool(newID.ToUpper());
            Data.AllToolsItems.Add(t.ControlIdent);
            AllTools.SelectedItem = t.ControlIdent;
            HWC.Save();
        }
Exemple #23
0
        public override void ExecuteConsole(Invoker command, ICalculatorComponent calculator, ILogger <CalculatorManager> logger)
        {
            bool check = UserChoiceCheck(command);

            while (check)
            {
                Prompts.Division();

                double a, b;
                int    c, d;
                double result, test;
                bool   skip = false;

                Prompts.FirstNumber();
                a = Convert.ToDouble(Console.ReadLine());
                c = (int)a;

                Prompts.SecondNumber();
                b = Convert.ToDouble(Console.ReadLine());
                d = (int)b;

                // Handles Divide By Zero Condition + Log Entry
                try
                {
                    test = c / d;
                }
                catch (DivideByZeroException e)
                {
                    skip = true;
                    Prompts.Logger();
                    logger.LogInformation(e.Message);
                }

                while ((skip.Equals(false)) && (b != 0))
                {
                    calculator.Operations["division"].CreateCalculation(calculator, a, b);
                    result = calculator.Operations["division"].GetResult(calculator);

                    Prompts.Result(result);

                    calculator.UserOperations.Add("/");
                    calculator.CalculatorState.Add(new Context(new Unmodified()));
                    check = false;
                    skip  = true;
                }

                check = false;
                skip  = false;
            }
        }
Exemple #24
0
 /// <summary>
 /// Creates and prints User object table
 /// </summary>
 /// <param name="userData"></param>
 /// <returns>List of List of base class objects</returns>
 public static List <List <object> > UserListReader(List <List <object> > userData)
 {
     if (userData.Count > 0)
     {
         Console.WriteLine();
         ConsoleTableBuilder.From(userData)
         .WithCharMapDefinition(CharMapDefinition.FramePipDefinition)
         .WithTitle("Users", ConsoleColor.Black, ConsoleColor.White, TextAligntment.Center)
         .WithColumn("Id", "Name", "Password", "Last login", "Sessiontimer", "Is active", "IsAdmin")
         .ExportAndWriteLine(TableAligntment.Center);
         Prompts.ClearAndContinue();
     }
     return(userData);
 }
Exemple #25
0
        public ActionResult JobAd(Guid jobAdId)
        {
            var member = CurrentMember;

            var jobAd = _memberJobAdViewsQuery.GetMemberJobAdView(member, jobAdId);

            if (jobAd == null)
            {
                return(NotFound("job ad", "id", jobAdId));
            }

            // Check the status of the job ad.

            var result = CheckStatus(jobAd);

            if (result != null)
            {
                return(result);
            }

            // Check url.

            result = EnsureUrl(jobAd.GenerateJobAdUrl());
            if (result != null)
            {
                return(result);
            }

            // Do some initial checks.

            var jobPoster = _employersQuery.GetEmployer(jobAd.PosterId);

            if (jobPoster == null)
            {
                return(NotFound("job poster", "id", jobAd.PosterId));
            }

            // Need to check that this job ad is allowed to be seen through a community portal.

            result = CheckCommunity(jobAd, jobPoster, member);
            if (result != null)
            {
                return(result);
            }

            var model = GetJobAdModel(member, jobAd, jobPoster);

            model.VisitorStatus = Prompts.GetVisitorStatus(member);
            return(View(model));
        }
 public ScoreBoardGameState(Lobby lobby, string title = "Scores:")
     : base(
         lobby,
         exit: new WaitForPartyLeader_StateExit(
             lobby: lobby,
             partyLeaderPromptGenerator: Prompts.ShowScoreBreakdowns(
                 lobby: lobby,
                 promptTitle: "Scoreboard",
                 userScoreScope: Score.Scope.Total,
                 leaderboardScope: Score.Scope.Total,
                 userPromptId: UserPromptId.PartyLeader_SkipScoreboard,
                 showPartyLeaderSkipButton: true),
             waitingPromptGenerator: Prompts.ShowScoreBreakdowns(
                 lobby: lobby,
                 promptTitle: "Scoreboard",
                 userScoreScope: Score.Scope.Total,
                 leaderboardScope: Score.Scope.Total
                 )))
 {
     this.Entrance.Transition(this.Exit);
     this.Legacy_UnityView = new Legacy_UnityView(this.Lobby)
     {
         ScreenId = new StaticAccessor <TVScreenId> {
             Value = TVScreenId.Scoreboard
         },
         Title = new StaticAccessor <string> {
             Value = title
         },
         UnityImages = new DynamicAccessor <IReadOnlyList <Legacy_UnityImage> >
         {
             DynamicBacker = () => this.Lobby.GetAllUsers().OrderByDescending(usr => usr.Score).Select(usr =>
                                                                                                       new Legacy_UnityImage
             {
                 Title = new StaticAccessor <string> {
                     Value = usr.DisplayName
                 },
                 Base64Pngs = new StaticAccessor <IReadOnlyList <string> >
                 {
                     Value = new List <string> {
                         usr.SelfPortrait
                     }
                 },
                 VoteCount = new StaticAccessor <int?> {
                     Value = usr.Score
                 },
             }).ToList()
         }
     };
 }
        // Console Manager
        public static void Activate(ICalculatorComponent calculator, Publisher publisher, ILogger <CalculatorManager> logger)
        {
            Prompts.Intro();

            // User adds functionality to calculator.
            Decorator.Activate(calculator, publisher);

            // User chooses the operation they want to calculate from the functionality they added to the calculator and performs calculations.
            Receiver.Activate(calculator, logger);

            // User is displayed options to view the calculation history if different formats, perform another calculation, or exit the program.
            Options.Activate(calculator, logger);

            Prompts.Outro();
        }
Exemple #28
0
        /// <summary>
        /// Start the NetJoy manager in an asynchronous context
        /// </summary>
        /// <returns></returns>
        public async Task Start()
        {
            //ask whether they want to start it as a server
            var server = Prompts.YesNoPrompt("Start as Server?");

            //start either the client or the server depending on the config file
            if (server)
            {
                await _server.Start();
            }
            else
            {
                await _client.Start();
            }
        }
Exemple #29
0
        public ActionResult Viewed(Guid jobAdId)
        {
            try
            {
                var user = CurrentUser;
                _jobAdViewsCommand.ViewJobAd(user == null ? (Guid?)null : user.Id, jobAdId);

                Prompts.AddView();
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new JobAdsErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
Exemple #30
0
        protected override IEnumerable <Prompt> Execute_Subclass()
        {
            try
            {
                StartMqttClient().Wait();
            }
            catch (Exception ex)
            {
                Logger.LogError(LogCategory.Processor, this.Name, $"Starting MQTT Client failed");
                Prompts.Add(ex.ToPrompt());
                return(Prompts);
            }

            if (Signals == null)
            {
                Prompts.Add(new Prompt
                {
                    Message  = "There are no signals in the cache, please run the SetupProcessor or verify that it has run successfully.",
                    Severity = PromptSeverity.MayNotContinue
                });
                return(Prompts);
            }

            // Read existing subscriptions
            if (!ReadExistingSubscriptions(Signals).Result)
            {
                Prompts.Add(new Prompt {
                    Message = $"Did not successfully read all existing subscriptions."
                });
            }

            // Subscribe and read new subscriptions
            if (!SubscribeAndReadNew(Signals).Result)
            {
                Prompts.Add(new Prompt {
                    Message = $"Did not successfully read all new subscriptions."
                });
            }

            ManagedMqttClient.StopAsync().Wait();
            ManagedMqttClient.Dispose();

            // Update the cache with new values..
            Signals = Signals;
            return(Prompts);
        }
Exemple #31
0
 /// <summary>
 /// Tries to determine why the Signal cache is empty, and attempts to resolve it if possible
 /// </summary>
 private void GetSignalNullReason()
 {
     try
     {
         var setupProcessorId = Cache.RetrieveItem("SetupProcessorConfigurationId", tenantId: CacheTenantId);
         if (setupProcessorId == null)
         {
             Prompts.Add(new Prompt
             {
                 Message  = "The Setup Processor has not been run. Make sure the Setup Processor has been configured correctly and run it again.",
                 Severity = PromptSeverity.MayNotContinue
             });
         }
         else
         {
             if (ActionBroker.IsConfigurationRunning((int)setupProcessorId))
             {
                 Prompts.Add(new Prompt
                 {
                     Message  = "The Setup Processor is currently running, once it has completed this will run successfully.",
                     Severity = PromptSeverity.MayNotContinue
                 });
             }
             else
             {
                 // For some reason the Setup Processor failed to run.. let's force it to run again, and hope it completes!
                 Logger.LogInfo(LogCategory.Processor, this.Name, "Force starting the Setup Processor, as it has failed to run for some reason, please check the logs for additional information.");
                 ActionBroker.StartConfiguration((int)setupProcessorId, DerivedFromConfigurationType.Processor);
                 Prompts.Add(new Prompt
                 {
                     Message  = "The Setup Processor processor has been forced to start, the Value Push Processor cannot run to completion until it has run successfully.",
                     Severity = PromptSeverity.MayNotContinue
                 });
             }
         }
     }
     catch (Exception ex)
     {
         Prompts.Add(new Prompt
         {
             Message  = ex.ToString(),
             Severity = PromptSeverity.MayNotContinue
         });
     }
 }
Exemple #32
0
            // method returns specified prompt based on option passed
            public static void sendPrompts(Prompts p)
            {
                string promptMessage;

                switch (p)
                {
                    case Prompts.AskforFile:
                        promptMessage = "Please Provide A Name for Input File.";
                        break;
                    case Prompts.InValidFile:
                        clearprompt();
                        promptMessage = "The filename you entered is not valid! Please try your requested again.";
                        break;
                    case Prompts.Congrats:
                        promptMessage = "Congrats! That's all folks...Press any key to quit";
                        break;
                    default:
                        promptMessage = "";
                        break;
                }

                if (promptMessage != "")
                    writeLine(promptMessage);
            }