Esempio n. 1
0
        /// <summary>
        /// 加载烟感器的数量
        /// </summary>
        /// <param name="companySysNo"></param>
        /// <returns></returns>
        public static List <AddressWarn> GetAddressWarnCount(List <int> addressIds)
        {
            var signleSql = string.Empty;


            DataCommand cmd = new DataCommand("GetAddressWarnCount");

            signleSql = cmd.CommandText;

            var allAddress = AddressDA.GetAddressBySysNos(addressIds);


            for (int i = 0; i < addressIds.Count; i++)
            {
                var addSql = signleSql.Replace("#AddressSysNo", addressIds[i].ToString());

                //var addSql = currentSql.Replace("#STRADDRESS#", $" AND AddressCode LIKE '{address.Code}%'");
                if (i == 0)
                {
                    cmd.CommandText = addSql;
                }
                else
                {
                    cmd.CommandText += " union " + addSql;
                }
            }



            List <AddressWarn> result = cmd.ExecuteEntityList <AddressWarn>();

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 加载烟感器的数量
        /// </summary>
        /// <param name="companySysNo"></param>
        /// <returns></returns>
        public static SmokeDetectorCount LoadSmokeDetectorCountInArea(int companySysNo, int?addressId = null)
        {
            string addressCode = string.Empty;

            if (addressId.HasValue)
            {
                var address = AddressDA.LoadAddress(addressId.Value);
                if (address != null)
                {
                    addressCode = address.Code;
                }
            }

            //烟感器按状态分为 三类  在线(除去 离线与未初始化都时在线)  离线(OutNet,Lost,Offline)  未初始化(status is not)
            List <int> offlineStatus = new List <int> {
                (int)SmokeDetectorStatus.Lost, (int)SmokeDetectorStatus.Offline, (int)SmokeDetectorStatus.OutNet
            };

            DataCommand cmd = new DataCommand("LoadSmokeDetectorCountInArea");

            cmd.SetParameter("@CompanySysNo", DbType.Int32, companySysNo);
            cmd.CommandText = cmd.CommandText.Replace("#offlineStatus", string.Join(",", offlineStatus));
            if (!string.IsNullOrWhiteSpace(addressCode))
            {
                cmd.CommandText = cmd.CommandText.Replace("#STRADDRESS#", $" AND AddressCode LIKE '{addressCode}%'");
            }
            else
            {
                cmd.CommandText = cmd.CommandText.Replace("#STRADDRESS#", "");
            }

            SmokeDetectorCount result = cmd.ExecuteEntity <SmokeDetectorCount>();

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 加载烟感器的数量
        /// </summary>
        /// <param name="companySysNo"></param>
        /// <returns></returns>
        public static List <SmokeDetectorCountAddress> LoadSmokeDetectorCountInArea(int companySysNo, List <int> addressIds)
        {
            var signleSql = string.Empty;

            //烟感器按状态分为 三类  在线(除去 离线与未初始化都时在线)  离线(OutNet,Lost,Offline)  未初始化(status is not)
            List <int> offlineStatus = new List <int> {
                (int)SmokeDetectorStatus.Lost, (int)SmokeDetectorStatus.Offline, (int)SmokeDetectorStatus.OutNet
            };

            DataCommand cmd = new DataCommand("LoadSmokeDetectorCountInAreaMany");

            cmd.SetParameter("@CompanySysNo", DbType.Int32, companySysNo);
            signleSql = cmd.CommandText.Replace("#offlineStatus", string.Join(",", offlineStatus));

            var allAddress = AddressDA.GetAddressBySysNos(addressIds);


            for (int i = 0; i < addressIds.Count; i++)
            {
                var currentSql = signleSql.Replace("#AddressSysNo", addressIds[i].ToString());
                var address    = allAddress.FirstOrDefault(a => a.SysNo == addressIds[i]);

                if (address != null)
                {
                    var addSql = currentSql.Replace("#STRADDRESS#", $" AND AddressCode LIKE '{address.Code}%'");
                    if (i == 0)
                    {
                        cmd.CommandText = addSql;
                    }
                    else
                    {
                        cmd.CommandText += " union " + addSql;
                    }
                }
            }


            List <SmokeDetectorCountAddress> result = cmd.ExecuteEntityList <SmokeDetectorCountAddress>();

            return(result);
        }