本文整理汇总了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);
}
示例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);
}
}
示例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;
}
}
}
示例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();
}
}
示例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;
}
}
}
示例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)));
}
示例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;
}
}
}
示例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;
}
}
}