コード例 #1
0
        public int SendData()
        {
            SaMiStatusInfo STI = new SaMiStatusInfo();

            foreach (MonnitDataType Monnit in Storage._instance.MonnitDataList)
            {
                if (Monnit.Data != null || Monnit.Data != "")
                {
                    MeasurementModel SensorDataset = new MeasurementModel();
                    List <DataModel> Sensors       = new List <DataModel>();

                    DataModel sensorValue = new DataModel();
                    sensorValue.Tag   = Monnit.SensorID.ToString();
                    sensorValue.Value = Double.Parse(Monnit.Data, System.Globalization.CultureInfo.InvariantCulture);

                    Sensors.Add(sensorValue);

                    SensorDataset.Data      = Sensors.ToArray();
                    SensorDataset.Object    = "Betonilabra";
                    SensorDataset.Timestamp = ParseMonnitDateStringToIso(Monnit.Date);
                    SensorDataset.Tag       = Monnit.SensorID.ToString();

                    All_measurements.Add(SensorDataset);
                }
            }

            MonnitDataType MDT = Storage._instance.MonnitDataList.First();

            STI.LatestSavedMeasurement = ParseMonnitDateStringToIso(MDT.Date);

            System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "Config.json", Newtonsoft.Json.JsonConvert.SerializeObject(STI));

            Package.Measurements = All_measurements.ToArray();

            Package.Key = Storage._instance.Key;
            //var result = Client.SaveMeasurementPackage(Package);

            Client.Close();

            return(0);
        }
コード例 #2
0
        public void TestSend()
        {
            if (Storage._instance.MonnitDataList.Count > 0)
            {
                foreach (MonnitDataType Monnit in Storage._instance.MonnitDataList)
                {
                    System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "TEST.txt", Monnit.ToString() + Environment.NewLine);

                    SaMiStatusInfo STI = new SaMiStatusInfo();

                    MonnitDataType MDT = Storage._instance.MonnitDataList.First();
                    STI.LatestSavedMeasurement = ParseMonnitDateStringToIso(MDT.Date);

                    System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "Config.json", Newtonsoft.Json.JsonConvert.SerializeObject(STI));
                }
            }
            else
            {
                System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "TEST.txt", "TYHJÄ" + Environment.NewLine);
            }
        }