예제 #1
0
        public void ShowToastNotification(string message, NotificationType notificationType, bool force = false)
        {
            var configurationController   = new ConfigurationController <NotificationConfiguration>();
            var notificationConfiguration = configurationController.ReadConfiguration(new NotificationConfiguration());

            if (!notificationConfiguration.ShowPushNotifications && !force)
            {
                return;
            }

            switch (notificationType)
            {
            case NotificationType.Information:
                _notifier.ShowInformation(message);
                break;

            case NotificationType.Success:
                _notifier.ShowSuccess(message);
                break;

            case NotificationType.Warning:
                _notifier.ShowWarning(message);
                break;

            case NotificationType.Error:
                _notifier.ShowError(message);
                break;

            case NotificationType.Dark:
                _notifier.ShowDarkMessage(message, string.Empty);
                break;
            }
        }
예제 #2
0
        private void OnSaveAndRestart(object sender, RoutedEventArgs e)
        {
            Exception ex = ConfigurationController.Save();

            if (ex == null)
            {
                Close();
                MarbleController.CloseHosting();

                var    commandArgs = Environment.GetCommandLineArgs();
                string path        = commandArgs[0];
                string args        = string.Join(" ", commandArgs.Skip(1));
                var    startInfo   = new ProcessStartInfo
                {
                    FileName        = path,
                    Arguments       = args,
                    UseShellExecute = true,
                };
                Process p = Process.Start(startInfo);
                p.WaitForInputIdle();
                Application.Current.Shutdown();
            }
            else
            {
                MessageBox.Show(ex.ToString(), "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #3
0
        public void GetConfigurationForToggle_Ok()
        {
            var toggleId        = new Guid();
            var configurationId = new Guid();
            var toggle          = new Toggle
            {
                Id             = toggleId,
                Name           = "test",
                Configurations = new List <Configuration> {
                    new Configuration {
                        Id = configurationId
                    }
                }
            };

            _repositoryMock.Setup(rep => rep.Get(toggleId)).Returns(toggle);
            var controller = new ConfigurationController(_repositoryMock.Object);

            var result       = controller.GetConfigurationForToggle(toggleId, configurationId);
            var actionResult = result as OkObjectResult;
            var model        = actionResult?.Value as ConfigurationDtoOutput;

            Assert.IsNotNull(actionResult);
            Assert.IsNotNull(model);
            Assert.AreEqual((int)HttpStatusCode.OK, actionResult.StatusCode);
        }
예제 #4
0
        public new bool Delete()
        {
            bool ret = true;

            try
            {
                base.Delete();
                ConfigurationController.RegisterChangeCall(
                    typeof(HuntGroupPlan),
                    new ADialPlan.sUpdateConfigurationsCall(
                        "DeleteHuntGroup",
                        new NameValuePair[] {
                    new NameValuePair("context", Context.Name),
                    new NameValuePair("extension", Number)
                }),
                    new IEvent[] {
                    new GenericEvent("HuntGroupDeleted",
                                     new NameValuePair[] {
                        new NameValuePair("Context", Context.Name),
                        new NameValuePair("Number", Number)
                    })
                }
                    );
            }
            catch (Exception e)
            {
                Log.Error(e);
                EventController.TriggerEvent(new ErrorOccuredEvent(e));
                ret = false;
            }
            return(ret);
        }
        public async void Patch_No_Errors()
        {
            ConfigurationControllerMockFacade mock = new ConfigurationControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiConfigurationResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(true);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <string>(), It.IsAny <ApiConfigurationRequestModel>()))
            .Callback <string, ApiConfigurationRequestModel>(
                (id, model) => model.JSON.Should().Be("A")
                )
            .Returns(Task.FromResult <UpdateResponse <ApiConfigurationResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <ApiConfigurationResponseModel>(new ApiConfigurationResponseModel()));
            ConfigurationController controller = new ConfigurationController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiConfigurationModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiConfigurationRequestModel>();

            patch.Replace(x => x.JSON, "A");

            IActionResult response = await controller.Patch(default(string), patch);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            mock.ServiceMock.Verify(x => x.Update(It.IsAny <string>(), It.IsAny <ApiConfigurationRequestModel>()));
        }
 public ConfigurationsControllerTest()
 {
     _emailConfig   = new Mock <IConfigurationService <EmailServiceConfig> >();
     _instaConfig   = new Mock <IConfigurationService <InstagramServiceConfig> >();
     _cfgController = new ConfigurationController(_emailConfig.Object, _instaConfig.Object);
     _fixture       = new Fixture();
 }
        /// <summary>
        /// Method to update production XML and ticket status to ProductionReady
        /// </summary>
        public void UpdateTicketAndXMLForProduction()
        {
            string waitSettings = ConfigurationManager.AppSettings[Constants.SchedulerWaitTimeInMinutes];
            int    waitTime     = Convert.ToInt32(waitSettings) * 60000; // 5 minute

            while (true)
            {
                try
                {
                    File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + " ---------------------Started - EMIE Scheduler----------------------------");
                    File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + " Fetching Scheduled requests...........");
                    TicketController ticketController = new TicketController();
                    List <Tickets>   lstTickets       = ticketController.GetTicketsDataByTicketStatus(TicketStatus.ProductionChangesScheduled);
                    File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + String.Format(" Total tickets scheduled for prod changes are : {0}", lstTickets.Count));

                    //Console.WriteLine("Fetching Configuration settings for production changes...........");
                    File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + " Fetching Configuration settings for production changes...........");

                    EMIEWebPortal.Models.Configuration config = null;
                    if (LoginController.config == null)
                    {
                        ConfigurationController configController = new ConfigurationController();
                        config = configController.GetConfiguration();
                    }
                    else
                    {
                        config = LoginController.config;
                    }

                    foreach (Tickets ticket in lstTickets)
                    {
                        File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + String.Format(" Checking ticket #{0}", ticket.TicketId));
                        DateTime today         = DateTime.Now;
                        DateTime ProdStartDate = ((DateTime)ticket.ScheduleDateTimeStart).ToLocalTime();
                        DateTime ProdEndDate   = ((DateTime)ticket.ScheduleDateTimeEnd).ToLocalTime();
                        if (today >= ProdStartDate && ticket.FinalTicketStatus == TicketStatus.ProductionChangesScheduled)
                        {
                            // Console.WriteLine(string.Format("Processing ticket #{0}...........", ticket.TicketId));
                            File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + String.Format(" Processing ticket #{0}...........", ticket.TicketId));
                            XMLHelper xmlHelper = new XMLHelper();
                            xmlHelper.OperationOnXML(ticket, Operation.AddInProduction, config);

                            ticketController.UpdateTicketStatus(ticket, TicketStatus.ProductionReady);
                            ticket.FinalTicketStatus = TicketStatus.ProductionReady;
                            CommonFunctions.SendMail(ticket, MailMessageType.ProductionChangesDoneThroughScheduler);
                        }
                    }
                    //Console.WriteLine("---------------------End - EMIE Scheduler----------------------------");
                    File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + " ---------------------End - EMIE Scheduler----------------------------");
                    //// Sleep for 5 minute

                    File.AppendAllText(logFileName, String.Format("{0} ", Environment.NewLine) + DateTime.Now.ToString() + String.Format(" Wait for {0} milisecounds till the scheduler is called again", waitTime.ToString()));
                }
                catch (Exception ex)
                {
                    File.AppendAllText(logFileName, ex.Message + DateTime.Now);
                }
                Thread.Sleep(waitTime);
            }
        }
