コード例 #1
0
        private void MergeDatabaseView()
        {
            var newList = _databases.Select(
                db => new DatabaseReference()
            {
                Name    = db,
                Caption = Connection.PowerBIFileName.Length > 0 ? Connection.PowerBIFileName : db
            }).OrderBy(db => db.Name);

            // remove deleted databases
            for (int i = _databasesView.Count - 1; i >= 0; i--)
            {
                var found = newList.Where(db => db.Name == _databasesView[i].Name).Any();
                if (!found)
                {
                    _databasesView.RemoveAt(i);
                }
            }

            // add new databases
            foreach (DatabaseReference dbRef in newList)
            {
                var found = _databasesView.Where(db => db.Name == dbRef.Name).DefaultIfEmpty();
                if (found != null)
                {
                    _databasesView.Add(dbRef);
                }
            }

            NotifyOfPropertyChange(() => DatabasesView);
            if (SelectedDatabase == null)
            {
                SelectedDatabase = DatabasesView.FirstOrDefault();
            }
        }
コード例 #2
0
        public BindableCollection <CTPTS> ReturnBookList(DOCGIA dg)
        {
            BindableCollection <CTSACH> temp;
            BindableCollection <CTPTS>  temp2;

            using (QLTVEntities db = new QLTVEntities())
            {
                temp  = new BindableCollection <CTSACH>(db.CTSACH.Include(Y => Y.SACH).Where(x => x.PHIEUMUONSACH.OrderByDescending(z => z.NGMUON).FirstOrDefault().MADG == dg.MADG && x.MATT == 3));
                temp2 = new BindableCollection <CTPTS>(temp.Select(x => new CTPTS
                {
                    MACTS   = x.MACTS,
                    MAPMS   = x.PHIEUMUONSACH.OrderByDescending(z => z.NGMUON).FirstOrDefault(y => y.MADG == dg.MADG).MAPMS,
                    MASACH  = x.MASACH ?? 0,
                    TENSACH = x.SACH.TENSACH,
                    NGMUON  = x.PHIEUMUONSACH.OrderByDescending(z => z.NGMUON).FirstOrDefault(y => y.MADG == dg.MADG).NGMUON ?? DateTime.Today,
                }));
                foreach (CTPTS item in temp2)
                {
                    if ((DateTime.Today - item.NGMUON).Days > LibraryRules.NGAYMUON)
                    {
                        item.TIENPHAT = ((DateTime.Today - item.NGMUON).Days - LibraryRules.NGAYMUON) * LibraryRules.TIENPHAT;
                    }
                    else
                    {
                        item.TIENPHAT = 0;
                    }
                }
            }
            return(temp2);
        }
コード例 #3
0
        private void GenerateTagData()
        {
            m_TagCategoryAxis.Labels.Clear();
            m_TagChartModel.Series.Clear();

            var tags = m_Positions.Select(p => p.Tag)
                       .Distinct()
                       .ToList();

            foreach (var tag in tags)
            {
                m_TagCategoryAxis.Labels.Add(tag);

                var positionsPerCategory = m_Positions.Where(cfp => cfp.Tag == tag);
                foreach (var positionPerCategory in positionsPerCategory)
                {
                    var columnSeries = new ColumnSeries
                    {
                        StrokeThickness = 0,
                        Title           = positionPerCategory.Name,
                        IsStacked       = false,
                        FillColor       = m_TagColorProvider.GetColorForTag(positionPerCategory.Tag)
                                          .OxyColor
                    };
                    m_TagChartModel.Series.Add(columnSeries);

                    columnSeries.Items.Add(new ColumnItem(positionPerCategory.CalculatedValue / 1000, tags.IndexOf(positionPerCategory.Tag)));
                }
            }

            m_TagChartModel.InvalidatePlot(true);
        }
