Ejemplo n.º 1
0
 private void Form1_Shown(object sender, EventArgs e)
 {
     OpenFileDialog of = new OpenFileDialog() {Filter = @"Файлы приложений|*.exe"};
     if (of.ShowDialog(this) != DialogResult.OK) return;
     string assemblyName = of.FileName;
     bool loaded = false;
     MiniSplash splash=new MiniSplash()
     {
         TaskName = "LoadEquipmentDetails",
         Text = "",
         Working = (worker) =>
         {
             worker.ReportProgress(0,"Загрузка объектов с главного приложения");
             loaded = LoadMainAssemply(assemblyName);
             if (!loaded) return;
             worker.ReportProgress(0, "Загрузка данных");
             _dataContext = new MainDataContexts();
             Invoke(new Action(RefreshGrid));
         }
     };
     splash.ShowDialog(this);
     if (!loaded)
     {
         Application.Exit();
         Application.ExitThread();
         return;
     }
     Text = @"Менеджер пользователей. Приложение: " + AppId.Description;
 }
Ejemplo n.º 2
0
        private void EquipmentPortsSelection_Show(object sender, EventArgs e)
        {
            
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadSelection",
                Text = "",
                Working = (worker) =>
                {
                    try
                    {
                        if (worker == null) throw new Exception("Invalid background worker process");
                        worker.ReportProgress(0, "Загрузка данных");
                        _cachedAreas = _dataContext.Areas.Where(area => area.Equipments.Count>0).ToList();
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                }
            };
            splash.ShowDialog(this);
            gvAreas.DataSource = _cachedAreas.OrderBy(area=>area.Description).ToList();
        }
Ejemplo n.º 3
0
 private void EquipmentTypesSelection_Shown(object sender, EventArgs e)
 {
     gvEquipmentTypes.ReadOnly = false;
     dcEquipmentType.ReadOnly = true;
     dcCount.ReadOnly = true;
     dcSelectedEquipment.ReadOnly = false;
     MiniSplash splash = new MiniSplash
     {
         TaskName = "LoadReportEquipmentTypes",
         Text = "",
         Working = (worker) =>
         {
             try
             {
                 if (worker == null) throw new Exception("Invalid background worker process");
                 worker.ReportProgress(0, "Загрузка данных");
                 _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = false;
                 var equipments = _dataContexts.AccEquipmentV2Entities.Equipments.Include(i => i.Area).AsNoTracking().ToList();
                 _typesData =
                     equipments
                         .GroupBy(grp => grp.Description, (key, group) => new { Key = key, Group = group })
                         .Select(item => new EquipmentTypesItem() { Selected = false, Count = item.Group.Count(), Description = item.Key, Group = item.Group.ToList() })
                         .OrderBy(o=>o.Description)
                         .ToList();
                 _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = true;
             }
             catch (Exception)
             {
                 throw;
             }
         }
     };
     splash.ShowDialog(this);
     gvEquipmentTypes.DataSource = _typesData;
 }
Ejemplo n.º 4
0
        private void AreasReport_Shown(object sender, EventArgs e)
        {
            reportViewer.LocalReport.ReportEmbeddedResource = "AccountingEquipment_V2.Reports.EquipmentListReport.EquipmentListDetailsReport.rdlc";
            reportViewer.Reset();
            reportViewer.LocalReport.DataSources.Clear();
            reportViewer.LocalReport.DataSources.Add(new ReportDataSource("ReportDataSet", (DataTable)_dataSet.EquipmentListDetails));
            reportViewer.RefreshReport();

            MiniSplash splash = new MiniSplash
            {
                    TaskName = "LoadEquipmentListDetailsReport",
                    Text = @"Загрузка отчета",
                    Working = (worker) =>
                    {
                        worker.ReportProgress(0, "Загрузка данных");
                        foreach (var detail in _reportedList.EquipmentListsDetails)
                        {
                            ReportDataSet.EquipmentListDetailsRow newRow = _dataSet.EquipmentListDetails.NewEquipmentListDetailsRow();
                            newRow.Description = detail.Description;
                            newRow.SerialNumber = detail.SerialNumber;
                            newRow.Comments = detail.Comments;
                            newRow.SideData = detail.SideData;
                            _dataSet.EquipmentListDetails.AddEquipmentListDetailsRow(newRow);
                        }
                        worker.ReportProgress(0, "Загрузка отчета");
                        Invoke(new Action(LoadReport));
                    }
            };
            splash.ShowDialog(this);
        }
