Beispiel #1
0
        internal static Command CreateAlertLevelRisedCommand(this Account account)
        {
            AlertCommand alertCommand = new AlertCommand();

            alertCommand.AccountID = account.Id;
            alertCommand.Content   = account.CreateXmlNodeForAlertLevelRised().ToXmlNode();
            return(alertCommand);
        }
Beispiel #2
0
        public MainPage()
        {
            InitializeComponent();

            AlertCommand.Subscribe(() => DisplayAlert("タイトル", "メッセージ", "OK"));
            ActionSheetCommand.Subscribe(() => DisplayActionSheet("選択してね", "キャンセル", "削除", "編集", "コピー", "貼り付け"));
            PopupCommand.Subscribe(() => PopupNavigation.PushAsync(new PopUp(true, false)));
            TransitionCommand.Subscribe(() => App.Current.MainPage = new PopUp(false, true));
        }
Beispiel #3
0
        private Command ProcessWhenRiskLevelChanged(AlertLevel alertLevel, List <Protocal.Commands.OrderPhaseChange> orderChanges)
        {
            AlertLevel liveAlertLevel = _account.AlertLevel;
            XmlNode    alertDb        = null;
            XmlNode    alertRisk      = null;

            if (alertLevel < AlertLevel.Cut)
            {
                if (liveAlertLevel > alertLevel)
                {
                    alertDb = this.GetAlertDb();
                }
                //Alert Risk
                if (liveAlertLevel > alertLevel && alertLevel == AlertLevel.Normal)
                {
                    alertRisk = this.GetAlertRisk();
                }
                if (alertDb != null)
                {
                    alertRisk = this.MargeAlertRisk(alertDb, alertRisk);
                }
            }

            if (this.ShouldAutoResetAlertLevel(alertLevel))
            {
                alertDb   = this.GetAlertDb();
                alertRisk = this.GetAlertRisk();
                alertRisk = this.MargeAlertRisk(alertDb, alertRisk);
                if (liveAlertLevel == AlertLevel.Normal)
                {
                    alertDb = null;
                }
                Logger.InfoFormat("accountId = {0}, ResetDBAlertLevel", _account.Id);
                DBHelper.ResetDBAlertLevel(Guid.Empty, _account.Id);
            }
            Logger.InfoFormat("accountId = {0} AutoResetAlertLevel = {1}, oldaLertLevel = {2}, liveAlertLevel = {3}, alertDb = {4}", _account.Id, this.ShouldAutoResetAlertLevel(alertLevel), alertLevel, liveAlertLevel, alertDb == null ? string.Empty : alertDb.OuterXml);

            if (alertDb != null)
            {
                this.NotifyFaxEmailEngine(alertLevel, orderChanges);
                Logger.WarnFormat("accountId = {0},dbo.P_UpdateAlertHistory @xmlAlert= {1}", _account.Id, alertDb.OuterXml);
                DBHelper.UpdateDBAlertHistory(_account.Id, alertDb);
            }

            if (alertRisk != null)
            {
                AlertCommand alertCommand = new AlertCommand();
                alertCommand.AccountID = _account.Id;
                alertCommand.Content   = alertRisk;
                Logger.InfoFormat("alert command {0}", alertRisk.OuterXml);
                return(alertCommand);
            }
            return(null);
        }
Beispiel #4
0
        public string ProcessCommand(string content)
        {
            var requestData = JsonConvert.DeserializeObject <Command>(content);
            var command     = requestData.Name;
            var parameters  = requestData.Parameters;

            string elementId = null;

            if (parameters == null)
            {
                throw new NullReferenceException("Parameters can not be NULL");
            }

            JToken elementIdObject;

            if (parameters.TryGetValue("ID", out elementIdObject))
            {
                elementId = elementIdObject.ToString();
            }

            CommandBase commandToExecute;

            if (command.Equals("ping"))
            {
                // Service command
                return("<pong>");
            }

            // TODO: Refactor similar to CommandExecutors in Driver
            if (command.Equals(DriverCommand.GetAlertText))
            {
                commandToExecute = new AlertTextCommand();
            }
            else if (command.Equals(DriverCommand.AcceptAlert))
            {
                commandToExecute = new AlertCommand {
                    Action = AlertCommand.With.Accept
                };
            }
            else if (command.Equals(DriverCommand.DismissAlert))
            {
                commandToExecute = new AlertCommand {
                    Action = AlertCommand.With.Dismiss
                };
            }
            else if (command.Equals(DriverCommand.FindElement) || command.Equals(DriverCommand.FindChildElement))
            {
                commandToExecute = new ElementCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.FindElements) || command.Equals(DriverCommand.FindChildElements))
            {
                commandToExecute = new ElementsCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.ClickElement))
            {
                commandToExecute = new ClickCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.SendKeysToElement))
            {
                var values = ((JArray)parameters["value"]).ToObject <List <string> >();
                var value  = string.Empty;
                if (values.Any())
                {
                    value = values.Aggregate((aggregated, next) => aggregated + next);
                }

                commandToExecute = new ValueCommand {
                    ElementId = elementId, KeyString = value
                };
            }
            else if (command.Equals(DriverCommand.GetElementText))
            {
                commandToExecute = new TextCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.IsElementDisplayed))
            {
                commandToExecute = new DisplayedCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.GetElementLocation))
            {
                commandToExecute = new LocationCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.GetElementLocationOnceScrolledIntoView))
            {
                commandToExecute = new LocationInViewCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.GetElementSize))
            {
                commandToExecute = new GetElementSizeCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.GetElementRect))
            {
                commandToExecute = new GetElementRectCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.GetPageSource))
            {
                commandToExecute = new PageSourceCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.GetOrientation))
            {
                commandToExecute = new OrientationCommand();
            }
            else if (command.Equals(DriverCommand.GetElementAttribute))
            {
                commandToExecute = new GetElementAttributeCommand {
                    ElementId = elementId
                };
            }
            else if (command.Equals(DriverCommand.ExecuteScript))
            {
                commandToExecute = new ExecuteCommand();
            }
            else if (command.Equals(ExtendedDriverCommand.InvokeAppBarItemCommand))
            {
                commandToExecute = new InvokeAppBarItemCommand();
            }
            else if (command.Equals(ExtendedDriverCommand.InvokeMethodCommand))
            {
                commandToExecute = new InvokeMethodCommand();
            }
            else
            {
                throw new NotImplementedException("Not implemented: " + command);
            }

            // TODO: Replace passing Automator to command with passing some kind of configuration
            commandToExecute.Automator  = this;
            commandToExecute.Parameters = parameters;

            var response = commandToExecute.Do();

            return(response);
        }
 public AlertCommandTest()
 {
     HubServiceMock  = new Mock <IHubService>();
     ChatServiceMock = new Mock <IChatService>();
     Sut             = new AlertCommand(HubServiceMock.Object);
 }