Beispiel #1
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     Messager.Caption  = "CCOW Dashboard";
     Text              = "C# " + Messager.Caption;
     Application.Idle += new EventHandler(Application_Idle);
     _ActiveScenario   = ActiveScenario.Load();
     InitializeScenarios();
 }
Beispiel #2
0
        protected override void OnContextChangesPending(int agentCoupon, string contextManager, string[] itemNames, string[] itemValues, int contextCoupon, string managerSignature, ref int outAgentCoupon, ref string[] outitemNames, ref string[] outitemValues, ref int outContextCoupon, ref string agentSignature, ref string decision, ref string reason)
        {
            ActiveScenario scenario = ActiveScenario.Load();

            if (scenario != null)
            {
                string[] names   = (string[])itemNames;
                object[] values  = (object[])itemValues;
                string   patient = string.Empty;

                for (int i = 0; i < names.Length; i++)
                {
                    ContextItem item = new ContextItem(names[i], values[i]);

                    if (((item.Name.ToLower() == "mpi" || item.Name.ToLower() == "mrn") && item.Role.ToLower() == "id" && item.Subject.ToLower() == "patient"))
                    {
                        patient = item.Value.ToString();
                    }
                }

                if (!string.IsNullOrEmpty(patient))
                {
                    Subject       patientSubject = new Subject("Patient");
                    MasterPatient mp             = GetMasterPatient(scenario.Scenario, patient);

                    if (mp != null)
                    {
                        ContextItem item = null;

                        if (mp.BirthDate.HasValue)
                        {
                            item = new ContextItem("Patient.Co.DateTimeOfBirth", mp.BirthDate.Value.ToShortDateString());
                            patientSubject.Items.Add(item);
                        }

                        item = new ContextItem("Patient.Co.Sex", mp.Sex);
                        patientSubject.Items.Add(item);

                        item = new ContextItem("Patient.Co.PatientName", mp.Name);
                        patientSubject.Items.Add(item);
                    }
                    outitemNames = patientSubject.ToItemNameArray();
                    List <string> itemsValuesList = new List <string>();
                    foreach (object obj in patientSubject.ToItemValueArray())
                    {
                        itemsValuesList.Add(obj.ToString());
                    }
                    outitemValues = itemsValuesList.ToArray();
                }
            }
        }