Ejemplo n.º 5
0
        private void EquipmentListsForm_Shown(object sender, EventArgs e)
        {
            ApplyRight();
            switch (_formType)
            {
                case EquipmentListTypes.toReceive:
                    Text = @"Списки оборудования на получение";
                    break;
                case EquipmentListTypes.toDismantle:
                    Text = @"Списки оборудования на демонтаж";
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadAreaEquipments",
                Text = "",
                Working = (worker) =>
                {
                    try
                    {
                        if (worker == null) throw new Exception("Invalid background worker process");
                        worker.ReportProgress(0, "Загрузка данных");
                        _equipmentList =
                            _dataContext.EquipmentLists
                                .Include(i => i.Access_Users)
                                .Include(i => i.EquipmentListsDetails)
                                .Where(l => l.ListType == (int)_formType)
                                .OrderByDescending(o => o.CreationDate)
                                .ToList();
                        _dataContext.EntityObjectContext.Refresh(RefreshMode.StoreWins, _equipmentList);
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                }
            };
            splash.ShowDialog(this);
            dgvEquipmentListActive.DataSource = _equipmentList.Where(l=>l.ListState).ToList();
            dgvEquipmentListArchive.AutoGenerateColumns = false;
            ToolTip tip=new ToolTip();
            tip.SetToolTip(btApplyDataFilter,@"Применить фильт по дате");
            tip.SetToolTip(btnClearFilters,@"Очистить фильтры");
        }
Ejemplo n.º 6
0
        private void AreasReport_Shown(object sender, EventArgs e)
        {
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadAreaReport",
                Text = @"Загрузка отчета",
                Working = (worker) =>
                {
                    worker.ReportProgress(0, @"Загрузка данных");
                    var data = _dataContexts.AccEquipmentV2Entities.Areas.Include(i => i.ParentArea).Include(i => i.ChildAreas)/*.AsNoTracking()*/.ToList();
                    PopulateAreasData(data.Where(area => area.ParentArea == null).ToList(), 1, null);
                    List<ReportDataSet.CustomDataRow> rowsToDelete = new List<ReportDataSet.CustomDataRow>();
                    foreach (ReportDataSet.CustomDataRow areasReportRow in _dataSet.CustomData)
                    {
                        foreach (ReportDataSet.CustomDataRow areasReportRowChecked in _dataSet.CustomData)
                        {
                            if (!ContainsRowData(areasReportRow, areasReportRowChecked)) continue;
                            if (rowsToDelete.Exists(i => i == areasReportRow)) continue;
                            rowsToDelete.Add(areasReportRow);
                        }
                    }
                    foreach (ReportDataSet.CustomDataRow row in rowsToDelete)
                    {
                        _dataSet.CustomData.RemoveCustomDataRow(row);
                    }
                    worker.ReportProgress(0, "Загрузка отчета");
                    this.Invoke(new Action(() =>
                    {
                        reportViewer.Reset();
                        reportViewer.LocalReport.DataSources.Clear();
                        reportViewer.LocalReport.DataSources.Add(new ReportDataSource("ReportDataSet", (DataTable)_dataSet.CustomData));
                        reportViewer.LocalReport.ReportEmbeddedResource = "AccountingEquipment_V2.Reports.Areas.AreasReport.rdlc";
                        reportViewer.RefreshReport();
                    }));

                    
                }
            };
            splash.ShowDialog(this);
        }
