private Event LoadEventFromDb(Event sourceEvent) { //_dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = false; //_dataContexts.AccEquipmentV2Entities.Configuration.LazyLoadingEnabled = false; var loadedEvents = _dataContexts.AccEquipmentV2Entities.Events.Where(ev => ev.Id == sourceEvent.Id) .Include(i => i.Access_Users) .Include(i => i.Access_Users.Department) .Include(i => i.Access_Users1) .Include(i => i.Access_Users1.Department) .Include(i => i.Access_Users2) .Include(i => i.Access_Users2.Department) .Include(i => i.CustomerSide) .Include(i => i.EquipmentPort) .Include(i => i.EquipmentPort.SideLink) .Include(i => i.EquipmentPort.SideLink.EquipmentPort) .Include(i => i.EquipmentPort.PortType) .Include(i => i.EquipmentPort.Equipment) .Include(i => i.EquipmentPort.Equipment.Area) .Include(i => i.EventComments) .Include(i => i.EventComments.Select(c => c.Access_Users)) .Include(i => i.EventComments.Select(c => c.Access_Users.Department)) .Include(i => i.EventStatusHistories) .Include(i => i.EventStatusHistories.Select(h => h.Access_Users)) .Include(i => i.EventStatusHistories.Select(h => h.Access_Users.Department)); _dataContexts.AccEquipmentV2Entities.EntityObjectContext.Refresh(RefreshMode.StoreWins, loadedEvents); Event loadedEvent = loadedEvents.AsNoTracking().ToList().First(); //_dataContexts.AccEquipmentV2Entities.Configuration.LazyLoadingEnabled = true; //_dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = true; return loadedEvent; }
public EventEditorForm(MainDataContexts dataContexts, Event managedEvent, RequestAction requestAction, ENotifySenderManager manager) { InitializeComponent(); _dataContexts = dataContexts; _managedEvent = managedEvent; _requestAction = requestAction; _manager = manager; _indexValues = new BindingList<IndexValues>(); _receiversLists = new List<NotifyReceiversList>(); _contacts = new List<string>(); }
public void SendNotify(Event notifiedEvent, RequestAction action,NotifyReceiversList receiversList,object tag=null) { MiniSplash_TF sp0 = new MiniSplash_TF(Properties.Resources.load4) {Text=@"Отправка сообщения" , StatusText = @"Отправка почтового уведомления"}; sp0.WorkingFunction = () => { ClearHeaders(); List<string> fullReceivers = new List<string>(); List<string> shortReceivers = new List<string>(); if (receiversList != null) { List<NotifyReceiver> receivers = receiversList.NotifyReceivers.ToList(); receivers.ForEach(r => { if (r.Required) r.Selected = true; }); var selectedReceivers = receivers.Where(r => r.Selected).ToList(); if (selectedReceivers.Count == 0) return; fullReceivers = selectedReceivers.Where(r => !r.IsSms).Select(r => r.Receiver).ToList(); shortReceivers = selectedReceivers.Where(r => r.IsSms).Select(r => r.Receiver).ToList(); } else { if (tag != null) { var data = tag as string[]; if (data != null) { fullReceivers.Add(data[0]); if (data.Length == 2) shortReceivers.Add(data[1]); } } } string shortDepartmentId = string.Empty; if (notifiedEvent.Access_Users.Department != null) if (notifiedEvent.Access_Users.Department.ShortId != string.Empty) shortDepartmentId = notifiedEvent.Access_Users.Department.ShortId.Trim() + ";"; string eventNumber = @"#" + notifiedEvent.Number; string eventTypeDescription = ((EventType) notifiedEvent.Type).GetAttributeValue<DescriptionAttribute, string>(x => x.Description); string eventIndex = notifiedEvent.EventIndex.ToString(); int customerId = notifiedEvent.CustomerId.HasValue ? notifiedEvent.CustomerId.Value : 0; int firmId = notifiedEvent.FirmId.HasValue ? notifiedEvent.FirmId.Value : 0; string[] customerInfo = _dataContexts.GetCustomerDescription2(firmId, customerId); string eventCustomerFull = string.Join(",", customerInfo); string fullEventText = string.Empty; string shortEventText = string.Empty; string fullEmailSubject = string.Empty; string shortEmailSubject = string.Empty; string eventCustomerSide = string.Empty; string eventCustomerPort = string.Empty; string eventCustomerPortShort = string.Empty; if (notifiedEvent.CustomerSide != null) { eventCustomerSide = notifiedEvent.CustomerSide.Description; if (notifiedEvent.EquipmentPort != null) { eventCustomerPort = GetPortFullDescription(notifiedEvent.EquipmentPort); eventCustomerPortShort = GetPortShortDescription(notifiedEvent.EquipmentPort); } } else { if (notifiedEvent.EquipmentPort != null) { if (notifiedEvent.EquipmentPort.SideLink.LinkType == (int) SideLinkType.toEquipmentPort) eventCustomerPort = GetPortFullDescription(notifiedEvent.EquipmentPort.SideLink.EquipmentPort); eventCustomerSide = notifiedEvent.EquipmentPort.Equipment.Area.Description; eventCustomerPortShort = GetPortShortDescription(notifiedEvent.EquipmentPort); } } string eventCustomerContact = notifiedEvent.CustomerInfo; string eventDescription = notifiedEvent.Description; switch (action) { case RequestAction.Transfer: { var user = notifiedEvent.Access_Users; if (user == null) return; fullEmailSubject = @"Номер заявки: " + eventNumber + @" изменена"; fullEventText = @"Заявка: " + eventNumber + " передана в департамент [" + user.Department.Description + "]"; //+ @"Тип заявки: " + eventTypeDescription + Environment.NewLine //+ @"Вес заявки: " + eventIndex + Environment.NewLine //+ @"Абонент: " + eventCustomerFull + Environment.NewLine //+ (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") //+ (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") //+ @"Контакт абонента: " + eventCustomerContact + Environment.NewLine //+ @"Текст заявки: " + eventDescription; _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@transfer.event>")); break; } case RequestAction.Renew: case RequestAction.New: { fullEventText = @"Номер заявки: " + eventNumber + @" Новая заявка" + Environment.NewLine + @"Тип заявки: " + eventTypeDescription + Environment.NewLine + @"Вес заявки: " + eventIndex + Environment.NewLine + @"Абонент: " + eventCustomerFull + Environment.NewLine + (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") + (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") + @"Контакт абонента: " + eventCustomerContact + Environment.NewLine + @"Текст заявки: " + eventDescription; fullEmailSubject = eventNumber + ", " + eventCustomerFull + (!string.IsNullOrEmpty(eventCustomerSide) ? ", " + eventCustomerSide : ""); shortEventText = eventNumber + ";NEW;" + shortDepartmentId + customerId + ";" + eventIndex + ";" + eventCustomerSide + ";" + eventDescription + ";" + customerInfo.Last(); shortEmailSubject = ""; _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@open.event>")); break; } case RequestAction.Edit: break; case RequestAction.Remedy: { string remedyPerson = string.Empty; string remedyData = string.Empty; if (tag != null) { var data = tag as string[]; if (data != null) { remedyPerson = data[0]; remedyData = data[1]; } } fullEventText = @"Номер заявки: " + eventNumber + @" Изменено состояние" + Environment.NewLine + @"Тип заявки: " + eventTypeDescription + Environment.NewLine + @"Вес заявки: " + eventIndex + Environment.NewLine + @"Устранил: " + remedyPerson + @" Выполнены работы: " + remedyData + Environment.NewLine + @"Абонент: " + eventCustomerFull + Environment.NewLine + (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") + (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") + @"Текст заявки: " + eventDescription; fullEmailSubject = eventNumber + ", " + eventCustomerFull + (!string.IsNullOrEmpty(eventCustomerSide) ? ", " + eventCustomerSide : ""); shortEventText = eventNumber + ";REMEDY;" + shortDepartmentId + customerId + ";" + eventIndex + ";" + (eventCustomerSide) + ";" + remedyPerson + ";" + remedyData + ";" + eventDescription + ";" + customerInfo.Last(); shortEmailSubject = ""; _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@remedy.event>")); _headers.Add(new KeyValuePair<string, string>("References", "<" + notifiedEvent.Id.ToString() + "@open.event>")); _headers.Add(new KeyValuePair<string, string>("In-Reply-To", "<" + notifiedEvent.Id.ToString() + "@open.event>")); break; } case RequestAction.Close: { string closedPerson = notifiedEvent.Access_Users2 != null ? notifiedEvent.Access_Users2.Description : string.Empty; string checkPerson = notifiedEvent.Access_Users1 != null ? notifiedEvent.Access_Users1.Description : string.Empty; string closedDate = notifiedEvent.CloseDate.HasValue ? notifiedEvent.CloseDate.Value.ToShortDateString() : string.Empty; string closedFixer = notifiedEvent.ClosePerson; string closedCheckDate = notifiedEvent.CheckDate.HasValue ? notifiedEvent.CheckDate.Value.ToShortDateString() : string.Empty; fullEmailSubject = eventNumber + ", " + eventCustomerFull + (!string.IsNullOrEmpty(eventCustomerSide) ? ", " + eventCustomerSide : ""); fullEventText = @"Номер заявки: " + eventNumber + @" Закрытие заявки" + Environment.NewLine + @"Тип заявки: " + eventTypeDescription + Environment.NewLine + @"Абонент: " + eventCustomerFull + Environment.NewLine + (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") + (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") + @"Закрыл: " + closedPerson + " " + closedDate + Environment.NewLine + @"Проверил: " + checkPerson + " " + closedDate + Environment.NewLine + @"Исполнитель: " + closedFixer + " " + closedCheckDate + Environment.NewLine + @"Отчет: " + notifiedEvent.CloseInfo; shortEventText = eventNumber + ";CLOSE;" + shortDepartmentId + customerId + ";" + eventIndex + ";" + eventCustomerSide + ";" + closedPerson + ";" + eventDescription + ";" + customerInfo.Last(); _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@close.event>")); _headers.Add(new KeyValuePair<string, string>("References", "<" + notifiedEvent.Id.ToString() + "@open.event>")); _headers.Add(new KeyValuePair<string, string>("In-Reply-To", "<" + notifiedEvent.Id.ToString() + "@open.event>")); break; } case RequestAction.Unknown: break; default: throw new ArgumentOutOfRangeException("action"); } if (fullReceivers.Any()) { try { if (!string.IsNullOrEmpty(fullEventText)) { string emailFrom = @"*****@*****.**"; if (SharedAppData.LoggedUser.Email != null && !string.IsNullOrEmpty(SharedAppData.LoggedUser.Email)) { emailFrom = SharedAppData.LoggedUser.Email; } SendEmail(_headers, fullReceivers, emailFrom, fullEmailSubject, fullEventText); } } catch (Exception) { throw; } } if (shortReceivers.Any()) { try { if (!string.IsNullOrEmpty(shortEventText)) { shortEventText = Translator.ToTranslite(shortEventText); shortReceivers.ForEach(receiver => { MailMessage mailMessage = new MailMessage {From = new MailAddress("*****@*****.**"), Subject = shortEmailSubject, Body = shortEventText}; mailMessage.Headers.Add("Return-Path", "*****@*****.**"); mailMessage.Headers.Add("X-Original-To", "*****@*****.**"); mailMessage.Headers.Add("X-Mailer", "event registrator"); mailMessage.ReplyToList.Add("*****@*****.**"); mailMessage.To.Add(receiver); SmtpClient client = new SmtpClient("212.90.160.3") {EnableSsl = false, DeliveryMethod = SmtpDeliveryMethod.Network}; client.Send(mailMessage); mailMessage.Dispose(); }); } } catch (Exception) { throw; } } }; sp0.ShowDialog(_parentForm); }
private void EventEditor_Shown(object sender, EventArgs e) { _uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Top = 1; if (Screen.FromControl(Owner).Bounds.Height <= 768) { tlMain.RowStyles[3].Height = tlMain.RowStyles[3].Height - 40; } #region load data MiniSplash_TF sp0 = new MiniSplash_TF(Resources.load4) {Text = @"Загрузка данных редактора"}; sp0.WorkingFunction = () => { sp0.StatusText = "Загрузка данных"; _contacts = _dataContexts.AccEquipmentV2Entities.Events .Where(c => !c.CustomerInfo.Equals(string.Empty) & c.CustomerInfo != null) .GroupBy(g => g.CustomerInfo) .Select(g => g.Key.Trim()).ToList(); _dataContexts.AccEquipmentV2Entities.Configuration.LazyLoadingEnabled = false; _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = false; _receiversLists = _dataContexts.AccEquipmentV2Entities.NotifyReceiversLists .Include(i=>i.NotifyReceivers) .OrderBy(o => o.Description) .AsNoTracking() .ToList(); _dataContexts.AccEquipmentV2Entities.Configuration.LazyLoadingEnabled = true; _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = true; switch (_requestAction) { case RequestAction.New: { int number = _dataContexts.AccEquipmentV2Entities.Events.Count() + 5000; _clonedEvent = new Event() { CreationDate = DateTime.Now, CreationUserId = SharedAppData.LoggedUser.Id, Access_Users = SharedAppData.LoggedUser, Id = Guid.NewGuid(), State = (int) EventState.OpenedEvent, Type = (int) EventType.StandartEvent, Number = number, EventIndex = 0 }; _clonedEvent.EventStatusHistories.Add(new EventStatusHistory() { ChangedDate = DateTime.Now, ChangedInfo = @"Создание заявки", ChangedUserId = SharedAppData.LoggedUser.Id, Access_Users = SharedAppData.LoggedUser, Id = Guid.NewGuid(), NewState = (int) EventState.OpenedEvent, NewType = (int) EventType.StandartEvent, OldState = -1, OldType = -1, Event = _clonedEvent }); break; } case RequestAction.Edit: _clonedEvent = LoadEventFromDb(_managedEvent); break; case RequestAction.Close: _clonedEvent = LoadEventFromDb(_managedEvent); //_clonedEvent.CheckUserId = SharedAppData.LoggedUser.Id; _clonedEvent.CheckUserId = _managedEvent.CreationUserId; _clonedEvent.EventStatusHistories.Add(new EventStatusHistory() { ChangedDate = DateTime.Now, ChangedInfo = @"Закрытие заявки", ChangedUserId = SharedAppData.LoggedUser.Id, Access_Users = SharedAppData.LoggedUser, Id = Guid.NewGuid(), OldState = _clonedEvent.State, NewState = (int) EventState.ClosedEvent, OldType = _clonedEvent.Type, NewType = _clonedEvent.Type, Event = _clonedEvent, }); break; case RequestAction.Renew: { int number = _dataContexts.AccEquipmentV2Entities.Events.Count() + 5000; _clonedEvent = new Event() { CreationDate = DateTime.Now, CreationUserId = SharedAppData.LoggedUser.Id, Access_Users = SharedAppData.LoggedUser, Id = Guid.NewGuid(), State = (int) EventState.OpenedEvent, Type = _managedEvent.Type == (int) EventType.RemedyEvent ? (int) EventType.TroubleEvent : _managedEvent.Type, Number = number, CustomerId = _managedEvent.CustomerId, FirmId = _managedEvent.FirmId, CustomerInfo = _managedEvent.CustomerInfo, Description = _managedEvent.Description, CustomerSideId = _managedEvent.CustomerSideId, EquipmentPortId = _managedEvent.EquipmentPortId, EventIndex = _managedEvent.EventIndex }; _clonedEvent.EventStatusHistories.Add(new EventStatusHistory() { ChangedDate = DateTime.Now, ChangedInfo = @"Повторение заявки №" + _managedEvent.Number, ChangedUserId = SharedAppData.LoggedUser.Id, Access_Users = SharedAppData.LoggedUser, Id = Guid.NewGuid(), NewState = (int) EventState.OpenedEvent, NewType = _managedEvent.Type, OldState = _managedEvent.State, OldType = _managedEvent.Type, EventId = _clonedEvent.Id, Event = _clonedEvent, }); foreach (var eventComment in _managedEvent.EventComments) { _clonedEvent.EventComments.Add(new EventComment() { Access_Users = eventComment.Access_Users, UserId = eventComment.Access_Users.Id, CreationDate = eventComment.CreationDate, Description = eventComment.Description, Id = Guid.NewGuid(), Event = _clonedEvent, EventId = _clonedEvent.Id }); } _dataContexts.AccEquipmentV2Entities.Events.Attach(_clonedEvent); _dataContexts.AccEquipmentV2Entities.Entry(_clonedEvent).Reference(ee => ee.CustomerSide).Load(); _dataContexts.AccEquipmentV2Entities.Entry(_clonedEvent).Reference(ee => ee.EquipmentPort).Load(); _dataContexts.AccEquipmentV2Entities.EventIndexValues.Where(index => index.OvnerEventid == _managedEvent.Id) .ToList() .ForEach(index => _indexValues.Add(new IndexValues() { Description = index.Description, Value = index.Value, SortIndex = index.SortIndex })); break; } default: throw new ArgumentOutOfRangeException(); } if (!_indexValues.Any()) _dataContexts.AccEquipmentV2Entities.EventIndexValues.Where(index => index.OvnerEventid == _clonedEvent.Id) .ToList() .ForEach(index => _indexValues.Add(new IndexValues() {SortIndex = index.SortIndex, Description = index.Description, Value = index.Value})); }; sp0.ShowDialog(this); #endregion #region Init visual elements //TODO:Apply right cbReceiversLists.DataSource = _receiversLists; cbReceiversLists.SelectedValue = Properties.Settings.Default.LastReceiversListId != Guid.Empty ? Properties.Settings.Default.LastReceiversListId : ENotifyReceivers.StandartGuid; tbNumber.Text = _clonedEvent.Number.ToString(); nbCustomerIndex.Text = _clonedEvent.EventIndex.HasValue ? _clonedEvent.EventIndex.Value.ToString() : "0"; tbCreationUser.Text = _clonedEvent.Access_Users.Description + @" [" + (_clonedEvent.Access_Users.Department != null ? _clonedEvent.Access_Users.Department.Description : "Неизвестное подразделение") + @"]"; tbCreationDate.Text = _clonedEvent.CreationDate.ToString("MM/dd/yyyy H:mm"); tbCustomer.Text = _clonedEvent.FirmId.HasValue & _clonedEvent.CustomerId.HasValue ? _dataContexts.GetCustomerDescription(_clonedEvent.FirmId.Value, _clonedEvent.CustomerId.Value) : string.Empty; if (_clonedEvent.CustomerSide != null) { tbCustomerSide.Text = _clonedEvent.CustomerSide.Description; } else { if (_clonedEvent.EquipmentPort != null) { tbCustomerSide.Text = _clonedEvent.EquipmentPort.Equipment.Area.Description; } } tbInfo.Text = _clonedEvent.Description; tbCustomerInfo.Text = _clonedEvent.CustomerInfo; var port = _clonedEvent.EquipmentPort; if (port != null) { if (port.SideLink!=null && port.SideLink.LinkType == (int)SideLinkType.toEquipmentPort) tbCustomerPort.Text = GetPortFullDescription(port.SideLink.EquipmentPort); else tbCustomerPort.Text = GetPortFullDescription(port); } else tbCustomerPort.Text = string.Empty; cbType.SelectedIndexChanged -= cbType_SelectedIndexChanged; cbType.DataSource = Enum.GetValues(typeof (EventType)) .Cast<EventType>() .Select(c => new KeyValuePair<string, EventType>(c.GetAttributeValue<DescriptionAttribute, string>(x => x.Description), c)) .Where(k => k.Value < EventType.ComplexRemedyTrouble) .ToList(); cbType.SelectedValue = (EventType) _clonedEvent.Type; cbType.SelectedIndexChanged += cbType_SelectedIndexChanged; _firstType = (EventType) _clonedEvent.Type; cbState.DataSource = Enum.GetValues(typeof (EventState)) .Cast<EventState>() .Select(c => new KeyValuePair<string, EventState>(c.GetAttributeValue<DescriptionAttribute, string>(x => x.Description), c)) .Where(k => !string.IsNullOrEmpty(k.Key)) .ToList(); cbState.SelectedValue = (EventState) _clonedEvent.State; cbSendENotify.Checked = (EventType) cbType.SelectedValue != EventType.StandartEvent & (EventType) cbType.SelectedValue != EventType.RemedyEvent; switch (_requestAction) { case RequestAction.New: Text = @"Добавление новой заявки"; cbType.SelectedValue = EventType.TroubleEvent; break; case RequestAction.Edit: { Text = @"Просмотр заявки"; bool isOwner = SharedAppData.LoggedUser.Id == _clonedEvent.CreationUserId; tbInfo.Enabled = isOwner; if (_clonedEvent.State == (int) EventState.ClosedEvent) { if (_clonedEvent.Access_Users1 == null) throw new Exception("Invalid data in closed event!!!"); if (!_clonedEvent.CloseDate.HasValue & !_clonedEvent.CheckDate.HasValue) throw new Exception("Invalid data in closed event!!!"); btSelectCustomerSide.Enabled = btSelectCustomer.Enabled = btSelectCustomerPort.Enabled = false; gbEventCloseInfo.Visible = true; dpClosedDate.Value = _clonedEvent.CloseDate ?? DateTime.Now; dpCheckedDate.Value = _clonedEvent.CheckDate ?? DateTime.Now; tbClosePerson.Text = _clonedEvent.ClosePerson; tbClosePerson.Enabled = false; //tbCheckedUser.Text = _clonedEvent.Access_Users1.Description + @" [" + // (_clonedEvent.Access_Users1.Department != null ? _clonedEvent.Access_Users1.Department.Description : "Неизвестное подразделение") + @"]"; tbCheckedUser.SelectedIndexChanged -= tbCheckedUser_SelectedIndexChanged; tbCheckedUser.DataSource = _dataContexts.AccEquipmentV2Entities.Access_Users.OrderBy(o => o.Description).ToList(); tbCheckedUser.SelectedIndexChanged += tbCheckedUser_SelectedIndexChanged; tbCheckedUser.SelectedValue = _clonedEvent.Access_Users1.Id; tbCheckedUser.Enabled = false; tbClosedInfo.Text = _clonedEvent.CloseInfo; this.FilterControls(f => f is TextBox).ForEach(c => { TextBox box = (c as TextBox); if (box != null) box.ReadOnly = true; }); btAddComment.Enabled = btSave.Enabled = cbType.Enabled = dpClosedDate.Enabled = dpCheckedDate.Enabled = nbCustomerIndex.Enabled = cbSendENotify.Enabled = false; } else { btSelectCustomerSide.Enabled = _clonedEvent.CustomerSide != null; btSelectCustomer.Enabled = _clonedEvent.FirmId.HasValue & _clonedEvent.CustomerId.HasValue; btSelectCustomerPort.Enabled = _clonedEvent.EquipmentPort != null; } break; } case RequestAction.Close: { Text = @"Закрытие заявки"; tbClosePerson.DataSource = _dataContexts.AccEquipmentV2Entities.Events.Where(ev => ev.ClosePerson != string.Empty & ev.ClosePerson != null).GroupBy(grp => grp.ClosePerson).Select(grp => grp.Key).ToList(); tbClosePerson.SelectedIndex = -1; gbEventCloseInfo.Visible = true; btSelectCustomerSide.Enabled = btSelectCustomer.Enabled = btSelectCustomerPort.Enabled = false; cbState.SelectedValue = EventState.ClosedEvent; cbType.Enabled = false; nbCustomerIndex.ReadOnly = true; //tbCustomerInfo.ReadOnly = true; //tbCheckedUser.Text = _clonedEvent.Access_Users1.Description + @" [" + // (_clonedEvent.Access_Users1.Department != null ? _clonedEvent.Access_Users1.Department.Description : "Неизвестное подразделение") + @"]"; tbCheckedUser.SelectedIndexChanged -= tbCheckedUser_SelectedIndexChanged; tbCheckedUser.DataSource = _dataContexts.AccEquipmentV2Entities.Access_Users.OrderBy(o => o.Description).ToList(); tbCheckedUser.SelectedIndexChanged += tbCheckedUser_SelectedIndexChanged; tbCheckedUser.SelectedValue = SharedAppData.LoggedUser.Id; tbInfo.ReadOnly = true; break; } case RequestAction.Renew: Text = @"Возобновление заявки"; break; default: throw new ArgumentOutOfRangeException(); } gvEventHistory.DataSource = _clonedEvent.EventStatusHistories.OrderBy(o => o.ChangedDate).ToList(); gvEventComments.DataSource = _clonedEvent.EventComments.OrderBy(o => o.CreationDate).ToList(); ListBox boxl = new ListBox(); boxl.Items.AddRange(_contacts.ToArray<object>()); tbCustomerInfo.DropDownControl = boxl; #endregion }