Esempio n. 1
0
        //public IEnumerable<AlarmLogModel> GetLogList(int alarmId)
        //{
        //    string condition = " and alarmId = @alarmId";
        //    var searchObj = new { alarmId = alarmId };
        //    return _provider.GetLog(condition, searchObj);
        //}


        public IEnumerable <AlarmModel> GetList(int organId)
        {
            int[] organs = _organBusiness.GetChildren(organId).Select(m => m.Id).ToArray();

            string condition = new ConditionHelper().And("OrganId", organs, CompareType.In)
                               .And("Confirm", 0, CompareType.Equal)
                               .ToString();
            var searchObj = new { OrganId = organs, Confirm = 0 };

            return(_provider.GetList(condition, searchObj, "  order by LastTime desc  LIMIT 0,100"));
        }
Esempio n. 2
0
        public PageableData <TelbookModel> GetPage(string name, string telephone, int limit, int offset)
        {
            string condition = new ConditionHelper().And("Name", name, CompareType.Like)
                               .And("Telephone", telephone, CompareType.Like)
                               .ToString();
            var searchObj = new
            {
                Name      = $"%{name}%",
                Telephone = $"%{telephone}%"
            };

            return(_provider.GetPage(condition, searchObj, "order by Id ASC", offset, limit));
        }
Esempio n. 3
0
        public object GetPage(string name, int?state, int?typeId, int limit, int offset)
        {
            string condition = new ConditionHelper().And("Name", ref name, CompareType.Like)
                               .And("State", state, CompareType.Equal)
                               .ToString();
            var searchObj = new
            {
                Name  = name,
                State = state
            };

            return(_provider.GetAllItems(condition, searchObj, " order by Id ASC"));
        }
Esempio n. 4
0
        /// <summary>
        /// 返回Line的页数据
        /// </summary>
        /// <param name="organizationName"></param>
        /// <param name="name"></param>
        /// <param name="lineIP"></param>
        /// <param name="user"></param>
        /// <param name="limit"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public PageableData <LineModel> GetPage(string organizationName, string name, string lineIP, int OrganId, int limit, int offset)
        {
            string condition = "";
            var    searchObj = new object();

            int[] organs = _organBusiness.GetChildren(OrganId).Select(m => m.Id).ToArray();
            condition = new ConditionHelper().And("OrganizationName", ref organizationName, CompareType.Like)
                        .And("Name", ref name, CompareType.Like)
                        .And("OrganizationId", organs, CompareType.In)
                        .And("LineIP", lineIP, CompareType.Equal)
                        .ToString();
            searchObj = new { OrganizationName = organizationName, Name = name, LineIP = lineIP, OrganizationId = organs };

            return(_provider.GetPage(condition, searchObj, " ", offset, limit));
        }
Esempio n. 5
0
        public PageableData <UserModel> GetPage(string userName, int?state, int?typeId, int limit, int offset)
        {
            string condition = new ConditionHelper().And("Username", ref userName, CompareType.Like)
                               .And("State", state, CompareType.Equal)
                               //.And("TypeId", typeId, CompareType.Equal)
                               .ToString();


            var searchObj = new
            {
                Username = string.Format("%{0}%", userName),
                State    = state
            };

            return(_provider.GetPage(condition, searchObj, " order by Id ASC", offset, limit));
        }
