示例#1
0
        public ActionResult EditSite(string siteCode = "1007", int typeId = 0, string name = "", string lat = "", string lon = "")
        {
            string result = "";

            try
            {
                Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient();
                Site theSite = theHydro.GetSite(siteCode, typeId);
                if (name != "")
                {
                    theSite.Name = name;
                }
                else
                {
                    throw new Exception("Пустое поле Наименование поста");
                }
                if (lat != "")
                {
                    theSite.Lat = Convert.ToDecimal(lat);
                }
                else
                {
                    throw new Exception("Пустое поле Lat поста");
                }
                if (lon != "")
                {
                    theSite.Lon = Convert.ToDecimal(lon);
                }
                else
                {
                    throw new Exception("Пустое поле Lon поста");
                }
                theHydro.SaveSiteWithRelation(theSite, null);
                result = "Ok:" + siteCode;
            }
            catch (Exception ex)
            {
                result = "Error:" + ex.Message;
            }


            return(Content(result));
        }
示例#2
0
        public ActionResult Change(int SiteCode, int SiteType, int WaterObject, bool isChecked)
        {
            Hydro.Site theSite = null;
            try
            {
                Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient();
                theSite = theHydro.GetSite(SiteCode.ToString(), SiteType);


                if (isChecked)
                {
                    Hydro.WaterObject theWO = null;

                    foreach (var item in theHydro.GetWaterObjects(false))
                    {
                        if (item.Id == WaterObject)
                        {
                            theWO = item;
                            break;
                        }
                    }

                    theHydro.SaveSiteWithRelation(theSite, theWO);
                }
                else
                {
                    Hydro.WaterObject wo = new Hydro.WaterObject();
                    wo.Id = -1;
                    theHydro.SaveSiteWithRelation(theSite, wo);
                }
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
            return(Content("Станция " + theSite.Name + " успешно обновлена"));
        }
示例#3
0
        public ActionResult Months(int SiteCode = -1, int YYYY = -1, int MM = -1, int DD = 1)
        {
            DateTime currDate;

            try
            {
                currDate = new DateTime(YYYY, MM, DD);
            }
            catch
            {
                currDate = DateTime.Now;
            }

            ViewBag.currDate = currDate;

            Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient();

            ViewLevel theView  = new ViewLevel();
            const int TYPE_AGK = 6;

            theView.theSiteList      = ViewSite.GetAll(TYPE_AGK);
            theView.SelectedSiteCode = SiteCode;
            if (theView.SelectedSiteCode == -1)
            {
                theView.SelectedSiteCode = theView.theSiteList[0].Code;
            }

            int SiteID = theView.theSiteList.Where(x => x.Code == theView.SelectedSiteCode).Single().ID;

            DateTime dateBgn = new DateTime(currDate.Year, currDate.Month, 1);
            DateTime dateEnd = new DateTime(currDate.Year, currDate.Month, DateTime.DaysInMonth(currDate.Year, currDate.Month));

            const int LEVEL_CODE = 2;

            var ValueCollection = theHydro.GetDataValues(SiteID, dateBgn, dateEnd, LEVEL_CODE, null, null, null);

            if (ValueCollection == null)
            {
                return(View(theView));
            }

            foreach (var item in ValueCollection)
            {
                if (item.Value > -9000)
                {
                    ViewLevel.Level theLevel = new ViewLevel.Level();
                    theLevel.Value = item.Value;
                    theLevel.YYYY  = item.Date.Year;
                    theLevel.MM    = item.Date.Month;
                    theLevel.DD    = item.Date.Day;
                    theLevel.HH    = item.Date.Hour;
                    theLevel.MI    = 0;
                    theLevel.SS    = 0;
                    theLevel.ID    = item.Id;
                    theView.theLevelList.Add(theLevel);
                }
            }

            const int HydroPostType = 2;

            var HydroPost = theHydro.GetSite(theView.SelectedSiteCode.ToString(), HydroPostType);
            var HydroPostValueCollection = theHydro.GetDataValues(HydroPost.SiteId, dateBgn, dateEnd, LEVEL_CODE, null, null, null);

            if (HydroPostValueCollection == null)
            {
                return(View(theView));
            }

            foreach (var item in HydroPostValueCollection)
            {
                if (item.Value > -9000)
                {
                    ViewLevel.Level theLevel = new ViewLevel.Level();
                    theLevel.Value = item.Value;
                    theLevel.YYYY  = item.Date.Year;
                    theLevel.MM    = item.Date.Month;
                    theLevel.DD    = item.Date.Day;
                    theLevel.HH    = item.Date.Hour;
                    theLevel.MI    = 0;
                    theLevel.SS    = 0;
                    theLevel.ID    = item.Id;
                    theView.theHydroPostLevelList.Add(theLevel);
                }
            }



            return(View(theView));
        }