Esempio n. 1
0
        private void UpdateRules(object obj)
        {
            var sendToAmazon = false;
            var viewModel    = new AwsSettingsViewModel(RuleApplicationService.RuleApplicationDef);

            var window = WindowFactory.CreateWindow("Service Settings", new AwsSettingsView(viewModel), false, Strings.OK, Strings.Cancel);

            window.ButtonClicked += delegate(object sender, WindowButtonClickedEventArgs <AwsSettingsView> args)
            {
                if (args.ClickedButtonText == Strings.OK)
                {
                    _awsServiceInfo.TopEntityName    = viewModel.EntityName;
                    _awsServiceInfo.AwsFunctionName  = viewModel.AwsFunctionName;
                    _awsServiceInfo.ReturnDefinition = viewModel.ReturnDefinition;

                    sendToAmazon = true;
                }

                window.Close();
            };
            window.Show();

            if (sendToAmazon)
            {
                var waitWindow = new BackgroundWorkerWaitWindow("Beaming rules...", "Creating temporary rule application file...", true, false, true);
                waitWindow.DoWork += delegate
                {
                    InRuleJavaScriptDistributionService.GenerateIndexFile(_awsServiceInfo);

                    var javaScript = InRuleJavaScriptDistributionService.GetJavaScriptRules(RuleApplicationService.RuleApplicationDef);

                    AwsConnection.UpdateLambdaFunction(_awsServiceInfo.AwsFunctionName, javaScript);
                };

                waitWindow.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    var error = e.Error;

                    if (error != null)
                    {
                        var text = $"The following error occurred:\n\n{error.Message}";
                        MessageBoxFactory.Show(text, "Error getting JavaScript", MessageBoxFactoryImage.Warning);
                    }
                    else if (e.Result != null)
                    {
                        var lines = ((string)e.Result).Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                        WindowFactory.ShowLabeledListWindow("Output", "The following information was returned:", lines);
                    }
                };

                waitWindow.ShowDialog();
            }
        }
Esempio n. 2
0
        public AwsSettingsView(AwsSettingsViewModel awsSettingsViewModel)
        {
            InitializeComponent();

            DataContext = awsSettingsViewModel;
        }