Пример #1
0
        public ChartDataModel GetOrganStateData(int?organId)
        {
            ChartDataModel result = new ChartDataModel(); //{ Titles = new List<string>(), Datas = new List<int>() };

            if (organId == null)                          //SysAdmin
            {
                var item        = new OrganDataProvider().GetPosition("", "");
                var alarmcount  = item.Where(n => n.State == 0).Count();
                var normalcount = item.Where(n => n.State == 1).Count();
                result.Titles = new List <string> {
                    "异常网点", "正常网点"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            else
            {
                var list = new OrganBusiness().GetChildren(organId.Value);

                var alarmcount  = list.FindAll(n => n.State != 1).Count;
                var normalcount = list.Count - alarmcount;
                result.Titles = new List <string> {
                    "异常网点", "正常网点"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            return(result);
        }
Пример #2
0
        public void InsertTest()
        {
            LineDataProvider  _provider = new LineDataProvider();
            double            count     = 0;
            List <string>     ipList    = new IPHelper().GetIPListFromStartHost("192.167.1.1", 20, out count);
            List <OrganModel> organList = new List <OrganModel>();
            List <LineModel>  lineList  = new List <LineModel>();
            double            x         = 0;
            double            y         = 0;
            int    j = 0;
            Random r = new Random();

            for (int i = 0; i < 1000; i++)
            {
                x = r.Next(-200, 200) * 0.1;
                y = r.Next(-200, 200) * 0.1;
                organList.Add(new OrganModel()
                {
                    Name = "数据中心" + i, Description = i.ToString(), ParentId = 43, X = x.ToString(), Y = y.ToString()
                });
            }
            new OrganDataProvider().Insert(organList);

            List <OrganModel> newOrganList = new OrganDataProvider().GetAllItems("", "", "");

            foreach (var item in ipList)
            {
                j = r.Next(43, 1000);
                lineList.Add(new LineModel()
                {
                    AlarmMax = 3, Description = item, LineIP = item, OrganizationId = newOrganList[j].Id, LineType = LineType.mainline, PingInterval = 30, Pingsize = 32, Pingtimes = 4, ServiceProvider = ServiceProviderType.ChinaMobile, Timeout = 2, Name = item
                });
            }
            _provider.Insert(lineList);
        }
Пример #3
0
 public OrganBusiness()
 {
     _provider = new OrganDataProvider();
 }