Beispiel #3
0
        protected override void OnContextChangesPending(int agentCoupon, string contextManager, string[] itemNames, string[] itemValues, int contextCoupon, string managerSignature, ref int outAgentCoupon, ref string[] outitemNames, ref string[] outitemValues, ref int outContextCoupon, ref string agentSignature, ref string decision, ref string reason)
        {
            ActiveScenario scenario = ActiveScenario.Load();

            if (scenario != null)
            {
                string[] names  = itemNames;
                string[] values = itemValues;
                string   user   = string.Empty;

                for (int i = 0; i < names.Length; i++)
                {
                    ContextItem item = new ContextItem(names[i], values[i]);

                    if (item.Name.ToLower() == "logon" && item.Role.ToLower() == "id" && item.Subject.ToLower() == "user")
                    {
                        //
                        // Found user name.
                        //
                        user = item.Value.ToString();
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(user))
                {
                    Subject    userSubject = new Subject("User");
                    MasterUser mu          = GetMasterUser(scenario.Scenario, user);

                    if (mu != null)
                    {
                        foreach (ApplicationUser au in mu.ApplicationUsers)
                        {
                            ContextItem item = new ContextItem("User.Id.Logon." + au.ApplicationName);

                            item.Value = string.IsNullOrEmpty(user) ? string.Empty : au.LogonName;
                            userSubject.Items.Add(item);
                        }
                    }

                    outitemNames = userSubject.ToItemNameArray();
                    List <string> itemsValuesList = new List <string>();
                    foreach (object obj in userSubject.ToItemValueArray())
                    {
                        itemsValuesList.Add(obj.ToString());
                    }
                    outitemValues = itemsValuesList.ToArray();
                }
            }
        }
Beispiel #4
0
        public string ContextChangesPending(int agentCoupon, IContextManager contextManager, object itemNames, object itemValues, int contextCoupon, string managerSignature, ref int outAgentCoupon, ref object outitemNames, ref object outitemValues, ref int outContextCoupon, ref string agentSignature, ref string decision, ref string reason)
        {
            ActiveScenario scenario = ActiveScenario.Load();

            if (scenario != null)
            {
                string[] names   = (string[])itemNames;
                object[] values  = (object[])itemValues;
                string   patient = string.Empty;

                for (int i = 0; i < names.Length; i++)
                {
                    ContextItem item = new ContextItem(names[i], values[i]);

                    if (((item.Name.ToLower() == "mpi" || item.Name.ToLower() == "mrn") && item.Role.ToLower() == "id" && item.Subject.ToLower() == "patient"))
                    {
                        patient = item.Value.ToString();
                    }
                }

                if (!string.IsNullOrEmpty(patient))
                {
                    Subject       patientSubject = new Subject("Patient");
                    MasterPatient mp             = GetMasterPatient(scenario.Scenario, patient);

                    if (mp != null)
                    {
                        ContextItem item = new ContextItem("Patient.Id.MPI");

                        item.Value = mp.Id;
                        patientSubject.Items.Add(item);
                        foreach (ApplicationPatient a in mp.ApplicationPatients)
                        {
                            item = new ContextItem("Patient.Id.MRN." + a.ApplicationName);

                            item.Value = a.PatientId;
                            patientSubject.Items.Add(item);
                        }
                    }
                    outitemNames  = patientSubject.ToItemNameArray();
                    outitemValues = patientSubject.ToItemValueArray();
                }
            }
            return("valid");
        }
Beispiel #5
0
        public string ContextChangesPending(int agentCoupon, IContextManager contextManager, object itemNames, object itemValues, int contextCoupon, string managerSignature, ref int outAgentCoupon, ref object outitemNames, ref object outitemValues, ref int outContextCoupon, ref string agentSignature, ref string decision, ref string reason)
        {
            ActiveScenario scenario = ActiveScenario.Load();

            if (scenario != null)
            {
                string[] names  = (string[])itemNames;
                object[] values = (object[])itemValues;
                string   user   = string.Empty;

                for (int i = 0; i < names.Length; i++)
                {
                    ContextItem item = new ContextItem(names[i], values[i]);

                    if (item.Name.ToLower() == "logon" && item.Role.ToLower() == "id" && item.Subject.ToLower() == "user")
                    {
                        //
                        // Found user name.
                        //
                        user = item.Value.ToString();
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(user))
                {
                    Subject    userSubject = new Subject("User");
                    MasterUser mu          = GetMasterUser(scenario.Scenario, user);

                    if (mu != null)
                    {
                        ContextItem item = new ContextItem("User.Co.Name");

                        item.Value = mu.Name;
                        userSubject.Items.Add(item);
                    }

                    outitemNames  = userSubject.ToItemNameArray();
                    outitemValues = userSubject.ToItemValueArray();
                }
            }
            return(string.Empty);
        }
Beispiel #6
0
 private void LoginDialog_Load(object sender, EventArgs e)
 {
     _ActiveScenario = ActiveScenario.Load();
     LoadMasterUsers();
     Application.Idle += new EventHandler(Application_Idle);
 }
Beispiel #7
0
        private void HandleShipRequest(object sender, ShipMessage msg)
        {
            ShipPeer    peer    = sender as ShipPeer;
            ShipRequest request = msg as ShipRequest;

            JoinShipResponce responce = new JoinShipResponce();

            PlayerShip shipToLink = null;

            if (peer.LinkedShip != null)
            {
                shipToLink = peer.LinkedShip;
            }
            else
            {
                if (request.Join)
                {
                    shipToLink = PlayerShips.Find((x) => x.LinkedShip.GUID == request.RequestedShipID);
                    if (shipToLink == null || shipToLink.Locked && shipToLink.Password != request.Password)
                    {
                        responce.Error   = true;
                        responce.Message = "NoShipToJoin";
                        peer.Send(responce);
                        return; // nope!
                    }
                    else
                    {
                        if (!shipToLink.ControlingPeers.Contains(peer))
                        {
                            shipToLink.ControlingPeers.Add(peer);
                        }

                        peer.LinkedShip = shipToLink;
                    }
                }
            }

            if (shipToLink == null)
            {
                var template = TemplateDatabase.GetTemplate(request.RequestedShipID);
                int shipID   = ActiveScenario.SpawnPlayableShip(peer.Connection.RemoteUniqueIdentifier.ToString(), template == null ? string.Empty : template.Name, request.Name);

                var ship = ZoneManager.GetFirstMatch(new PlayableShipFinder(shipID)) as Ship;

                shipToLink            = new PlayerShip();
                shipToLink.LinkedShip = ship;
                shipToLink.ControlingPeers.Add(peer);
                shipToLink.Locked   = request.Password != string.Empty;
                shipToLink.Password = request.Password;

                peer.LinkedShip = shipToLink;
                PlayerShips.Add(shipToLink);
            }

            // send back the responce with the ship they are on
            responce.Error   = false;
            responce.Message = shipToLink.LinkedShip.Name;
            responce.ShipID  = shipToLink.LinkedShip.GUID;
            peer.Send(responce);

            // send an info and status update
        }