예제 #8
0
        /// <summary>
        /// Load configuration from file. If there's no open project, file will be 'default.json'
        /// </summary>
        public void LoadConfiguration()
        {
            var config = new ConfigurationController().GetConfiguration();

            Program.cfgCurrent = config;

#if PLUGINS
            var arPluginsPaths = SPathsPlugins.Split('|');
            foreach (var t in arPluginsPaths.Where(t => !string.IsNullOrEmpty(t)))
            {
                try
                {
                    Program.data.plugins.AddPlugin(new Plugin(t));
                }
                catch (Exception)
                {
                    SPathsPlugins = string.Empty;
                    MessageBox.Show(@"Plugin '" + t + @"' not found. Restoring plugin list as default.");
                    break;
                }
            }
#endif
            LoadFingerprintingConfiguration(Program.cfgCurrent.PassiveFingerPrintingHttp,
                                            Program.cfgCurrent.PasiveFingerPrintingSmtp, Program.cfgCurrent.FingerPrintingAllFtp,
                                            Program.cfgCurrent.FingerPrintingDns);

            Program.LogThis(new Log(Log.ModuleType.FOCA, "Loaded config", Log.LogType.debug));
        }
        public void AddTaskSelections()
        {
            var model = new ConfigurationModel();

            model.Tasks = new ConfigurationModel.TasksToExecuteSettings
            {
                GatherFiles = true,
                BuildSelfExtractingDownloadPackage = true,
                Compile             = true,
                OutputFolder        = "C:/temp",
                RememberSettings    = true,
                SelfExtractingStyle = "SfxFw",
                WriteInstallerXml   = true,
                WriteDownloadsXml   = true
            };
            var controller = new ConfigurationController(model);
            var testView   = new ConfigViewForTests();

            // Assert defaults to ensure a valid test
            Assert.False(testView.GatherFiles || testView.Compile || testView.BuildSelfExtractingDownloadPackage ||
                         testView.RememberSettings || testView.WriteInstallerXml || testView.WriteDownloadsXml, "Expected all booleans to default to false, test invalid");
            controller.PopulateWithModelSettings(testView);
            Assert.True(testView.GatherFiles && testView.Compile && testView.BuildSelfExtractingDownloadPackage &&
                        testView.RememberSettings && testView.WriteInstallerXml && testView.WriteDownloadsXml, "Expected all booleans to be set to true");
            Assert.That(testView.OutputFolder, Is.EqualTo(model.Tasks.OutputFolder));
            Assert.That(testView.SelfExtractingStyle, Is.EqualTo(model.Tasks.SelfExtractingStyle));
        }
