Exemplo n.º 1
0
        public static void WorkAllDevices()
        {
            Random rnd = new Random();

            do
            {
                Thread.Sleep(180000);

                EntityModelContainer container = new EntityModelContainer();

                foreach (Device device in container.DeviceSet)
                {
                    int choice = rnd.Next(0, 50);

                    if (choice != 49)
                    {
                        MeasuredData newData = CreateMeasure(device, device.Patient);
                        AddMeasuredData(newData, device.Patient, device);
                    }
                    else
                    {
                        DeviceMessage message = CreateDeviceMessage(device);
                        AddDeviceMessage(message);
                    }
                }
            } while (true);
        }
Exemplo n.º 2
0
        static DeviceMessage CreateDeviceMessage(Device sender)
        {
            DeviceMessage message = new DeviceMessage();

            message.SenderCode    = sender.DeviceCode;
            message.RecipientCode = 1;
            message.Title         = "Ошибка записи измерения";
            message.Text          = "Не удалось произвести сохранение измерения";
            message.Date          = DateTime.Now;

            return(message);
        }
Exemplo n.º 3
0
        static void AddDeviceMessage(DeviceMessage message)
        {
            EntityModelContainer container = new EntityModelContainer();

            container.DeviceMessageSet.Add(message);

            DeviceMessage m = container.DeviceMessageSet.Find(message.Id);

            m.Administrator = container.AdministratorSet.Find(m.RecipientCode);
            m.Device        = container.DeviceSet.Find(m.SenderCode);

            Administrator recipient = container.AdministratorSet.Find(m.RecipientCode);

            recipient.DeviceMessage.Add(m);

            container.SaveChanges();
        }
        private void MessageList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int row         = MessageList.SelectedCells[0].RowIndex;
            int messageCode = (int)MessageList.Rows[row].Cells[3].Value;

            if (MessageList.Rows[row].Cells[1].Value.ToString() == "Запрос доступа к системе")
            {
                DoctorMessage message = (from userMessage in _container.DoctorMessageSet.AsParallel()
                                         where userMessage.Id == messageCode
                                         select userMessage).ToList()[0];

                message = _container.DoctorMessageSet.Find(message.Id);

                ReadMessageForm readMessage = new ReadMessageForm();

                readMessage.needSignUp   = true;
                readMessage.docMessage   = message;
                readMessage.isDocMessage = true;

                DialogResult messageResult = readMessage.ShowDialog();

                if (messageResult == DialogResult.OK)
                {
                    message.Checked = true;
                    _container.SaveChanges();
                }
                else
                {
                    if (messageResult == DialogResult.Ignore)
                    {
                        message.Checked = false;
                        _container.SaveChanges();
                    }
                }
            }
            else
            {
                if (MessageList.Rows[row].Cells[1].Value.ToString() == "Зарегистрирован новый пациент")
                {
                    DoctorMessage message = (from userMessage in _container.DoctorMessageSet.AsParallel()
                                             where userMessage.Id == messageCode
                                             select userMessage).ToList()[0];

                    message = _container.DoctorMessageSet.Find(message.Id);

                    ReadMessageForm readMessage = new ReadMessageForm();

                    readMessage.needSignUp   = false;
                    readMessage.docMessage   = message;
                    readMessage.isDocMessage = true;

                    DialogResult messageResult = readMessage.ShowDialog();

                    if (messageResult == DialogResult.OK)
                    {
                        message.Checked = true;
                        _container.SaveChanges();
                    }
                    else
                    {
                        if (messageResult == DialogResult.Ignore)
                        {
                            message.Checked = false;
                            _container.SaveChanges();
                        }
                    }
                }
                else
                {
                    DeviceMessage message = (from userMessage in _container.DeviceMessageSet.AsParallel()
                                             where userMessage.Id == messageCode
                                             select userMessage).ToList()[0];

                    message = _container.DeviceMessageSet.Find(message.Id);

                    ReadMessageForm readMessage = new ReadMessageForm();

                    readMessage.needSignUp    = false;
                    readMessage.deviceMessage = message;
                    readMessage.isDocMessage  = false;

                    DialogResult messageResult = readMessage.ShowDialog();

                    if (messageResult == DialogResult.OK)
                    {
                        message.Checked = true;
                        _container.SaveChanges();
                    }
                    else
                    {
                        if (messageResult == DialogResult.Ignore)
                        {
                            message.Checked = false;
                            _container.SaveChanges();
                        }
                    }
                }
            }

            //  MessageList.Update();
            RefreshMessages();
            MessageList.Columns[0].Width   = 117;
            MessageList.Columns[1].Width   = 170;
            MessageList.Columns[2].Width   = 100;
            MessageList.Columns[3].Visible = false;
        }