Exemplo n.º 1
0
        async void GetData()
        {
            AgentCollection data = await Task.Run(() => GetMachData());

            agents.RemoveAllViews();
            foreach (Agent agent in data.Agents)
            {
                TextView view = new TextView(ApplicationContext);
                view.SetText(agent.Name, null);
                view.Gravity = Android.Views.GravityFlags.CenterHorizontal;
                if (agent.IsDead())
                {
                    view.SetTextColor(Color.Red);
                }
                else if (agent.IsIdle())
                {
                    view.SetTextColor(Color.White);
                }
                else
                {
                    view.SetTextColor(Color.Green);
                }
                view.SetTextSize(Android.Util.ComplexUnitType.Sp, 25);
                view.Click += delegate {
                    StartActivity(typeof(AgentStatus));
                };
                agents.AddView(view);
            }
            AllAgents = data;
        }
Exemplo n.º 2
0
        public string FocusOn(int userid, int agentid)
        {
            try
            {
                using (shhouseEntities ent = new shhouseEntities())
                {
                    var Single = ent.AgentCollection.Where(p => p.UserID == userid && p.AgentID == agentid).FirstOrDefault();
                    if (Single == null)
                    {
                        var AgentCollection = new AgentCollection
                        {
                            UserID  = userid,
                            AgentID = agentid,
                            AddTime = DateTime.Now
                        };
                        ent.AgentCollection.Add(AgentCollection);
                        ent.SaveChanges();
                    }
                }

                return(JsonConvert.SerializeObject(new repmsg {
                    state = 1, msg = "关注成功!"
                }));
            }
            catch
            {
                return(JsonConvert.SerializeObject(new repmsg {
                    state = 0, msg = "暂无数据,请稍后再试!"
                }));
            }
        }
Exemplo n.º 3
0
        private void AddAgent(string agent)
        {
            if (AllAgents == null)
            {
                AllAgents = new AgentCollection();
                AllAgents.AddAgent(new Agent(agent));
            }
            else
            {
                AllAgents.AddAgent(new Agent(agent));
            }
            TextView view = new TextView(ApplicationContext);

            view.SetText(agent, null);
            view.Gravity = Android.Views.GravityFlags.CenterHorizontal;
            view.Click  += (sender, e) =>
            {
                StartActivity(typeof(AgentStatus));
            };
            RunOnUiThread(() => agents.AddView(view));
        }
Exemplo n.º 4
0
        static AgentCollection GetMachData()
        {
            AgentCollection col = AgentAPI.GetAllAgents();

            return(col);
        }