예제 #10
0
        public void UpdateConfigurationForToggle_Successful()
        {
            var toggleId        = new Guid();
            var configurationId = new Guid();
            var configuration   = new Configuration {
                Id = configurationId
            };
            var toggle = new Toggle
            {
                Id             = toggleId,
                Name           = "test",
                Configurations = new List <Configuration> {
                    configuration
                }
            };

            _repositoryMock.Setup(rep => rep.Get(toggleId)).Returns(toggle);
            var controller = new ConfigurationController(_repositoryMock.Object);

            var result =
                controller.UpdateConfigurationForToggle(toggleId, configurationId, new ConfigurationDtoInput());
            var objectResult = result as NoContentResult;

            Assert.IsNotNull(objectResult);
            Assert.AreEqual((int)HttpStatusCode.NoContent, objectResult.StatusCode);
        }
예제 #11
0
        public new bool Delete()
        {
            bool ret = true;

            try
            {
                base.Delete();
                ConfigurationController.RegisterChangeCall(
                    typeof(VacationRoutePlan),
                    new ADialPlan.sUpdateConfigurationsCall(
                        "DeleteVacationRoute",
                        new NameValuePair[] {
                    new NameValuePair("context", Context.Name),
                    new NameValuePair("extension", Number),
                    new NameValuePair("startDate", StartDate)
                }),
                    new IEvent[] {
                    new GenericEvent("VacationRouteDeleted",
                                     new NameValuePair[] {
                        new NameValuePair("DomainName", Domain.Current.Name),
                        new NameValuePair("Name", Name),
                        new NameValuePair("Number", Number)
                    })
                });
            }
            catch (Exception e)
            {
                Log.Error(e);
                EventController.TriggerEvent(new ErrorOccuredEvent(e));
                ret = false;
            }
            return(ret);
        }
예제 #12
0
        public void Setup()
        {
            serviceMock   = new Mock <IConfigurationService>();
            validatorMock = new Mock <IValidator <RemoteServiceAddressViewModel> >();

            controller = new ConfigurationController(serviceMock.Object, validatorMock.Object);
        }
        public ConfigurationControllerTest(/*IcuModel icuModel*/)
        {
            //Model = icuModel;
            var configMock = new Mock <IConfigurationRepository>();

            _configurationController = new ConfigurationController(configMock.Object);
        }
예제 #14
0
        public new bool Delete()
        {
            bool ret = true;

            try
            {
                base.Delete();
                ConfigurationController.RegisterChangeCall(
                    typeof(PinnedRoutePlan),
                    new ADialPlan.sUpdateConfigurationsCall(
                        "DeletePinset",
                        new NameValuePair[] {
                    new NameValuePair("context", Context.Name),
                    new NameValuePair("name", Name)
                }),
                    new IEvent[] {
                    new GenericEvent("PinSetDeleted",
                                     new NameValuePair[] {
                        new NameValuePair("Name", Name),
                        new NameValuePair("Context", Context.Name),
                        new NameValuePair("IsAdvanced", Advanced)
                    })
                });
            }
            catch (Exception e)
            {
                Log.Error(e);
                EventController.TriggerEvent(new ErrorOccuredEvent(e));
                ret = false;
            }
            return(ret);
        }