Ejemplo n.º 7
0
 private void EquipmentTypesReport_Shown(object sender, EventArgs e)
 {
     MiniSplash splash = new MiniSplash
     {
         TaskName = "LoadReportData",
         Text = @"Загрузка отчета",
         Working = (worker) =>
         {
             try
             {
                 if (worker == null) throw new Exception("Invalid background worker process");
                 worker.ReportProgress(0, "Загрузка данных отчета");
                 foreach (CustomerTypesItem customerTypesItem in _reportedItems)
                 {
                     var areaGroup = customerTypesItem.Group.GroupBy(grp => grp.Equipment.Area.Description, (key, group) => new {Key = key,Group = group}).Select(item=>new {item.Key,item.Group});
                     foreach (var portGroup in areaGroup)
                     {
                         ReportDataSet.CustomerPortTypesRow row = _dataSet.CustomerPortTypes.NewCustomerPortTypesRow();
                         row.PortType = customerTypesItem.Description;
                         row.Area = portGroup.Key;
                         row.Count = portGroup.Group.Count();
                         //row.Count1 = equipmentGroup.Group.Count(item => item.OwnerType == (int) EquipmentOwner.Provider & item.PlaceType == (int) EquipmentSide.ProviderArea);
                         //row.Count2 = equipmentGroup.Group.Count(item => item.OwnerType == (int) EquipmentOwner.Provider & item.PlaceType == (int) EquipmentSide.ClientArea);
                         //row.Count3 = equipmentGroup.Group.Count(item => item.OwnerType == (int) EquipmentOwner.Client & item.PlaceType == (int) EquipmentSide.ProviderArea);
                         _dataSet.CustomerPortTypes.AddCustomerPortTypesRow(row);
                     }
                 }
                 worker.ReportProgress(0, "Загрузка отчета");
                 this.Invoke(new Action(LoadReport));
             }
             catch (Exception)
             {
                 throw;
             }
         }
     };
     splash.ShowDialog(this);
 }
Ejemplo n.º 8
0
 private void PortSelectorForm_Shown(object sender, EventArgs e)
 {
     
     MiniSplash splash = new MiniSplash
     {
         TaskName = "LoadReportEquipmentTypes",
         Text = "",
         Working = (worker) =>
         {
             try
             {
                 if (worker == null) throw new Exception("Invalid background worker process");
                 worker.ReportProgress(0, "Загрузка данных");
                 _dataContexts = new DataContextAccEq_V2.DataContext.MainDataContexts();
                 _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = false;
                 _ports = _dataContexts.AccEquipmentV2Entities.EquipmentPorts.Include(i => i.PortType).Include(i => i.Equipment).Include(i => i.Equipment.Area).Where(port => port.SideLink == null).ToList();
                 _areas=new List<Area>();
                 _equipments = new List<Equipment>();
                 foreach (EquipmentPort equipmentPort in _ports)
                 {
                    if (!_areas.Exists(area=>area.AreaId==equipmentPort.Equipment.Area.AreaId))
                        _areas.Add(equipmentPort.Equipment.Area);
                    if (!_equipments.Exists(equ => equ.EquipmentId== equipmentPort.Equipment.EquipmentId))
                        _equipments.Add(equipmentPort.Equipment);
                 }
                 _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = true;
             }
             catch (Exception)
             {
                 throw;
             }
         }
     };
     splash.ShowDialog(this);
     gvAreas.DataSource = _areas.OrderBy(o=>o.Description).ToList();
     
 }
Ejemplo n.º 9
0
 private void AreaDetailSelection_Shown(object sender, EventArgs e)
 {
     List<Area> data=new List<Area>();
     MiniSplash splash = new MiniSplash
     {
         TaskName = "LoadAreasVocab",
         Text = "",
         Working = (worker) =>
         {
             try
             {
                 if (worker == null) throw new Exception("Invalid background worker process");
                 worker.ReportProgress(0, "Загрузка данных");
                 data= _dataContexts.AccEquipmentV2Entities.Areas.Where(area => area.Equipments.Any()).OrderBy(area => area.Description).ToList();
             }
             catch (Exception)
             {
                 throw;
             }
         }
     };
     splash.ShowDialog(this);
     gvAreasTree.DataSource = data;
 }
Ejemplo n.º 10
0
 private void AreasVocabForm_Shown(object sender, EventArgs e)
 {
     MiniSplash splash = new MiniSplash
     {
         TaskName = "LoadAreasVocab",
         Text = "",
         Working = (worker) =>
         {
             try
             {
                 if (worker == null) throw new Exception("Invalid background worker process");
                 worker.ReportProgress(0, "Загрузка данных");
                 AreasTree.BeginUpdate();
                 AreasTree.Model = new AreasTreeModelVocab(_dataContext);
                 AreasTree.EndUpdate();
             }
             catch (Exception)
             {
                 throw;
             }
         }
     };
     splash.ShowDialog(this);
 }
