Example #1
0
        //Async load of the items
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                WeatherStations.Clear();
                //From the main page we want to always show them all the data
                bool succ = await WeatherStationDependency.RefreshWeatherSets(WeatherSet.WeatherSetDateRanges.AllTime);

                IEnumerable <WeatherStation> items = await WeatherStationDependency.GetAllWeatherSets(true);

                foreach (var item in items)
                {
                    WeatherStations.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #2
0
        protected WeatherStationFull SearchWS(string state, string municipality, string ws)
        {
            WeatherStationFull answer = WeatherStations.SingleOrDefault(p => p.State.Equals(state) &&
                                                                        p.Municipality.Equals(municipality) &&
                                                                        p.Name.Equals(ws));

            return(answer);
        }
Example #3
0
        static void Main()
        {
            var weatherStations = new WeatherStations();
            var weatherStation = weatherStations.First();

            weatherStation.SettingsLoaded += WeatherStationSettingsLoaded;
            weatherStation.HistoryData += WeatherStationHistoryData;

            Console.WriteLine("Press any key to quit.");
            Console.ReadKey();
        }
Example #4
0
        public IHttpActionResult PostWeatherStations(WeatherStations weatherStations)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            weatherStations.Inclusao = DateTime.Now;
            db.WeatherStations.Add(weatherStations);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = weatherStations.ID }, weatherStations));
        }
Example #5
0
        ///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
        //[EditorBrowsable(EditorBrowsableState.Never)]
        //protected override void InitData()
        //{
        //    base.InitData();

        //    // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
        //    // Meta.Count是快速取得表记录数
        //    if (Meta.Count > 0) return;

        //    // 需要注意的是,如果该方法调用了其它实体类的首次数据库操作,目标实体类的数据初始化将会在同一个线程完成
        //    if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}[{1}]数据……", typeof(SysDepartment).Name, Meta.Table.DataTable.DisplayName);

        //    var entity = new SysDepartment();
        //    entity.Serialnum = "abc";
        //    entity.CreateTime = DateTime.Now;
        //    entity.CreateSysUserSerialnum = "abc";
        //    entity.UpdateTime = DateTime.Now;
        //    entity.UpdateSysUserSerialnum = "abc";
        //    entity.SysAreaSerialnum = "abc";
        //    entity.Name = "abc";
        //    entity.ParentSerialnum = "abc";
        //    entity.Status = 0;
        //    entity.Description = "abc";
        //    entity.Sort = 0;
        //    entity.Remark = "abc";
        //    entity.Insert();

        //    if (XTrace.Debug) XTrace.WriteLine("完成初始化{0}[{1}]数据!", typeof(SysDepartment).Name, Meta.Table.DataTable.DisplayName);
        //}

        /// <summary>已重载。删除关联数据</summary>
        /// <returns></returns>
        protected override int OnDelete()
        {
            if (AreaStations != null)
            {
                AreaStations.Delete();
            }
            if (AWProducts != null)
            {
                AWProducts.Delete();
            }
            if (CameraStationss != null)
            {
                CameraStationss.Delete();
            }
            if (Companys != null)
            {
                Companys.Delete();
            }
            if (Farms != null)
            {
                Farms.Delete();
            }
            if (SysUsers != null)
            {
                SysUsers.Delete();
            }
            if (WeatherStations != null)
            {
                WeatherStations.Delete();
            }
            if (WeatherWarns != null)
            {
                WeatherWarns.Delete();
            }

            return(base.OnDelete());
        }
Example #6
0
 /// <summary>
 /// Method that returns the first weather station provide for the API
 /// </summary>
 /// <returns></returns>
 public WeatherStationFull DefaultWeatherStation()
 {
     return(WeatherStations.FirstOrDefault());
 }