コード例 #4
0
        private void BuildTrackerConnectionProgressChanged(object sender, BuildTrackerConnectionProgressEventArgs e)
        {
            if (ShouldExitHandler(e))
            {
                return;
            }

            foreach (var project in e.Projects)
            {
                var projectToUpdate = _projects.SingleOrDefault(p => p.Id == project.Id);

                if (projectToUpdate != null)
                {
                    projectToUpdate.TryUpdate(project.Name);
                }
                else
                {
                    _application.Dispatcher.Invoke(() =>
                    {
                        var projectToAdd = _projectFactory.Create(SettingsId, project.Id, project.Name);

                        var names = _projects.Select(p => p.Name).Concat(new[] { projectToAdd.Name }).OrderBy(name => name).ToArray();

                        var index = Array.IndexOf(names, projectToAdd.Name);

                        _projects.Insert(index, projectToAdd);
                    });
                }
            }

            var projectsToKeep   = e.Projects.Select(project => project.Id).ToArray();
            var projectsToRemove = _projects.Where(project => !projectsToKeep.Contains(project.Id)).ToArray();

            if (_projects.Any())
            {
                _application.Dispatcher.Invoke(() =>
                {
                    _projects.RemoveRange(projectsToRemove);
                });
            }

            _trie = new SuffixTrie <IProjectViewModel>(3);

            foreach (var project in _projects)
            {
                _trie.Add(project.Name.ToLowerInvariant(), project);
            }

            IsErrored = false;
            IsBusy    = false;

            NotifyOfPropertyChange(() => HasProjects);
            NotifyOfPropertyChange(() => HasNoProjects);
            NotifyOfPropertyChange(() => IsViewable);
        }
コード例 #5
0
ファイル: ProjectViewModel.cs プロジェクト: lulzzz/Overseer-1
        private void BuildTrackerProjectProgressChanged(object sender, BuildTrackerProjectProgressEventArgs e)
        {
            if (ShouldExitHandler(e))
            {
                return;
            }

            foreach (var build in e.Builds)
            {
                var buildToUpdate = _builds.SingleOrDefault(b => b.Id == build.Id);

                if (buildToUpdate != null)
                {
                    buildToUpdate.TryUpdate(e.Project.Name, build.Status, build.StartTime, build.EndTime, build.RunTime());
                }
                else
                {
                    _application.Dispatcher.Invoke(() =>
                    {
                        var buildToAdd = _buildFactory.Create(e.Project.Name, build.Id, build.Branch, build.VersionNumber(), build.RequestedBy, build.Changes, build.Status, build.StartTime, build.EndTime, build.RunTime(), build.WebUrl);

                        var time = new Tuple <DateTime, DateTime>(buildToAdd.EndTime ?? DateTime.MaxValue, buildToAdd.StartTime ?? DateTime.MaxValue);

                        var times = _builds.Select(b => new Tuple <DateTime, DateTime>(b.EndTime ?? DateTime.MaxValue, b.StartTime ?? DateTime.MaxValue)).Concat(new[] { time }).OrderByDescending(t => t.Item1).ThenByDescending(t => t.Item2).ToArray();

                        var index = Array.IndexOf(times, time);

                        _builds.Insert(index, buildToAdd);
                    });
                }
            }

            var buildsToKeep   = e.Builds.Select(build => build.Id).ToArray();
            var buildsToRemove = _builds.Where(build => !buildsToKeep.Contains(build.Id)).ToArray();

            if (buildsToRemove.Any())
            {
                _application.Dispatcher.Invoke(() =>
                {
                    _builds.RemoveRange(buildsToRemove);
                });
            }

            IsErrored = false;
            IsBusy    = false;

            NotifyOfPropertyChange(() => HasBuilds);
            NotifyOfPropertyChange(() => HasNoBuilds);
            NotifyOfPropertyChange(() => LatestBuild);
            NotifyOfPropertyChange(() => HasLatestBuild);
            NotifyOfPropertyChange(() => QueuedBuilds);
            NotifyOfPropertyChange(() => HasQueuedBuilds);
            NotifyOfPropertyChange(() => IsViewable);
        }
コード例 #6
0
ファイル: TimesByDay.cs プロジェクト: haefele/CTime2
        private TimesByDay(DateTime day, BindableCollection<TimeForGrouping> times)
        {
            this.Day = day;
            this.Times = times;
            this.Hours = times.Select(f => f.Time.Hours).FirstOrDefault();

            var clockInTimes = times.Where(f => f.ClockInTime != null).Select(f => f.ClockInTime.Value.TimeOfDay).ToList();
            this.DayStartTime = clockInTimes.Any() ? clockInTimes.Min() : (TimeSpan?)null;

            var clockOutTimes = times.Where(f => f.ClockOutTime != null).Select(f => f.ClockOutTime.Value.TimeOfDay).ToList();
            this.DayEndTime = clockOutTimes.Any() ? clockOutTimes.Max() : (TimeSpan?)null;
        }