예제 #15
0
        private void AppOnStartup(object sender, StartupEventArgs e)
        {
            Current.DispatcherUnhandledException += ApplicationCurrentOnDispatcherUnhandledException;
            Current.Exit += ApplicationCurrentOnExit;

            RemoveOldFiles();

            var serverConfigurationController           = new ConfigurationController <ServerConfiguration>();
            ServerConfiguration serverConfigurationFile = serverConfigurationController.ReadConfiguration(new ServerConfiguration
            {
                Host        = "localhost",
                Port        = "1232",
                FtpUser     = "******",
                FtpPassword = "******"
            });

            var colorConfigurationController = new ConfigurationController <ColorConfiguration>();
            var colorConfiguration           = colorConfigurationController.ReadConfiguration(new ColorConfiguration
            {
                Color = "Steel"
            });

            ThemeManager.AddAccent("Orgadata", new Uri("Styles/OrgadataTheme.xaml", UriKind.Relative));

            var foundAccent = ThemeManager.Accents.FirstOrDefault(accent =>
                                                                  accent.Name.Equals(colorConfiguration.Color, StringComparison.CurrentCultureIgnoreCase));
            var theme = ThemeManager.DetectAppStyle(Current);

            ThemeManager.ChangeAppStyle(Current, foundAccent, theme.Item1);

            Chat.DataAccess.DatabaseClient.InitializeDatabase();
            _viewProvider = new ViewProvider();

            _hubConnectionHelper = new SignalHubConnectionHelper("http://" + serverConfigurationFile.Host + ":" + serverConfigurationFile.Port + "/signalr/hubs");

            ISignalHelperFacade signalHelperFacade = new SignalHelperFacade
            {
                ChatSignalHelper     = new ChatSignalHelper(_hubConnectionHelper.CreateHubProxy("ChatHub")),
                LoginSignalHelper    = new LoginSignalHelper(_hubConnectionHelper.CreateHubProxy("LoginHub")),
                RegisterSignalHelper = new RegisterSignalHelper(_hubConnectionHelper.CreateHubProxy("RegisterHub")),
                VoteSignalHelper     = new VoteSignalHelper(_hubConnectionHelper.CreateHubProxy("VoteHub"))
            };

            _cappuMainPresenter = new CappuMainPresenter(signalHelperFacade, _viewProvider)
            {
                CappuLoginPresenter = { ConnectedToServer = _hubConnectionHelper.Connected }
            };

            _cappuMainPresenter.CappuLoginPresenter.StartConnection += LoginPresenterOnStartConnection;

            _viewProvider.Show(_cappuMainPresenter);

            var changelog = GetChangelog();

            if (!string.IsNullOrEmpty(changelog))
            {
                _cappuMainPresenter.ShowChangelog(changelog);
            }
            _cappuMainPresenter.Load();
        }
예제 #16
0
        public new bool Save()
        {
            bool ret = true;

            try
            {
                base.Save();
                ConfigurationController.RegisterExtensionChangeCall(
                    Number,
                    Domain.Current.Name,
                    typeof(CallExtensionPlan),
                    new ADialPlan.sUpdateConfigurationsCall(
                        "AddVoicemail",
                        new NameValuePair[] {
                    new NameValuePair("context", Context.Name),
                    new NameValuePair("extension", Number)
                }),
                    new IEvent[] {
                    new GenericEvent("VoicemailAttachedToExtension",
                                     new NameValuePair[] {
                        new NameValuePair("Number", Number),
                        new NameValuePair("Domain", Domain.Current.Name),
                        new NameValuePair("ContextName", Context.Name)
                    }
                                     )
                });
            }
            catch (Exception e)
            {
                Log.Error(e);
                EventController.TriggerEvent(new ErrorOccuredEvent(e));
                ret = false;
            }
            return(ret);
        }
