Beispiel #1
0
        private async void readmitDialog_OnConfirmDown(object sender, RoutedEventArgs e)
        {
            InjectionsManager.changePatientStatusNetwork(Injection.AccessionNumber, "Registered");
            await NewInjection.window.HideMetroDialogAsync(readmitConfirmDialog);

            NewInjection.window.Close();
        }
Beispiel #2
0
        private async void deleteDialog_OnDeleteDown(object sender, RoutedEventArgs e)
        {
            InjectionsManager.removeInjectionNetwork(Injection.AccessionNumber);
            await NewInjection.window.HideMetroDialogAsync(deleteConfirmDialog);

            if (NewInjection.window != null)
            {
                NewInjection.window.Close();
            }
        }
Beispiel #3
0
        public MainWindow()
        {
            ConsoleLogger.Init();

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);

            window = this;

            InitializeComponent();

            WindowConfig.Init();

            //the timer is used to let the window initialize first, then move the screen
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Start();
            timer.Tick += new EventHandler(delegate(object s, EventArgs a)
            {
                if (WindowConfig.IsAutoRestart == 1)
                {
                    this.Height      = WindowConfig.WindowHeight;
                    this.Width       = WindowConfig.WindowWidth;
                    this.Top         = WindowConfig.WindowTop;
                    this.Left        = WindowConfig.WindowLeft;
                    this.WindowState = WindowConfig.WindowState;
                }
                //reset the window config
                WindowConfig.IsAutoRestart = 0;
                WindowConfig.Save();

                timer.Stop();
            });



            DataContext = new MainWindowViewModel();

            //set the default selection to 1
            leftControlBar.SelectedIndex = 0;

            Modality.AddDefault();
            RP.AddDefault();
            Doctor.AddDefault();
            Room.AddDefault();

            //Start the timer, restart the program automatically every day
            WindowAutoRestart.Init();

            InjectionsManager.Init();

            NetworkManager.Init(this, WindowConfig.IsAutoRestart == 1, WindowConfig.IsServer == 1);
        }
Beispiel #4
0
        public void add()
        {
            //Clone the observable collection into another collection
            ObservableCollection <RP> RPs = new ObservableCollection <RP>();

            foreach (RP rP in ((NewInjection)NewInjection.window).RP_injection.SelectedItems)
            {
                RPs.Add(rP);
            }

            //Convert the uptakeindex into float;
            float UptakeTime;

            switch (UptakeTimeIndex)
            {
            case 0:
                UptakeTime = 60f;
                break;

            case 1:
                UptakeTime = 90f;
                break;

            default:
                UptakeTime = 60f;
                break;
            }

            //add new injection
            if (Injection == null)
            {
                InjectionsManager.modInjectionNetWork("", SelectedModality, patientID, patientSurname, patientLastname, UniqueExamIdentifier, ExamCode, DateOfBirth, GenderIndex == 0, InpatientIndex == 0, WardNumber, RPs, SelectedDoctor, UptakeTime, DateTime, SelectedRoom, isContrast, isDelay, patientStatus);
                Console.Out.WriteLine("adding injection with patient ID: " + patientID);
            }
            //modify existing injection
            else
            {
                InjectionsManager.modInjectionNetWork(Injection.AccessionNumber, SelectedModality, patientID, patientSurname, patientLastname, UniqueExamIdentifier, ExamCode, DateOfBirth, GenderIndex == 0, InpatientIndex == 0, WardNumber, RPs, SelectedDoctor, UptakeTime, DateTime, SelectedRoom, isContrast, isDelay, patientStatus);
                Console.Out.WriteLine("modifying injection with patient ID:" + patientID);
            }

            NewInjection.window.Close();
        }
Beispiel #5
0
        /// <summary>Выполняет задания, назначенные в указанном проекте</summary>
        /// <param name="Project">Проект для обработки</param>
        public void Process(GenerationProject Project)
        {
            var injectionsManager = new InjectionsManager();
            var extensionsManager = new ReflectingExtensionsManager();

            foreach (GenerationTask task in Project.Tasks)
            {
                var             propertiesResolverFactory = new PropertiesResolverFactory(task.Globals);
                IActionsManager actionsManager            = new ProjectActionsManager(Project.Actions, injectionsManager,
                                                                                      new TemplateProcessor(propertiesResolverFactory,
                                                                                                            extensionsManager));

                foreach (GenerationActionCalling actionCalling in task.CallingActions)
                {
                    actionsManager.ExecuteAction(actionCalling.ActionName, actionCalling.TargetFileName, task.Items);
                }
            }

            injectionsManager.Apply();
        }