コード例 #7
0
        public void Save()
        {
            foreach (var viewModel in Consoles.Where(x => x.Unsaved))
            {
                viewModel.Instance.SetId();
            }

            _repo.ReplaceAll(Consoles.Select(x => x.Instance).ToList());
            _repo.Flush();
            MessageBox.Show($"Saved {_repo.Items.Count}");
            TryClose();
        }
コード例 #8
0
        public void SetTable()
        {
            int value = 0;

            int.TryParse(PAD_TEXT, out value);
            Numero = value;
            if (Numero < 1)
            {
                MessageBox.Show("Saisir numero table");
                return;
            }

            if (!Edit)
            {
                ticketType = TicketType.TABLE;
                this.RequestClose();
            }
            else
            {
                bool DoJumle = false;
                if (tickets.Select(a => a.Numero).Contains(Numero))
                {
                    var item = tickets.First(a => a.Numero == Numero);
                    // JUMLAGE
                    var response = MessageBox.Show("Table existe déja, jumeler les commandes?", "Jumler", MessageBoxButton.YesNo);
                    if (response == MessageBoxResult.Yes)
                    {
                        DoJumle = true;
                        var items = currentTicket.CarteLines;
                        item.CarteLines.AddRange(items);

                        tickets.Remove(currentTicket);
                        currentTicket.ticketType = TicketType.TABLE;
                        currentTicket.Numero     = Numero;
                    }
                    else
                    {
                        RequestClose();
                    }
                }
                else
                {
                    currentTicket.ticketType = TicketType.TABLE;
                    currentTicket.Numero     = Numero;
                }
                this.RequestClose();
            }
        }
コード例 #9
0
        /// <summary>
        /// Provides the observer with new data.
        /// </summary>
        /// <param name="value">The current notification information.</param>
        public void OnNext(Notification <ConnectionSettings>[] value)
        {
            if (_isDisposed)
            {
                // Do nothing if disposed (pattern practice).
                return;
            }

            var currentConnections = Connections.ToDictionary(connection => connection.SettingsId, connection => connection);

            foreach (var settings in Notification <ConnectionSettings> .GetPayloads(value, NotificationType.Removed, s => currentConnections.ContainsKey(s.Id)))
            {
                var connectionToRemove = currentConnections[settings.Id];

                _application.Dispatcher.Invoke(() =>
                {
                    _connections.Remove(connectionToRemove);
                });
            }

            foreach (var settings in Notification <ConnectionSettings> .GetPayloads(value, NotificationType.Updated, s => currentConnections.ContainsKey(s.Id)))
            {
                var connectionToUpdate = currentConnections[settings.Id];

                connectionToUpdate.SettingsName = settings.Name;
            }

            foreach (var settings in Notification <ConnectionSettings> .GetPayloads(value, NotificationType.Added, s => !currentConnections.ContainsKey(s.Id)))
            {
                _application.Dispatcher.Invoke(() =>
                {
                    var connectionToAdd = _connectionViewModelStrategy.Create(settings);

                    var names = _connections.Select(c => c.SettingsName).Concat(new[] { connectionToAdd.SettingsName }).OrderBy(name => name).ToArray();

                    var index = Array.IndexOf(names, connectionToAdd.SettingsName);

                    _connections.Insert(index, connectionToAdd);
                });
            }
        }
コード例 #10
0
 public override IEnumerable <Color.RGB> GetColours()
 {
     return(Colors.Select(c => c.Color.FromSystemColor()));
 }