Ejemplo n.º 11
0
 private void CustomerSidesReport_Shown(object sender, EventArgs e)
 {
     MiniSplash splash = new MiniSplash()
     {
         TaskName = "LoadCustomerSidesReport",
         Text = @"Загрузка отчета",
         Working = (worker) =>
         {
             worker.ReportProgress(0, @"Загрузка данных");
             string desc = _reportedCustomer.CustomerId.ToString() + ", " + _reportedCustomer.Title;
             _dataSet.CustomerAreas.Clear();
             foreach (CustomerLink customerLink in _reportedLinks)
             {
                 ReportDataSet.CustomerAreasRow newRow = _dataSet.CustomerAreas.NewCustomerAreasRow();
                 newRow.Customer = desc;
                 if (customerLink.Tag is Equipment)
                 {
                     Equipment equipment = customerLink.Tag as Equipment;
                     newRow.LinkType = "Оборудование";
                     newRow.LinkedArea = equipment.Area.Description;
                     newRow.LinkDeviceDesc = string.Format("{0} {1}", equipment.Description,
                         equipment.NetworkDescription != string.Empty ? "[" + equipment.NetworkDescription + "]" : "");
                     newRow.LinkedCustomerArea = _dataContexts.GetSideLinkDescription2(equipment.SideLink, true);
                     newRow.LinkPortDesc = "";
                     switch (equipment.OwnerType)
                     {
                         case (int) EquipmentOwner.Provider:
                             newRow.OwnerDesc = @"Провайдер";
                             break;
                         case (int) EquipmentOwner.Client:
                             newRow.OwnerDesc = @"Абонент";
                             break;
                         default:
                             newRow.OwnerDesc = "";
                             break;
                     }
                 }
                 else if (customerLink.Tag is EquipmentPort)
                 {
                     EquipmentPort port = customerLink.Tag as EquipmentPort;
                     newRow.LinkType = "Порты";
                     newRow.LinkedArea = port.Equipment.Area.Description;
                     newRow.LinkPortDesc = port.Description;
                     newRow.LinkDeviceDesc = string.Format("{0} {1}", port.Equipment.Description,
                         port.Equipment.NetworkDescription != string.Empty ? "[" + port.Equipment.NetworkDescription + "]" : "");
                     newRow.LinkedCustomerArea = _dataContexts.GetSideLinkDescription2(port.SideLink, true);
                     switch (port.Equipment.OwnerType)
                     {
                         case (int) EquipmentOwner.Provider:
                             newRow.OwnerDesc = @"Провайдер";
                             break;
                         case (int) EquipmentOwner.Client:
                             newRow.OwnerDesc = @"Абонент";
                             break;
                         default:
                             newRow.OwnerDesc = "";
                             break;
                     }
                 }
                 _dataSet.CustomerAreas.AddCustomerAreasRow(newRow);
             }
             worker.ReportProgress(0, "Загрузка отчета");
             this.Invoke(new Action(() => LoadReport("AccountingEquipment_V2.Reports.ClientSides.CustomerAreasByLinkType.rdlc")));
         }
     };
     splash.ShowDialog(this);
 }
Ejemplo n.º 12
0
 public void RefreshData(object sender, EventArgs e)
 {
     MiniSplash miniSplash = new MiniSplash
     {
         TaskName = "LoadCustomerSidesReport",
         Text = "Загрузка отчета",
         Working = delegate(BackgroundWorker worker)
         {
             if (worker == null)
             {
                 throw new Exception("worker is null in form load");
             }
             worker.ReportProgress(0, "Загрузка данных");
             LoadData();
         }
     };
     miniSplash.ShowDialog(this);
     SetDataSources();
 }
