Example #1
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();
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            if (!String.IsNullOrEmpty(context.Request.QueryString["ID"]))

            {
                int id = int.Parse(context.Request.QueryString["ID"]);

                context.Response.ContentType = "image/bmp";

                var db = new TDataEntities();
                var myData = from td in db.TDataItems where td.ID == id select td;
                var pic = myData.First().Transacto;

                // debug code push predefined bit map over
                //

                //var fileStrm = new FileStream("c:\\temp\\bb.bmp", FileMode.Open);
                //var memStrm = new MemoryStream();
                //fileStrm.CopyTo(memStrm) ;

                //pic = memStrm.GetBuffer();

                context.Response.BinaryWrite(pic);

            }
        }
Example #3
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);
 }