예제 #17
0
        private void ExportConfigPathButtonClick(object sender, EventArgs e)
        {
            using (SaveFileDialog fileDialog = new SaveFileDialog
            {
                Filter = "JSON Files|*.json",
                OverwritePrompt = false
            })
            {
                var result = fileDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    tbExportConfig.Text = fileDialog.FileName.ToString(CultureInfo.InvariantCulture);

                    if (File.Exists(tbExportConfig.Text))
                    {
                        var controller = new ConfigurationController();
                        controller.LoadExportConfigFile(NotificationService, tbExportConfig, filterQuery, lookupMaping);
                    }
                }
                else if (result == DialogResult.Cancel)
                {
                    tbExportConfig.Text = null;
                }
            }
        }
        public void Setup()
        {
            certificateService = A.Fake <ICertificateService>();
            controller         =
                new ConfigurationController(
                    centresDataService,
                    mapsApiHelper,
                    logger,
                    imageResizeService,
                    certificateService
                    )
                .WithDefaultContext()
                .WithMockUser(true);

            A.CallTo(
                () => centresDataService.UpdateCentreWebsiteDetails(
                    A <int> ._,
                    A <string> ._,
                    A <double> ._,
                    A <double> ._,
                    A <string> ._,
                    A <string> ._,
                    A <string> ._,
                    A <string> ._,
                    A <string> ._,
                    A <string> ._,
                    A <string> ._
                    )
                ).DoesNothing();
        }
예제 #19
0
        /// <summary>
        /// The main entry point for the application
        /// </summary>
        /// <param name="args">Arguments passed at start up</param>
        private static void Main(string[] args)
        {
            System.Console.Title = "Stock Bandit Console";

            Log.Info("*********** Stock Bandit Server Console Started ***********");
            Log.InfoFormat("Service Version: {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString(4));
            Log.InfoFormat("Running on {0} ({1})", System.Environment.MachineName, System.Environment.OSVersion.VersionString);

            string cmd = string.Empty;

            // Create controller for instantiating the server
            ConfigurationController configurationController = new ConfigurationController();
            StockServer             server = configurationController.SetupServer(new LogQueue(1000));

            if (server == null)
            {
                System.Console.WriteLine("********** Console cannot be started due to these errors: ************");
                foreach (string errorMessage in configurationController.ErrorMessages)
                {
                    System.Console.WriteLine("{0} - {1}", DateTime.Now.ToString("HH:mm:ss.fff"), errorMessage);
                }
                System.Console.ReadLine();
                return;
            }

            if (server.StartServer())
            {
                // Server has started successfully
                Log.Info("**************** Server Started ********************");

                // Send an email for compliance sites
                server.SendStartedEmail();

                cmd = System.Console.ReadLine();
                while (cmd.ToUpper() != "QUIT")
                {
                    switch (cmd.ToUpper())
                    {
                    case "EVALUATE":
                        server.PriceFetchTimerElapsed(null);
                        break;

                    default:
                        System.Console.WriteLine(string.Format("Unrecognised command - {0}", cmd.ToUpper()));
                        break;
                    }

                    cmd = System.Console.ReadLine();
                }

                Log.Info("**************** Stopping Server ********************");
                server.StopServer();
                Log.Info("**************** Server Stopped ********************");
            }
            else
            {
                System.Console.WriteLine("Server failed to start - press ENTER to close");
                System.Console.ReadLine();
            }
        }
        public void DeleteFlavorWorks()
        {
            var deleteFlavor = new ConfigurationModel.FlavorOptions {
                FlavorName = "DeletedFlavor", DownloadURL = "localhost"
            };
            var model      = new ConfigurationModel();
            var flavorName = "TestFlavor";

            model.Flavors = new List <ConfigurationModel.FlavorOptions>
            {
                new ConfigurationModel.FlavorOptions {
                    FlavorName = flavorName
                },
                deleteFlavor
            };
            var controller = new ConfigurationController(model);
            var testView   = new ConfigViewForTests();

            controller.PopulateWithModelSettings(testView);
            TestThatViewHasFlavor(testView, model.Flavors[0]);
            TestThatViewHasFlavor(testView, model.Flavors[1]);
            // SUT
            controller.DeleteLastFlavor(testView);
            TestThatViewHasFlavor(testView, model.Flavors[0]);
            TestThatViewDoesNotHaveFlavor(testView, deleteFlavor);
        }
예제 #21
0
        public void DeleteConfigurationForToggle_Successful()
        {
            var toggleId        = new Guid();
            var configurationId = new Guid();
            var configuration   = new Configuration {
                Id = configurationId
            };
            var toggle = new Toggle
            {
                Id             = toggleId,
                Name           = "test",
                Configurations = new List <Configuration> {
                    configuration
                }
            };

            _repositoryMock.Setup(rep => rep.Get(toggleId)).Returns(toggle);
            var controller = new ConfigurationController(_repositoryMock.Object);

            var result       = controller.DeleteConfigurationForToggle(toggleId, configurationId);
            var actionResult = result as NoContentResult;

            Assert.IsNotNull(actionResult);
            _repositoryMock.Verify(rep => rep.Save(), Times.Once);
            Assert.AreEqual((int)HttpStatusCode.NoContent, actionResult.StatusCode);
        }
        public async void BulkInsert_No_Errors()
        {
            ConfigurationControllerMockFacade mock = new ConfigurationControllerMockFacade();

            var mockResponse = new CreateResponse <ApiConfigurationResponseModel>(new FluentValidation.Results.ValidationResult());

            mockResponse.SetRecord(new ApiConfigurationResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiConfigurationRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiConfigurationResponseModel> >(mockResponse));
            ConfigurationController controller = new ConfigurationController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiConfigurationRequestModel>();

            records.Add(new ApiConfigurationRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var result = (response as OkObjectResult).Value as List <ApiConfigurationResponseModel>;

            result.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiConfigurationRequestModel>()));
        }