Ejemplo n.º 13
0
        private void CustomersSidesForm_Shown(object sender, EventArgs e)
        {
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadCustomerSidesForm",
                Text = @"Загрузка данных абонентов",
                Working = (worker) =>
                {
                    worker.ReportProgress(0, "Загрузка компаний");
                    _cachedFirms = _dataContexts.NumEquipmentEntities.Firms.Where(item => item.TestFlag.HasValue && !item.TestFlag.Value).OrderBy(firm => firm.FirmName).ToList();
                    worker.ReportProgress(0, "Загрузка абонентов");
                    _cachedCustomers = _dataContexts.NumEquipmentEntities.Customers.Where(cust => cust.Visible.HasValue && cust.Visible.Value).ToList();
                    worker.ReportProgress(0, "Загрузка адресов площадок");
                    _cachedCustomerSides = _dataContexts.AccEquipmentV2Entities.CustomerSides.ToList();
                    _defaultOrder = cust => int.Parse(cust.Customer_id.Trim());
                    Expression<Func<Customer, bool>> currentFirmFilter = cust => cust.FirmId == ((Firm) cbFirms.SelectedItem).FirmId;
                    _compiledCurrentFirmFilter = currentFirmFilter.Compile();
                    Expression<Func<CustomerSide, Customer, bool>>
                        currentSideFilter = (side, customer) =>
                                String.Equals(side.CustomerId.ToString(), customer.Customer_id.Trim()) &
                                side.Firmid == customer.FirmId;
                    _compiledCurrentSideFilter = currentSideFilter.Compile();
                },
                
            };
            splash.Worker.RunWorkerCompleted += (s, ee) =>
            {
                Cursor = Cursors.WaitCursor;
                cbFirms.DataSource = _cachedFirms;
                cbFirms.SelectedIndex = 3;
                gvCustomers.DataSource = _cachedCustomers.Where(_compiledCurrentFirmFilter).OrderBy(_defaultOrder).ToList();
                Cursor = Cursors.Default;
                if (FocusedLink != null)
                {
                    gvCustomers.SelectionChanged -= gvCustomers_SelectionChanged;
                    CustomerSide focusedSide = FocusedLink.CustomerSide;
                    if (focusedSide == null)
                    {
                        MessageBox.Show(@"Неизвестные данные о абоненте!");
                        return;
                    }
                    Customer focusedCustomer = _cachedCustomers.Find(cust => cust.FirmId == focusedSide.Firmid & Convert.ToInt32(cust.Customer_id.Trim()) == focusedSide.CustomerId);
                    Firm custFirm = _cachedFirms.SingleOrDefault(firm => firm.FirmId == focusedCustomer.FirmId);
                    if (custFirm == null)
                        return;
                    cbFirms.SelectedItem = custFirm;
                    cbFirms_SelectionChangeCommitted(cbFirms, new EventArgs());
                    var selectedNumEqRow =
                        gvCustomers.Rows.Cast<DataGridViewRow>()
                            .SingleOrDefault(
                                item =>
                                {
                                    Customer custCheck = ((Customer)item.DataBoundItem);
                                    return Convert.ToInt32(custCheck.Customer_id.Trim()) == focusedSide.CustomerId &
                                           custCheck.FirmId == focusedSide.Firmid;

                                });
                    if (selectedNumEqRow != null)
                    {
                        gvCustomers.CurrentCell = gvCustomers.Rows[selectedNumEqRow.Index].Cells[0];
                        selectedNumEqRow.Selected = true;
                        gvCustomers_SelectionChanged(gvCustomers, new EventArgs());
                        gvCustomers.BlinkRow(selectedNumEqRow);
                        var selectedCustomerSideRow =
                            gvSides.Rows.Cast<DataGridViewRow>()
                                .SingleOrDefault(
                                    item =>
                                    {
                                        CustomerSide checkSide = (CustomerSide)item.DataBoundItem;
                                        return checkSide.Id == focusedSide.Id;
                                    });
                        if (selectedCustomerSideRow != null)
                        {
                            gvSides.CurrentCell = gvSides.Rows[selectedCustomerSideRow.Index].Cells[0];
                            selectedCustomerSideRow.Selected = true;
                            gvSides.BlinkRow(selectedCustomerSideRow);
                        }
                    }
                    gvCustomers.SelectionChanged += gvCustomers_SelectionChanged;
                }
            };
            splash.ShowDialog(this);
        }