Beispiel #6
0
        private static async void StartServer(object sender, RoutedEventArgs e)
        {
            if (System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners().Any(p => p.Port == 15000))
            {
                if (!simultaneousErrorDialog.IsVisible)
                {
                    await window.ShowMetroDialogAsync(simultaneousErrorDialog);
                }
                simultaneousErrorDialog.MessageText.Content = "Error when starting server- UDP port already occupied. Check whether there is another instance running";
                Console.Out.WriteLine("[NetworkManager] error when starting server- UDP port already occupied. Check whether there is another instance running");
                return;
            }

            server = new Server();

            connected    = true;
            clientNumber = 0;
            clientCount  = 0;

            //client view object for displaying in the network page
            ClientViewObject.Add(clientNumber, NetworkUtil.GetMachineName(), NetworkUtil.GetLocalIPAddress());

            //TODO: add -= when server shut down?
            server.MessageReceivedFromClientEvent += MessageReceivedFromClient;
            server.ClientConnectedEvent           += ClientConnected;
            server.ClientDisconnectedEvent        += ClientDisconnected;


            //load all patient in registered patient after starting server, the client will load the patient via requesting
            PatientManager.LoadAllPatientFromSchedular();
            PatientManager.LoadAllPatient();

            //load all the injection after starting server, the client will load the injection via contacting with server
            InjectionsManager.loadAllInjections();

            if (twoChoiceDialog.IsVisible)
            {
                await window.HideMetroDialogAsync(twoChoiceDialog);
            }
            await window.ShowMessageAsync("No server found. \nStarted as server instead!", "Server Name: " + NetworkUtil.GetMachineName() + "\nServer IP:" + NetworkUtil.GetLocalIPAddress());
        }