예제 #23
0
        public new bool Save()
        {
            bool ret = false;

            try
            {
                base.Save();
                ConfigurationController.RegisterChangeCall(
                    typeof(PinnedRoutePlan),
                    new ADialPlan.sUpdateConfigurationsCall(
                        "AddPinnedRoute",
                        new NameValuePair[] {
                    new NameValuePair("name", Name),
                    new NameValuePair("context", RouteContext.Name),
                    new NameValuePair("condition", DestinationCondition),
                    new NameValuePair("pinsetName", PinFile.Name)
                }
                        ),
                    new IEvent[] {
                    new GenericEvent("PinnedRouteCreated", new NameValuePair[] {
                        new NameValuePair("Name", Name),
                        new NameValuePair("Context", RouteContext.Name)
                    })
                }
                    );
            }
            catch (Exception e)
            {
                Log.Error(e);
                EventController.TriggerEvent(new ErrorOccuredEvent(e));
                ret = false;
            }
            return(ret);
        }
예제 #24
0
        public new bool Update()
        {
            bool ret = _isValid;

            if (ret)
            {
                try
                {
                    base.Update();
                    List <NameValuePair> pars = new List <NameValuePair>(
                        new NameValuePair[] {
                        new NameValuePair("context", RouteContext.Name),
                        new NameValuePair("name", Name),
                        new NameValuePair("originalName", _originalName),
                        new NameValuePair("condition", DestinationCondition.Value),
                        new NameValuePair("performOnFail", PerformOnFail),
                        new NameValuePair("start", Start),
                        new NameValuePair("end", End)
                    });
                    switch (Type)
                    {
                    case VacationRouteRedirectTypes.PhoneExtension:
                        pars.Add(new NameValuePair("extensionNumber", new sDomainExtensionPair(BridgeExtension.Number, BridgeExtension.Domain.Name)));
                        break;

                    case VacationRouteRedirectTypes.PlayFile:
                        pars.Add(new NameValuePair("audioFile", AudioFile.ToString()));
                        break;

                    case VacationRouteRedirectTypes.TransferToExtension:
                        pars.Add(new NameValuePair("callExtension", ExtensionReference));
                        break;

                    case VacationRouteRedirectTypes.OutGateway:
                        pars.Add(new NameValuePair("gateway", new sGatewayNumberPair(GatewayNumber, OutGateway.Name)));
                        break;
                    }
                    ConfigurationController.RegisterChangeCall(
                        typeof(TimedRoute),
                        new ADialPlan.sUpdateConfigurationsCall(
                            "UpdateTimedRoute",
                            pars.ToArray()),
                        new IEvent[] {
                        new GenericEvent("TimedRouteUpdated",
                                         new NameValuePair[] {
                            new NameValuePair("DomainName", Domain.Current.Name),
                            new NameValuePair("Name", Name)
                        })
                    });
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    EventController.TriggerEvent(new ErrorOccuredEvent(e));
                    ret = false;
                }
            }
            return(ret);
        }
 public void given_settings_are_being_retrieved_from_the_controller()
 {
     context["when a parameterless http get is issued"] = () =>
         {
             var config = new ConfigurationController().Get();
             it["then valid json is returned"] = () => config.should_not_be(null);
         };
 }
