public ReportView(int id)
        {
            InitializeComponent();

            var list = ReportWrapper.GetReports(id);

            if (list.Count != 0)
            {
                lstReports.ItemsSource = list;
            }

            var agentlist    = AgentWrapper.GetAllAgents();
            var informerlist = InformerWrapper.GetAllInformers();

            foreach (var i in agentlist)
            {
                authorlist.Add(new Person(i.Id, "", "", i.Name));
            }

            foreach (var i in informerlist)
            {
                authorlist.Add(new Person(i.Id, "", "", i.Name));
            }

            cmbAuthor.ItemsSource = authorlist;

            observedlist = ObservedWrapper.GetAllObserved();

            cmbObserved.ItemsSource = observedlist;
        }
예제 #2
0
        private void OnAgentSelected(int?agentId)
        {
            AgentWrapper selectedAgent = null;

            // Get the agent entity with the selected ID.
            if (agentId.HasValue)
            {
                selectedAgent = _dataService.GetAgents(a => a.ID == agentId.Value).SingleOrDefault();
            }

            // Get a reference to the main region.
            IRegion ribbonRegion = _regionManager.Regions[RegionNames.RibbonRegion];

            if (ribbonRegion == null)
            {
                return;
            }

            // Check to see if we need to create an instance of the view.
            var view = ribbonRegion.Views.SingleOrDefault() as IAgentsRibbonTabView;

            // Set the current agent property on the view model.
            if (view != null && view.ViewModel != null)
            {
                view.ViewModel.CurrentEntity = selectedAgent;
            }
        }
        private void btnGetAllAgents_Click(object sender, RoutedEventArgs e)
        {
            var list = AgentWrapper.GetAllAgents();

            if (list.Count != 0)
            {
                lstAgents.ItemsSource = list;
            }
        }
예제 #4
0
 public void RunAgentThread(IAgent agent)
 {
     lock (_threadList)
     {
         IAgentWrapper wrapper = new AgentWrapper(agent);
         Thread th = new Thread(new ThreadStart(wrapper.DoWork));
         th.Name = "AT:" + wrapper.Name;
         _threadList.Add(th);
         LOG.Debug("Starting Agent thread :" + th.Name);
         th.Start();
     }
 }
예제 #5
0
        private List <AgentWrapper> WrapAgents(IEnumerable <Agent> agents)
        {
            var agentWrappers = new List <AgentWrapper>();

            foreach (var agent in agents)
            {
                var wrapperAgent = new AgentWrapper()
                {
                    Data   = agent.Data,
                    ID     = agent.ID,
                    Name   = agent.Name,
                    Status = agent.Status
                };
                agentWrappers.Add(wrapperAgent);
            }

            return(agentWrappers);
        }
        private void OnAgentSelected(int?agentId)
        {
            AgentWrapper selectedAgent = null;

            // Get the agent entity with the selected ID.
            if (agentId.HasValue)
            {
                selectedAgent = _dataService.GetAgents(a => a.ID == agentId.Value).SingleOrDefault();
            }

            // Get a reference to the main region.
            IRegion mainRegion = _regionManager.Regions[RegionNames.RightContentRegion];

            if (mainRegion == null)
            {
                return;
            }

            // Check to see if we need to create an instance of the view.
            var view = mainRegion.GetView("AgentSummaryView") as IAgentSummaryView;

            if (view == null)
            {
                // Create a new instance of the IAgentDetailsView implementation using the Unity container.
                view = _container.Resolve <IAgentSummaryView>();

                // Add the view to the right region. This automatically activates the view too.
                mainRegion.Add(view, "AgentSummaryView");
            }
            else
            {
                // The view has already been added to the region so just activate it.
                mainRegion.Activate(view);
            }

            // Set the current agent property on the view model.
            if (view.ViewModel != null)
            {
                view.ViewModel.CurrentEntity = selectedAgent;
            }
        }
        private void btnSaveAgent_Click(object sender, RoutedEventArgs e)
        {
            try {
                Agent agent = new Agent();

                agent.Id          = int.Parse(txtAgentId.Text);
                agent.Name        = txtAgentName.Text;
                agent.Nationality = txtAgentNationality.Text;
                agent.CPR         = txtAgentCPR.Text;

                AgentWrapper.SaveAgent(agent);

                // Try to save appearance
                if (txtAgentHeight.Text != "" || txtAgentEyecolor.Text != "" || txtAgentHaircolor.Text != "")
                {
                    Appearance appearance;
                    if (agent.Id == -1)
                    {
                        appearance = new Appearance(int.Parse(txtAgentHeight.Text), txtAgentEyecolor.Text, txtAgentHaircolor.Text, InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        appearance = new Appearance(int.Parse(txtAgentHeight.Text), txtAgentEyecolor.Text, txtAgentHaircolor.Text, agent.Id);
                    }

                    InfoWrapper.SaveAppearence(appearance);
                }

                // Try to save address
                if (txtAgentStreet.Text != "" || txtAgentAreacode.Text != "")
                {
                    Address address;
                    // Check if it's a new agent
                    if (agent.Id == -1)
                    {
                        address = new Address(txtAgentStreet.Text, int.Parse(txtAgentAreacode.Text), InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        address = new Address(txtAgentStreet.Text, int.Parse(txtAgentAreacode.Text), agent.Id);
                    }

                    InfoWrapper.SaveAddress(address);
                }

                // Try to save image
                if (txtAgentImagePath.Text != "")
                {
                    if (File.Exists(txtAgentImagePath.Text))
                    {
                        FileStream   fs = new FileStream(txtAgentImagePath.Text, FileMode.Open, FileAccess.Read);
                        BinaryReader br = new BinaryReader(fs);

                        Database.Entities.Image img;

                        // if new agent
                        if (agent.Id == -1)
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), InfoWrapper.GetLastPersonId());
                        }
                        else
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), agent.Id);
                        }

                        InfoWrapper.SaveImage(img);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show($"Der er sket en fejl. Er alle felterne korrekt udfyldt?\n\n{ex.Message}");
            }
        }