Esempio n. 1
0
        public List <SolarData> getSolarDataYear(List <string> pData)
        {
            int year           = int.Parse(pData[0]);
            List <SolarData> p = new List <SolarData>();

            using (SqlConnection con = new SqlConnection(getConnectionString()))
            {
                //string query = "SELECT DISTINCT PlantSectionID, SUM(Yield) AS TOTAL FROM SolarProduction WHERE (SELECT YEAR(DATE) AS y) =@year GROUP BY PlantSectionID";
                SqlCommand cmd = new SqlCommand("spgetSolarbyYear", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@syear", year);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        SolarData spDatat = new SolarData();
                        spDatat.PlantName  = dr["PlantName"].ToString();
                        spDatat.solarYield = Convert.ToInt32(dr["TOTAL"].ToString());
                        p.Add(spDatat);
                    }
                }
            }
            return(p);
        }
Esempio n. 2
0
        public List <SolarData> getSolarDataDay(List <string> pData)
        {
            string   day        = pData[0];
            int      num        = day.Length;
            string   dayS       = day.Substring(0, 2);
            string   monthS     = day.Substring(3, 2);
            string   yearS      = day.Substring(day.Length - 4);
            string   actualData = yearS + "-" + monthS + "-" + dayS;
            DateTime d          = DateTime.Parse(actualData).Date;
            DateTime dt         = d.Date;

            // string actualDate = ///change date formst
            List <SolarData> p = new List <SolarData>();

            using (SqlConnection con = new SqlConnection(getConnectionString()))
            {
                //string query = "SELECT DISTINCT PlantSectionID, SUM(Yield) AS TOTAL FROM SolarProduction WHERE (SELECT YEAR(DATE) AS y) =@year GROUP BY PlantSectionID";
                SqlCommand cmd = new SqlCommand("spgetSolarbyDay", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@date", dt);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        SolarData spDatat = new SolarData();
                        spDatat.PlantName  = dr["PlantName"].ToString();
                        spDatat.solarYield = Convert.ToInt32(dr["TOTAL"].ToString());
                        p.Add(spDatat);
                    }
                }
            }
            return(p);
        }
 /// <summary>
 /// Warps to the current seed.
 /// </summary>
 public static void Warp(bool processActions, string theSeed, bool savePersistence = true)
 {
     Debugger.Log("Beginning warp to " + theSeed);
     // Replace any newline or tab characters.
     theSeed = Regex.Replace(theSeed, "[^ -~]+", string.Empty, RegexOptions.Multiline);
     // Make sure the seed is valid
     if (string.IsNullOrEmpty(theSeed))
     {
         ScreenMessages.PostScreenMessage("Invalid coordinates.", 3.0f, ScreenMessageStyle.UPPER_CENTER);
         return;
     }
     // Set the seeds
     lastSeed   = seedString;
     seedString = theSeed;
     try
     {
         // Create the RNG
         Randomizers.WarpRNG.ReSeed(seedString);
         // Create and randomize the system
         SolarData.CreateSystem(seedString);
         // Write the current seed to file
         SeedTracker.Jump();
     }
     catch (System.Exception e)
     {
         // Catch all exceptions so users know if something goes wrong
         ScreenMessages.PostScreenMessage("Warp Drive failed due to " + e.GetType() + ".");
         Debugger.LogException("Unable to jump to system!", e);
         return;
     }
     if (seedString != AstroUtils.KERBIN_SYSTEM_COORDS)
     {
         // We've left Kerbol, so we need to purge the Kerbol vessels
         needsPurge = true;
     }
     if (processActions)
     {
         // Call each post-warp action
         foreach (OnWarpDelegate onWarp in nextWarpActions)
         {
             onWarp();
         }
         // Clear the list of methods
         nextWarpActions.Clear();
     }
     if (savePersistence)
     {
         PersistenceGenerator.SavePersistence();
     }
     if (hasInit)
     {
         instance.Invoke("PostWarp", Time.deltaTime);
     }
     Debugger.LogWarning("Created system " + currentSystem.name + " from string " + seedString + ".");
 }
Esempio n. 4
0
        public List <SolarData> getDrillDownSolarMonth(List <string> pData)
        {
            List <String> months = new List <string>();

            months.Add("January");
            months.Add("February");
            months.Add("March");
            months.Add("April");
            months.Add("May");
            months.Add("June");
            months.Add("July");
            months.Add("August");
            months.Add("September");
            months.Add("October");
            months.Add("November");
            months.Add("December");


            string name  = pData[0];
            int    mon   = months.IndexOf(pData[1]);
            int    month = mon + 1;
            int    year  = int.Parse(pData[2]);


            List <SolarData> p = new List <SolarData>();

            using (SqlConnection con = new SqlConnection(getConnectionString()))
            {
                //string query = "SELECT DISTINCT PlantSectionID, SUM(Yield) AS TOTAL FROM SolarProduction WHERE (SELECT YEAR(DATE) AS y) =@year GROUP BY PlantSectionID";
                SqlCommand cmd = new SqlCommand("spMonthDrilldownforday", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@name", name);
                cmd.Parameters.AddWithValue("@m", month);
                cmd.Parameters.AddWithValue("@year", year);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        SolarData spDatat = new SolarData();
                        spDatat.yieldDate  = DateTime.Parse(dr["Date"].ToString());
                        spDatat.solarYield = Convert.ToInt32(dr["Yield"].ToString());
                        p.Add(spDatat);
                    }
                }
            }
            return(p);
        }
Esempio n. 5
0
        // Notes:
        //  - Device updates come from within the EweLinkAPI. The websocket receives a message
        //    for a device. It then calls 'Update' on the device, which the Consumer observes.

        public Model()
        {
            ConsumersList = new ConsumerList();
            Settings      = new SettingsData(SettingsData.Filepath);
            Shutdown      = new CancellationTokenSource();
            History       = new History();
            Fronius       = new FroniusAPI(Settings.SolarInverterIP, Shutdown.Token);
            Ewe           = new EweLinkAPI(Shutdown.Token);
            Solar         = new SolarData();
            Sched         = new Schedule();

            Sched.Add(new Schedule.Range("Monitor Active", Schedule.ERepeat.Daily,
                                         new DateTimeOffset(1, 1, 1, 8, 0, 0, TimeSpan.Zero),
                                         new DateTimeOffset(1, 1, 1, 18, 0, 0, TimeSpan.Zero)));

            Log.Write(ELogLevel.Info, "Model initialised");
            m_settings.NotifyAllSettingsChanged();

            // Prevent system sleep
            WinOS.SystemSleep(keep_awake: true);
        }