Exemplo n.º 1
0
 public ListSelectionForm(MainDataContexts dataContext, Equipment managedEquipment, EquipmentListTypes formListType)
 {
     InitializeComponent();
     _dataContext = dataContext;
     _managedEquipment = managedEquipment;
     _formListType = formListType;
     cbLists.DataSource = _dataContext.AccEquipmentV2Entities.EquipmentLists.Where(l => l.ListState & l.ListType == (int)_formListType).OrderBy(o => o.Description).ThenByDescending(o=>o.CreationDate).ToList();
 }
Exemplo n.º 2
0
 public EquipmentManage(MainDataContexts dataContexts,Area area,Equipment manageEquipment, int buttonTag)
 {
     InitializeComponent();
     _dataContexts = dataContexts;
     _manageEquipment = manageEquipment;
     _buttonTag = buttonTag;
     _area = area;
     lbPorts.MultiSelect = true;
     lbCards.MultiSelect = true;
 }
Exemplo n.º 3
0
 public void SetEquipmentSelection(Equipment selectedEquipment)
 {
     if (selectedEquipment == null)
         return;
     if (!(gvProviderSetProviderSummary.DataSource is List<EquipmentGridViewItemGrouped>))
         return;
     DataGridViewCustomed mainGrid = null;
     if (gvProviderSetProviderSummary.DataSource != null)
     {
         var fg = ((List<EquipmentGridViewItemGrouped>)gvProviderSetProviderSummary.DataSource).Where(item => item.GroupedEquipemnts.Any(wi => wi.EquipmentId == selectedEquipment.EquipmentId)).ToList();
         if (fg.Count > 0)
             mainGrid = gvProviderSetProviderSummary;
     }
     if (gvProviderSetClientSummary.DataSource != null)
     {
         var sg = ((List<EquipmentGridViewItemGrouped>)gvProviderSetClientSummary.DataSource).Where(item => item.GroupedEquipemnts.Any(wi => wi.EquipmentId == selectedEquipment.EquipmentId)).ToList();
         if (sg.Count > 0)
             mainGrid = gvProviderSetClientSummary;
     }
     if (gvClientSetProviderSummary.DataSource != null)
     {
         var tg = ((List<EquipmentGridViewItemGrouped>)gvClientSetProviderSummary.DataSource).Where(item => item.GroupedEquipemnts.Any(wi => wi.EquipmentId == selectedEquipment.EquipmentId)).ToList();
         if (tg.Count > 0)
             mainGrid = gvClientSetProviderSummary;
     }
     if (mainGrid == null)
     {
         MessageBox.Show(@"Оборудование " + selectedEquipment.Description + @" не найдено, возможно, удалено!", @"Информация", MessageBoxButtons.OK);
         return;
     }
     gvProviderSetClientSummary.ClearSelection();
     gvProviderSetClientDetail.ClearSelection();
     gvProviderSetProviderSummary.ClearSelection();
     gvProviderSetProviderDetail.ClearSelection();
     gvClientSetProviderSummary.ClearSelection();
     gvClientSetProviderDetail.ClearSelection();
     var searchedRow = mainGrid.Rows.Cast<DataGridViewRow>().FirstOrDefault(row =>
     {
         var rowDesc = ((EquipmentGridViewItemGrouped)row.DataBoundItem).Description;
         return rowDesc == selectedEquipment.Description;
     });
     if (searchedRow != null)
     {
         searchedRow.Selected = true;
         mainGrid.CurrentCell = mainGrid.Rows[searchedRow.Index].Cells[0];
         mainGrid.BlinkRow(searchedRow);
     }
     var searchedDependRow = mainGrid.DependentGridView.Rows.Cast<DataGridViewRow>().FirstOrDefault(row =>
     {
         var rowDesc = (Equipment)((EquipmentGridViewItemDetailed)row.DataBoundItem).Tag;
         return rowDesc.SideLinkId == selectedEquipment.SideLinkId;
     });
     if (searchedDependRow != null)
     {
         searchedDependRow.Selected = true;
         mainGrid.DependentGridView.CurrentCell = mainGrid.DependentGridView.Rows[searchedDependRow.Index].Cells[0];
         mainGrid.DependentGridView.BlinkRow(searchedDependRow);
     }
 }
Exemplo n.º 4
0
 private string GetSideData(Equipment equipment)
 {
     if (equipment.PlaceType == (int) EquipmentSide.ProviderArea)
     {
         return _loadedArea.Description;
     }
     else
     {
         return _dataContexts.GetSideLinkDescription2(equipment.SideLink, addressOnly: true);
     }
 }