コード例 #11
0
        public ModelSetupWizardViewModel(Autodesk.Revit.UI.UIDocument uidoc)
        {
            doc = uidoc.Document;
            ProjectInformation          = new BindableCollection <ProjectInformationParameter>(ElementCollectors.GetProjectInformationParameters(doc));
            Worksets                    = new BindableCollection <WorksetParameter>(ElementCollectors.GetWorksetParameters(doc));
            SelectedWorksets            = new List <WorksetParameter>();
            SelectedProjectInformations = new List <ProjectInformationParameter>();
            optionsVm                   = new ModelSetupWizardOptionsViewModel();
            NominatedArchitects         = optionsVm.NominatedArchitects;
            ColourSchemes               = optionsVm.ColourSchemes;
            NominatedArchitects.Insert(0, new NominatedArchitect("Architects Name", "0000"));
            selectedNominatedArchitect = NominatedArchitects[0];
            selectedColourScheme       = ColourSchemes[0];
            FileName = doc.PathName;

            var iniFile = IniIO.GetIniFile(doc);

            if (iniFile.Length > 0)
            {
                var colors = IniIO.ReadColours(iniFile);
                Colours = new BindableCollection <System.Windows.Media.Color>(colors);
            }
            else
            {
                SCaddinsApp.WindowManager.ShowMessageBox(iniFile + " does not exist");
            }

            var fileNameParam = ProjectInformation.Where(p => p.Name == ModelSetupWizardSettings.Default.FileNameParameterName);

            if (fileNameParam.Count() == 1)
            {
                if (string.IsNullOrEmpty(doc.PathName))
                {
                    SCaddinsApp.WindowManager.ShowMessageBox("Document not saved... filename cannot be assigned.");
                }
                var path = System.IO.Path.GetFileName(doc.PathName);
                fileNameParam.First().Value = path;
            }

            foreach (var pinf in optionsVm.ProjectInformationReplacements)
            {
                var match = ProjectInformation.Where(p => p.Name == pinf.ParamaterName);
                if (match.Count() == 1)
                {
                    match.First().Format = pinf.ReplacementFormat;
                    match.First().Value  = pinf.ReplacementValue;
                }
            }
            foreach (var winf in optionsVm.Worksets)
            {
                if (Worksets.Select(w => w.Name.Trim()).Contains(winf.Name.Trim()))
                {
                    continue;
                }
                if (!Worksets.Select(w => w.Name).Contains(winf.ExistingName.Trim()))
                {
                    Worksets.Add(winf);
                }
                var match = Worksets.Where(w => w.Name.Trim() == winf.ExistingName.Trim());
                if (match.Any())
                {
                    match.First().Name = winf.Name;
                }
            }
        }
コード例 #12
0
 private AttendingUserByIsAttending(BindableCollection<AttendingUser> users)
 {
     this.IsAttending = users.Select(f => f.IsAttending).FirstOrDefault();
     this.Users = users;
 }