Ejemplo n.º 14
0
        public void ReloadData(Area reloadedArea,bool force=false)
        {
            if (reloadedArea == null)
                return;
            if (!force)
                if (reloadedArea == _loadedArea)
                    return;
            _loadedArea = reloadedArea;
            if (!SharedAppData.IsAccesible(ObjectAccessId))
            {
                label1.Text = @"Нет прав для просмотра " + ObjectAccessId.Description;
                label1.ForeColor = Color.Red;
                label2.Text = "";
                label3.Text = "";
                return;
            }
            tbAdd1.Enabled = tbAdd2.Enabled = tbAdd3.Enabled = SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Add) ;
            tbEdit1.Enabled = tbEdit2.Enabled = tbEdit3.Enabled = SharedAppData.IsFlagSet(EquipmentManage.ObjectAccessId, RightsFlags.Change) | SharedAppData.IsFlagSet(EquipmentManage.ObjectAccessId, RightsFlags.View);
            tbDelete1.Enabled = tbDelete2.Enabled = tbDelete3.Enabled = SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Delete);
            RemoveGridsSelectionHandler();

            #region Set label texts
            label1.Text = @"Оборудование провайдера, установленное на " + reloadedArea.Description;
            label2.Text = @"Оборудование провайдера, установленное у абонента";
            label3.Text = @"Оборудование абонента, установленное на " + reloadedArea.Description;
            #endregion

            Cursor = Cursors.WaitCursor;
            List<Equipment> areaEquipments=new List<Equipment>();
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadAreaEquipments",
                Text = "",
                Working = (worker) =>
                {
                    try
                    {
                        if (worker == null) throw new Exception("Invalid background worker process");
                        worker.ReportProgress(0, "Загрузка данных");
                        areaEquipments =
                            _dataContexts.AccEquipmentV2Entities.Equipments.Where(equipment => equipment.Area.AreaId == reloadedArea.AreaId)
                                .Include(equipment => equipment.SideLink)
                                .Include(equipment => equipment.SideLink.CustomerSide)
                                .Include(equipment => equipment.EquipmentPorts.Select(port => port.PortType))
                                .ToList();
                        _dataContexts.AccEquipmentV2Entities.EntityObjectContext.Refresh(RefreshMode.StoreWins, areaEquipments);
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                }
            };
            splash.ShowDialog(this);
            var dataProviderSetProviderAll = areaEquipments.Where(equipment => equipment.ParentEquipment==null & equipment.OwnerType == (int) EquipmentOwner.Provider & equipment.PlaceType == (int) EquipmentSide.ProviderArea).ToList();
            var dataProviderSetClientAll = areaEquipments.Where(equipment => equipment.ParentEquipment == null & equipment.OwnerType == (int)EquipmentOwner.Provider & equipment.PlaceType == (int)EquipmentSide.ClientArea).ToList();
            var dataClientSetProviderAll = areaEquipments.Where(equipment => equipment.ParentEquipment == null & equipment.OwnerType == (int)EquipmentOwner.Client & equipment.PlaceType == (int)EquipmentSide.ProviderArea).ToList();

            gvProviderSetProviderSummary.DataSource = null;
            gvProviderSetClientSummary.DataSource = null;
            gvClientSetProviderSummary.DataSource = null;
            if (dataProviderSetProviderAll.Any())
                gvProviderSetProviderSummary.DataSource = dataProviderSetProviderAll
                    .GroupBy(grp => grp.Description, (key, group) => new {Key = key, Group = group})
                    .Select(item => new EquipmentGridViewItemGrouped {Description = item.Key, Count = item.Group.Count(), GroupedEquipemnts = item.Group.ToList()})
                    .OrderBy(item=>item.Description)
                    .ToList();
            if (dataProviderSetClientAll.Any())
                gvProviderSetClientSummary.DataSource = dataProviderSetClientAll
                    .GroupBy(grp => grp.Description, (key, group) => new {Key = key, Group = group})
                    .Select(item => new EquipmentGridViewItemGrouped {Description = item.Key, Count = item.Group.Count(), GroupedEquipemnts = item.Group.ToList()})
                    .OrderBy(item => item.Description)
                    .ToList();
            if (dataClientSetProviderAll.Any())
                gvClientSetProviderSummary.DataSource = dataClientSetProviderAll
                    .GroupBy(grp => grp.Description, (key, group) => new {Key = key, Group = group})
                    .Select(item => new EquipmentGridViewItemGrouped {Description = item.Key, Count = item.Group.Count(), GroupedEquipemnts = item.Group.ToList()})
                    .OrderBy(item => item.Description)
                    .ToList();
            SetGridsSelectionHandler(true);
            Cursor = Cursors.Default;
        }
