Esempio n. 1
0
        private void RegisterServices()
        {
            var endpoint = loginSettings.Endpoint;

            var serverUserService = new UserService(endpoint);

            Guid sessionId;

            using (var channelManager = serverUserService.CreateChannelManager())
            using (var channel = channelManager.CreateChannel())
            {
                var currentUser = channel.Service.UserLogin(loginSettings.User, loginSettings.Password).Result as Administrator;
                sessionId = currentUser.SessionId;
                Container.RegisterInstance(currentUser);
            }

            Container.RegisterInstance(serverUserService);
            Container.RegisterType<ChannelManager<IServerTcpService>>
                (new InjectionFactory(c => serverUserService.CreateChannelManager(sessionId)));

            var serverService = new ServerService(endpoint);
            Container.RegisterInstance(serverService);
            Container.RegisterType<ChannelManager<IServerTcpService>>
                (new InjectionFactory(c => serverService.CreateChannelManager(sessionId)));

            var queuePlanService = new QueuePlanService(endpoint);
            Container.RegisterInstance(queuePlanService);
            Container.RegisterType<DuplexChannelManager<IQueuePlanTcpService>>
                (new InjectionFactory(c => queuePlanService.CreateChannelManager(sessionId)));

            var templateService = new TemplateService(endpoint);
            Container.RegisterInstance(templateService);
            Container.RegisterType<ChannelManager<ITemplateTcpService>>
                (new InjectionFactory(c => templateService.CreateChannelManager(sessionId)));

            var theme = string.IsNullOrEmpty(portalSettings.Theme)
                ? Templates.Themes.Default : portalSettings.Theme;

            var templateManager = new TemplateManager(Templates.Apps.Common, theme);
            Container.RegisterInstance<ITemplateManager>(templateManager);
        }
Esempio n. 2
0
        private async Task<bool> ConnectionValid()
        {
            try
            {
                using (var service = new ServerService(Endpoint))
                using (var channelManager = service.CreateChannelManager())
                using (var channel = channelManager.CreateChannel())
                {
                    var date = await channel.Service.GetDateTime();
                }

                return true;
            }
            catch (Exception e)
            {
                UIHelper.Error(null, "Не удалось подключиться к серверу", e);
            }

            return false;
        }
Esempio n. 3
0
        private static void RegisterServices()
        {
            qualityService = new QualityService(hubSettings.Endpoint);
            container.RegisterInstance(qualityService);
            container.RegisterType<DuplexChannelManager<IQualityTcpService>>
                (new InjectionFactory(c => qualityService.CreateChannelManager()));

            serverService = new ServerService(endpoint);
            container.RegisterInstance(serverService);
            container.RegisterType<ChannelManager<IServerTcpService>>
                (new InjectionFactory(c => serverService.CreateChannelManager(sessionId)));

            userService = new UserService(endpoint);
            container.RegisterInstance(userService);
            container.RegisterType<ChannelManager<IUserTcpService>>
                (new InjectionFactory(c => userService.CreateChannelManager(sessionId)));

            queuePlanService = new QueuePlanService(endpoint);
            container.RegisterInstance(queuePlanService);
            container.RegisterType<DuplexChannelManager<IQueuePlanTcpService>>
                (new InjectionFactory(c => queuePlanService.CreateChannelManager(sessionId)));
        }
Esempio n. 4
0
        private static void RegisterServices()
        {
            serverService = new ServerService(endpoint);
            container.RegisterInstance(serverService);
            container.RegisterType<ChannelManager<IServerTcpService>>
                (new InjectionFactory(c => serverService.CreateChannelManager(sessionId)));

            userService = new UserService(endpoint);
            container.RegisterInstance(userService);
            container.RegisterType<ChannelManager<IUserTcpService>>
                (new InjectionFactory(c => userService.CreateChannelManager(sessionId)));

            templateService = new TemplateService(endpoint);
            container.RegisterInstance(templateService);
            container.RegisterType<ChannelManager<ITemplateTcpService>>
                (new InjectionFactory(c => templateService.CreateChannelManager(sessionId)));

            workplaceService = new WorkplaceService(endpoint);
            container.RegisterInstance(workplaceService);
            container.RegisterType<ChannelManager<IWorkplaceTcpService>>
                (new InjectionFactory(c => workplaceService.CreateChannelManager(sessionId)));

            queuePlanService = new QueuePlanService(endpoint);
            container.RegisterInstance(queuePlanService);
            container.RegisterType<DuplexChannelManager<IQueuePlanTcpService>>
                (new InjectionFactory(c => queuePlanService.CreateChannelManager(sessionId)));

            lifeSituationService = new LifeSituationService(endpoint);
            container.RegisterInstance(lifeSituationService);
            container.RegisterType<ChannelManager<ILifeSituationTcpService>>
                (new InjectionFactory(c => lifeSituationService.CreateChannelManager(sessionId)));

            var theme = string.IsNullOrEmpty(administratorSettings.Theme)
                ? Templates.Themes.Default : administratorSettings.Theme;

            templateManager = new TemplateManager(Templates.Apps.Common, theme);
            container.RegisterInstance<ITemplateManager>(templateManager);
        }