本文整理汇总了C#中ClientProcessor.ConnectService方法的典型用法代码示例。如果您正苦于以下问题:C# ClientProcessor.ConnectService方法的具体用法?C# ClientProcessor.ConnectService怎么用?C# ClientProcessor.ConnectService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClientProcessor
的用法示例。
在下文中一共展示了ClientProcessor.ConnectService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IWMainForm_Shown
//.........这里部分代码省略.........
navigationBar.Visible = true;
miAddTask.Enabled = SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Add);
miDeleteTask.Enabled = SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Delete);
miChangeTask.Enabled = SharedAppData.IsFlagsSet(ObjectAccessId, new[] {RightsFlags.Change, RightsFlags.View});
RefreshCurrentPage(false);
#endregion
#region Notifier service connection
_clientProcessor = new ClientProcessor();
_clientProcessor.OnServerOnline += (message, icon) => Extensions.RunActionInGUIThread(() =>
{
btNotifyDisconnect.Enabled = true;
btNotifyConnect.Enabled = false;
notifyIcon.ShowBalloonTip(5, @"Уведомление", message, icon);
},_uiScheduler);
_clientProcessor.OnMessageShow += (message, icon) => Extensions.RunActionInGUIThread(() =>
{
if (icon == ToolTipIcon.Error)
{
btNotifyDisconnect.Enabled = false;
btNotifyConnect.Enabled = true;
notifyIcon.ShowBalloonTip(10, @"Ошибка", message, icon);
}
else
{
notifyIcon.ShowBalloonTip(5, @"Уведомление", message, icon);
}
}, _uiScheduler);
_clientProcessor.OnServerOffline += (message, icon) => Extensions.RunActionInGUIThread(() =>
{
btNotifyDisconnect.Enabled = false;
btNotifyConnect.Enabled = true;
notifyIcon.ShowBalloonTip(5, @"Уведомление", message, icon);
},_uiScheduler);
_clientProcessor.OnReceiveNotifyApp += (data) => Extensions.RunActionInGUIThread(() =>
{
Guid eventId;
NotifyData notifyData = new NotifyData(data);
if (!Guid.TryParse(notifyData.Data, out eventId))
{
notifyIcon.ShowBalloonTip(5, @"Уведомление", @"Получены неправильные данные в обновлении!", ToolTipIcon.Error);
return;
}
if (!_dataHandlerLoading)
{
_dataHandlerLoading = true;
RefreshCurrentPage();
_dataHandlerLoading = false;
}
notifyIcon.ShowBalloonTip(5, @"Уведомление", @"Данные обновились!", ToolTipIcon.Info);
},_uiScheduler);
_clientProcessor.ConnectService();
#endregion
Task.Factory.StartNew(() =>
{
while (_chekingRun)
{
Thread.Sleep(10000);
if (btNotifyConnect.Enabled)
{
#region scrolling text :)
//if (!_startedScrolling)
//{
// _startedScrolling = true;
// RunActionInGUIThread(() => toolStripStatusLabel1.Text = NotConnectScrolltext);
// Task.Factory.StartNew(() =>
// {
// while (_startedScrolling)
// {
// var size = TextRenderer.MeasureText(toolStripStatusLabel1.Text, toolStripStatusLabel1.Font);
// string movingText = toolStripStatusLabel1.Text;
// if (size.Width+10 > toolStripStatusLabel1.Width)
// {
// movingText = movingText.Substring(1) + movingText[0];
// }
// else
// {
// movingText = " " + movingText;
// }
// RunActionInGUIThread(() => toolStripStatusLabel1.Text = movingText);
// Thread.Sleep(50);
// }
// });
//}
#endregion
Extensions.RunActionInGUIThread(() => notifyIcon.ShowBalloonTip(5, @"Уведомление", NotConnectScrolltext, ToolTipIcon.Warning),_uiScheduler);
}
else
{
//_startedScrolling = false;
//RunActionInGUIThread(() => toolStripStatusLabel1.Text = "");
}
}
}, TaskCreationOptions.LongRunning);
}
示例2: EventsMainForm_Shown
//.........这里部分代码省略.........
btNotifyConnect.Enabled = true;
notifyIcon.ShowBalloonTip(5, @"Уведомление", message, icon);
});
_clientProcessor.OnReceiveNotifyApp += (data) => RunActionInGUIThread(() =>
{
Guid eventId;
NotifyData notifyData = new NotifyData(data);
if (!Guid.TryParse(notifyData.Data, out eventId))
{
notifyIcon.ShowBalloonTip(5, @"Уведомление", @"Получены неправильные данные о обновленной заявке!", ToolTipIcon.Info);
return;
}
else
{
string message = "Данные о заявках обновились";
if (!_dataHandlerLoading)
{
_dataHandlerLoading = true;
RefreshCurrentPage();
_dataHandlerLoading = false;
}
var eventRefreshed = _dataContexts.AccEquipmentV2Entities.Events.SingleOrDefault(ev => ev.Id == eventId);
if (eventRefreshed != null)
{
int customerId = eventRefreshed.CustomerId.HasValue ? eventRefreshed.CustomerId.Value : 0;
int firmId = eventRefreshed.FirmId.HasValue ? eventRefreshed.FirmId.Value : 0;
string[] customerInfo = _dataContexts.GetCustomerDescription2(firmId, customerId);
message = string.Format("Заявка №{0} {1}, {2} - данные обновились!", eventRefreshed.Number, customerInfo[0], customerInfo[1]);
}
notifyIcon.ShowBalloonTip(5, @"Уведомление", message, ToolTipIcon.Error);
}
});
_clientProcessor.ConnectService();
#endregion
#region Visual elements init
Cursor = Cursors.WaitCursor;
Version version = ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion : System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
VersionLabel.Text = string.Format("Версия:{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
VersionLabel.Visible = true;
List<Department> deps = _dataContexts.AccEquipmentV2Entities.Departments.OrderBy(o => o.Description).ToList();
deps.Insert(0, new Department() {Id = Guid.Empty, Description = @"Все подразделения"});
deps.Insert(1, new Department() {Id = _customSelfGuidValue, Description = @"Только свои заявки"});
deps.Insert(2, new Department() {Id = _customSelfDepartmentGuidValue, Description = @"Только заявки своего департамента"});
cbDepartmentFilter.DataSource = deps;
List<KeyValuePair<string, int>> data1 = Enum.GetValues(typeof (EventState))
.Cast<EventState>()
.Select(c => new KeyValuePair<string, int>(c.GetAttributeValue<DescriptionAttribute, string>(x => x.Description), (int) c))
.Where(k => !string.IsNullOrEmpty(k.Key))
.ToList();
data1.Insert(0, new KeyValuePair<string, int>("Все заявки", -100));
cbEventStateFilter.DataSource = data1;
List<KeyValuePair<string, int>> data2 = Enum.GetValues(typeof (EventType))
.Cast<EventType>()
.Select(c => new KeyValuePair<string, int>(c.GetAttributeValue<DescriptionAttribute, string>(x => x.Description), (int) c))
.Where(k => !string.IsNullOrEmpty(k.Key))
.ToList();
data2.Insert(0, new KeyValuePair<string, int>("Все заявки", -100));
cbEventTypeFilter.DataSource = data2;
if (Settings.Default.SelectedDepartmentId != Guid.Empty)
{