当前位置: 首页>>代码示例>>C#>>正文


C# UserService.CreateChannelManager方法代码示例

本文整理汇总了C#中UserService.CreateChannelManager方法的典型用法代码示例。如果您正苦于以下问题:C# UserService.CreateChannelManager方法的具体用法?C# UserService.CreateChannelManager怎么用?C# UserService.CreateChannelManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserService的用法示例。


在下文中一共展示了UserService.CreateChannelManager方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterServices

        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);
        }
开发者ID:breslavsky,项目名称:queue,代码行数:41,代码来源:PortalInstance.cs

示例2: Connect

        public async void Connect()
        {
            bool connected = false;

            try
            {
                if (string.IsNullOrWhiteSpace(Settings.Endpoint))
                {
                    throw new QueueException("Не указан адрес сервера");
                }

                using (var userService = new UserService(Settings.Endpoint))
                using (var channelManager = userService.CreateChannelManager())
                using (var channel = channelManager.CreateChannel())
                {
                    connectButton.Enabled = false;

                    userControl.Initialize(await channel.Service.GetUserLinks(UserRole));
                    if (Settings.User != Guid.Empty)
                    {
                        userControl.Select<User>(new User() { Id = Settings.User });
                    }

                    passwordTextBox.Focus();

                    connected = true;

                    connectionGroupBox.Enabled = false;
                    loginGroupBox.Enabled = true;
                }
            }
            catch (OperationCanceledException) { }
            catch (CommunicationObjectAbortedException) { }
            catch (ObjectDisposedException) { }
            catch (InvalidOperationException) { }
            catch (FaultException ex)
            {
                UIHelper.Warning(ex.Reason.ToString());
            }
            catch (Exception ex)
            {
                UIHelper.Warning(ex.Message);
            }
            finally
            {
                connectButton.Enabled = true;
            }

            if (connected)
            {
                OnConnected(this, null);
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:53,代码来源:LoginSettingsControl.cs

示例3: officeGridView_CellClick

        private async void officeGridView_CellClick(object sender, DataGridViewCellEventArgs eventArgs)
        {
            int rowIndex = eventArgs.RowIndex,
                columnIndex = eventArgs.ColumnIndex;
            if (rowIndex >= 0 && columnIndex >= 0)
            {
                var row = officesGridView.Rows[rowIndex];
                var cell = row.Cells[columnIndex];

                var office = row.Tag as Office;

                switch (cell.OwningColumn.Name)
                {
                    case LoginColumn:

                        using (var f = new OfficeLoginForm(office.Id))
                        {
                            if (f.ShowDialog() == DialogResult.OK)
                            {
                                office.Endpoint = f.Settings.Endpoint;
                                office.SessionId = f.SessionId;

                                using (var channel = ChannelManager.CreateChannel())
                                {
                                    try
                                    {
                                        office = await taskPool.AddTask(channel.Service.EditOffice(office));

                                        UIHelper.Information("Вход успешно выполнен. Управление доступно.");
                                    }
                                    catch (OperationCanceledException) { }
                                    catch (CommunicationObjectAbortedException) { }
                                    catch (ObjectDisposedException) { }
                                    catch (InvalidOperationException) { }
                                    catch (FaultException exception)
                                    {
                                        UIHelper.Warning(exception.Reason.ToString());
                                    }
                                    catch (Exception exception)
                                    {
                                        UIHelper.Warning(exception.Message);
                                    }
                                }
                            }
                        }
                        break;

                    case ManageColumn:

                        if (office.SessionId != Guid.Empty)
                        {
                            var officeServerUserService = new UserService(office.Endpoint);

                            using (var officeChannelManager = officeServerUserService.CreateChannelManager())
                            using (var officeChannel = officeChannelManager.CreateChannel())
                            {
                                try
                                {
                                    var administrator = await taskPool.AddTask(officeChannel.Service.OpenUserSession(office.SessionId));

                                    Process.Start(new ProcessStartInfo()
                                    {
                                        UseShellExecute = true,
                                        FileName = "Queue.Administrator.exe",
                                        Arguments = string.Format("--AutoLogin --Endpoint=\"{0}\" --SessionId={1}",
                                            office.Endpoint, administrator.SessionId),
                                        WorkingDirectory = Environment.CurrentDirectory
                                    });
                                }
                                catch (OperationCanceledException) { }
                                catch (CommunicationObjectAbortedException) { }
                                catch (ObjectDisposedException) { }
                                catch (InvalidOperationException) { }
                                catch (FaultException exception)
                                {
                                    UIHelper.Warning(exception.Reason.ToString());
                                }
                                catch (Exception exception)
                                {
                                    UIHelper.Warning(exception.Message);
                                }
                            }
                        }
                        else
                        {
                            UIHelper.Warning("Вход не выполнен");
                        }
                        break;
                }
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:91,代码来源:OfficesForm.cs

示例4: Connect

        public async void Connect()
        {
            serverUserService = new UserService(Endpoint);
            channelManager = serverUserService.CreateChannelManager();

            var result = await Window.ExecuteLongTask(async () =>
                  {
                      using (var channel = channelManager.CreateChannel())
                      {
                          return await channel.Service.GetUserLinks(userRole);
                      }
                  });

            if (result == null)
            {
                return;
            }

            Users = result.Select(u => new UserComboBoxItem(u.Id, u.ToString())).ToArray();

            if (AppSettings.User != Guid.Empty)
            {
                SelectedUser = Users.SingleOrDefault(u => u.Id == AppSettings.User);
            }

            if (SelectedUser == null)
            {
                SelectedUser = Users.First();
            }

            IsConnected = true;

            if (IsConnected && IsRemember)
            {
                Login();
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:37,代码来源:LoginPageViewModel.cs

示例5: Main

        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            container = new UnityContainer();
            container.RegisterInstance(container);
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

            configuration = new ConfigurationManager(Product.Operator.AppName, SpecialFolder.ApplicationData);
            container.RegisterInstance(configuration);

            loginSettings = configuration.GetSection<LoginSettings>(LoginSettings.SectionKey);
            container.RegisterInstance(loginSettings);

            loginFormSettings = configuration.GetSection<LoginFormSettings>(LoginFormSettings.SectionKey);
            container.RegisterInstance(loginFormSettings);

            hubSettings = configuration.GetSection<HubSettings>(HubSettings.SectionKey);
            container.RegisterInstance(hubSettings);

            ParseOptions();

            if (options.AutoLogin)
            {
                endpoint = options.Endpoint;

                try
                {
                    using (var serverUserService = new UserService(endpoint))
                    using (var channelManager = serverUserService.CreateChannelManager())
                    using (var channel = channelManager.CreateChannel())
                    {
                        sessionId = Guid.Parse(options.SessionId);
                        currentUser = channel.Service.OpenUserSession(sessionId).Result as QueueOperator;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.InnerException.Message);
                    return;
                }

                container.RegisterInstance<User>(currentUser);
                container.RegisterInstance<QueueOperator>(currentUser);

                RegisterServices();

                Application.Run(new OperatorForm());
            }
            else
            {
                while (true)
                {
                    var loginForm = new LoginForm(UserRole.Operator);
                    if (loginForm.ShowDialog() == DialogResult.OK)
                    {
                        configuration.Save();

                        endpoint = loginSettings.Endpoint;
                        currentUser = loginForm.CurrentUser as QueueOperator;
                        sessionId = currentUser.SessionId;

                        container.RegisterInstance<User>(currentUser);
                        container.RegisterInstance<QueueOperator>(currentUser);

                        RegisterServices();

                        loginForm.Dispose();

                        using (var f = new OperatorForm())
                        {
                            Application.Run(f);

                            if (f.IsLogout)
                            {
                                ResetSettings();
                                continue;
                            }
                        }
                    }

                    break;
                }
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:86,代码来源:Program.cs

示例6: RegisterServices

        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)));
        }
开发者ID:breslavsky,项目名称:queue,代码行数:22,代码来源:Program.cs

示例7: Login

        private async void Login()
        {
            if (serverUserService != null)
            {
                serverUserService.Dispose();
            }

            serverUserService = new UserService(LoginSettings.Endpoint);

            if (channelManager != null)
            {
                channelManager.Dispose();
            }

            channelManager = serverUserService.CreateChannelManager();

            using (var channel = channelManager.CreateChannel())
            {
                try
                {
                    loginButton.Enabled = false;

                    CurrentUser = await taskPool.AddTask(channel.Service.UserLogin(LoginSettings.User, LoginSettings.Password));

                    if (!LoginFormSettings.IsRemember)
                    {
                        LoginSettings.Password = string.Empty;
                    }

                    ApplicationSettings.Language = languageControl.Selected<Language>();

                    DialogResult = DialogResult.OK;
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException ex)
                {
                    UIHelper.Warning(ex.Reason.ToString());
                }
                catch (Exception ex)
                {
                    UIHelper.Warning(ex.Message);
                }
                finally
                {
                    loginButton.Enabled = true;
                }
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:51,代码来源:LoginForm.cs

示例8: loginButton_Click

        private async void loginButton_Click(object sender, EventArgs e)
        {
            using (var serverUserService = new UserService(Settings.Endpoint))
            using (var channelManager = serverUserService.CreateChannelManager())
            using (var channel = channelManager.CreateChannel())
            {
                try
                {
                    loginButton.Enabled = false;

                    var user = await taskPool.AddTask(channel.Service.UserLogin(Settings.User, Settings.Password));
                    SessionId = user.SessionId;
                    DialogResult = DialogResult.OK;
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
                finally
                {
                    loginButton.Enabled = true;
                }
            }
        }
开发者ID:breslavsky,项目名称:queue,代码行数:32,代码来源:OfficeLoginForm.cs


注:本文中的UserService.CreateChannelManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。