Exemple #1
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            var db = new TDataEntities();

            foreach (var item in db.TDataItems)
            {
                db.DeleteObject(item);
            }
            db.SaveChanges();
            Response.Redirect(Request.RawUrl);
        }
Exemple #2
0
        public void onPost(string light, string hum, string temp, Stream fileCont)
        {
            // save POST content as BMP file ...
            string docname = (DateTime.Now.ToLongTimeString() + "." + light + "_" + hum + "_" + temp + ".bmp").Replace(":", "_");
            string strdocPath;

            strdocPath = System.Web.Hosting.HostingEnvironment.MapPath("~/pics/") + docname;

            // Save Stream to local memory stream for later distrbution ...
            var ms = new MemoryStream();

            fileCont.CopyTo(ms);
            ms.Position = 0;


            FileStream fs = new FileStream(strdocPath, FileMode.Create, FileAccess.ReadWrite);

            ms.CopyTo(fs);
            ms.Position = 0;
            fs.Close();;

            Byte[] bytes = new Byte[ms.Length];
            ms.Read(bytes, 0, bytes.Length);



            var objContext = new TDataEntities();
            var newData    = new TDataItem();

            newData.lightSENS = int.Parse(light);
            newData.humSENS   = int.Parse(hum);
            newData.tempSENS  = decimal.Parse(temp);
            newData.Date      = DateTime.Now;

            newData.Transacto = bytes;

            objContext.TDataItems.AddObject(newData);
            objContext.SaveChanges();
        }