예제 #26
0
        public new bool Save()
        {
            bool ret = _isValid;

            if (ret)
            {
                try
                {
                    base.Save();
                    List <NameValuePair> pars = new List <NameValuePair>(
                        new NameValuePair[] {
                        new NameValuePair("context", Context.Name),
                        new NameValuePair("extension", Number),
                        new NameValuePair("startDate", StartDate),
                        new NameValuePair("enddate", EndDate),
                        new NameValuePair("endWithVoicemail", EndWithVoicemail)
                    });
                    switch (Type)
                    {
                    case VacationRouteRedirectTypes.PhoneExtension:
                        pars.Add(new NameValuePair("bridgeExtension", new sDomainExtensionPair(BridgeExtension.Number, BridgeExtension.Domain.Name)));
                        break;

                    case VacationRouteRedirectTypes.PlayFile:
                        pars.Add(new NameValuePair("audioFile", AudioFile));
                        break;

                    case VacationRouteRedirectTypes.TransferToExtension:
                        pars.Add(new NameValuePair("callExtension", ExtensionReference));
                        break;

                    case VacationRouteRedirectTypes.OutGateway:
                        pars.Add(new NameValuePair("outGateway", new sGatewayNumberPair(GatewayNumber, OutGateway.Name)));
                        break;
                    }
                    ConfigurationController.RegisterChangeCall(
                        typeof(VacationRoutePlan),
                        new ADialPlan.sUpdateConfigurationsCall(
                            "AddVacationRoute",
                            pars.ToArray()),
                        new IEvent[] {
                        new GenericEvent("VacationRouteCreated",
                                         new NameValuePair[] {
                            new NameValuePair("DomainName", Domain.Current.Name),
                            new NameValuePair("Name", Name),
                            new NameValuePair("Number", Number)
                        })
                    });
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    EventController.TriggerEvent(new ErrorOccuredEvent(e));
                    ret = false;
                }
            }
            return(ret);
        }
예제 #27
0
        public void LoadAllFiles(INotificationService feedbackManager, TextBox schemaPath, TextBox exportConfig, TextBox importConfig, bool inputWorkingstate, CollectionParameters collectionParameters)
        {
            LoadSchemaFile(schemaPath.Text, inputWorkingstate, feedbackManager, collectionParameters.EntityAttributes, collectionParameters.EntityRelationships);

            var controller = new ConfigurationController();

            controller.LoadExportConfigFile(feedbackManager, exportConfig, collectionParameters.FilterQuery, collectionParameters.LookupMaping);
            controller.LoadImportConfigFile(feedbackManager, importConfig, collectionParameters.Mapper, collectionParameters.Mapping);
        }
예제 #28
0
 public StatBot(ConfigurationController configurationController,
                IAppAuthVkApi vkApi,
                IWallStatisticsCollector wallStatisticsCollector, IInputOutputSource io)
 {
     this.configurationController = configurationController;
     this.vkApi = vkApi;
     this.wallStatisticsCollector = wallStatisticsCollector;
     this.io = io;
 }
        public void GetConfig()
        {
            var controller = new ConfigurationController(GetConfiguration());
            var result     = controller.GetConfig();
            var unboxed    = AssertOkResult(result);

            Assert.Equal(string.Empty, unboxed["AppInsightsKey"]);
            Assert.Equal("http://localhost:3000", unboxed["PublicAppUrl"]);
        }
예제 #30
0
        public void UpdateConfigurationForToggle_BadRequest()
        {
            var controller = new ConfigurationController(_repositoryMock.Object);

            var result       = controller.UpdateConfigurationForToggle(new Guid(), new Guid(), null);
            var objectResult = result as BadRequestResult;

            Assert.IsNotNull(objectResult);
            Assert.AreEqual((int)HttpStatusCode.BadRequest, objectResult.StatusCode);
        }
