Пример #1
0
        /// <summary>
        /// Create a new TDataItem object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        /// <param name="lightSENS">Initial value of the lightSENS property.</param>
        /// <param name="humSENS">Initial value of the humSENS property.</param>
        /// <param name="tempSENS">Initial value of the tempSENS property.</param>
        /// <param name="date">Initial value of the Date property.</param>
        public static TDataItem CreateTDataItem(global::System.Int32 id, global::System.Int32 lightSENS, global::System.Int32 humSENS, global::System.Decimal tempSENS, global::System.DateTime date)
        {
            TDataItem tDataItem = new TDataItem();

            tDataItem.ID        = id;
            tDataItem.lightSENS = lightSENS;
            tDataItem.humSENS   = humSENS;
            tDataItem.tempSENS  = tempSENS;
            tDataItem.Date      = date;
            return(tDataItem);
        }
Пример #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();
        }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the TDataItems EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTDataItems(TDataItem tDataItem)
 {
     base.AddObject("TDataItems", tDataItem);
 }