public static List <ViewSite> GetAll(int TYPE = -1) { List <ViewSite> theList = new List <ViewSite>(); Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient(); foreach (var theType in theHydro.GetSiteTypes()) { if (TYPE != -1) { if (TYPE != theType.Id) { continue; } } Hydro.Site[] theSites = theHydro.GetSiteList(theType.Id); if (theSites != null) { foreach (var theSite in theHydro.GetSiteList(theType.Id)) { ViewSite theViewSite = new ViewSite(); theViewSite.ID = theSite.SiteId; theViewSite.Code = Convert.ToInt32(theSite.SiteCode); theViewSite.Name = theSite.Name; theViewSite.TypeID = theType.Id; theViewSite.TypeNameFull = theType.Name; theViewSite.TypeNameShort = theType.ShortName; theList.Add(theViewSite); } } } return(theList); }
public ActionResult Days(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; } return(View(theView)); }
// // GET: /Water/ public ActionResult Index(int WaterObject = -1) { Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient(); ViewWater theViewData = new ViewWater(); theViewData.SelectedWaterObject = WaterObject; theViewData.theWaterObjectCollection = theHydro.GetWaterObjects(false); if (theViewData.SelectedWaterObject == -1) { theViewData.SelectedWaterObject = theViewData.theWaterObjectCollection[0].Id; } theViewData.theSites = theHydro.GetSitesByWaterObject(theViewData.SelectedWaterObject); theViewData.theSiteList = ViewSite.GetAll(); return(View(theViewData)); }
// // GET: /Map/ public ActionResult Index(int SiteType = -1) { Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient(); ViewMap theViewData = new ViewMap(); theViewData.SelectedSiteType = SiteType; theViewData.theSiteTypeCollection = theHydro.GetSiteTypes(); if (theViewData.SelectedSiteType == -1) { theViewData.SelectedSiteType = theViewData.theSiteTypeCollection[0].Id; } theViewData.theSites = theHydro.GetSiteList(theViewData.SelectedSiteType); return(View(theViewData)); }
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)); }
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 + " успешно обновлена")); }
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { eventLog1.WriteEntry("timer1_Elapsed"); eventLog1.WriteEntry(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); string setting = ConfigurationManager.AppSettings["DataExport"]; if (setting == null) { setting = "Setting not found"; } eventLog1.WriteEntry(setting); string strAgkDataFolder = setting; strAgkDataFolder.TrimEnd(new char[] { '\\' }); Hydro.HydroServiceClient theClient = new Hydro.HydroServiceClient(); const int TYPE_AGK = 6; foreach (var Site in theClient.GetSiteList(TYPE_AGK)) { string strSiteFolder = strAgkDataFolder + "\\" + Convert.ToInt32(Site.SiteCode).ToString(("00000")); if (!Directory.Exists(strSiteFolder)) { Directory.CreateDirectory(strSiteFolder); } strSiteFolder += "\\уровни"; if (!Directory.Exists(strSiteFolder)) { Directory.CreateDirectory(strSiteFolder); } int countPrevMonth = 12; for ( ; countPrevMonth > 0; countPrevMonth--) { DateTime bgnDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month, countPrevMonth); DateTime endDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month, DateTime.DaysInMonth(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month)); const int WATER_LEVEL = 2; string strFileName = strSiteFolder + "\\" + Convert.ToInt32(Site.SiteCode).ToString(("00000")) + "_" + bgnDate.ToString("yyyy_MM") + ".asc"; if (File.Exists(strFileName)) { continue; } var fileHandle = File.CreateText(strFileName); var DataValueList = theClient.GetDataValues(Site.SiteId, bgnDate, endDate, WATER_LEVEL, null, null, null); if (DataValueList != null) { foreach (var item in DataValueList) { string line = item.Date.ToString("dd.MM.yyyy ") + item.Date.ToLongTimeString() + "\t" + item.Value.ToString() + "\tcм"; fileHandle.WriteLine(line); } } fileHandle.Close(); } } } catch (Exception ex) { eventLog1.WriteEntry(ex.Message); eventLog1.WriteEntry(ex.StackTrace); } }
void IExport.Run() { try { this.theLogger.Log("Export:Run"); AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "AgkExportSettings.ini"); if (!Ini.HasSection("COMMON")) { Ini.SetValue("COMMON", "AgkDataFolder", "C:\\Данные_АГК"); Ini.SetValue("COMMON", "CountPrevMonth", "1"); } string strAgkDataFolder = Ini.GetValue("COMMON", "AgkDataFolder", "C:\\Данные_АГК"); int countPrevMonth = Ini.GetValue("COMMON", "CountPrevMonth", 1); strAgkDataFolder.TrimEnd(new char[] { '\\' }); if (!Directory.Exists(strAgkDataFolder)) { Directory.CreateDirectory(strAgkDataFolder); } Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient("BasicHttpBinding_IHydroService"); const int TYPE_AGK = 6; foreach (var Site in theHydro.GetSiteList(TYPE_AGK)) { string strSiteFolder = strAgkDataFolder + "\\" + Site.SiteCode.ToString(); if (!Directory.Exists(strSiteFolder)) { Directory.CreateDirectory(strSiteFolder); theLogger.Log(strSiteFolder); } strSiteFolder = strSiteFolder + "\\уровни"; if (!Directory.Exists(strSiteFolder)) { Directory.CreateDirectory(strSiteFolder); theLogger.Log(strSiteFolder); } DateTime bgnDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month, countPrevMonth); DateTime endDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month, DateTime.DaysInMonth(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month)); const int WATER_LEVEL = 2; string strFileName = strSiteFolder + "\\" + Site.SiteCode.ToString() + "_" + bgnDate.ToString("yyyy_MM") + ".asc"; theLogger.Log(strFileName); var fileHandle = File.CreateText(strFileName); var DataValueList = theHydro.GetDataValues(Site.SiteId, bgnDate, endDate, WATER_LEVEL, null, null, null); if (DataValueList != null) { foreach (var item in DataValueList) { string line = item.Date.ToString("dd.MM.yyyy hh:mm:ss") + "\t" + item.Value.ToString() + "\tсм"; fileHandle.WriteLine(line); } } fileHandle.Close(); //for (DateTime currDate = bgnDate; currDate <= endDate; currDate.AddDays(1)) //{ // var DataValueList = theHydro.GetDataValues(Site.SiteId, TYPE_AGK, currDate, WATER_LEVEL, null, null); // foreach (var item in DataValueList) // { // } //} } this.theLogger.Log(strAgkDataFolder); } catch (Exception ex) { this.theLogger.Error(ex.Message); this.theLogger.Error(ex.Source); this.theLogger.Error(ex.StackTrace); } }
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)); }
public ActionResult DeleteLevel(int SiteCode, int DataValueID) { Hydro.HydroServiceClient theClient = new Hydro.HydroServiceClient(); return(Content("")); }