Example #1
0
 public string PiSendImage(HttpPostedFileBase file, string deviceID)
 {
     if (!String.IsNullOrEmpty(deviceID))
     {
         Device device = db.Devices.Find(deviceID);
         if (device == null || device.device_status == 1)
         {
             return("reg_fail");
         }
     }
     if (file != null && file.ContentLength > 0)
     {
         string userid = db.TempUsers.Select(m => m.tempuser_id).FirstOrDefault();
         User   user   = db.Users.Find(userid);
         if (String.IsNullOrEmpty(userid) || db.TempUsers.ToList().Count > 1 || user == null)
         {
             return("reg_fail");
         }
         var fileName = string.Format("{0}.bmp", userid);
         var path     = Path.Combine(Server.MapPath(string.Format("~/Images/User/{0}", userid)), fileName);
         file.SaveAs(path);
         return(string.Format("Oke_{0}_{1}", userid, CreateController.RemoveVietnamese(user.full_name)));
     }
     return("reg_fail");
 }
Example #2
0
        public FileContentResult ExportCSV(ExportLOGModel model)
        {
            List <Attent> atList = db.Attents.Where(t => (t.attent_time >= model.startDate && t.attent_time <= model.endDate)).ToList();
            String        csv    = "ID,Name,Time,Location";

            foreach (var item in atList)
            {
                csv += Environment.NewLine + item.attent_user + "," + CreateController.RemoveVietnamese(db.Users.Find(item.attent_user).full_name) + "," + item.attent_time + "," + item.attent_device;
            }
            return(File(new System.Text.UTF8Encoding().GetBytes(csv), "text/csv", "Report.csv"));
        }