Exemplo n.º 5
0
 private void cmiCardAdd_Click(object sender, EventArgs e)
 {
     InputDualLine input = new InputDualLine {Label1 = {Text = @"Название линейной карты"}, Label2 = {Text = @"Серийный номер"}, Text = @"Добавление новой карты"};
     if (input.ShowDialog(this) == DialogResult.OK)
     {
         Equipment newCard=new Equipment
         {
             EquipmentId = Guid.NewGuid(),
             Description = !string.IsNullOrEmpty(input.InputLine1.Text) ? input.InputLine1.Text : @"Новое название",
             SerialNumber = input.InputLine2.Text,
             Area = _area,
             ParentEquipment = _clonedEquipment
         };
         _clonedEquipment.ChildEquipments.Add(newCard);
         lbCards.DataSource = _clonedEquipment.ChildEquipments.OrderBy(equ => equ.Description).ToList();
     }
 }
Exemplo n.º 6
0
 private bool IsDifferentPorts(Equipment left, Equipment right)
 {
     if (left.EquipmentPorts.Count != right.EquipmentPorts.Count)
         return true;
     foreach (EquipmentPort leftPort in left.EquipmentPorts)
     {
         var rightPort = right.EquipmentPorts.FirstOrDefault(port => port.PortId == leftPort.PortId);
         if (rightPort == null) return true;
         if (IsDifferentPort(leftPort, rightPort)) return true;
     }
     return false;
 }