Ejemplo n.º 15
0
        private void AreaDetailReport_Shown(object sender, EventArgs e)
        {
            MiniSplash splash = new MiniSplash
            {
                TaskName = "LoadAreaDetailReport",
                Text = @"Загрузка отчета",
                Working = (worker) =>
                {
                    worker.ReportProgress(0, @"Загрузка данных");
                    List<Equipment> data =
                        _dataContexts.AccEquipmentV2Entities.Equipments.Where(equ => equ.ParentAreaId == _reportedArea.AreaId)
                            .Include(i => i.SideLink)
                            .Include(i => i.EquipmentPorts.Select(port => port.PortType))
                            .Include(i => i.EquipmentPorts.Select(port => port.SideLink))
                            .Include(i => i.ChildEquipments)
                            .ToList();
                    foreach (Equipment equipment in data)
                    {
                        ReportDataSet.AreaDetailsTotalRow newRow = _dataSet.AreaDetailsTotal.NewAreaDetailsTotalRow();
                        newRow.AreaDescription = _reportedArea.Description;
                        newRow.EquipmentDescription = equipment.Description + (!string.IsNullOrEmpty(equipment.NetworkDescription) ? " ["+equipment.NetworkDescription+"]":"");
                        newRow.EquipmentOwner = equipment.OwnerType;
                        newRow.EquipmentPlace = equipment.PlaceType;
                        newRow.EquipmentCustomer = _dataContexts.GetSideLinkDescription2(equipment.SideLink);
                        _dataSet.AreaDetailsTotal.AddAreaDetailsTotalRow(newRow);
                        if (equipment.EquipmentPorts.Any())
                        {
                            foreach (EquipmentPort equipmentPort in equipment.EquipmentPorts.OrderBy(portt => portt, new PortNameComparer()).ThenBy(port => port.PortType.Description))
                            {
                                ReportDataSet.AreaDetailsPortsRow newPortRow = _dataSet.AreaDetailsPorts.NewAreaDetailsPortsRow();
                                newPortRow.Area = _reportedArea.Description;
                                newPortRow.Equipment = equipment.Description + (!string.IsNullOrEmpty(equipment.NetworkDescription) ? " [" + equipment.NetworkDescription + "]" : "");
                                newPortRow.PortName = equipmentPort.Description;
                                newPortRow.PortDesc = _dataContexts.GetSideLinkDescription2(equipmentPort.SideLink); 
                                _dataSet.AreaDetailsPorts.AddAreaDetailsPortsRow(newPortRow);
                            }
                        }

                    }
                    worker.ReportProgress(0, "Загрузка отчета");
                    this.Invoke(new Action(() => button1_Click(this,new EventArgs())));
                }
            };
            splash.ShowDialog(this);
        }
 public void RefreshData(object sender, EventArgs e)
 {
     MiniSplash splash = new MiniSplash()
     {
         TaskName = "LoadCustomerSides",
         Text = @"Загрузка отчета",
         Working = (worker) =>
         {
             if (worker == null)
                 throw new Exception("worker is null in form load");
             worker.ReportProgress(0, @"Загрузка данных");
             LoadData();
         }
     };
     splash.ShowDialog(this);
     SetDataSources();
 }
