public List <FlowDay_t> GetAllFlowDayByFMUid(Guid fmuid)
        {
            dpnetwork_data_20160419_NewEntities db = new dpnetwork_data_20160419_NewEntities();

            return(db.FlowDay_t.Where(p => p.Fld_FlowMeterUid == fmuid).ToList());
            //return fdlist.Count() == 0 ? new List<FlowDay_t>() : fdlist.ToList();
        }
Beispiel #2
0
        public List <FlowHour_t> GetMonthFlowByUidAndDate(Guid uid, DateTime date)
        {
            List <FlowHour_t> OneDay = new List <FlowHour_t>();
            int year  = date.Year;
            int month = date.Month;

            //List<FlowHour_t> result = new List<FlowHour_t>();
            var time      = int.Parse(date.ToString("yyyyMMdd"));
            var lastmonth = date.AddMonths(-1).AddDays(1);
            var days      = date.Subtract(lastmonth).Days;
            var starttime = int.Parse(lastmonth.ToString("yyyyMMdd")) * 100 + 9;
            var endtime   = time * 100 + 9;
            dpnetwork_data_20160419_NewEntities db = new dpnetwork_data_20160419_NewEntities();

            return(db.FlowHour_t.Where(p => p.Flh_FlowMeterUid == uid && p.Flh_Time >= starttime && p.Flh_Time <= endtime).ToList());
            //for (var i = 0; i <= days - 1; i++)
            //{
            //    var day = int.Parse(lastmonth.AddDays(i).ToString("yyyyMMdd"));
            //    var secday = int.Parse(lastmonth.AddDays(i + 1).ToString("yyyyMMdd"));
            //    var startTime = day * 100 + 9;
            //    var endTime = secday * 100 + 9;
            //    List<FlowHour_t> fhPerHour = GetTimeFlowHourByUid(uid, startTime, endTime);
            //    result.AddRange(fhPerHour);
            //}
            //return result;
        }
Beispiel #3
0
        public List <FlowHour_t> GetFlowHourByFMUid(Guid fmUid)
        {
            dpnetwork_data_20160419_NewEntities db = new dpnetwork_data_20160419_NewEntities();

            return(db.FlowHour_t.Where(p => p.Flh_FlowMeterUid == fmUid).ToList());
            //return fhlist.Count() == 0 ? new List<FlowHour_t>() : fhlist.ToList();
        }
Beispiel #4
0
        public bool UpdateById(string keyName, T input)
        {
            using (dpnetwork_data_20160419_NewEntities WaterEntities = new dpnetwork_data_20160419_NewEntities())
            {
                try
                {
                    PropertyInfo[] propertyList = typeof(T).GetProperties();
                    //获取T类里面的主键名称keyName
                    Type         type     = typeof(dpnetwork_data_20160419_NewEntities);
                    PropertyInfo property = type.GetProperty(typeof(T).Name);
                    DbSet <T>    value    = (DbSet <T>)property.GetValue(WaterEntities, null);
                    //获取数据库实体集
                    PropertyInfo propertyKey = typeof(T).GetProperty(keyName);
                    //获取T类关键字段属性
                    var    recordAll   = value.ToArray();
                    object recordOld   = new object();
                    long   keyValueNew = (long)(propertyKey.GetValue(input, null));//要修改保存的关键字段属性值
                    for (int i = 0; i < recordAll.Length; i++)
                    {
                        if ((long)(propertyKey.GetValue(recordAll[i], null)) == keyValueNew)
                        {
                            recordOld = recordAll;
                            break;
                        }
                    }
                    //找出关键字段匹配的T实例
                    foreach (var item in propertyList)
                    {
                        if (!item.Name.Equals(keyName))
                        {
                            item.SetValue(recordOld, item.GetValue(input, null), null);
                        }
                    }
                    //给T实例的非关键字段属性进行赋值
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);

                    throw e;
                }
            }
        }
Beispiel #5
0
        public List <T> FindAll()
        {
            using (dpnetwork_data_20160419_NewEntities WaterEntities = new dpnetwork_data_20160419_NewEntities())
            {
                try
                {
                    Type           type       = typeof(dpnetwork_data_20160419_NewEntities);
                    PropertyInfo[] properties = type.GetProperties();
                    PropertyInfo   property   = type.GetProperty(typeof(T).Name);
                    DbSet <T>      value      = (DbSet <T>)property.GetValue(WaterEntities, null);
                    //List<T> list = new List<T>();
                    List <T> valuelist = value.ToList();
                    //IEnumerable<T> list = valuelist.AsEnumerable();
                    return(valuelist);
                }
                catch (Exception e)
                {
                    return(null);

                    throw e;
                }
            }
        }
Beispiel #6
0
        public List <FlowHour_t> GetTimeFlowHourByUid(Guid fmUid, int startTime, int endTime)
        {
            dpnetwork_data_20160419_NewEntities db = new dpnetwork_data_20160419_NewEntities();

            return(db.FlowHour_t.Where(p => p.Flh_FlowMeterUid == fmUid && p.Flh_Time <= endTime && p.Flh_Time >= startTime).ToList());
        }