private void timer_Tick(object sender, EventArgs e)
        {
            string qrdecode = "";

            if (BitImage is null)
            {
                return;
            }
            Bitmap        bit      = BitmapImageToBitmap(BitImage);
            BarcodeReader Reader   = new BarcodeReader();
            Result        qrResult = Reader.Decode(bit);

            try
            {
                qrdecode = qrResult?.Text.Trim();
            }
            catch (Exception ex)
            {
                qrdecode = "error";
            }
            QRString = qrdecode;
            if (!string.IsNullOrEmpty(qrdecode))
            {
                int    t  = int.Parse(QRString);
                DOCGIA dg = ClientList.FirstOrDefault(x => x.MADG == t);
                dataProvider.SelectedClient = dg;
                StopCamera();
                IsDialogOpen = false;
                eventAggregator.PublishOnCurrentThread("OpenClientView");
            }
        }
        //private async Task AddClientDataItem(EditContext context)
        //{
        //    var model = context.Model as PersonalDataItem;
        //    var client = SelectedClient;
        //    if (client != null && model != null)
        //    {
        //        client.PersonalData.DataItems.Add(model);
        //        await ClientModal.ToggleModal();
        //        NewDataItemModel = new PersonalDataItem();
        //        await InvokeAsync(() => StateHasChanged());
        //    }
        //}

        private void SelectedClientUpdated(Client client)
        {
            var c = ClientList.FirstOrDefault(x => x.ClientId == client.ClientId);

            c.PersonalData.DataItems = client.PersonalData.DataItems;
            StateHasChanged();
        }
 private async Task OnViewClientClickAsync(int clientId)
 {
     SelectedClient = ClientList.FirstOrDefault(c => c.ClientId == clientId);
     if (SelectedClient != null)
     {
         await ClientModal.ToggleModal();
         await InvokeAsync(() => StateHasChanged());
     }
 }
Пример #4
0
        public Client TryGetClient(IntPtr hwnd)
        {
            var foundItem = ClientList.FirstOrDefault(c => c.Hwnd == hwnd);

            if (foundItem != null)
            {
                return(foundItem);
            }
            return(null);
        }
        public void ContractSaveAndEditValues()
        {
            var    clientName           = ClientList.FirstOrDefault(x => x.ClientId == SelectedClientId);
            string selectedClientname   = (clientName != null) ? clientName.ClientName : "";
            var    contractName         = ClientList.FirstOrDefault(x => x.ContractId == SelectedContractId);
            string selectedContractName = (contractName != null) ? contractName.ContractName : "";

            var startDate = StartDate.Date;
            var endDate   = EndDate.Date;

            _contract.EmployeeId   = CurrentUser.EmployeeId;
            _contract.ClientId     = SelectedClientId;
            _contract.ClientName   = selectedClientname;
            _contract.ContractName = selectedContractName;
            _contract.StartDate    = startDate;
            _contract.EndDate      = endDate;
        }
        public async Task LoadClients()
        {
            ClientManager manager = new ClientManager();

            List <TimeReport> clientList = await manager.GetAllClients();

            if (clientList != null && clientList.Count > 0)
            {
                ClientList = clientList;
            }

            ClientNameList = new List <string>();

            if (ClientList != null)
            {
                ClientNameList.AddRange(ClientList.Select(x => x.ClientName).Distinct());
                var cl = ClientList.FirstOrDefault();
                ContractNameList = new List <string>();
                if (cl != null)
                {
                    foreach (var client in ClientList)
                    {
                        if (client.ClientName == cl.ClientName)
                        {
                            ContractNameList.Add(client.ClientName);
                        }
                    }
                }

                ContractNameList.AddRange(ClientList.Where(x => x.ClientName == ClientList.FirstOrDefault().ClientName).Select(x => x.ContractName).Distinct());

                var firstClient     = ContractNameList.First();
                var matchingClients = ClientList.Where(x => x.ClientName == firstClient).ToList();

                ContractList = new List <string>();

                foreach (var contract in matchingClients)
                {
                    ContractList.Add(contract.ContractName);
                }
            }
        }
Пример #7
0
        public void SaveCurrentClient()
        {
            DataModel.Client matchByCode = ClientList.FirstOrDefault(client => client.IdCode == CurrentClient.IdCode);

            // An IdCode collision occurred and it's not the same client.
            if (matchByCode != null && matchByCode.Id != CurrentClient.Id)
            {
                throw new Exception($"Asiakas tunnisteella {CurrentClient.IdCode} on jo olemassa.");
            }
            if (SaveAsNew && matchByCode == null)
            {
                CurrentClient.Id = null;
            }

            CurrentClient.Save();
            ClientList = new ObservableCollection <DataModel.Client>(DataModel.Client.LoadAll());

            // If the user changes the IdCode and saves the client as new, this updates the Id to the view model.
            CurrentClient = ClientList.First(client => client.IdCode == CurrentClient.IdCode).Copy();
        }
Пример #8
0
        private void ResponseDeviceDetection(MessageModel request, HostName remoteHost)
        {
            MessageModel response = new MessageModel();

            response.Type       = MessageType.DeviceDetection;
            response.RemotePort = request.RemotePort;

            string     token       = "";
            ClientInfo existClient = null;

            if (ClientList.Count > 0)
            {
                existClient = ClientList.FirstOrDefault(p => p.HostName.Equals(remoteHost.RawName));
            }
            if (existClient != null)
            {
                token = existClient.Token;
            }
            else
            {
                token = GenerateRandomToken(8);

                ClientList.Add(new ClientInfo()
                {
                    HostName   = remoteHost.RawName,
                    RemotePort = response.RemotePort,
                    Token      = token
                });
            }

            response.Token = token;
            var data = MessageModel.FromMessage(response);

            UDPClient.SendData(remoteHost.CanonicalName, response.RemotePort.ToString(), data);
            Debug.WriteLine("response to " + remoteHost.CanonicalName + " for " + response.Type);
        }