コード例 #13
0
        public void BackUp(DateTime selectedDateTime, string filePath)
        {
            using (_dbContext = new WHTDbContext())
            {
                Employees  = new BindableCollection <EmployeeModel>(_dbContext.Employees);
                Hours      = new BindableCollection <HoursModel>(_dbContext.Hours.Where(x => x.WorkingDate.Year.Equals(selectedDateTime.Year) && x.WorkingDate.Month.Equals(selectedDateTime.Month)));
                YearMonths = new BindableCollection <YearMonthModel>(_dbContext.YearMonths.Where(x => x.Year.Equals(selectedDateTime.Year) && x.Month.Equals(selectedDateTime.Month)));
            }

            var fileName       = $"{selectedDateTime.ToShortDateString()}_backup.xlsx";
            var daysInMonth    = DateTime.DaysInMonth(selectedDateTime.Year, selectedDateTime.Month);
            var numOfEmployees = Employees.Count;
            var weekends       = YearMonths.Select(x => x.MonthsWeekendDays).First();

            using (var p = new ExcelPackage(new System.IO.FileInfo($"{filePath}/{fileName}")))
            {
                var ws = p.Workbook.Worksheets.Add("BU");

                #region SET BORDER/STYLE ON WHOLE WORKSHEET
                var tempRange = ws.Cells[1, 1, daysInMonth + 4, numOfEmployees + 1];
                tempRange.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                tempRange.Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                tempRange.Style.Border.Right.Style  = ExcelBorderStyle.Thin;
                tempRange.Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                tempRange.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                tempRange.Style.Border.Left.Color.SetColor(Color.Black);
                tempRange.Style.Border.Right.Color.SetColor(Color.Black);
                tempRange.Style.Border.Top.Color.SetColor(Color.Black);
                tempRange.Style.Border.Bottom.Color.SetColor(Color.Black);
                #endregion

                #region SET WEEKENDS/HOLIDAYS
                for (int row = 1; row <= daysInMonth; row++)
                {
                    var dt = new DateTime(selectedDateTime.Year, selectedDateTime.Month, row);
                    ws.Cells[row + 1, 1].Value = dt.ToLongDateString();

                    if (weekends.Contains(dt.Day))
                    {
                        var range = ws.Cells[row + 1, 1, row + 1, numOfEmployees + 1];
                        range.Style.Fill.PatternType = ExcelFillStyle.Solid;
                        range.Style.Fill.BackgroundColor.SetColor(Color.Brown);  //.Style.Font.Color.SetColor(System.Drawing.Color.Brown);
                    }
                }

                ws.Cells[daysInMonth + 2, 1].Value = "Podstawowe";
                ws.Cells[daysInMonth + 3, 1].Value = "Nadgodziny";
                ws.Cells[daysInMonth + 4, 1].Value = "Suma";
                ws.Cells[daysInMonth + 2, 1, daysInMonth + 4, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                ws.Cells[daysInMonth + 2, 1, daysInMonth + 4, numOfEmployees + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
                ws.Cells[daysInMonth + 2, 1, daysInMonth + 4, numOfEmployees + 1].Style.Fill.BackgroundColor.SetColor(Color.Yellow);
                #endregion

                #region SET EMPLOYEES HOURS
                for (int employeeNo = 0; employeeNo < numOfEmployees; employeeNo++)
                {
                    var emp  = Employees[employeeNo];
                    var cell = ws.Cells[1, employeeNo + 2];
                    cell.Value = emp.FirstName;

                    var empHours = Hours.Where(x => x.EmployeeId.Equals(emp.Id)).ToList();

                    double normalHoursSum = 0, overtimeHoursSum = 0, allHoursSum = 0;
                    foreach (var workDay in empHours)
                    {
                        var      day        = workDay.WorkingDate.Day;
                        TimeSpan interval   = (TimeSpan)(workDay.To - workDay.From);
                        var      totalHours = interval.TotalHours;
                        ws.Cells[day + 1, employeeNo + 2].Value = totalHours;

                        allHoursSum += totalHours;

                        if (weekends.Contains(day))
                        {
                            overtimeHoursSum += totalHours;
                            continue;
                        }

                        if (totalHours > 8)
                        {
                            normalHoursSum   += 8;
                            overtimeHoursSum += totalHours - 8;
                        }
                        else
                        {
                            normalHoursSum += totalHours;
                        }
                    }

                    ws.Cells[daysInMonth + 2, employeeNo + 2].Value = normalHoursSum;
                    ws.Cells[daysInMonth + 3, employeeNo + 2].Value = overtimeHoursSum;
                    ws.Cells[daysInMonth + 4, employeeNo + 2].Value = allHoursSum;
                }
                #endregion

                ws.Cells[1, 1, daysInMonth, numOfEmployees + 1].AutoFitColumns();

                p.Save();
            }

            MessageQueue.Enqueue("Backup utworzony!");
        }
コード例 #14
0
 public IBindableCollection <TEntity> GetAll()
 {
     AssertDispatcherThread();
     return(_itemReferences.Select(weak => weak.Target as TEntity).Where(entity => entity != null));
 }
コード例 #15
0
 public void OpenEditor(object dataContext)
 {
     m_EditItem = dataContext is GroupViewModel
 ? (IScreen)m_GroupViewModelFactory.CreateEditViewModelFromExisting(((GroupViewModel)dataContext).Model, m_Employees.Select(g => g.Model)
                                                                    .ToArray(), RemoveEmployeeGroup)
 : m_EmployeeViewModelFactory.CreateEditViewModelFromExisting(((EmployeeViewModel)dataContext).Model, m_Groups.Select(g => g.Model)
                                                              .ToArray(), RemoveEmployee);
     Dialogs.ShowDialog(m_EditItem);
 }