Ejemplo n.º 17
0
        private void AccountEquipmentMainForm_Shown(object sender, EventArgs ee)
        {
            List<Access_Users> users = new List<Access_Users>();
            bool isRestarting = false;
            MiniSplash splash1 = new MiniSplash
            {
                TaskName = "LoadMainApp_Step1",
                Text = @"Запуск приложения",
                Working = (worker) =>
                {
                    #region Stage1 (Update app)

                    worker.ReportProgress(0, "Проверка обновлений для программы");
                    string message;
                    if (!CheckApplicationUpdateAvailable(out message))
                    {
                        if (message != string.Empty) throw new Exception(message);
                    }
                    else
                    {
                        ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                        try
                        {
                            worker.ReportProgress(0, @"Обновление приложения");
                            if (Properties.Settings.Default.UpgradeRequired)
                            {
                                Properties.Settings.Default.Upgrade();
                                Properties.Settings.Default.UpgradeRequired = false;
                                Properties.Settings.Default.Save();
                            }
                            ad.Update();
                            MessageBox.Show(this, @"Обновления приложения прошло успешно, нажмите ОК для перезапуска программы", "", MessageBoxButtons.OK);
                            isRestarting = true;
                            Invoke(new Action(Application.Restart));
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            MessageBox.Show(this, @"Обновление для приложения завершилась с ошибкой: " + dde.Message);
                            Application.Exit();
                        }
                    }

                    #endregion

                    #region Detect Debug|Release run

#if DEBUG
                    if (!Debugger.IsAttached)
                    {
                        Text += @"Попытка запуска отладочной версии программы без среды разработки! Переустановите приложение!";
                        //throw new Exception(@"Попытка запуска отладочной версии программы без среды разработки! Переустановите приложение!");
                    }
#else
                    if (Debugger.IsAttached)
                    {
                        throw new Exception(@"Запущена релизная версия программы из среды разработки! Измените платформу на Debug!");
                    }
#endif

                    #endregion

                    #region Stage2 (database connect)

                    worker.ReportProgress(0, "Подключение к базе данных");
                    _dataContexts = new MainDataContexts();
                    _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = false;
                    var tUsers =
                        _dataContexts.AccEquipmentV2Entities.Access_Users.OrderBy(u => u.Description)
                            .Select(u => new
                            {
                                u.Description,
                                u.Id,
                                u.IsAdmin,
                                Password = ""

                            })
                            .ToList();
                    tUsers.ForEach(t => users.Add(new Access_Users() {Id = t.Id, Description = t.Description, IsAdmin = t.IsAdmin}));
                    //.Include(i => i.Access_Associations.Where(a => a.AppId.Equals(Program.AppId.Id)))

                    _dataContexts.AccEquipmentV2Entities.Configuration.ProxyCreationEnabled = true;
                    SharedAppData.HistoryStore = new HistoryStore();

                    #endregion
                }
            };
            splash1.ShowDialog(this);
            if (isRestarting)
                return;

            #region Stage 3 Authorization

            if (users == null)
            {
                throw new Exception(@"Неизвествная ошибка в программе");
            }
            Access_Users fakeUser = new Access_Users() {Id = Guid.Empty, Description = "--- выберите пользователя для входа в систему---"};
            users.Insert(0, fakeUser);
            InputLogin input = new InputLogin
            {
                ComboBox1 =
                {
                    DisplayMember = "Description",
                    ValueMember = "Id",
                    DataSource = users
                }
            };
            var selectedUser = ((List<Access_Users>) input.ComboBox1.DataSource).SingleOrDefault(u => u.Id == Settings.Default.LastLoggedId);
            input.ComboBox1.SelectedItem = selectedUser ?? fakeUser;
            input.btnOk.Click += (_, __) =>
            {
                if (input.ComboBox1.SelectedItem == fakeUser)
                {
                    input.DialogResult = DialogResult.None;
                    return;
                }
                var authUser = (Access_Users) input.ComboBox1.SelectedItem;
                bool? checkResult = _dataContexts.AccEquipmentV2Entities.sp_CheckLogin(authUser.Id, input.InputLine1.Text).SingleOrDefault();
                if (checkResult.HasValue && checkResult.Value)
                {
                    input.DialogResult = DialogResult.OK;
                }
                else
                {

                    MessageBox.Show(@"Неправильные данные для авторизации!");
                    SharedAppData.HistoryStore.AddHistoryEvent("LoginFailed", "RequestUser: "******"LoginComplete", "RequestUser: "******" [" + SharedAppData.LoggedUser.Description + @"]";

            #endregion

            if (!SharedAppData.IsAccesible(ObjectAccessId))
            {
                MessageBox.Show(@"Отсутсвуют права на использование приложения!");
                Application.Exit();
                return;
            }

            #region Stage 4 Continue startup

            MiniSplash splash2 = new MiniSplash
            {
                TaskName = "LoadMainApp_Step2",
                Text = @"Запуск приложения",
                Working = (worker) =>
                {
                    #region Stage4 (fill areas tree)

                    worker.ReportProgress(0, "Загрузка первичных данных");
                    areaDetails.InitDataContext(_dataContexts);
                    equipmentDetails.InitDataContext(_dataContexts);
                    if (Settings.Default.AreasViewAsList)
                    {
                        areasTree.Model = new AreasTreeModelList(_dataContexts.AccEquipmentV2Entities);
                    }
                    else
                    {
                        areasTree.Model = new AreasTreeModelTree(_dataContexts.AccEquipmentV2Entities);
                    }

                    #endregion
                }
            };
            splash2.Worker.RunWorkerCompleted += (_, e) =>
            {
                if (e.Cancelled)
                {
                    MessageBox.Show(@"Запуск приложения был отменён");
                }
                else if (e.Error != null)
                {
                    throw e.Error;
                }
                else
                {
                    Enabled = true;
                }
            };
            splash2.ShowDialog(this);
            FormatAreasTreeViewToolBox(Settings.Default.AreasViewAsList);
            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;

            StatusLabel1.Text = @"Подготовка данных с базы нарядов";
            ProgressBar.Visible = true;
            Task.Factory.StartNew(() => _dataContexts.RefreshSideLinkInfos(), TaskCreationOptions.LongRunning).ContinueWith(_ =>
            {
                StatusLabel1.Text = @"Подготовка данных завершена";
                ProgressBar.Visible = false;
            }, TaskScheduler.FromCurrentSynchronizationContext());

            miEmptyNetworkName.Visible = SharedAppData.LoggedUser.IsAdmin;

            #endregion
        }
Ejemplo n.º 18
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();
        }