예제 #31
0
        public void GetConfigurationForToggle_ToggleNotFound()
        {
            var controller = new ConfigurationController(_repositoryMock.Object);

            var result       = controller.GetConfigurationForToggle(new Guid(), new Guid());
            var objectResult = result as NotFoundResult;

            Assert.IsNotNull(objectResult);
            Assert.AreEqual((int)HttpStatusCode.NotFound, objectResult.StatusCode);
        }
        public void given_settings_are_being_sent_to_the_controller()
        {
            context["when a valid set of data including all possible fields"] = () =>
                {

                    //all possible fields are set
                    var postData = new TfsServerConfiguration()
                    {
                        IsWindowsIntegratedSecurity = true,
                        TfsUrl = "http://www.mytfsserver.com/default/",
                        TfsUserName = "******",
                        TfsPassword = "******",
                        VersionOneUrl = "http://www.versionone.com/",
                        VersionOneUserName = "******",
                        VersionOnePassword = "******",
                        ProxyIsEnabled = true,
                        TfsWorkItemRegex = "[]",
                        BaseListenerUrl = "http://localhost:9090/",
                        DebugMode = true,
                        ProxyUrl = "http://192.168.1.1/home/",
                        ProxyDomain = "AD1",
                        ProxyUsername = "******",
                        ProxyPassword = "******"
                    };

                    it["then the data is saved accurately"] = () =>
                        {
                            new ConfigurationProvider().ClearAllSettings();
                            var postResult = new ConfigurationController().Post(postData);
                            var getData = new ConfigurationController().Get();
                            postResult[StatusKey.Status].should_be(StatusCode.Ok);
                            getData.should_be(postData);
                        };
                };

            context["when a valid object is sent to the server"] = () =>
                {
                    //min acceptable valid set of data
                    var postData = new TfsServerConfiguration()
                    {
                        TfsUrl = "http://www.mytfsserver.com/default/",
                        TfsUserName = "******",
                        TfsPassword = "******",
                        VersionOneUrl = "http://www.versionone.com/",
                        VersionOneUserName = "******",
                        VersionOnePassword = "******",
                        ProxyIsEnabled = false,
                        BaseListenerUrl = "http://locahost:9090/",
                        TfsWorkItemRegex = "[]" //not a required field, but returns a default so needs to be set in order for a valid comparison to occur below.
                    };

                    it["then the data is saved accurately"] = () =>
                        {

                            new ConfigurationProvider().ClearAllSettings();
                            var postResult = new ConfigurationController().Post(postData);
                            var getData = new ConfigurationController().Get();

                            //the data retrieved should equal the data posted
                            getData.should_be(postData);

                            it["and the status of 'ok' is in the result data"] = () =>
                                {
                                    postResult.should_contain(kvp => kvp.Key == StatusKey.Status);
                                    postResult[StatusKey.Status].should_be(StatusCode.Ok);
                                };
                        };
                };

            context["when an invalid object is sent to the server"] = () =>
                {

                    //invalid data missing v1url
                    var postData = new TfsServerConfiguration()
                    {
                        TfsUrl = "http://www.mytfsserver.com/default/",
                        TfsUserName = "******",
                        TfsPassword = "******",
                        VersionOneUserName = "******",
                        VersionOnePassword = "******",
                        ProxyIsEnabled = false
                    };

                    it["then a proper list of errors is received"] = () =>
                        {
                            new ConfigurationProvider().ClearAllSettings();
                            var postResult = new ConfigurationController().Post(postData);
                            postResult.should_contain(x => x.Key == "VersionOneUrl");
                            postResult["VersionOneUrl"].should_be(StatusCode.Required);
                            postResult[StatusKey.Status].should_be(StatusCode.Exception);
                        };
                };
        }
예제 #33
0
        public void Should_be_possible_raising_a_configuration_event_on_a_view()
        {
            MockRepository mocks = new MockRepository();

            var fakeView = mocks.DynamicMock<IConfigurationView>();

            mocks.ReplayAll();

            var controller = new ConfigurationController(fakeView);

            fakeView.Raise(x => x.OnReadConfiguration += null, this, EventArgs.Empty);
            fakeView.Raise(x => x.OnWriteConfiguration += null, this, EventArgs.Empty);

            mocks.VerifyAll();

            Assert.IsTrue(controller.OnReadConfigurationCalled);
            Assert.IsTrue(controller.OnWriteConfigurationCalled);
        }
예제 #34
0
 public static ConfigurationController Fixture()
 {
     ConfigurationController controller = new ConfigurationController(new ConfigurationRepository(), "", new LoginView());
     return controller;
 }