Example #1
0
        public ActionResult AjaxGetMultiElements(string StationNames, string StationNums, int ElementID)
        {
            try
            {
                using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
                {
                    string[] stationnums = StationNums.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string[] stationnames = StationNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    if (stationnums != null && stationnames != null)
                    {
                        DateTime start = DateTime.Now;
                        List<dynamic> res = new List<dynamic>();
                        for (int i = 0; i < stationnums.Length; i++)
                        {
                            List<dynamic> templist = new List<dynamic>();
                            var TEMP = 88.8;
                            for (int time = 0; time <= DateTime.Now.Hour; time++)
                            {
                                DATA_DMGD_InfoManage element = context.DATA_DMGD_InfoManages.Where(c => c.STATION_NUMBER.Equals(stationnums[i]) && c.OBSERVATION_DATA_DATE.Year.Equals(DateTime.Now.Year) && c.OBSERVATION_DATA_DATE.Month.Equals(DateTime.Now.Month) && c.OBSERVATION_DATA_DATE.Day.Equals(DateTime.Now.Day) && c.OBSERVATION_DATA_DATE.Hour.Equals(time)).FirstOrDefault();
                                if (element != null)
                                {
                                    switch (AllConsts.getElementName(ElementID))
                                    {
                                        case "气温":
                                            if (element.TEMP != null)
                                                TEMP = (((int)(element.TEMP * 10)) / 10.0);
                                            break;
                                        case "最高气温":
                                            if (element.MOST_TEMP != null)
                                                TEMP = (((int)(element.TEMP * 10)) / 10.0);
                                            break;
                                        case "最低气温":
                                            if (element.LEAST_TEMP != null)
                                                TEMP = (((int)(element.TEMP * 10)) / 10.0);
                                            break;
                                        case "气压":
                                            if (element.PRES != null)
                                                TEMP = (((int)(element.TEMP * 10)) / 10.0);
                                            break;
                                    }
                                    templist.Add(new { time, TEMP });
                                }
                            }
                            if (templist.Count != 0)
                                res.Add(new { label = stationnames[i], data = templist });
                        }
                        DateTime end = DateTime.Now;
                        TimeSpan span = end - start;
                        int seconds = (int)span.TotalSeconds;
                        return Json(new { res, d = seconds }, JsonRequestBehavior.AllowGet);
                    }
                    return Json(new { res = "", d = -1 }, JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                return Json(new { res = "", d = -1 }, JsonRequestBehavior.AllowGet);
            }
        }
Example #2
0
 public ActionResult AjaxTransforStatus(int StoragesInfoID)
 {
     try
     {
         int storageID = StoragesInfoID;
         if (StoragesInfoID.Equals(AllConsts.BAOZHANG_UNIT_NUM))
         {
             storageID = AllConsts.XLHT_UNIT_NUM;
         }
         int[] timeout = new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
         using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
         {
             DateTime nowdate = DateTime.Now.AddDays(-1);
             List<dynamic> res = new List<dynamic>();
             using (InfoManageDataContext infocontext = new InfoManageDataContext())
             {
                 List<Station> stations = infocontext.Stations.Where(c => c.StoragesInfoID.Equals(storageID)).ToList<Station>();
                 for (int time = 0; time <= DateTime.Now.Hour; time++)
                 {
                     foreach (Station sta in stations)
                     {
                         DRF_InfoManage transforstatus = context.DRF_InfoManages.Where(c => c.SN.Equals(sta.StationNum) && c.FROM_DATE.Year.Equals(nowdate.Year) && c.FROM_DATE.Month.Equals(nowdate.Month) && c.FROM_DATE.Day.Equals(nowdate.Day) && c.FROM_DATE.Hour.Equals(time)).FirstOrDefault();
                         Type t = transforstatus.GetType();
                         System.Reflection.PropertyInfo propertyInfo = t.GetProperty("A" + time);
                         var stat = propertyInfo.GetValue(transforstatus, null);
                         if (null != stat)
                         {
                             int munite = Convert.ToInt32(stat);
                             if (transforstatus != null && munite > 15)
                                 timeout[time]++;
                         }
                     }
                 }
             }
             return Json(timeout, JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("", JsonRequestBehavior.AllowGet);
     }
 }
Example #3
0
 public ActionResult AjaxSubStationElement(string StationNum, string ElementName)
 {
     try
     {
         using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
         {
             List<dynamic> templist = new List<dynamic>();
             var TEMP = 88.8;
             for (int time = 0; time <= DateTime.Now.Hour; time++)
             {
                 DATA_DMGD_InfoManage element = context.DATA_DMGD_InfoManages.Where(c => c.STATION_NUMBER.Equals(StationNum) && c.OBSERVATION_DATA_DATE.Year.Equals(DateTime.Now.Year) && c.OBSERVATION_DATA_DATE.Month.Equals(DateTime.Now.Month) && c.OBSERVATION_DATA_DATE.Day.Equals(DateTime.Now.Day) && c.OBSERVATION_DATA_DATE.Hour.Equals(time)).FirstOrDefault();
                 switch (ElementName)
                 {
                     case "气温":
                         if (element.TEMP != null)
                             TEMP = (((int)(element.TEMP * 10)) / 10.0);
                         break;
                     case "最高气温":
                         if (element.MOST_TEMP != null)
                             TEMP = (((int)(element.TEMP * 10)) / 10.0);
                         break;
                     case "最低气温":
                         if (element.LEAST_TEMP != null)
                             TEMP = (((int)(element.TEMP * 10)) / 10.0);
                         break;
                     case "气压":
                         if (element.PRES != null)
                             TEMP = (((int)(element.TEMP * 10)) / 10.0);
                         break;
                 }
                 templist.Add(new { time, TEMP });
             }
             return Json(new { ElementName, templist }, JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("", JsonRequestBehavior.AllowGet);
     }
 }
Example #4
0
        public ActionResult AjaxSubStationData(string StationNum)
        {
            try
            {
                using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
                {
                    List<dynamic> templist = new List<dynamic>();
                    List<dynamic> pressurelist = new List<dynamic>();

                    var TEMP = 88.8;
                    var PRES = 888.8;
                    for (int time = 0; time <= DateTime.Now.Hour; time++)
                    {
                        DATA_DMGD_InfoManage element = context.DATA_DMGD_InfoManages.Where(c => c.STATION_NUMBER.Equals(StationNum) && c.OBSERVATION_DATA_DATE.Year.Equals(DateTime.Now.Year) && c.OBSERVATION_DATA_DATE.Month.Equals(DateTime.Now.Month) && c.OBSERVATION_DATA_DATE.Day.Equals(DateTime.Now.Day) && c.OBSERVATION_DATA_DATE.Hour.Equals(time)).FirstOrDefault();
                        if (element.TEMP != null)
                            TEMP = (((int)(element.TEMP * 10)) / 10.0);
                        if (element.PRES != null)
                            PRES = (((int)(element.PRES * 10)) / 10.0);
                        templist.Add(new { time, TEMP });
                        pressurelist.Add(new { time, PRES });
                    }
                    return Json(new { templist, pressurelist }, JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }
 public ActionResult AjaxBatteryStatus()
 {
     try
     {
         using (InfoManageDataContext infocontext = new InfoManageDataContext())
         {
             using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
             {
                 List<DATA_STAB_InfoManage> stations = context.DATA_STAB_InfoManages.Where(c => c.CREATE_DATE.Year.Equals(DateTime.Now.Year) && c.CREATE_DATE.Month.Equals(DateTime.Now.Month) && c.CREATE_DATE.Day.Equals(DateTime.Now.Day) && c.CREATE_DATE.Hour.Equals(DateTime.Now.Hour)).ToList<DATA_STAB_InfoManage>();
                 List<dynamic> res = new List<dynamic>();
                 foreach (DATA_STAB_InfoManage battery in stations)
                 {
                     AWS_InfoManage aws = context.AWS_InfoManages.Where(c => c.STATION_NUMBER.Equals(battery.STATION_NUMBER)).FirstOrDefault();
                     if (aws != null)
                     {
                         Station infosta = infocontext.Stations.Where(c => c.StationNum.Equals(battery.STATION_NUMBER)).FirstOrDefault();
                         if (infosta != null)
                         {
                             //StationEquipmentsOnline online = infocontext.StationEquipmentsOnlines.Where(c => c.StationID.Equals(infosta.StationID) && c.ElementID.Equals(29)).FirstOrDefault();
                             var VOLTAGE = ((int)(battery.MB_VOLTAGE * 10)) / 10.0;
                             var TEMP = ((int)(battery.AWS_TEMP * 10)) / 10.0;
                             res.Add(new { SolerBord = "XS500", VaildDate = DateTime.Now.AddYears(3), SIM = infosta.SIM, StationTyp = infosta.StationType, STATION_NAME = aws.STATION_NAME, STATION_NUMBER = battery.STATION_NUMBER, VOLTAGE = VOLTAGE });
                         }
                     }
                 }
                 return Json(res, JsonRequestBehavior.AllowGet);
             }
         }
     }
     catch
     {
         return Json("", JsonRequestBehavior.AllowGet);
     }
 }
 public ActionResult AjaxUpdateStation(int flag)
 {
     try
     {
         if (flag.Equals(1))
         {
             using (InfoManageDataContext context = new InfoManageDataContext())
             {
                 List<dynamic> res = new List<dynamic>();
                 var result = (from c in context.Stations
                               select new
                               {
                                   c.StationName,
                                   c.StationNum,
                                   c.StationLatitude,
                                   c.StationLongitude
                               });
                 foreach (dynamic sta in result)
                 {
                     string StationLongitude = sta.StationLongitude;
                     string StationLatitude = sta.StationLatitude;
                     double longitude, latitude;
                     if (StationLongitude.Length == 7 && !StationLongitude.Contains("."))
                         longitude = int.Parse(StationLongitude.Substring(0, 3)) + int.Parse(StationLongitude.Substring(3, 2)) / 60.0 + int.Parse(StationLongitude.Substring(5, 2)) / 3600.0;
                     else
                         continue;
                     if (StationLatitude.Length == 6 && !StationLatitude.Contains("."))
                         latitude = int.Parse(StationLatitude.Substring(0, 2)) + int.Parse(StationLatitude.Substring(2, 2)) / 60.0 + int.Parse(StationLatitude.Substring(4, 2)) / 3600.0;
                     else
                         continue;
                     res.Add(new { sta.StationNum, sta.StationName, StationLongitude = longitude.ToString(), StationLatitude = latitude.ToString() });
                 }
                 return Json(res, JsonRequestBehavior.AllowGet);
             }
             //using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
             //{
             //    List<dynamic> res = new List<dynamic>();
             //    List<AWS_InfoManage> stations = context.AWS_InfoManages.ToList<AWS_InfoManage>();
             //    foreach (AWS_InfoManage sta in stations)
             //    {
             //        TIMEOUT_EVENT_InfoManage timeout = context.TIMEOUT_EVENT_InfoManages.Where(c => c.STATION_NUMBER.Equals(sta.STATION_NUMBER) && c.EVENT_DATE.Year.Equals(DateTime.Now.Year) && c.EVENT_DATE.Month.Equals(DateTime.Now.Month) && c.EVENT_DATE.Day.Equals(DateTime.Now.Day) && c.EVENT_DATE.Hour.Equals(DateTime.Now.Hour) && c.EVENT_DATE.Minute.Equals(DateTime.Now.Minute)).FirstOrDefault();
             //        if (sta.ENABLED.ToString() == "1")
             //        {
             //            if (timeout != null)
             //                res.Add(new { STATION_NAME = sta.STATION_NAME, STATION_NUMBER = sta.STATION_NUMBER, LATITUDE_FV = sta.LATITUDE_FV, LONGITUDE_FV = sta.LONGITUDE_FV, STATION_STATUS = AllConsts.TIMEOUT_EVENT_TYPE.timeout });
             //            else
             //                res.Add(new { STATION_NAME = sta.STATION_NAME, STATION_NUMBER = sta.STATION_NUMBER, LATITUDE_FV = sta.LATITUDE_FV, LONGITUDE_FV = sta.LONGITUDE_FV, STATION_STATUS = AllConsts.TIMEOUT_EVENT_TYPE.online });
             //        }
             //        if (sta.ENABLED.ToString() == "0")
             //        {
             //            res.Add(new { STATION_NAME = sta.STATION_NAME, STATION_NUMBER = sta.STATION_NUMBER, LATITUDE_FV = sta.LATITUDE_FV, LONGITUDE_FV = sta.LONGITUDE_FV, STATION_STATUS = AllConsts.TIMEOUT_EVENT_TYPE.disabled });
             //        }
             //    }
             //    return Json(res, JsonRequestBehavior.AllowGet);
             //}
         }
         if (flag.Equals(2))
         {
             using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
             {
                 List<dynamic> res = new List<dynamic>();
                 List<AWS_InfoManage> stations = context.AWS_InfoManages.ToList<AWS_InfoManage>();
                 foreach (AWS_InfoManage sta in stations)
                 {
                     TIMEOUT_EVENT_InfoManage timeout = context.TIMEOUT_EVENT_InfoManages.Where(c => c.STATION_NUMBER.Equals(sta.STATION_NUMBER) && c.EVENT_DATE.Year.Equals(DateTime.Now.Year) && c.EVENT_DATE.Month.Equals(DateTime.Now.Month) && c.EVENT_DATE.Day.Equals(DateTime.Now.Day) && c.EVENT_DATE.Hour.Equals(DateTime.Now.Hour) && c.EVENT_DATE.Minute.Equals(DateTime.Now.Minute)).FirstOrDefault();
                     if (sta.ENABLED.ToString() == "1")
                     {
                         if (timeout == null)
                             res.Add(new { STATION_NAME = sta.STATION_NAME, STATION_NUMBER = sta.STATION_NUMBER, LATITUDE_FV = sta.LATITUDE_FV, LONGITUDE_FV = sta.LONGITUDE_FV, STATION_STATUS = AllConsts.TIMEOUT_EVENT_TYPE.online });
                     }
                 }
                 return Json(res, JsonRequestBehavior.AllowGet);
             }
         }
         if (flag.Equals(3))
         {
             using (InfoManageDataContext infocontext = new InfoManageDataContext())
             {
                 using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
                 {
                     List<dynamic> res = new List<dynamic>();
                     List<AWS_InfoManage> stations = context.AWS_InfoManages.ToList<AWS_InfoManage>();
                     foreach (AWS_InfoManage sta in stations)
                     {
                         if (sta.STATION_NUMBER != null || sta.STATION_NUMBER != "")
                         {
                             Station infostation = infocontext.Stations.Where(c => c.StationNum.Equals(sta.STATION_NUMBER)).FirstOrDefault();
                             TIMEOUT_EVENT_InfoManage timeout = context.TIMEOUT_EVENT_InfoManages.Where(c => c.STATION_NUMBER.Equals(sta.STATION_NUMBER) && c.EVENT_DATE.Year.Equals(DateTime.Now.Year) && c.EVENT_DATE.Month.Equals(DateTime.Now.Month) && c.EVENT_DATE.Day.Equals(DateTime.Now.Day) && c.EVENT_DATE.Hour.Equals(DateTime.Now.Hour) && c.EVENT_DATE.Minute.Equals(DateTime.Now.Minute)).FirstOrDefault();
                             if (sta.ENABLED.ToString() == "1" && infostation != null)
                             {
                                 if (timeout != null)
                                 {
                                     res.Add(new { samplingMod = AllConsts.getSamplingMod(infostation.samplingMod), infostation.SIM, StationTyp = infostation.StationType, transportManageType = AllConsts.gettransportManageType(infostation.transportManageType), STATION_NAME = sta.STATION_NAME, STATION_NUMBER = sta.STATION_NUMBER, LATITUDE_FV = sta.LATITUDE_FV, LONGITUDE_FV = sta.LONGITUDE_FV, STATION_STATUS = AllConsts.TIMEOUT_EVENT_TYPE.timeout });
                                 }
                             }
                             //if (sta.ENABLED.ToString() == "0")
                             //{
                             //    res.Add(new { samplingMod = AllConsts.getSamplingMod(infostation.samplingMod), infostation.SIM, StationTyp = infostation.StationType, transportManageType = AllConsts.gettransportManageType(infostation.transportManageType), STATION_NAME = sta.STATION_NAME, STATION_NUMBER = sta.STATION_NUMBER, LATITUDE_FV = sta.LATITUDE_FV, LONGITUDE_FV = sta.LONGITUDE_FV, STATION_STATUS = AllConsts.TIMEOUT_EVENT_TYPE.disabled });
                             //}
                         }
                     }
                     return Json(res, JsonRequestBehavior.AllowGet);
                 }
             }
         }
         return Json("", JsonRequestBehavior.AllowGet);
     }
     catch
     {
         return Json("", JsonRequestBehavior.AllowGet);
     }
 }
        public ActionResult AjaxTransforStatus()
        {
            try
            {
                using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
                {
                    DateTime nowdate = DateTime.Now.AddDays(-1);
                    List<dynamic> res = new List<dynamic>();
                    List<DRF_InfoManage> transforstatus = context.DRF_InfoManages.Where(c => c.ITP < 1 && c.FROM_DATE.Year.Equals(nowdate.Year) && c.FROM_DATE.Month.Equals(nowdate.Month) && c.FROM_DATE.Day.Equals(nowdate.Day)).ToList<DRF_InfoManage>();
                    foreach (DRF_InfoManage drf in transforstatus)
                    {
                        AWS_InfoManage aws = context.AWS_InfoManages.Where(c => c.STATION_NUMBER.Equals(drf.SN)).FirstOrDefault();
                        if (aws != null)
                        {

                            var ITP = ((int)(drf.ITP * 1000)) / 10.0;
                            var OTP = ((int)(drf.OTP * 1000)) / 10.0;
                            var MTP = ((int)(drf.MTP * 1000)) / 10.0;

                            res.Add(new { ITP, OTP, MTP, drf.SN, A0 = AllConsts.transforLable(drf.A0, 0), A1 = AllConsts.transforLable(drf.A1, 1), A2 = AllConsts.transforLable(drf.A2, 2), A3 = AllConsts.transforLable(drf.A3, 3), A4 = AllConsts.transforLable(drf.A4, 4), A5 = AllConsts.transforLable(drf.A5, 5), A6 = AllConsts.transforLable(drf.A6, 6), A7 = AllConsts.transforLable(drf.A7, 7), A8 = AllConsts.transforLable(drf.A8, 8), A9 = AllConsts.transforLable(drf.A9, 9), A10 = AllConsts.transforLable(drf.A10, 10), A11 = AllConsts.transforLable(drf.A11, 11), A12 = AllConsts.transforLable(drf.A12, 12), A13 = AllConsts.transforLable(drf.A13, 13), A14 = AllConsts.transforLable(drf.A14, 14), A15 = AllConsts.transforLable(drf.A15, 15), A16 = AllConsts.transforLable(drf.A16, 16), A17 = AllConsts.transforLable(drf.A17, 17), A18 = AllConsts.transforLable(drf.A18, 18), A19 = AllConsts.transforLable(drf.A19, 19), A20 = AllConsts.transforLable(drf.A20, 20), A21 = AllConsts.transforLable(drf.A21, 21), A22 = AllConsts.transforLable(drf.A22, 22), A23 = AllConsts.transforLable(drf.A23, 23), aws.STATION_NAME });

                        }
                    }
                    return Json(res, JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }
 public ActionResult AjaxDataStatus(int StoragesInfoID)
 {
     try
     {
         using (webmeteo_g2DataContext context = new webmeteo_g2DataContext())
         {
             List<Station> mystations;
             using (InfoManageDataContext infocontext = new InfoManageDataContext())
             {
                 mystations = infocontext.Stations.Where(c => c.StoragesInfoID.Equals(StoragesInfoID)).ToList<Station>();
             }
             if (mystations != null)
             {
                 List<dynamic> res = new List<dynamic>();
                 foreach (Station stat in mystations)
                 {
                     int minute = ((int)(DateTime.Now.Minute / 10)) * 10;
                     DATA_DMGD_InfoManage battery = context.DATA_DMGD_InfoManages.Where(c => c.STATION_NUMBER.Equals(stat.StationNum) && c.OBSERVATION_DATA_DATE.Year.Equals(DateTime.Now.Year) && c.OBSERVATION_DATA_DATE.Month.Equals(DateTime.Now.Month) && c.OBSERVATION_DATA_DATE.Day.Equals(DateTime.Now.Day) && c.OBSERVATION_DATA_DATE.Hour.Equals(DateTime.Now.Hour) && c.OBSERVATION_DATA_DATE.Minute.Equals(minute)).FirstOrDefault();
                     if (battery != null)
                     {
                         var TEMP = ((int)(battery.TEMP * 10)) / 10.0;
                         var MOST_TEMP = ((int)(battery.MOST_TEMP * 10)) / 10.0;
                         var LEAST_TEMP = ((int)(battery.LEAST_TEMP * 10)) / 10.0;
                         res.Add(new { stat.StationName, stat.StationNum, battery.STATION_NUMBER, battery.CREATE_DATE, TEMP, MOST_TEMP, battery.MOST_TEMP_DATE, LEAST_TEMP, battery.LEAST_TEMP_DATE, battery.BUCKET_RAIN_COUNT });
                     }
                 }
                 return Json(res, JsonRequestBehavior.AllowGet);
             }
             return Json("", JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return Json("", JsonRequestBehavior.AllowGet);
     }
 }