예제 #1
0
        public ActionResult DeviceList(UISmokeDetectorStatus?uiStatus)
        {
            ViewBag.status = uiStatus;
            DeviceListModel model = new DeviceListModel();

            if (curentUser.UserType == UserType.Installer)
            {
                QF_SmokeDetector filter = new QF_SmokeDetector();
                filter.InstallerSysNo = curentUser.ManagerSysNo.Value;
                filter.Status         = uiStatus;
                filter.PageIndex      = 0;
                filter.PageSize       = 10;
                filter.SortFields     = "InstalledTime desc";
                var allsmks = SmokeDetectorServices.LoadSmokeDetectorsByInstaller(curentUser.ManagerSysNo.Value).Where(e => e.Status != SmokeDetectorStatus.Delete).ToList();
                model.CountInfo = new SmokeDetectorCount
                {
                    ALLSmokeCount = allsmks.Count,
                    OfflineCount  = (allsmks.Where(e => e.UIStatus == UISmokeDetectorStatus.OffLine) ?? new List <SmokeDetector>()).Count(),
                    OnlineCount   = (allsmks.Where(e => e.UIStatus == UISmokeDetectorStatus.Online) ?? new List <SmokeDetector>()).Count(),
                    LowPowerCount = (allsmks.Where(e => e.UIStatus == UISmokeDetectorStatus.LowPowerWarning) ?? new List <SmokeDetector>()).Count(),
                    WarningCount  = (allsmks.Where(e => e.UIStatus == UISmokeDetectorStatus.FireWarning) ?? new List <SmokeDetector>()).Count(),
                };
                //model.CountInfo.OnlineCount = model.CountInfo.ALLSmokeCount - model.CountInfo.OfflineCount;
                var result = SmokeDetectorServices.QuerySmokeDetectorList(filter);
                model.DeviceList = new QueryResult <QR_SmokeDetector>();
                model.DeviceList = result;
            }
            else
            {
                QF_UserDetector filter = new QF_UserDetector();
                filter.PageIndex   = 0;
                filter.PageSize    = 10;
                filter.Status      = uiStatus;
                filter.ClientSysNo = curentUser.UserSysNo;
                model.CountInfo    = SmokeDetectorServices.LoadUserSmokeDetectorCount(curentUser.UserSysNo);
                QueryResult <QR_SmokeDetector> list = SmokeDetectorServices.LoadUserSmokeDeletetorList(filter);
                model.DeviceList = new QueryResult <QR_SmokeDetector>();
                model.DeviceList = list;
            }
            ViewBag.UserType = curentUser.UserType;
            return(View(model));
        }