Beispiel #7
0
        /// <summary>
        /// Handle message if client recieved anything from server
        ///
        /// The message contain two part,
        /// first part is a identifier (string) to distinguish what type of message is it
        /// second part is the message content
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void MessageReceivedFromServer(object sender, MessageReceivedFromServerEventArgs args)
        {
            Console.WriteLine("[NetworkManager-Client] Recieved message from server");
            string[] messages = Encoding.UTF8.GetString(args.Data).Split(new char[] { '_' }, 2);
            try
            {
                Console.Out.WriteLine("[NetworkManager-Client] Recieved message type: " + messages[0]);
                Console.Out.WriteLine("[NetworkManager-Client] The message is: " + messages[1]);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
            }

            switch (messages[0])
            {
            case "autoRestart":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving Auto Restart Request from server, proceed to restart client");

                //disable connection to prevent reconnection to server before restarting
                connectionEnabled = false;



                window.Dispatcher.Invoke(() =>
                {
                    Console.Out.WriteLine("[NetworkManager-Client] Start timer of 15 seconds");
                    DispatcherTimer timer = new DispatcherTimer();
                    timer.Interval        = TimeSpan.FromMinutes(1);
                    timer.Start();
                    timer.Tick += new EventHandler(delegate(object s, EventArgs a)
                    {
                        //only restart if it is a different date
                        if (WindowAutoRestart.isSameDate())
                        {
                            Console.Out.WriteLine("[NetworkManager-Client] It is still yesterday. Wait until auto restart.");
                        }
                        else
                        {
                            Console.Out.WriteLine("[NetworkManager-Client] AutoRestarting...");
                            WindowAutoRestart.AutoRestart();
                            timer.Stop();
                        }
                    });
                });
                break;

            case "setClientNumber":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving Set ClientNumber Request from server, proceed to set self ClientNumber");
                window.Dispatcher.Invoke(() =>
                {
                    clientNumber = int.Parse(messages[1]);
                    Console.Out.WriteLine("[NetworkManager-Client] My client number is:" + clientNumber);
                });
                break;

            case "addAllClientInfo":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving Add All ClientInfo Request from server, proceed to add client view objects for network page");
                window.Dispatcher.Invoke(() =>
                {
                    ClientViewObject.XMLtoClient(XElement.Parse(messages[1]));
                });
                break;

            case "modInjection":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving Mod Injection Request from server, proceed to modify injection");
                window.Dispatcher.Invoke(() =>
                {
                    InjectionsManager.modInjection(XElement.Parse(messages[1]));
                });
                break;

            case "changePatientStatus":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving change PatientStatus Request from server, proceed to change PatientStatus");
                window.Dispatcher.Invoke(() =>
                {
                    //try to splite the message back to (accessionNumber, patientStatus)
                    if (messages[1].Split('^').Length == 2)
                    {
                        InjectionsManager.changePatientStatus(messages[1].Split('^')[0], messages[1].Split('^')[1]);
                    }
                    else
                    {
                        Console.Out.WriteLine("[NetworkManager-Client_changePatientStatus()] Corrupted changePatientStatus message, require 2 input. Message: " + messages[1]);
                    }
                });
                break;

            //////////////////////////////////////////////////
            ////////    Obsolete    //////////////////////////
            case "dischargeInjection":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving Discharge Injection Request from server, proceed to discharge injection");
                window.Dispatcher.Invoke(() =>
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    InjectionsManager.dischargeInjection(messages[1]);
#pragma warning restore CS0618 // Type or member is obsolete
                });
                break;
            //////////////////////////////////////////////////

            case "removeInjection":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving remove Injection Request from server, proceed to remove injection");
                window.Dispatcher.Invoke(() =>
                {
                    InjectionsManager.removeInjection(messages[1]);
                });
                break;

            case "addPatient":
                Console.Out.WriteLine("[NetworkManager-Client] Receiving Add Patient Request from server, proceed to add Patient");
                window.Dispatcher.Invoke(() =>
                {
                    PatientManager.ModPatient(new Patient(XElement.Parse(messages[1])));
                });
                break;

            default:
                Console.Error.WriteLine("[NetworkManager-Client] Unhandled message type: " + messages[0]);
                break;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Handle message if client send anything to the server
        ///
        /// The message contain two part,
        /// first part is a identifier (string) to distinguish what type of message is it
        /// second part is the message content
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void MessageReceivedFromClient(object sender, MessageReceivedFromClientEventArgs args)
        {
            string[] messages = Encoding.UTF8.GetString(args.Data).Split(new char[] { '_' }, 2);
            try
            {
                Console.Out.WriteLine("[NetworkManager-Server] Recieved message type: " + messages[0]);
                Console.Out.WriteLine("[NetworkManager-Server] The message is: " + messages[1]);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
            }

            switch (messages[0])
            {
            case "ConnectionSucessful":
                Console.Out.WriteLine("[NetworkManager-Server] New connection established with client IP: {0}, Name: {1}", args.IpPort, messages[1]);
                window.Dispatcher.Invoke(() =>
                {
                    //Send the clientNumber to the client
                    clientCount += 1;
                    Console.Out.WriteLine("[NetworkManager-Server] Setting client with IPPort: {0} as client number {1}", args.IpPort, clientCount);
                    server.TCPSendMessage(args.IpPort, "setClientNumber", clientCount.ToString());

                    //Add the client view object for networking page
                    ClientViewObject.Add(clientCount, messages[1], args.IpPort);
                });
                break;

            case "modInjection":
                Console.Out.WriteLine("[NetworkManager-Server] Receiving Mod Injection Request from client, proceed to modify injection");
                window.Dispatcher.Invoke(() =>
                {
                    server.TCPBroadcastMessage("modInjection", messages[1]);
                    InjectionsManager.modInjection(XElement.Parse(messages[1]));
                });
                break;

            case "requestInitialInjection":
                Console.Out.WriteLine("[NetworkManager-Server] Receiving Initial Injection Request from client, proceed to send all injection to client with ip: {0}", args.IpPort);
                foreach (Injection injection in InjectionsManager.injections)
                {
                    server.TCPSendMessage(args.IpPort, "modInjection", injection.toXML().ToString());
                }
                break;

            case "requestInitialPatient":
                Console.Out.WriteLine("[NetworkManager-Server] Receiving Initial Patient Request from client, proceed to send all patient to client with ip: {0}", args.IpPort);
                foreach (Patient patient in PatientManager.Patients)
                {
                    server.TCPSendMessage(args.IpPort, "addPatient", patient.toXML().ToString());
                }
                break;

            //////////////////////////////////////////////////
            ////////    Obsolete    //////////////////////////
            case "dischargeInjection":
                Console.Out.WriteLine("[NetworkManager-Server] Receiving discharge Injection Request from client, proceed to discharge injection");
                window.Dispatcher.Invoke(() =>
                {
                    server.TCPBroadcastMessage("dischargeInjection", messages[1]);
#pragma warning disable CS0618 // Type or member is obsolete
                    InjectionsManager.dischargeInjection(messages[1]);
#pragma warning restore CS0618 // Type or member is obsolete
                });
                break;
            //////////////////////////////////////////////////

            case "changePatientStatus":
                Console.Out.WriteLine("[NetworkManager-Server] Receiving changePatientStatus Request from client, proceed to change PatientStatus");
                window.Dispatcher.Invoke(() =>
                {
                    server.TCPBroadcastMessage("changePatientStatus", messages[1]);
                    //try to splite the message back to (accessionNumber, patientStatus)
                    if (messages[1].Split('^').Length == 2)
                    {
                        InjectionsManager.changePatientStatus(messages[1].Split('^')[0], messages[1].Split('^')[1]);
                    }
                    else
                    {
                        Console.Out.WriteLine("[NetworkManager-Server_changePatientStatus()] Corrupted changePatientStatus message, require 2 input. Message: " + messages[1]);
                    }
                });

                break;

            case "removeInjection":
                Console.Out.WriteLine("[NetworkManager-Server] Receiving remove Injection Request from client, proceed to remove injection");
                window.Dispatcher.Invoke(() =>
                {
                    server.TCPBroadcastMessage("removeInjection", messages[1]);
                    InjectionsManager.removeInjection(messages[1]);
                });
                break;

            default:
                Console.Error.WriteLine("[NetworkManager-Server] Unhandled message type: " + messages[0]);
                break;
            }

            try
            {
                window.Dispatcher.Invoke(() =>
                {
                    ClientViewObject.GetClientViaIP(args.IpPort).UpdateMessage(messages[0], messages[1]);
                });
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
            }
        }