Exemple #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);
        }
Exemple #2
0
 private void OnSwitchIn(ITdiTab tabFrom)
 {
     UpdateLastReadedMessage();
     ChatCallbackObservable.GetInstance().NotifyChatUpdate(chatUoW.Root.Id, this);
     isActive = true;
     updateTitle();
 }
Exemple #3
0
 public override void Destroy()
 {
     if (ChatCallbackObservable.IsInitiated)
     {
         ChatCallbackObservable.GetInstance().RemoveObserver(this);
     }
     base.Destroy();
 }
Exemple #4
0
 public override void Destroy()
 {
     if (ChatCallbackObservable.IsInitiated)
     {
         ChatCallbackObservable.GetInstance().RemoveObserver(this);
     }
     GLib.Source.Remove(timerId);
     gmapWidget.Destroy();
     if (mapWindow != null)
     {
         mapWindow.Destroy();
     }
     base.Destroy();
 }
Exemple #5
0
 protected void OnButtonSendClicked(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(textViewMessage.Buffer.Text))
     {
         return;
     }
     if (chatUoW.Root.ChatType == ChatType.DriverAndLogists)
     {
         if (currentEmployee != null)
         {
             getChatService().SendMessageToDriver(
                 currentEmployee.Id,
                 chatUoW.Root.Driver.Id,
                 textViewMessage.Buffer.Text
                 );
         }
         textViewMessage.Buffer.Text = String.Empty;
     }
     ChatCallbackObservable.GetInstance().NotifyChatUpdate(chatUoW.Root.Id, this);
 }
Exemple #6
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();
        }