Example #1
0
        public static void SendtoAzure(List <string> fileall)
        {
            //JsonObject
            try
            {
                foreach (string onefile in fileall)
                {
                    JavaScriptSerializer js = new JavaScriptSerializer();

                    dynamic jobject = js.Deserialize <dynamic>(onefile);

                    string   name     = (string)jobject["FileName"];
                    object[] objects  = (object[])jobject["Content"];
                    string   macadd   = (string)jobject["MacAddress"];
                    string   timeZone = (string)jobject["timeZone"];


                    switch (name)
                    {
                    case "sleepTable.json":
                        sleepController sleepctrl = new sleepController();


                        List <sleepEntity> sleepentities = sleepctrl.processData(objects, macadd, timeZone);

                        GenericAzureTableEntity <sleepEntity> sleepG = new GenericAzureTableEntity <sleepEntity>("sleepTable");
                        if (sleepentities.Count > 0)
                        {
                            sleepG.BatchInset(sleepentities);
                        }
                        break;

                    case "fitnessTable.json":
                        fitnessController fitctrl = new fitnessController();

                        List <fitnessEntity> fitentities = fitctrl.processData(objects, macadd, timeZone);

                        GenericAzureTableEntity <fitnessEntity> fitgeneric = new GenericAzureTableEntity <fitnessEntity>("fitnessTable");

                        if (fitentities.Count > 0)
                        {
                            fitgeneric.BatchInset(fitentities);
                        }
                        break;

                    case "stepTable.json":

                        StepController    stpctrl  = new StepController();
                        List <stepEntity> entities = stpctrl.processData(objects, macadd, timeZone);

                        GenericAzureTableEntity <stepEntity> gestepentity = new GenericAzureTableEntity <stepEntity>("stepTable");
                        if (entities.Count > 0)
                        {
                            gestepentity.BatchInset(entities);
                        }

                        break;

                    case "pulseTable.json":
                        pulseController    pulsctrl      = new pulseController();
                        List <pulseEntity> pulseentities = pulsctrl.processData(objects, macadd, timeZone);

                        GenericAzureTableEntity <pulseEntity> pulseG = new GenericAzureTableEntity <pulseEntity>("pulseTable");
                        if (pulseentities.Count > 0)
                        {
                            pulseG.BatchInset(pulseentities);
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }