Beispiel #1
0
        /// <summary>
        /// gis所需墒情数据
        /// </summary>
        /// <param name="subcenter"></param>
        /// <returns></returns>
        public static List <RealTimeMoisture> RealTimeMoisture(int subcenter)
        {
            LNRRDB   ln  = new LNRRDB();
            Maintain mt  = new Maintain();
            DateTime now = DateTime.Now;
            List <RealTimeMoisture> ret      = new List <RealTimeMoisture>();
            List <string>           stations = StationService.ListAllRawIDByTypes(new List <StationTypes> {
                StationTypes.soilStation
            }, subcenter);

            IEnumerable <soildata> records = CurrentService.ListRealSoil(ln, stations);

            // TODO 此处总是报错
            //foreach (string id in stations)
            //{
            //    if (records.Any(i => (i.StationID) == id))
            //    {
            //        soildata s = records.Where(i => (i.StationID) == id).OrderByDescending(r => r.DataTime).First();
            //        RealTimeMoisture temp = new Models.RealTimeMoisture(s);
            //        if (temp != null)
            //            ret.Add(temp);
            //    }
            //}

            return(ret);
        }
Beispiel #2
0
 /// <summary>
 /// 墒情数据查询,结构为(时间)
 /// </summary>
 /// <param name="fromTime"></param>
 /// <param name="toTime"></param>
 /// <param name="stationIds"></param>
 /// <returns></returns>
 public static QueryResult ListHourSoil_Standard(DateTime fromTime, DateTime toTime, string stationId)
 {
     //查询为空
     if (stationId == null)
     {
         return(new QueryResult());
     }
     //创建数据库对象
     using (RWDB rw = new RWDB())
     {
         using (Maintain mt = new Maintain())
         {
             //获取数据
             IQueryable <ST_SOIL_R> rainRecord          = ListHourSoil_Standard(rw, fromTime, toTime, stationId);
             QueryResult            result              = new QueryResult();
             List <ST_SOIL_R>       singleStationRecord = new List <ST_SOIL_R>();
             singleStationRecord = rainRecord.Where(r => r.STCD.Equals(stationId)).OrderByDescending(r => r.TM).ToList();
             Station    station = StationService.GetStationById(stationId);
             TimeRecord record  = new TimeRecord {
                 stationId = station.stationId, stationName = station.stationName, stationType = station.stationType
             };
             foreach (var r in singleStationRecord)
             {
                 //gm 20190221
                 TimeSoil ts = new TimeSoil(r.TM, null, r.SLM10, r.SLM20, r.SLM40);
                 record.tsoils.Add(ts);
             }
             result.records.Add(record);
             return(result);
         }
     }
 }
        public ActionResult Maintain(int id)
        {
            var asset = _service.LoadDto(id);

            if (asset == null)
            {
                return(new EmptyResult());
            }

            var mt = new Maintain
            {
                AssetCode       = asset.Code,
                AssetName       = asset.Name,
                Position        = asset.Position,
                Imei            = asset.Imei,
                Model           = asset.Model,
                Band            = asset.Band,
                OrigState       = asset.State,
                DeptId          = asset.DeptId,
                DeptName        = asset.DeptName,
                AccountId       = asset.AccountId,
                AccountName     = asset.AccountName,
                RepairAt        = DateTime.Today,
                ServiceFinishAt = DateTime.Today,
                ServiceStartAt  = DateTime.Today
            };

            return(View(mt));
        }
Beispiel #4
0
 public void JudgeTime(Maintain maintain)
 {
     if (DateTime.Now > maintain.ClocKtime.AddDays(maintain.TipNumber) && maintain.IsCleared)
     {
         Current.maintains.First(a => a.Id == maintain.Id).IsCleared = false;
     }
 }
Beispiel #5
0
        /// <summary>
        /// 用户登陆操作,需要用户名和密码,返回的是登陆状态和提示信息,并且将登陆状态存在登陆表中<see cref="Persistence.UserStatus"/>。获取用户信息则需要使用<see cref="getUser(string)"/>
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public static OperationResult Login(Maintain mt, string username, string password)
        {
            UserInfo user = GetUser(mt, username);

            if (user == null)
            {
                return(new OperationResult()
                {
                    ErrorMessage = Conf.MessageInfo.USER_NOT_EXIST, ErrorCode = Conf.ErrorCode.USER_NOT_EXIST
                });
            }
            else
            {
                if (!password.Equals(user.Password.Trim()))
                {
                    return(new OperationResult()
                    {
                        ErrorMessage = Conf.MessageInfo.WRONG_PASSWORD, ErrorCode = Conf.ErrorCode.WRONG_PASSWORD
                    });
                }
                else
                {
                    //将登陆状态保存在服务器上
                    Persistence.UserStatus.Add(user);
                    return(new OperationResult()
                    {
                        ErrorMessage = Conf.MessageInfo.LOGIN_SUCCESS, ErrorCode = 0
                    });
                }
            }
        }
Beispiel #6
0
 public ViewResult SettingUser()
 {
     using (Maintain mt = new Maintain())
     {
         var subcenters = DAL.SubCenterService.ListCenter(mt);
         ViewBag.Subcenters = subcenters;
         return(View());
     }
 }
        public JsonResult Maintain(IFormCollection collection)
        {
            var mt = new Maintain();

            TryUpdateModelAsync(mt);

            var result = _service.Maintain(mt, AppUser);

            return(Json(result));
        }
        public static void  getSubCenterInfoList()
        {
            Maintain mt = new Maintain();

            subCenterInfoList = DAL.SubCenterService.ListCenter(mt);
            for (int i = 0; i < subCenterInfoList.Count; i++)
            {
                subcenterInfoDic[subCenterInfoList[i].SubCenterID] = subCenterInfoList[i].SubCenterName;
            }
        }
Beispiel #9
0
        public JsonResult Edit(IFormCollection collection)
        {
            var entity = new Maintain();

            TryUpdateModelAsync(entity);
            var result = _service.Update(entity, AppUser);

            // 如果有缓存,注意在这里要清空缓存

            return(Json(result));
        }
Beispiel #10
0
        public async Task <ActionResult> Details(string id)
        {
            Maintain maintain = await FindMaintainAsync(id);

            if (maintain == null)
            {
                Logger.LogInformation("Details: Item not found {0}", id);
                return(NotFound());
            }
            return(View(maintain));
        }
Beispiel #11
0
        /// <summary>
        /// 获取BS表测站信息
        /// </summary>
        public static void getStationInfoList()
        {
            Maintain mt = new Maintain();

            stationInfoList = DAL.StationService.ListAllStations();
            for (int i = 0; i < stationInfoList.Count; i++)
            {
                stationInfoDic[stationInfoList[i].stationId] = stationInfoList[i];
                stationInfoDic4[stationInfoList[i].id]       = stationInfoList[i];
            }
        }
Beispiel #12
0
        public async Task <ActionResult> ConfirmDelete(string id, bool?retry)
        {
            Maintain maintain = await FindMaintainAsync(id);

            if (maintain == null)
            {
                Logger.LogInformation("Delete: Item not found {0}", id);
                return(NotFound());
            }
            ViewBag.Retry = retry ?? false;
            return(View(maintain));
        }
Beispiel #13
0
 public void Init()
 {
     //初始化控件
     for (int i = 0; i < labels.Length; i++)
     {
         labels[i]         = (Label)Controls.Find("Clear" + (i + 1), true)[0];
         labels[i].Text    = Current.maintains[i].Name;
         labels[i].Visible = false;
         Maintain maintains = Current.maintains.FirstOrDefault(a => a.Name.Contains(labels[i].Text));
         //labels[i].Tag = maintains.Id;
     }
 }
Beispiel #14
0
        public async Task <ActionResult> Edit(string id)
        {
            Maintain maintain = await FindMaintainAsync(id);

            if (maintain == null)
            {
                Logger.LogInformation("Edit: Item not found {0}", id);
                return(NotFound());
            }

            ViewBag.Tools = ToolService.GetToolsListItems(AppContext.Tools.ToList(), optional: true);
            return(View(maintain));
        }