Exemplo n.º 7
0
        private void EquipmentManage_Shown(object sender, EventArgs e)
        {
            EquipmentOwner owner;
            EquipmentSide side;
            switch (_buttonTag)
            {
                case 1: case 2: case 3:
                    owner = EquipmentOwner.Provider;
                    side = EquipmentSide.ProviderArea;
                    break;
                case 11: case 12: case 13:
                    owner = EquipmentOwner.Provider;
                    side = EquipmentSide.ClientArea;
                    break;
                case 21: case 22: case 23:
                    owner = EquipmentOwner.Client;
                    side = EquipmentSide.ProviderArea;
                    break;
                default:
                    throw new Exception("Unknown tag in button, invalid form");
            }
            SuspendLayout();
            cbOwner.DataSource = _owners;
            cbOwner.SelectedIndex = (int)owner;
            cbSide.DataSource = _placesAll;
            cbSide.SelectedIndex = (int) side;
            if (_manageEquipment == null)
            {
                MiniSplash splash = new MiniSplash
                {
                    TaskName = "LoadTemplateEquipments",
                    Text = "",
                    Working = (worker) =>
                    {
                        try
                        {
                            if (worker == null) throw new Exception("Invalid background worker process");
                            worker.ReportProgress(0, "Загрузка шаблонов");
                            _templates = _dataContexts.AccEquipmentV2Entities.EquipmentTemplates.Where(template => template.ParentElementTemplate == null).Include(templ => templ.ChildElementTemplates).OrderBy(item => item.Description).ToList();
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                };
                splash.ShowDialog(this);
                Text = @"Добавление оборудования";
                _clonedEquipment = new Equipment { EquipmentId = Guid.NewGuid(), Area = _area, OwnerType = (int)owner ,PlaceType = (int)side};
                TemplateSelectionControl control=new TemplateSelectionControl(_templates) { BorderStyle = BorderStyle.None };
                control.templatesTree.MouseClick += (_, __) =>
                {
                    NodeControlInfo info = control.templatesTree.GetNodeControlInfoAt(__.Location);
                    if (info.Node == null) return;
                    var data = info.Node.Tag as TemplateTreeItem;
                    if (data == null) return;
                    if (!data.IsLeaf) return;
                    var newTemplate=data.Tag as EquipmentTemplate;
                    if (newTemplate == null) return;

                    if (_selectedTemplate!=null && _selectedTemplate.ElementId == newTemplate.ElementId) return;
                    _selectedTemplate = data.Tag as EquipmentTemplate;
                    cbDescription.Text = _selectedTemplate.Description;
                    ChangeTemplate(_selectedTemplate);
                    cbDescription.HideDropDown();
                };
                cbDescription.DropDownControl = control;
                cbDescription.Visible = true;
                cbDescription.Text = string.Empty;
            }
            else
            {
                MiniSplash splash = new MiniSplash
                {
                    TaskName = "LoadTemplateEquipments",
                    Text = "",
                    Working = (worker) =>
                    {
                        try
                        {
                            if (worker == null) throw new Exception("Invalid background worker process");
                            worker.ReportProgress(0, "Загрузка данных оборудования");
                            _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = false;
                            _clonedEquipment =
                                _dataContexts.AccEquipmentV2Entities.Equipments.Where(equ => equ.EquipmentId == _manageEquipment.EquipmentId)
                                    .Include(equ => equ.ChildEquipments)
                                    .Include(equ => equ.EquipmentPorts)
                                    .Include(equ => equ.EquipmentPorts.Select(port => port.PortType))
                                    .Include(equ => equ.EquipmentPorts.Select(port => port.SideLink))
                                    .Include(equ => equ.SideLink)
                                    .Include(equ => equ.SideLink.CustomerSide)
                                    .AsNoTracking()
                                    .First();
                            _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = true;
                            if (_clonedEquipment == null)
                                throw new Exception("Invalid detach entry from data context");
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                };
                splash.ShowDialog(this);
                Text = @"Изменение оборудования " +
                       string.Format("{0} {1}", _clonedEquipment.Description, _clonedEquipment.NetworkDescription != string.Empty ? "[" + _clonedEquipment.NetworkDescription + "]" : "");
                tbDescription.Text = _clonedEquipment.Description;
                tbDescription.Visible = true;
                tbNetworkDescription.Text = _clonedEquipment.NetworkDescription;
                tbComments.Text = _clonedEquipment.Comments;
                tbSerialNumber.Text = _clonedEquipment.SerialNumber;
                lbCards.DataSource = _clonedEquipment.ChildEquipments.OrderBy(equ => equ.Description).ToList();
                lbPorts.DataSource = _clonedEquipment.EquipmentPorts.OrderBy(portn => portn, new PortNameComparer()).ThenBy(port => port.PortType.Description).ToList();
            }
            if (_clonedEquipment.SideLink != null)
                tbCustomer.Text = _dataContexts.GetSideLinkDescription2(_clonedEquipment.SideLink);
            ResumeLayout();
        }
Exemplo n.º 8
0
 private bool IsDifferentEquipment(Equipment left, Equipment right,out string diffString)
 {
     diffString = string.Empty;
     if (left==null || right==null)
         return true;
     if (left.Description != right.Description)
     {
         diffString += "Description: " + left.Description + " -> " + right.Description;
         return true;
     }
     if (left.SerialNumber != right.SerialNumber)
     {
         diffString += " SerialNumber: " + left.SerialNumber + " -> " + right.SerialNumber;
         return true;
     }
     if (left.NetworkDescription != right.NetworkDescription)
     {
         diffString += " NetworkDescription: " + left.NetworkDescription + " -> " + right.NetworkDescription;
         return true;
     }
     if (!left.OwnerType.Equals(right.OwnerType))
     {
         diffString += " OwnerType: " + left.OwnerType + " -> " + right.OwnerType;
         return true;
     }
     if (!left.PlaceType.Equals(right.PlaceType))
     {
         diffString += " PlaceType: " + left.PlaceType + " -> " + right.PlaceType;
         return true;
     }
     if (left.Comments != right.Comments)
         return true;
     return false;
 }
Exemplo n.º 9
0
 private bool IsDifferentSideLink(Equipment left, Equipment right)
 {
     if (left.SideLinkId != right.SideLinkId)
         return true;
     if (left.SideLinkId == null & right.SideLinkId == null)
         return false;
     switch (left.SideLink.LinkType)
     {
         case (int)SideLinkType.toEquipment:
             if (left.SideLink.LinkEquipmentId != right.SideLink.LinkEquipmentId)
                 return true;
             break;
         case (int)SideLinkType.toEquipmentPort:
             if (left.SideLink.LinkEquipmentPortId != right.SideLink.LinkEquipmentPortId)
                 return true;
             break;
         case (int)SideLinkType.toCustomData:
             if (left.SideLink.CustomData != right.SideLink.CustomData)
                 return true;
             break;
         case (int)SideLinkType.toCustomerSide:
             if (left.SideLink.LinkCustomerSideId!=right.SideLink.LinkCustomerSideId)
                 return true;
             break;
         default:
             return false;
     }
     return false;
 }
Exemplo n.º 10
0
 private bool IsDifferentChildEquipments(Equipment left, Equipment right)
 {
     if (left.ChildEquipments.Count != right.ChildEquipments.Count)
         return true;
     foreach (Equipment leftEquipment in left.ChildEquipments)
     {
         var rightEquipment = right.ChildEquipments.FirstOrDefault(eq => eq.EquipmentId == leftEquipment.EquipmentId);
         if (rightEquipment == null) return true;
         string diff;
         if (IsDifferentEquipment(leftEquipment, rightEquipment, out diff))
         {
             SharedAppData.HistoryStore.AddHistoryEvent("Change Child Equipment " + _manageEquipment.Description, diff);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 11
0
 public void SetEquipmentSelection(Equipment selectedEquipment)
 {
     var treeAreaItem = areasTree.AllNodes.SingleOrDefault(node => ((AreaTreeItem) node.Tag).Tag is Area & ((AreaTreeItem) node.Tag).Id == selectedEquipment.ParentAreaId);
     if (treeAreaItem != null)
     {
         areasTree.SelectedNode = treeAreaItem;
         areaDetails.SetEquipmentSelection(selectedEquipment);
     }
 }