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); }
// // 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)); }
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); } }