Beispiel #15
0
        private void Clear_CLick(object sender, EventArgs e)
        {
            Label        label  = (Label)sender;
            DialogResult result = MessageBox.Show(string.Format("你要结束本次提示【{0}】吗?", label.Text.ToString()), "维护提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (DialogResult.No == result)
            {
                return;
            }
            Maintain maintain = Current.maintains.First(a => a.Name == label.Text);

            maintain.ClocKtime = DateTime.Now;
            maintain.IsCleared = true;
            label.Visible      = false;
        }
Beispiel #16
0
        public async Task <ActionResult> Delete(string id)
        {
            try
            {
                Maintain maintain = await FindMaintainAsync(id);

                AppContext.Maintains.Remove(maintain);
                await AppContext.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(RedirectToAction("Delete", new { id = id, retry = true }));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #17
0
        public async Task <Maintain> Store(Maintain order)
        {
            if (AppContext.Orders.Any(e => e.ID == order.ID))
            {
                AppContext.Maintains.Attach(order);
                AppContext.Entry(order).State = EntityState.Modified;
            }
            else
            {
                AppContext.Maintains.Add(order);
            }

            AppContext.SaveChanges();

            return(await GetById(order.ID));
        }
Beispiel #18
0
        public async Task <ActionResult> ConfirmClose(string id, bool?retry)
        {
            Maintain maintain = await FindMaintainAsync(id);

            if (maintain.FinishedDate != null)
            {
                throw new Exception("Обслуживание не может быть закрыто дважды. Дата закрытия обслуживания уже указана - " + maintain.FinishedDate);
            }
            if (maintain == null)
            {
                Logger.LogInformation("Close: Item not found {0}", id);
                return(NotFound());
            }
            ViewBag.Retry = retry ?? false;
            return(View(new CloseMaintainModel(maintain)));
        }
Beispiel #19
0
        public async Task <ActionResult> Update(string id, Maintain maintain)
        {
            try
            {
                maintain.ID = id;
                AppContext.Maintains.Attach(maintain);
                AppContext.Entry(maintain).State = EntityState.Modified;
                await AppContext.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Не удалось сохранить изменения: " + ex.ToString());
            }
            return(View(maintain));
        }
Beispiel #20
0
        public Result ServiceApply(Maintain maintain)
        {
            if (string.IsNullOrWhiteSpace(maintain.RepairMan))
            {
                return(ResultUtil.Do(ResultCodes.验证失败, "未知来源,此功能仅限企业微信用户使用"));
            }

            if (string.IsNullOrWhiteSpace(maintain.AssetName))
            {
                return(ResultUtil.Do(ResultCodes.验证失败, "物品不能为空"));
            }

            var service = new MaintainService();

            return(service.Create2(maintain, new AppUserDto {
                Id = 0, Name = "WeixinApi"
            }));
        }
Beispiel #21
0
        public async Task <ActionResult> Create(Maintain maintain)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    AppContext.Maintains.Add(maintain);
                    await AppContext.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Не удалось сохранить изменения: " + ex.ToString());
            }
            return(View(maintain));
        }
Beispiel #22
0
 /// <summary>
 /// 根据用户的UID返回分中心列表。如果是一级分中心,那么返回的是所有分中心,如果是二级就返回当前分中心。
 /// </summary>
 /// <param name="uid">用户UID</param>
 /// <returns>分中心列表,如果是二级的,只有一个成员</returns>
 public static List <Models.SubCenterInfo> ListSubcenterByUid(int uid)
 {
     using (Maintain mt = new Maintain())
     {
         int subcenter = GetSubCenterByUid(uid);
         if (subcenter == Conf.Config.MAIN_SUBCENTER)
         {
             return(ListCenter(mt));
         }
         else
         {
             return(new List <SubCenterInfo>()
             {
                 GetSubcenter(subcenter)
             });
         }
     }
 }
Beispiel #23
0
        /// <summary>
        /// 获取指定用户信息。登陆验证在login的时候处理。这里只获取用户。
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public static UserInfo GetUser(Maintain mt, string name)
        {
            //传递的参数
            Dictionary <string, object> param = new Dictionary <string, object>();
            //查询的条件
            Dictionary <string, string> paramInner = new Dictionary <string, string>();

            paramInner["name"] = name;
            //返回结果
            List <UserInfo> userList = new List <UserInfo>();
            string          url      = suffix + "/user/getUserBS";
            //string url = "http://127.0.0.1:8088/user/getUserBS";
            string jsonStr = HttpHelper.SerializeDictionaryToJsonString(paramInner);

            param["user"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
                userList = (List <UserInfo>)HttpHelper.JsonToObject(resultJson, new List <UserInfo>());
            }
            catch (Exception e)
            {
                return(null);
            }
            if (userList == null || userList.Count() == 0)
            {
                return(null);
            }
            else
            {
                return(userList.First());
            }

            //IQueryable<UserInfo> set = mt.UserInfo.Where(u => u.Name == name);
            //if (set == null || set.Count() == 0)
            //{
            //    return null;
            //}
            //else
            //{
            //    return set.First();
            //}
        }
Beispiel #24
0
 /// <summary>
 /// 所有用户
 /// </summary>
 /// <returns></returns>
 public ActionResult user()
 {
     try
     {
         var temp = Request.Params.Get("UID");
         int UID  = int.Parse(temp);
         using (Maintain mt = new Maintain())
         {
             var ret = JsonConvert.SerializeObject(DAL.UserService.ListAllUser(UID, mt));
             return(Json(ret, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception)
     {
         QueryResult error = new QueryResult();
         var         ret   = JsonConvert.SerializeObject(error);
         return(Json(ret, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #25
0
        public async Task <ActionResult> Close(string id)
        {
            try
            {
                Maintain maintain = await FindMaintainAsync(id);

                maintain.FinishedDate = DateTime.UtcNow;

                AppContext.Maintains.Attach(maintain);
                AppContext.Entry(maintain).State = EntityState.Modified;
                await AppContext.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(RedirectToAction("Close", new { id = id, retry = true }));
            }
        }
        public async Task <ActionResult> Store([FromBody] Maintain item)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var savedStore = await _service.Store(item);

                    return(Json(savedStore));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Не удалось сохранить изменения: " + ex.ToString());
                return(StatusCode(500));
            }
        }
Beispiel #27
0
 /// <summary>
 /// 登陆操作
 /// </summary>
 /// <returns></returns>
 public ActionResult login()
 {
     Models.OperationResult result = new Models.OperationResult()
     {
         ErrorCode = 001, ErrorMessage = "参数错误"
     };
     try
     {
         string username = Request.Params.Get("username");
         string password = Request.Params.Get("password");
         using (Maintain mt = new Maintain())
         {
             result = DAL.UserService.Login(mt, username, password);
             if (result.ErrorCode == 0)
             {
                 Models.UserInfo user = DAL.UserService.GetUser(mt, username);
                 //不可把password明文传回客户端
                 String temp = user.Password;
                 user.Password = "";
                 var j = JsonConvert.SerializeObject(user);
                 user.Password = temp;
                 return(Json(j, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 //登录失败返回错误信息
                 return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception e)
     {
         //异常时返回错误信息
         Console.WriteLine("error:" + e.Message);
         result.ErrorMessage = e.Message;
         var j = JsonConvert.SerializeObject(result);
         return(Json(j, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #28
0
        /// <summary>
        /// 获取所有分中心的信息
        /// </summary>
        /// <returns></returns>
        public static List <Models.SubCenterInfo> ListCenter(Maintain mt)
        {
            //传递得参数
            Dictionary <string, object> param = new Dictionary <string, object>();

            //查询条件
            Dictionary <string, string> paramInner = new Dictionary <string, string>();

            paramInner["subcenterId"] = "";
            //返回结果
            List <SubCenterInfo> subcenterList = new List <SubCenterInfo>();
            //string suffix = "/subcenter/getSubcenter";
            string url = suffix + "/subcenter/getSubcenter";
            //string url = "http://127.0.0.1:8088/subcenter/getSubcenter";
            string jsonStr = HttpHelper.SerializeDictionaryToJsonString(paramInner);

            param["subcenter"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
                subcenterList = (List <SubCenterInfo>)HttpHelper.JsonToObject(resultJson, new List <SubCenterInfo>());
            }
            catch (Exception e)
            {
                Debug.WriteLine("查询分中心失败");
                throw e;
            }
            //List<SubCenterInfo> resultList = new List<SubCenterInfo>();
            //SubCenterInfo subCenterInfo = new SubCenterInfo();
            //foreach (SubCenterInfo s in subcenterList)
            //{
            //    subCenterInfo.SubCenterID = s.SubCenterID;
            //    subCenterInfo.SubCenterName = s.SubCenterName;
            //    resultList.Add(subCenterInfo);
            //}
            return(subcenterList);

            //return mt.SubCenterInfo.ToList();
        }
Beispiel #29
0
        public Result <int> Maintain(Maintain entity, IAppUser user)
        {
            var service = new MaintainService();

            return(service.Create2(entity, user));
        }
Beispiel #30
0
        /// <summary>
        /// 原始库墒情数据查询
        /// </summary>
        /// <param name="fromTime"></param>
        /// <param name="toTime"></param>
        /// <param name="stationIds"></param>
        /// <returns></returns>
        public static QueryResult ListHourSoil(DateTime fromTime, DateTime toTime, string id)
        {
            //查询为空
            if (id == null)
            {
                return(new QueryResult());
            }

            // //传递得参数
            // Dictionary<string, object> param = new Dictionary<string, object>();
            // //TODO添加datatime转string timeStart timeEnd

            // //查询条件
            // Dictionary<string, string> paramInner = new Dictionary<string, string>();
            // paramInner["stationid"] = id;
            // paramInner["strttime"] = fromTime.ToString();
            // paramInner["endtime"] = toTime.ToString();
            // //返回结果
            // QueryResult result = new QueryResult();
            // List<soildata> soildataList = new List<soildata>();
            // //string suffix = "/subcenter/getSubcenter";
            // string url = "http://127.0.0.1:8088/soildata/getSoildataBS";
            // string jsonStr = HttpHelper.SerializeDictionaryToJsonString(paramInner);
            // param["soildata"] = jsonStr;
            // try
            //  {
            //       string resultJson = HttpHelper.Post(url, param);
            //      //warningInfoList = (List<CEntityWarningInfo>)HttpHelper.JsonToObject(resultJson, new List<CEntityWarningInfo>());
            //      soildataList = (List<soildata>)HttpHelper.JsonDeserialize<List<soildata>>(resultJson, new List<soildata>());
            //  }
            //  catch (Exception e)
            // {
            //            Debug.WriteLine("查询墒情信息失败");
            //     throw e;
            // }
            // //处理数据
            // Station station = StationService.GetStationByRawId(id);
            // TimeRecord record = new TimeRecord { stationId = station.id, stationName = station.stationName, stationType = station.stationType };
            // List<TimeSoil> tsoils = new List<TimeSoil>();
            // foreach (soildata soildata in soildataList)
            // {
            //   TimeSoil timeSoil = new TimeSoil(soildata.DataTime, soildata.Voltage, soildata.Moisture10, soildata.Moisture20, soildata.Moisture40);
            //   timeSoil.time = soildata.DataTime;
            //   timeSoil.Voltage = soildata.Voltage;
            //   timeSoil.Moisture10 = soildata.Moisture10;
            //   timeSoil.Moisture20 = soildata.Moisture20;
            //   timeSoil.Moisture40 = soildata.Moisture40;
            //   tsoils.Add(timeSoil);
            //}
            //record.tsoils = tsoils;
            //record.tsoils = record.tsoils.OrderByDescending(r => r.time).ToList();
            //result.records.Add(record);
            //return result;
            //创建数据库对象
            using (LNRRDB ln = new LNRRDB())
            {
                using (Maintain mt = new Maintain())
                {
                    //获取数据
                    IQueryable <soildata> rainRecord          = ListHourSoil(ln, fromTime, toTime, id);
                    QueryResult           result              = new QueryResult();
                    List <soildata>       singleStationRecord = new List <soildata>();
                    singleStationRecord = rainRecord.Where(r => r.StationID.Equals(id)).OrderByDescending(r => r.DataTime).ToList();
                    Station station = StationService.GetStationByRawId(id);
                    //原始库ID
                    TimeRecord record = new TimeRecord {
                        stationId = station.id, stationName = station.stationName, stationType = station.stationType
                    };
                    foreach (var r in singleStationRecord)
                    {
                        TimeSoil ts = new TimeSoil(r.DataTime, r.Voltage, r.Moisture10, r.Moisture20, r.Moistrue40);
                        record.tsoils.Add(ts);
                    }
                    result.records.Add(record);
                    return(result);
                }
            }
        }