Ejemplo n.º 1
0
        public RouteListTrackDlg()
        {
            this.Build();
            this.TabName = "Мониторинг";
            yTreeViewDrivers.RepresentationModel = new ViewModel.WorkingDriversVM(uow);
            yTreeViewDrivers.RepresentationModel.UpdateNodes();
            yTreeViewDrivers.Selection.Mode     = Gtk.SelectionMode.Multiple;
            yTreeViewDrivers.Selection.Changed += OnSelectionChanged;
            buttonChat.Sensitive = false;
            currentEmployee      = EmployeeRepository.GetEmployeeForCurrentUser(uow);
            if (currentEmployee == null)
            {
                MessageDialogWorks.RunErrorDialog("Ваш пользователь не привязан к сотруднику. Чат не будет работать.");
            }
            else
            {
                if (!ChatCallbackObservable.IsInitiated)
                {
                    ChatCallbackObservable.CreateInstance(currentEmployee.Id);
                }
                ChatCallbackObservable.GetInstance().AddObserver(this);
            }

            //Configure map
            gmapWidget.MapProvider   = GMapProviders.OpenStreetMap;
            gmapWidget.Position      = new PointLatLng(59.93900, 30.31646);
            gmapWidget.HeightRequest = 150;
            //MapWidget.HasFrame = true;
            gmapWidget.Overlays.Add(carsOverlay);
            gmapWidget.Overlays.Add(tracksOverlay);
            gmapWidget.ExposeEvent += GmapWidget_ExposeEvent;
            UpdateCarPosition();
            timerId = GLib.Timeout.Add(carRefreshInterval, new GLib.TimeoutHandler(UpdateCarPosition));
            yenumcomboMapType.ItemsEnum = typeof(MapProviders);
        }
Ejemplo n.º 2
0
        private void Configure(int chatId, IEmployeeRepository employeeRepository)
        {
            chatUoW         = UnitOfWorkFactory.CreateForRoot <Chat>(chatId);
            currentEmployee = employeeRepository.GetEmployeeForCurrentUser(chatUoW);

            if (currentEmployee == null)
            {
                MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к сотруднику. Невозможно открыть чат.");
                this.Destroy();
                return;
            }

            if (!ChatCallbackObservable.IsInitiated)
            {
                ChatCallbackObservable.CreateInstance(currentEmployee.Id, _chatMessageRepository);
            }

            ChatCallbackObservable.GetInstance().AddObserver(this);
            var lastReaded = _lastReadedRepository.GetLastReadedMessageForEmployee(chatUoW, chatUoW.Root, currentEmployee);

            if (lastReaded != null)
            {
                var readDays = (DateTime.Today - lastReaded.LastDateTime.Date).Days;
                if (showMessagePeriod < readDays)
                {
                    showMessagePeriod = readDays;
                }
            }
            else
            {
                var readDays = (DateTime.Today - currentEmployee.CreationDate.Date).Days;
                if (showMessagePeriod < readDays)
                {
                    showMessagePeriod = readDays;
                }
            }
            updateChat();
        }