Esempio n. 6
0
        public string GetTelephone(params string[] ids)
        {
            string condition = new ConditionHelper().And("Id", new { Id = ids }, CompareType.In).ToString();
            var    searchObj = new { Id = ids };
            var    list      = _provider.GetList(condition, searchObj).ToList();
            string result    = string.Empty;

            list.ForEach(n =>
            {
                result += $"{n.Name}-{n.Telephone},";
            });
            if (!string.IsNullOrEmpty(result))
            {
                result = result.Substring(0, result.Length - 1);
            }
            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 获取部门地址及状态
        /// </summary>
        /// <param name="id">父部门Id,空为全部</param>
        /// <returns></returns>
        public List <OrganModel> GetPosition(int?id)
        {
            List <OrganModel> items;

            if (id == null)
            {
                items = _provider.GetPosition("", null);
            }
            else
            {
                var    organs    = GetChildren(id.Value).Select(n => n.Id).ToArray();
                string condition = new ConditionHelper().And("Id", organs, CompareType.In).ToString();
                var    searchObj = new { Id = organs };
                items = _provider.GetPosition(condition, searchObj);
            }
            return(items);
        }
Esempio n. 8
0
        public PageableData <LogModel> GetPage(int?logType, DateTime?startTime, DateTime?endTime, int limit, int offset)
        {
            string conditionTimeStr = "";

            if (startTime != null)
            {
                conditionTimeStr += " AND TIME >=@StartTime";
            }
            if (endTime != null)
            {
                conditionTimeStr += " AND TIME <=@EndTime";
            }
            if (conditionTimeStr.Length > 0)
            {
                conditionTimeStr = conditionTimeStr.Substring(4);
            }
            //var condition = new ConditionHelper().And("Type", logType, CompareType.Equal)
            //                                        .And(conditionTimeStr)
            //                                         .ToString();
            string condition = string.Empty;

            if (logType > -1)
            {
                condition = new ConditionHelper().And("Type", logType, CompareType.Equal)
                            .And(conditionTimeStr)
                            .ToString();
            }
            condition += new ConditionHelper().And(conditionTimeStr).ToString();
            var searchObj = new
            {
                Type      = logType,
                StartTime = startTime,
                EndTime   = endTime
            };

            return(_provider.GetPage(condition, searchObj, " ORDER BY TIME DESC", offset, limit));
        }
Esempio n. 9
0
        public void Del(params int[] ids)
        {
            string condition = new ConditionHelper().And("Id", new { Id = ids }, CompareType.In).ToString();

            _provider.Del(condition, ids);
        }
Esempio n. 10
0
        /// <summary>
        /// 将总天数划分时间段返回时间节点报警总数的集合
        /// </summary>
        /// <param name="startTime">起始时间</param>
        /// <param name="endTime">终止时间</param>
        /// <param name="groupDays">时间组节点天数</param>
        /// <param name="totalDays">总天数</param>
        /// <returns></returns>
        public Dictionary <DateTime, int> GetLogDataForStatistics(DateTime?startTime, DateTime?endTime, int[] alarmIds, int groupDays, int totalDays)
        {
            #region condition
            string conditionIPStr = "";
            if (startTime != null)
            {
                conditionIPStr += " AND LastTime >= @startTime";
            }
            if (endTime != null)
            {
                conditionIPStr += " AND LastTime <= @endTime";
            }
            if (conditionIPStr.Length > 0)
            {
                conditionIPStr = conditionIPStr.Substring(4);
            }

            string condition = new ConditionHelper().And(conditionIPStr)
                               .And("AlarmId", alarmIds, CompareType.In).ToString() + " and state > 0 order by LastTime asc";
            var searchObj = new { startTime = startTime, endTime = endTime, AlarmId = alarmIds };
            #endregion

            List <AlarmModel>          list        = _provider.GetList(condition, searchObj, "").ToList();
            Dictionary <DateTime, int> dicDayCount = new Dictionary <DateTime, int>();
            Dictionary <DateTime, int> result      = new Dictionary <DateTime, int>();

            if (list.Count > 0)
            {
                int      tempCount = 0;
                DateTime tempTime  = list[0].LastTime.Date;
                dicDayCount.Add(tempTime, tempCount);

                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].LastTime.Date == tempTime)
                    {
                        dicDayCount[tempTime] += list[i].AlarmCount;
                    }
                    else
                    {
                        tempTime  = list[i].LastTime.Date;
                        tempCount = list[i].AlarmCount;
                        dicDayCount.Add(tempTime, tempCount);
                    }
                }

                //开始生成节点
                for (int i = groupDays; i < totalDays + groupDays; i++)
                {
                    if (i % groupDays == 0)
                    {
                        tempTime  = startTime.Value.AddDays(i).Date;
                        tempCount = !dicDayCount.ContainsKey(tempTime) ? 0 : dicDayCount[tempTime];
                        result.Add(tempTime, tempCount);
                    }
                    else
                    {
                        result[tempTime] += !dicDayCount.ContainsKey(startTime.Value.AddDays(i).Date) ? 0 : dicDayCount[startTime.Value.AddDays(i).Date];
                    }
                }
            }
            return(result);
        }